SGF-398 - Provide early support of Apache Geode (Pivotal GemFire OSS).
Source compilation and resource processing build step complete.
This commit is contained in:
@@ -37,15 +37,13 @@ import org.springframework.data.gemfire.client.InterestResultPolicyConverter;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicyConverter;
|
||||
import org.springframework.data.gemfire.wan.OrderPolicyConverter;
|
||||
import org.springframework.data.gemfire.wan.StartupPolicyConverter;
|
||||
import org.springframework.data.gemfire.wan.StartupPolicyType;
|
||||
|
||||
import com.gemstone.gemfire.cache.EvictionAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* The CustomEditorRegistrationBeanFactoryPostProcessorTest class...
|
||||
@@ -79,10 +77,8 @@ public class CustomEditorRegistrationBeanFactoryPostProcessorTest {
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(InterestResultPolicy.class),
|
||||
eq(InterestResultPolicyConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(Scope.class), eq(ScopeConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(Gateway.OrderPolicy.class),
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(GatewaySender.OrderPolicy.class),
|
||||
eq(OrderPolicyConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(StartupPolicyType.class),
|
||||
eq(StartupPolicyConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(SubscriptionEvictionPolicy.class),
|
||||
eq(SubscriptionEvictionPolicyConverter.class));
|
||||
}
|
||||
|
||||
@@ -1,221 +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.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEvent;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEventListener;
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
import com.gemstone.gemfire.cache.util.GatewayQueueAttributes;
|
||||
|
||||
/**
|
||||
* The GatewayHubNamespaceTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the GatewayHub SDG XML namespace (XSD) configuration meta-data.
|
||||
*
|
||||
* @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.GatewayHubFactoryBean
|
||||
* @see org.springframework.data.gemfire.wan.GatewayProxy
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see com.gemstone.gemfire.cache.util.Gateway
|
||||
* @see com.gemstone.gemfire.cache.util.GatewayHub
|
||||
* @since 1.5.3
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@SuppressWarnings({"deprecation", "unused" })
|
||||
public class GatewayHubNamespaceTest {
|
||||
|
||||
@Resource(name = "Example")
|
||||
private Region<?, ?> example;
|
||||
|
||||
@Autowired
|
||||
private GatewayHub gatewayHub;
|
||||
|
||||
protected Gateway getGatewayById(final List<Gateway> gateways, final String id) {
|
||||
for (Gateway gateway : gateways) {
|
||||
if (gateway.getId().equals(id)) {
|
||||
return gateway;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionConfiguration() {
|
||||
assertNotNull("The '/Example' Region was not properly initialized!", example);
|
||||
assertEquals("Example", example.getName());
|
||||
assertEquals("/Example", example.getFullPath());
|
||||
assertNotNull(example.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, example.getAttributes().getDataPolicy());
|
||||
assertTrue(example.getAttributes().getEnableGateway());
|
||||
assertEquals("testGatewayHub", example.getAttributes().getGatewayHubId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGatewayConfiguration() {
|
||||
assertNotNull("The 'TestGatewayHub' GatewayHub was not properly initialized!", gatewayHub);
|
||||
assertEquals("localhost", gatewayHub.getBindAddress());
|
||||
assertEquals("TestGatewayHub", gatewayHub.getId());
|
||||
assertTrue(gatewayHub.getManualStart());
|
||||
assertEquals(125, gatewayHub.getMaxConnections());
|
||||
assertEquals(5000, gatewayHub.getMaximumTimeBetweenPings());
|
||||
assertEquals(45123, gatewayHub.getPort());
|
||||
assertEquals(16384, gatewayHub.getSocketBufferSize());
|
||||
assertEquals("primary", gatewayHub.getStartupPolicy());
|
||||
|
||||
List<Gateway> gateways = gatewayHub.getGateways();
|
||||
|
||||
assertNotNull(gateways);
|
||||
assertFalse(gateways.isEmpty());
|
||||
assertEquals(3, gateways.size());
|
||||
|
||||
Gateway gatewayOne = getGatewayById(gateways, "gateway1");
|
||||
|
||||
assertNotNull(gatewayOne);
|
||||
assertEquals("gateway1", gatewayOne.getId());
|
||||
assertEquals(8, gatewayOne.getConcurrencyLevel());
|
||||
assertEquals(Gateway.OrderPolicy.THREAD, gatewayOne.getOrderPolicy());
|
||||
assertEquals(65536, gatewayOne.getSocketBufferSize());
|
||||
assertEquals(75000, gatewayOne.getSocketReadTimeout());
|
||||
assertTrue(gatewayOne.getEndpoints() == null || gatewayOne.getEndpoints().isEmpty());
|
||||
|
||||
List<GatewayEventListener> gatewayEventListeners = gatewayOne.getListeners();
|
||||
|
||||
assertNotNull(gatewayEventListeners);
|
||||
assertFalse(gatewayEventListeners.isEmpty());
|
||||
assertEquals(2, gatewayEventListeners.size());
|
||||
assertTrue(gatewayEventListeners.get(0) instanceof TestGatewayListener);
|
||||
assertEquals("ListenerOne", gatewayEventListeners.get(0).toString());
|
||||
assertTrue(gatewayEventListeners.get(1) instanceof TestGatewayListener);
|
||||
assertEquals("ListenerTwo", gatewayEventListeners.get(1).toString());
|
||||
|
||||
GatewayQueueAttributes gatewayQueueAttributes = gatewayOne.getQueueAttributes();
|
||||
|
||||
assertNotNull(gatewayQueueAttributes);
|
||||
assertEquals(99, gatewayQueueAttributes.getAlertThreshold());
|
||||
assertTrue(gatewayQueueAttributes.getBatchConflation());
|
||||
assertEquals(3, gatewayQueueAttributes.getBatchSize());
|
||||
assertEquals(10, gatewayQueueAttributes.getBatchTimeInterval());
|
||||
assertEquals("TestGatewayQueueDiskStore", gatewayQueueAttributes.getDiskStoreName());
|
||||
assertFalse(gatewayQueueAttributes.getEnablePersistence());
|
||||
assertEquals(5, gatewayQueueAttributes.getMaximumQueueMemory());
|
||||
|
||||
Gateway gatewayTwo = getGatewayById(gateways, "gateway2");
|
||||
|
||||
assertNotNull(gatewayTwo);
|
||||
assertEquals("gateway2", gatewayTwo.getId());
|
||||
assertEquals(Gateway.DEFAULT_CONCURRENCY_LEVEL, gatewayTwo.getConcurrencyLevel());
|
||||
assertNull(gatewayTwo.getOrderPolicy());
|
||||
assertEquals(Gateway.DEFAULT_SOCKET_BUFFER_SIZE, gatewayTwo.getSocketBufferSize());
|
||||
assertEquals(Gateway.DEFAULT_SOCKET_READ_TIMEOUT, gatewayTwo.getSocketReadTimeout());
|
||||
assertTrue(gatewayTwo.getListeners() == null || gatewayTwo.getListeners().isEmpty());
|
||||
|
||||
List gatewayEndpoints = gatewayTwo.getEndpoints();
|
||||
|
||||
assertNotNull(gatewayEndpoints);
|
||||
assertFalse(gatewayEndpoints.isEmpty());
|
||||
assertEquals(2, gatewayEndpoints.size());
|
||||
|
||||
Gateway.Endpoint gatewayEndpointOne = (Gateway.Endpoint) gatewayEndpoints.get(0);
|
||||
|
||||
assertEquals("endpoint1", gatewayEndpointOne.getId());
|
||||
assertEquals("localhost", gatewayEndpointOne.getHost());
|
||||
assertEquals(1234, gatewayEndpointOne.getPort());
|
||||
|
||||
Gateway.Endpoint gatewayEndpointTwo = (Gateway.Endpoint) gatewayEndpoints.get(1);
|
||||
|
||||
assertEquals("endpoint2", gatewayEndpointTwo.getId());
|
||||
assertEquals("localhost", gatewayEndpointTwo.getHost());
|
||||
assertEquals(4321, gatewayEndpointTwo.getPort());
|
||||
|
||||
gatewayQueueAttributes = gatewayTwo.getQueueAttributes();
|
||||
|
||||
assertNotNull(gatewayQueueAttributes);
|
||||
assertEquals(GatewayQueueAttributes.DEFAULT_ALERT_THRESHOLD, gatewayQueueAttributes.getAlertThreshold());
|
||||
assertFalse(gatewayQueueAttributes.getBatchConflation());
|
||||
assertEquals(6, gatewayQueueAttributes.getBatchSize());
|
||||
assertEquals(20, gatewayQueueAttributes.getBatchTimeInterval());
|
||||
assertNull(gatewayQueueAttributes.getDiskStoreName());
|
||||
assertTrue(gatewayQueueAttributes.getEnablePersistence());
|
||||
assertEquals(GatewayQueueAttributes.DEFAULT_MAXIMUM_QUEUE_MEMORY, gatewayQueueAttributes.getMaximumQueueMemory());
|
||||
|
||||
Gateway gatewayThree = getGatewayById(gateways, "gateway3");
|
||||
|
||||
assertNotNull(gatewayThree);
|
||||
assertEquals("gateway3", gatewayThree.getId());
|
||||
assertEquals(Gateway.DEFAULT_CONCURRENCY_LEVEL, gatewayThree.getConcurrencyLevel());
|
||||
assertNull(gatewayThree.getOrderPolicy());
|
||||
assertEquals(Gateway.DEFAULT_SOCKET_BUFFER_SIZE, gatewayThree.getSocketBufferSize());
|
||||
assertEquals(Gateway.DEFAULT_SOCKET_READ_TIMEOUT, gatewayThree.getSocketReadTimeout());
|
||||
assertTrue(gatewayThree.getEndpoints() == null || gatewayThree.getEndpoints().isEmpty());
|
||||
|
||||
gatewayEventListeners = gatewayThree.getListeners();
|
||||
|
||||
assertNotNull(gatewayEventListeners);
|
||||
assertFalse(gatewayEventListeners.isEmpty());
|
||||
assertEquals(1, gatewayEventListeners.size());
|
||||
assertTrue(gatewayEventListeners.get(0) instanceof TestGatewayListener);
|
||||
assertEquals("ListenerTwo", gatewayEventListeners.get(0).toString());
|
||||
}
|
||||
|
||||
public static final class TestGatewayListener implements GatewayEventListener {
|
||||
|
||||
private String name;
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processEvents(final List<GatewayEvent> events) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,106 +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.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.TestUtils;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.data.gemfire.wan.GatewayHubFactoryBean;
|
||||
import org.springframework.data.gemfire.wan.GatewayProxy;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEvent;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEventListener;
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/gateway-v6-ns.xml",
|
||||
initializers=GemfireTestApplicationContextInitializer.class)
|
||||
public class GemfireV6GatewayNamespaceTest {
|
||||
|
||||
@Autowired ApplicationContext ctx;
|
||||
|
||||
@Test
|
||||
public void testGatewayHubFactoryBean() throws Exception {
|
||||
GatewayHubFactoryBean gwhfb = ctx.getBean("&gateway-hub", GatewayHubFactoryBean.class);
|
||||
List<GatewayProxy> gateways = TestUtils.readField("gateways", gwhfb);
|
||||
assertNotNull(gateways);
|
||||
assertEquals(2, gateways.size());
|
||||
GatewayProxy gwp = gateways.get(0);
|
||||
assertEquals("gateway", gwp.getId());
|
||||
assertTrue(gwp.getListeners().get(0) instanceof GatewayListener);
|
||||
|
||||
gwp = gateways.get(1);
|
||||
assertEquals("gateway2", gwp.getId());
|
||||
List<GatewayProxy.GatewayEndpoint> endpoints = gwp.getEndpoints();
|
||||
assertEquals(2, endpoints.size());
|
||||
GatewayProxy.GatewayEndpoint endpoint;
|
||||
|
||||
endpoint = endpoints.get(0);
|
||||
assertEquals("endpoint1", endpoint.getId());
|
||||
assertEquals("host1", endpoint.getHost());
|
||||
assertEquals(1234, endpoint.getPort());
|
||||
|
||||
endpoint = endpoints.get(1);
|
||||
assertEquals("endpoint2", endpoint.getId());
|
||||
assertEquals("host2", endpoint.getHost());
|
||||
assertEquals(2345, endpoint.getPort());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testGatewaysInGemfire() {
|
||||
Cache cache = ctx.getBean("gemfireCache", Cache.class);
|
||||
GatewayHub gwh = cache.getGatewayHub("gateway-hub");
|
||||
assertNotNull(gwh);
|
||||
|
||||
Region region = ctx.getBean("region-with-gateway", Region.class);
|
||||
assertTrue(region.getAttributes().getEnableGateway());
|
||||
assertEquals("gateway-hub", region.getAttributes().getGatewayHubId());
|
||||
}
|
||||
|
||||
public static class GatewayListener implements GatewayEventListener {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processEvents(List<GatewayEvent> event) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,324 +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.wan;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.same;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEventListener;
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
import com.gemstone.gemfire.cache.util.GatewayQueueAttributes;
|
||||
|
||||
/**
|
||||
* The GatewayHubFactoryBeanTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the GatewayHubFactoryBean.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class GatewayHubFactoryBeanTest {
|
||||
|
||||
private Cache mockCache;
|
||||
|
||||
private GatewayHubFactoryBean factoryBean;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
mockCache = mock(Cache.class, "GemFire Cache");
|
||||
factoryBean = new GatewayHubFactoryBean(mockCache);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectType() throws Exception {
|
||||
assertNull(factoryBean.getObject());
|
||||
assertEquals(GatewayHub.class, factoryBean.getObjectType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetBindAddress() {
|
||||
assertEquals(GatewayHub.DEFAULT_BIND_ADDRESS, factoryBean.getBindAddress());
|
||||
factoryBean.setBindAddress("10.127.255.1");
|
||||
assertEquals("10.127.255.1", factoryBean.getBindAddress());
|
||||
factoryBean.setBindAddress(null);
|
||||
assertEquals(GatewayHub.DEFAULT_BIND_ADDRESS, factoryBean.getBindAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGateways() {
|
||||
List<GatewayProxy> gateways = factoryBean.getGateways();
|
||||
|
||||
assertNotNull(gateways);
|
||||
assertTrue(gateways.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndIsManualStart() {
|
||||
assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
|
||||
factoryBean.setManualStart(true);
|
||||
assertTrue(factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
|
||||
factoryBean.setManualStart(false);
|
||||
assertFalse(factoryBean.isManualStart(true));
|
||||
factoryBean.setManualStart(null);
|
||||
assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetMaxConnections() {
|
||||
assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue());
|
||||
factoryBean.setMaxConnections(8192);
|
||||
assertEquals(8192, factoryBean.getMaxConnections().intValue());
|
||||
factoryBean.setMaxConnections(null);
|
||||
assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetMaximumTimeBetweenPings() {
|
||||
assertEquals(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS, factoryBean.getMaximumTimeBetweenPings().intValue());
|
||||
factoryBean.setMaximumTimeBetweenPings(15000);
|
||||
assertEquals(15000, factoryBean.getMaximumTimeBetweenPings().intValue());
|
||||
factoryBean.setMaximumTimeBetweenPings(null);
|
||||
assertEquals(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS, factoryBean.getMaximumTimeBetweenPings().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetPort() {
|
||||
assertEquals(GatewayHub.DEFAULT_PORT, factoryBean.getPort().intValue());
|
||||
factoryBean.setPort(15221);
|
||||
assertEquals(15221, factoryBean.getPort().intValue());
|
||||
factoryBean.setPort(null);
|
||||
assertEquals(GatewayHub.DEFAULT_PORT, factoryBean.getPort().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetSocketBufferSize() {
|
||||
assertEquals(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE, factoryBean.getSocketBufferSize().intValue());
|
||||
factoryBean.setSocketBufferSize(16384);
|
||||
assertEquals(16384, factoryBean.getSocketBufferSize().intValue());
|
||||
factoryBean.setSocketBufferSize(null);
|
||||
assertEquals(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE, factoryBean.getSocketBufferSize().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetStartUpPolicy() {
|
||||
assertEquals(StartupPolicyType.DEFAULT, factoryBean.getStartupPolicy());
|
||||
factoryBean.setStartupPolicy(StartupPolicyType.PRIMARY);
|
||||
assertEquals(StartupPolicyType.PRIMARY, factoryBean.getStartupPolicy());
|
||||
factoryBean.setStartupPolicy(null);
|
||||
assertEquals(StartupPolicyType.DEFAULT, factoryBean.getStartupPolicy());
|
||||
factoryBean.setStartupPolicy(StartupPolicyType.SECONDARY);
|
||||
assertEquals(StartupPolicyType.SECONDARY, factoryBean.getStartupPolicy());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testAfterPropertiesSetWitNullCache() throws Exception {
|
||||
try {
|
||||
new GatewayHubFactoryBean(null).afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Cache must not be null.", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testAfterPropertiesSetWithNullName() throws Exception {
|
||||
try {
|
||||
factoryBean.afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Name must not be null.", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoInit() throws Exception {
|
||||
String gatewayHubName = "testDoInit";
|
||||
|
||||
GatewayProxy.GatewayEndpoint gatewayEndpointOne = new GatewayProxy.GatewayEndpoint();
|
||||
|
||||
gatewayEndpointOne.setHost("localhost");
|
||||
gatewayEndpointOne.setId("123");
|
||||
gatewayEndpointOne.setPort(2121);
|
||||
|
||||
GatewayProxy.GatewayEndpoint gatewayEndpointTwo = new GatewayProxy.GatewayEndpoint();
|
||||
|
||||
gatewayEndpointOne.setHost("localhost");
|
||||
gatewayEndpointOne.setId("456");
|
||||
gatewayEndpointOne.setPort(4242);
|
||||
|
||||
GatewayEventListener mockGatewayListener = mock(GatewayEventListener.class,
|
||||
"testDoInit.MockGatewayEventListener");
|
||||
|
||||
GatewayProxy.GatewayQueue gatewayQueue = new GatewayProxy.GatewayQueue();
|
||||
|
||||
gatewayQueue.setAlertThreshold(20);
|
||||
gatewayQueue.setBatchSize(100);
|
||||
gatewayQueue.setBatchTimeInterval(60000);
|
||||
gatewayQueue.setDiskStoreRef("diskX");
|
||||
gatewayQueue.setEnableBatchConflation(true);
|
||||
gatewayQueue.setMaximumQueueMemory(1024);
|
||||
gatewayQueue.setPersistent(true);
|
||||
|
||||
GatewayProxy gatewayProxy = new GatewayProxy();
|
||||
|
||||
gatewayProxy.setId("gatewayProxyId");
|
||||
gatewayProxy.setConcurrencyLevel(4);
|
||||
gatewayProxy.setEndpoints(Arrays.asList(gatewayEndpointOne, gatewayEndpointTwo));
|
||||
gatewayProxy.setListeners(Arrays.asList(mockGatewayListener));
|
||||
gatewayProxy.setOrderPolicy(Gateway.OrderPolicy.THREAD);
|
||||
gatewayProxy.setQueue(gatewayQueue);
|
||||
gatewayProxy.setSocketBufferSize(16384);
|
||||
gatewayProxy.setSocketReadTimeout(300);
|
||||
|
||||
GatewayHub mockGatewayHub = mock(GatewayHub.class, "testDoInit.MockGatewayHub");
|
||||
|
||||
Gateway mockGateway = mock(Gateway.class, "testDoInit.MockGateway");
|
||||
|
||||
GatewayQueueAttributes mockGatewayQueueAttributes = mock(GatewayQueueAttributes.class,
|
||||
"testDoInit.MockGatewayQueueAttributes");
|
||||
|
||||
when(mockCache.addGatewayHub(eq(gatewayHubName), eq(8484))).thenReturn(mockGatewayHub);
|
||||
when(mockCache.getGatewayHub(eq(gatewayHubName))).thenReturn(mockGatewayHub);
|
||||
when(mockGatewayHub.addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel().intValue())))
|
||||
.thenReturn(mockGateway);
|
||||
when(mockGatewayHub.getManualStart()).thenReturn(false);
|
||||
when(mockGateway.getQueueAttributes()).thenReturn(mockGatewayQueueAttributes);
|
||||
|
||||
factoryBean.setBindAddress("10.124.210.42");
|
||||
factoryBean.setGateways(Arrays.asList(gatewayProxy));
|
||||
factoryBean.setManualStart(false);
|
||||
factoryBean.setMaxConnections(50);
|
||||
factoryBean.setMaximumTimeBetweenPings(20480);
|
||||
factoryBean.setName(gatewayHubName);
|
||||
factoryBean.setPort(8484);
|
||||
factoryBean.setSocketBufferSize(4096);
|
||||
factoryBean.setStartupPolicy(StartupPolicyType.PRIMARY);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
verify(mockGatewayHub, times(1)).setBindAddress(eq("10.124.210.42"));
|
||||
verify(mockGatewayHub, times(1)).setManualStart(eq(false));
|
||||
verify(mockGatewayHub, times(1)).setMaxConnections(eq(50));
|
||||
verify(mockGatewayHub, times(1)).setMaximumTimeBetweenPings(eq(20480));
|
||||
verify(mockGatewayHub, times(1)).setSocketBufferSize(eq(4096));
|
||||
verify(mockGatewayHub, times(1)).setStartupPolicy(eq(StartupPolicyType.PRIMARY.getName()));
|
||||
verify(mockGatewayHub, times(1)).addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel()));
|
||||
verify(mockGatewayHub, times(1)).start();
|
||||
verify(mockGateway, times(1)).addEndpoint(eq(gatewayEndpointOne.getId()), eq(gatewayEndpointOne.getHost()),
|
||||
eq(gatewayEndpointOne.getPort()));
|
||||
verify(mockGateway, times(1)).addEndpoint(eq(gatewayEndpointTwo.getId()), eq(gatewayEndpointTwo.getHost()),
|
||||
eq(gatewayEndpointTwo.getPort()));
|
||||
verify(mockGateway, times(1)).addListener(same(mockGatewayListener));
|
||||
verify(mockGateway, times(1)).setOrderPolicy(eq(gatewayProxy.getOrderPolicy()));
|
||||
verify(mockGateway, times(1)).setSocketBufferSize(eq(gatewayProxy.getSocketBufferSize()));
|
||||
verify(mockGateway, times(1)).setSocketReadTimeout(eq(gatewayProxy.getSocketReadTimeout()));
|
||||
verify(mockGateway, times(1)).getQueueAttributes();
|
||||
verify(mockGatewayQueueAttributes, times(1)).setAlertThreshold(eq(gatewayQueue.getAlertThreshold()));
|
||||
verify(mockGatewayQueueAttributes, times(1)).setBatchConflation(eq(gatewayQueue.getEnableBatchConflation()));
|
||||
verify(mockGatewayQueueAttributes, times(1)).setBatchSize(eq(gatewayQueue.getBatchSize()));
|
||||
verify(mockGatewayQueueAttributes, times(1)).setBatchTimeInterval(eq(gatewayQueue.getBatchTimeInterval()));
|
||||
verify(mockGatewayQueueAttributes, times(1)).setDiskStoreName(eq(gatewayQueue.getDiskStoreRef()));
|
||||
verify(mockGatewayQueueAttributes, times(1)).setMaximumQueueMemory(eq(gatewayQueue.getMaximumQueueMemory()));
|
||||
verify(mockGatewayQueueAttributes, times(1)).setEnablePersistence(eq(gatewayQueue.getPersistent()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGatewayQueueWithOverflowNoPersistence() throws Exception {
|
||||
String gatewayHubName = "testGatewayQueueWithOverflowNoPersistence";
|
||||
|
||||
GatewayProxy.GatewayQueue gatewayQueue = new GatewayProxy.GatewayQueue();
|
||||
|
||||
gatewayQueue.setAlertThreshold(100);
|
||||
gatewayQueue.setBatchSize(250);
|
||||
gatewayQueue.setBatchTimeInterval(120000);
|
||||
gatewayQueue.setDiskStoreRef("diskZ");
|
||||
gatewayQueue.setEnableBatchConflation(true);
|
||||
gatewayQueue.setMaximumQueueMemory(2048);
|
||||
gatewayQueue.setPersistent(false);
|
||||
|
||||
GatewayProxy gatewayProxy = new GatewayProxy();
|
||||
|
||||
gatewayProxy.setId("gatewayProxyId");
|
||||
gatewayProxy.setConcurrencyLevel(2);
|
||||
gatewayProxy.setEndpoints(null);
|
||||
gatewayProxy.setListeners(null);
|
||||
gatewayProxy.setOrderPolicy(Gateway.OrderPolicy.THREAD);
|
||||
gatewayProxy.setQueue(gatewayQueue);
|
||||
gatewayProxy.setSocketBufferSize(4096);
|
||||
gatewayProxy.setSocketReadTimeout(60);
|
||||
|
||||
GatewayHub mockGatewayHub = mock(GatewayHub.class, "testGatewayQueueWithOverflowNoPersistence.MockGatewayHub");
|
||||
|
||||
Gateway mockGateway = mock(Gateway.class, "testGatewayQueueWithOverflowNoPersistence.MockGateway");
|
||||
|
||||
GatewayQueueAttributes mockGatewayQueueAttributes = mock(GatewayQueueAttributes.class,
|
||||
"testGatewayQueueWithOverflowNoPersistence.MockGatewayQueueAttributes");
|
||||
|
||||
when(mockCache.addGatewayHub(eq(gatewayHubName), eq(10224))).thenReturn(mockGatewayHub);
|
||||
when(mockCache.getGatewayHub(eq(gatewayHubName))).thenReturn(mockGatewayHub);
|
||||
when(mockGatewayHub.addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel())))
|
||||
.thenReturn(mockGateway);
|
||||
when(mockGatewayHub.getManualStart()).thenReturn(GatewayHub.DEFAULT_MANUAL_START);
|
||||
when(mockGateway.getQueueAttributes()).thenReturn(mockGatewayQueueAttributes);
|
||||
|
||||
factoryBean.setGateways(Arrays.asList(gatewayProxy));
|
||||
factoryBean.setName(gatewayHubName);
|
||||
factoryBean.setPort(10224);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
verify(mockGatewayHub, times(1)).setBindAddress(eq(GatewayHub.DEFAULT_BIND_ADDRESS));
|
||||
verify(mockGatewayHub, times(1)).setManualStart(eq(GatewayHub.DEFAULT_MANUAL_START));
|
||||
verify(mockGatewayHub, times(1)).setMaxConnections(GatewayHub.DEFAULT_MAX_CONNECTIONS);
|
||||
verify(mockGatewayHub, times(1)).setMaximumTimeBetweenPings(eq(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS));
|
||||
verify(mockGatewayHub, times(1)).setSocketBufferSize(eq(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE));
|
||||
verify(mockGatewayHub, times(1)).setStartupPolicy(eq(GatewayHub.DEFAULT_STARTUP_POLICY));
|
||||
verify(mockGatewayHub, times(1)).start();
|
||||
verify(mockGatewayHub, times(1)).addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel()));
|
||||
verify(mockGateway, times(1)).setOrderPolicy(eq(gatewayProxy.getOrderPolicy()));
|
||||
verify(mockGateway, times(1)).setSocketBufferSize(eq(gatewayProxy.getSocketBufferSize()));
|
||||
verify(mockGateway, times(1)).setSocketReadTimeout(eq(gatewayProxy.getSocketReadTimeout()));
|
||||
verify(mockGatewayQueueAttributes, times(1)).setAlertThreshold(gatewayQueue.getAlertThreshold());
|
||||
verify(mockGatewayQueueAttributes, times(1)).setBatchConflation(gatewayQueue.getEnableBatchConflation());
|
||||
verify(mockGatewayQueueAttributes, times(1)).setBatchSize(gatewayQueue.getBatchSize());
|
||||
verify(mockGatewayQueueAttributes, times(1)).setBatchTimeInterval(gatewayQueue.getBatchTimeInterval());
|
||||
verify(mockGatewayQueueAttributes, times(1)).setDiskStoreName(gatewayQueue.getDiskStoreRef());
|
||||
verify(mockGatewayQueueAttributes, times(1)).setMaximumQueueMemory(gatewayQueue.getMaximumQueueMemory());
|
||||
verify(mockGatewayQueueAttributes, times(1)).setEnablePersistence(gatewayQueue.getPersistent());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* The OrderPolicyConverterTest class is a test suite of test cases testing the contract and functionality
|
||||
@@ -31,6 +31,7 @@ import com.gemstone.gemfire.cache.util.Gateway;
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.wan.OrderPolicyConverter
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -45,9 +46,9 @@ public class OrderPolicyConverterTest {
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
assertEquals(Gateway.OrderPolicy.KEY, converter.convert("key"));
|
||||
assertEquals(Gateway.OrderPolicy.PARTITION, converter.convert("Partition"));
|
||||
assertEquals(Gateway.OrderPolicy.THREAD, converter.convert("THREAD"));
|
||||
assertEquals(GatewaySender.OrderPolicy.KEY, converter.convert("key"));
|
||||
assertEquals(GatewaySender.OrderPolicy.PARTITION, converter.convert("Partition"));
|
||||
assertEquals(GatewaySender.OrderPolicy.THREAD, converter.convert("THREAD"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -64,9 +65,9 @@ public class OrderPolicyConverterTest {
|
||||
@Test
|
||||
public void testSetAsText() {
|
||||
converter.setAsText("PartItIOn");
|
||||
assertEquals(Gateway.OrderPolicy.PARTITION, converter.getValue());
|
||||
assertEquals(GatewaySender.OrderPolicy.PARTITION, converter.getValue());
|
||||
converter.setAsText("thREAD");
|
||||
assertEquals(Gateway.OrderPolicy.THREAD, converter.getValue());
|
||||
assertEquals(GatewaySender.OrderPolicy.THREAD, converter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* The OrderPolicyTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
@@ -31,7 +31,7 @@ import com.gemstone.gemfire.cache.util.Gateway;
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.wan.OrderPolicyType
|
||||
* @see com.gemstone.gemfire.cache.util.Gateway
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -39,8 +39,8 @@ public class OrderPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetOrderPolicy() {
|
||||
assertEquals(Gateway.OrderPolicy.KEY, OrderPolicyType.getOrderPolicy(OrderPolicyType.KEY));
|
||||
assertEquals(Gateway.OrderPolicy.PARTITION, OrderPolicyType.getOrderPolicy(OrderPolicyType.PARTITION));
|
||||
assertEquals(GatewaySender.OrderPolicy.KEY, OrderPolicyType.getOrderPolicy(OrderPolicyType.KEY));
|
||||
assertEquals(GatewaySender.OrderPolicy.PARTITION, OrderPolicyType.getOrderPolicy(OrderPolicyType.PARTITION));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -50,7 +50,7 @@ public class OrderPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testValueOfGemFireOrderPolicies() {
|
||||
for (Gateway.OrderPolicy orderPolicy : Gateway.OrderPolicy.values()) {
|
||||
for (GatewaySender.OrderPolicy orderPolicy : GatewaySender.OrderPolicy.values()) {
|
||||
OrderPolicyType orderPolicyType = OrderPolicyType.valueOf(orderPolicy);
|
||||
|
||||
assertNotNull(orderPolicyType);
|
||||
@@ -60,7 +60,7 @@ public class OrderPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testValueOfNullGemFireOrderPolicy() {
|
||||
assertNull(OrderPolicyType.valueOf((Gateway.OrderPolicy) null));
|
||||
assertNull(OrderPolicyType.valueOf((GatewaySender.OrderPolicy) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,85 +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.wan;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The StartupPolicyConverterTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the StartupPolicyConverter class.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see StartupPolicyType
|
||||
* @see StartupPolicyConverter
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class StartupPolicyConverterTest {
|
||||
|
||||
private StartupPolicyConverter converter = new StartupPolicyConverter();
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
converter.setValue(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
assertEquals(StartupPolicyType.NONE, converter.convert("none"));
|
||||
assertEquals(StartupPolicyType.PRIMARY, converter.convert("Primary"));
|
||||
assertEquals(StartupPolicyType.SECONDARY, converter.convert("SecONdARY"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testConvertIllegalValue() {
|
||||
try {
|
||||
converter.convert("tertiary");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("(tertiary) is not a valid StartupPolicyType!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAsText() {
|
||||
converter.setAsText("priMARY");
|
||||
assertEquals(StartupPolicyType.PRIMARY, converter.getValue());
|
||||
converter.setAsText("SecondAry");
|
||||
assertEquals(StartupPolicyType.SECONDARY, converter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetAsTextWithIllegalValue() {
|
||||
try {
|
||||
assertNull(converter.getValue());
|
||||
converter.setAsText("invalid");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("(invalid) is not a valid StartupPolicyType!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
assertNull(converter.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +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.wan;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
|
||||
/**
|
||||
* The StartupPolicyTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the StartupPolicyType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see StartupPolicyType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class StartupPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertEquals(GatewayHub.DEFAULT_STARTUP_POLICY, StartupPolicyType.DEFAULT.getName());
|
||||
assertSame(StartupPolicyType.NONE, StartupPolicyType.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(StartupPolicyType.NONE, StartupPolicyType.valueOfIgnoreCase("NONE"));
|
||||
assertEquals(StartupPolicyType.PRIMARY, StartupPolicyType.valueOfIgnoreCase("Primary"));
|
||||
assertEquals(StartupPolicyType.SECONDARY, StartupPolicyType.valueOfIgnoreCase("secondary"));
|
||||
assertEquals(StartupPolicyType.SECONDARY, StartupPolicyType.valueOfIgnoreCase("SECONDary"));
|
||||
assertEquals(StartupPolicyType.PRIMARY, StartupPolicyType.valueOfIgnoreCase("PriMarY"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(StartupPolicyType.valueOfIgnoreCase("NO"));
|
||||
assertNull(StartupPolicyType.valueOfIgnoreCase("Prime"));
|
||||
assertNull(StartupPolicyType.valueOfIgnoreCase("second"));
|
||||
assertNull(StartupPolicyType.valueOfIgnoreCase("all"));
|
||||
assertNull(StartupPolicyType.valueOfIgnoreCase("N0N3"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user