SGF-328 - Add missing 'hostname-for-senders' attribute on the <gfe:gateway-receiver> element in the SDG XML namespace (XSD).
This commit is contained in:
@@ -58,12 +58,13 @@ public class GatewayReceiverNamespaceTest {
|
||||
// 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);
|
||||
assertFalse(defaultFactoryBean.isAutoStartup());
|
||||
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());
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiverFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
import com.gemstone.gemfire.management.internal.cli.util.spring.StringUtils;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
@@ -133,7 +134,8 @@ public class StubGatewayReceiverFactory implements GatewayReceiverFactory {
|
||||
when(gatewayReceiver.getBindAddress()).thenReturn(this.bindAddress);
|
||||
when(gatewayReceiver.getEndPort()).thenReturn(this.endPort);
|
||||
when(gatewayReceiver.getGatewayTransportFilters()).thenReturn(this.gatewayTransportFilters);
|
||||
when(gatewayReceiver.getHost()).thenReturn(this.hostnameForClients);
|
||||
when(gatewayReceiver.getHost()).thenReturn(StringUtils.hasText(this.hostnameForSenders)
|
||||
? this.hostnameForSenders : this.hostnameForClients);
|
||||
when(gatewayReceiver.getMaximumTimeBetweenPings()).thenReturn(this.maximumTimeBetweenPings);
|
||||
when(gatewayReceiver.getSocketBufferSize()).thenReturn(this.socketBufferSize);
|
||||
when(gatewayReceiver.getStartPort()).thenReturn(this.startPort);
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.same;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiverFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
|
||||
/**
|
||||
* The GatewayReceiverFactoryBeanTest class...
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class GatewayReceiverFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testDoInit() throws Exception {
|
||||
Cache mockCache = mock(Cache.class, "testDoInit.Cache");
|
||||
GatewayReceiverFactory mockGatewayReceiverFactory = mock(GatewayReceiverFactory.class, "testDoInit.GatewayReceiverFactory");
|
||||
GatewayTransportFilter mockGatewayTransportFilter = mock(GatewayTransportFilter.class, "testDoInit.GatewayTransportFilter");
|
||||
|
||||
when(mockCache.createGatewayReceiverFactory()).thenReturn(mockGatewayReceiverFactory);
|
||||
|
||||
GatewayReceiverFactoryBean factoryBean = new GatewayReceiverFactoryBean(mockCache);
|
||||
|
||||
factoryBean.setBindAddress("10.224.112.77");
|
||||
factoryBean.setHostnameForSenders("skullbox");
|
||||
factoryBean.setStartPort(2048);
|
||||
factoryBean.setEndPort(4096);
|
||||
factoryBean.setManualStart(true);
|
||||
factoryBean.setMaximumTimeBetweenPings(5000);
|
||||
factoryBean.setName("testDoInit");
|
||||
factoryBean.setSocketBufferSize(16384);
|
||||
factoryBean.setTransportFilters(Arrays.asList(mockGatewayTransportFilter));
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
verify(mockGatewayReceiverFactory).setBindAddress(eq("10.224.112.77"));
|
||||
verify(mockGatewayReceiverFactory).setHostnameForSenders(eq("skullbox"));
|
||||
verify(mockGatewayReceiverFactory).setStartPort(eq(2048));
|
||||
verify(mockGatewayReceiverFactory).setEndPort(eq(4096));
|
||||
verify(mockGatewayReceiverFactory).setMaximumTimeBetweenPings(eq(5000));
|
||||
verify(mockGatewayReceiverFactory).setSocketBufferSize(eq(16384));
|
||||
verify(mockGatewayReceiverFactory).addGatewayTransportFilter(same(mockGatewayTransportFilter));
|
||||
verify(mockGatewayReceiverFactory).create();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testDoInitWithIllegalStartEndPorts() throws Exception {
|
||||
try {
|
||||
Cache mockCache = mock(Cache.class, "testDoInitWithIllegalStartEndPorts.Cache");
|
||||
GatewayReceiverFactory mockGatewayReceiverFactory = mock(GatewayReceiverFactory.class,
|
||||
"testDoInitWithIllegalStartEndPorts.GatewayReceiverFactory");
|
||||
|
||||
when(mockCache.createGatewayReceiverFactory()).thenReturn(mockGatewayReceiverFactory);
|
||||
|
||||
GatewayReceiverFactoryBean factoryBean = new GatewayReceiverFactoryBean(mockCache);
|
||||
|
||||
factoryBean.setName("testDoInitWithIllegalStartEndPorts");
|
||||
factoryBean.setStartPort(10240);
|
||||
factoryBean.setEndPort(8192);
|
||||
factoryBean.afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("'startPort' must be less than or equal to 8192.", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user