SGF-335 - Refactor ProcessUtils and fix the GatewayReceiverNamespaceTest class hang in the Bamboo SDG Nightly Build when mocking is disabled.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
antlrVersion=2.7.7
|
||||
slf4jVersion=1.7.6
|
||||
junitVersion=4.11
|
||||
gemfireVersion=7.0.2
|
||||
spring.range="[4.0.0, 5.0.0)"
|
||||
aspectjVersion=1.8.2
|
||||
springDataBuildVersion=1.5.1.BUILD-SNAPSHOT
|
||||
springVersion=4.0.7.RELEASE
|
||||
springDataCommonsVersion=1.9.1.BUILD-SNAPSHOT
|
||||
log4jVersion=1.2.17
|
||||
gemfireVersion=7.0.2
|
||||
hamcrestVersion=1.3
|
||||
version=1.5.1.BUILD-SNAPSHOT
|
||||
jacksonVersion=1.9.12
|
||||
junitVersion=4.11
|
||||
log4jVersion=1.2.17
|
||||
mockitoVersion=1.9.5
|
||||
slf4jVersion=1.7.6
|
||||
spring.range="[4.0.0, 5.0.0)"
|
||||
springVersion=4.0.7.RELEASE
|
||||
springDataBuildVersion=1.5.1.BUILD-SNAPSHOT
|
||||
springDataCommonsVersion=1.9.1.BUILD-SNAPSHOT
|
||||
version=1.5.1.BUILD-SNAPSHOT
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
|
||||
/**
|
||||
* The GatewayReceiverAutoStartNamespaceTest class is a test suite of test cases testing the contract
|
||||
* and functionality of Gateway Receiver configuration in Spring Data GemFire using the XML namespace (XSD).
|
||||
* This test class tests the auto start configuration of the GatewayReceiver Gemfire Component in SDG.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
|
||||
* @see org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean
|
||||
* @see org.springframework.test.context.ActiveProfiles
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewayReceiver
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(value = "GatewayReceiverNamespaceTest-context.xml",
|
||||
initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@ActiveProfiles("autoStart")
|
||||
@SuppressWarnings("unused")
|
||||
public class GatewayReceiverAutoStartNamespaceTest {
|
||||
|
||||
@Resource(name = "&Auto")
|
||||
private GatewayReceiverFactoryBean autoGatewayReceiverFactory;
|
||||
|
||||
@Test
|
||||
public void testAuto() throws Exception {
|
||||
assertNotNull("The 'Auto' GatewayReceiverFactoryBean was not properly configured and initialized!",
|
||||
autoGatewayReceiverFactory);
|
||||
assertTrue(autoGatewayReceiverFactory.isAutoStartup());
|
||||
|
||||
GatewayReceiver autoGatewayReceiver = autoGatewayReceiverFactory.getObject();
|
||||
|
||||
try {
|
||||
assertNotNull(autoGatewayReceiver);
|
||||
assertTrue(StringUtils.isEmpty(autoGatewayReceiver.getBindAddress()));
|
||||
assertEquals("neo", autoGatewayReceiver.getHost());
|
||||
assertEquals(15500, autoGatewayReceiver.getStartPort());
|
||||
assertEquals(25500, autoGatewayReceiver.getEndPort());
|
||||
assertEquals(10000, autoGatewayReceiver.getMaximumTimeBetweenPings());
|
||||
assertTrue(autoGatewayReceiver.isRunning());
|
||||
assertEquals(16384, autoGatewayReceiver.getSocketBufferSize());
|
||||
}
|
||||
finally {
|
||||
autoGatewayReceiver.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
|
||||
/**
|
||||
* The GatewayReceiverDefaultStartNamespaceTest class is a test suite of test cases testing the contract
|
||||
* and functionality of Gateway Receiver configuration in Spring Data GemFire using the XML namespace (XSD).
|
||||
* This test class tests the default start configuration of the GatewayReceiver Gemfire Component in SDG.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
|
||||
* @see org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean
|
||||
* @see org.springframework.test.context.ActiveProfiles
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewayReceiver
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(value = "GatewayReceiverNamespaceTest-context.xml",
|
||||
initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@ActiveProfiles("defaultStart")
|
||||
@SuppressWarnings("unused")
|
||||
public class GatewayReceiverDefaultStartNamespaceTest {
|
||||
|
||||
@Resource(name = "&Default")
|
||||
private GatewayReceiverFactoryBean defaultGatewayReceiverFactory;
|
||||
|
||||
@Test
|
||||
public void testDefault() throws Exception {
|
||||
assertNotNull("The 'Default' GatewayReceiverFactoryBean was not properly configured and initialized!",
|
||||
defaultGatewayReceiverFactory);
|
||||
assertTrue(defaultGatewayReceiverFactory.isAutoStartup());
|
||||
|
||||
GatewayReceiver defaultGatewayReceiver = defaultGatewayReceiverFactory.getObject();
|
||||
|
||||
try {
|
||||
assertNotNull(defaultGatewayReceiver);
|
||||
assertTrue(StringUtils.isEmpty(defaultGatewayReceiver.getBindAddress()));
|
||||
assertEquals("skullbox", defaultGatewayReceiver.getHost());
|
||||
assertEquals(12345, defaultGatewayReceiver.getStartPort());
|
||||
assertEquals(54321, defaultGatewayReceiver.getEndPort());
|
||||
assertEquals(5000, defaultGatewayReceiver.getMaximumTimeBetweenPings());
|
||||
assertTrue(defaultGatewayReceiver.isRunning());
|
||||
assertEquals(32768, defaultGatewayReceiver.getSocketBufferSize());
|
||||
}
|
||||
finally {
|
||||
defaultGatewayReceiver.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
|
||||
/**
|
||||
* The GatewayReceiverManualStartNamespaceTest class is a test suite of test cases testing the contract
|
||||
* and functionality of Gateway Receiver configuration in Spring Data GemFire using the XML namespace (XSD).
|
||||
* This test class tests the manual start configuration of the GatewayReceiver Gemfire Component in SDG.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
|
||||
* @see org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean
|
||||
* @see org.springframework.test.context.ActiveProfiles
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewayReceiver
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(value = "GatewayReceiverNamespaceTest-context.xml",
|
||||
initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@ActiveProfiles("manualStart")
|
||||
@SuppressWarnings("unused")
|
||||
public class GatewayReceiverManualStartNamespaceTest {
|
||||
|
||||
@Resource(name = "&Manual")
|
||||
private GatewayReceiverFactoryBean manualGatewayReceiverFactory;
|
||||
|
||||
@Test
|
||||
public void testManual() throws Exception {
|
||||
assertNotNull("The 'Manual' GatewayReceiverFactoryBean was not properly configured and initialized!",
|
||||
manualGatewayReceiverFactory);
|
||||
assertFalse(manualGatewayReceiverFactory.isAutoStartup());
|
||||
|
||||
GatewayReceiver manualGatewayReceiver = manualGatewayReceiverFactory.getObject();
|
||||
|
||||
assertNotNull(manualGatewayReceiver);
|
||||
assertEquals("192.168.0.1", manualGatewayReceiver.getBindAddress());
|
||||
assertEquals("theOne", manualGatewayReceiver.getHost());
|
||||
assertEquals(100, manualGatewayReceiver.getStartPort());
|
||||
assertEquals(900, manualGatewayReceiver.getEndPort());
|
||||
assertEquals(1000, manualGatewayReceiver.getMaximumTimeBetweenPings());
|
||||
assertFalse(manualGatewayReceiver.isRunning());
|
||||
assertEquals(8192, manualGatewayReceiver.getSocketBufferSize());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
|
||||
/**
|
||||
* The GatewayReceiverNamespaceTest class is a test suite of test cases testing the contract and functionality of
|
||||
* Gateway Receiver configuration in Spring Data GemFire using the XML namespace and schema (XSD).
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class GatewayReceiverNamespaceTest {
|
||||
|
||||
@Resource(name = "&Default")
|
||||
private GatewayReceiverFactoryBean defaultFactoryBean;
|
||||
|
||||
@Resource(name = "&Auto")
|
||||
private GatewayReceiverFactoryBean autoGatewayReceiver;
|
||||
|
||||
@Resource(name = "&Manual")
|
||||
private GatewayReceiverFactoryBean manualGatewayReceiver;
|
||||
|
||||
@Test
|
||||
// TODO test the default value for "manual-start" (true) without explicitly setting the attribute in Spring XML
|
||||
public void testDefault() throws Exception {
|
||||
assertNotNull("The 'Default' GatewayReceiverFactoryBean was not properly configured and initialized!", defaultFactoryBean);
|
||||
assertTrue(defaultFactoryBean.isAutoStartup());
|
||||
|
||||
GatewayReceiver defaultGatewayReceiver = defaultFactoryBean.getObject();
|
||||
|
||||
assertNotNull(defaultGatewayReceiver);
|
||||
assertEquals("192.168.0.1", defaultGatewayReceiver.getBindAddress());
|
||||
assertEquals("skullbox", defaultGatewayReceiver.getHost());
|
||||
assertEquals(12345, defaultGatewayReceiver.getStartPort());
|
||||
assertEquals(54321, defaultGatewayReceiver.getEndPort());
|
||||
assertEquals(5000, defaultGatewayReceiver.getMaximumTimeBetweenPings());
|
||||
assertEquals(32768, defaultGatewayReceiver.getSocketBufferSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuto() {
|
||||
assertNotNull("The 'Auto' GatewayReceiverFactoryBean was not properly configured and initialized!", autoGatewayReceiver);
|
||||
assertTrue(autoGatewayReceiver.isAutoStartup());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManual() {
|
||||
assertNotNull("The 'Manual' GatewayReceiverFactoryBean was not properly configured and initialized!", manualGatewayReceiver);
|
||||
assertFalse(manualGatewayReceiver.isAutoStartup());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,12 +12,17 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.test;
|
||||
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiverFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
@@ -25,10 +30,13 @@ import com.gemstone.gemfire.management.internal.cli.util.spring.StringUtils;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
* @author John Blum
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewayReceiverFactory
|
||||
*/
|
||||
public class StubGatewayReceiverFactory implements GatewayReceiverFactory {
|
||||
|
||||
private volatile boolean running;
|
||||
|
||||
private int endPort;
|
||||
private int maximumTimeBetweenPings;
|
||||
private int socketBufferSize;
|
||||
@@ -126,6 +134,23 @@ public class StubGatewayReceiverFactory implements GatewayReceiverFactory {
|
||||
when(gatewayReceiver.getMaximumTimeBetweenPings()).thenReturn(this.maximumTimeBetweenPings);
|
||||
when(gatewayReceiver.getSocketBufferSize()).thenReturn(this.socketBufferSize);
|
||||
when(gatewayReceiver.getStartPort()).thenReturn(this.startPort);
|
||||
when(gatewayReceiver.isRunning()).thenAnswer(new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(InvocationOnMock invocation) throws Throwable {
|
||||
return running;
|
||||
}
|
||||
});
|
||||
try {
|
||||
doAnswer(new Answer<Void>() {
|
||||
public Void answer(InvocationOnMock invocation) {
|
||||
running = true;
|
||||
return null;
|
||||
}
|
||||
}).when(gatewayReceiver).start();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return gatewayReceiver;
|
||||
}
|
||||
|
||||
@@ -10,18 +10,32 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">GatewayReceiverNamespaceTest</prop>
|
||||
<prop key="name">GatewayReceiverDefaultStartNamespaceTest</prop>
|
||||
<prop key="mcast-port">0</prop>
|
||||
<prop key="log-level">config</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<gfe:gateway-receiver id="Default" bind-address="192.168.0.1" hostname-for-senders="skullbox"
|
||||
start-port="12345" end-port="54321" maximum-time-between-pings="5000" socket-buffer-size="32768"/>
|
||||
<beans profile="defaultStart">
|
||||
<gfe:gateway-receiver id="Default" hostname-for-senders="skullbox"
|
||||
start-port="12345" end-port="54321" maximum-time-between-pings="5000"
|
||||
socket-buffer-size="32768"/>
|
||||
</beans>
|
||||
|
||||
<gfe:gateway-receiver id="Auto" manual-start="false"/>
|
||||
|
||||
<gfe:gateway-receiver id="Manual" manual-start="true"/>
|
||||
<beans profile="autoStart">
|
||||
<gfe:gateway-receiver id="Auto" manual-start="false" hostname-for-senders="neo"
|
||||
start-port="15500" end-port="25500" maximum-time-between-pings="10000"
|
||||
socket-buffer-size="16384"/>
|
||||
</beans>
|
||||
|
||||
|
||||
<beans profile="manualStart">
|
||||
<gfe:gateway-receiver id="Manual" manual-start="true" bind-address="192.168.0.1" hostname-for-senders="theOne"
|
||||
start-port="100" end-port="900" maximum-time-between-pings="1000"
|
||||
socket-buffer-size="8192"/>
|
||||
</beans>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user