use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class WANTestBase method createReceiver_PDX.
public static int createReceiver_PDX(int locPort) {
WANTestBase test = new WANTestBase();
Properties props = test.getDistributedSystemProperties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "localhost[" + locPort + "]");
InternalDistributedSystem ds = test.getSystem(props);
CacheConfig cacheConfig = new CacheConfig();
File pdxDir = new File(CacheTestCase.getDiskDir(), "pdx");
cacheConfig.setPdxPersistent(true);
cacheConfig.setPdxDiskStore("pdxStore");
cache = GemFireCacheImpl.create(ds, false, cacheConfig);
cache.createDiskStoreFactory().setDiskDirs(new File[] { pdxDir }).setMaxOplogSize(1).create("pdxStore");
GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
fact.setStartPort(port);
fact.setEndPort(port);
fact.setManualStart(true);
GatewayReceiver receiver = fact.create();
try {
receiver.start();
} catch (IOException e) {
e.printStackTrace();
fail("Test " + test.getName() + " failed to start GatewayReceiver on port " + port);
}
return port;
}
use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class WANTestBase method createReceiverAndServer.
public static void createReceiverAndServer(int locPort) {
WANTestBase test = new WANTestBase();
Properties props = test.getDistributedSystemProperties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "localhost[" + locPort + "]");
InternalDistributedSystem ds = test.getSystem(props);
cache = CacheFactory.create(ds);
GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
int receiverPort = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
fact.setStartPort(receiverPort);
fact.setEndPort(receiverPort);
fact.setManualStart(true);
GatewayReceiver receiver = fact.create();
try {
receiver.start();
} catch (IOException e) {
e.printStackTrace();
fail("Test " + test.getName() + " failed to start GatewayReceiver on port " + receiverPort);
}
CacheServer server = cache.addCacheServer();
int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(serverPort);
server.setHostnameForClients("localhost");
try {
server.start();
} catch (IOException e) {
org.apache.geode.test.dunit.Assert.fail("Failed to start server ", e);
}
}
use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class WANTestBase method createReceiverInSecuredCache.
public static int createReceiverInSecuredCache() {
GatewayReceiverFactory fact = WANTestBase.cache.createGatewayReceiverFactory();
int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
fact.setStartPort(port);
fact.setEndPort(port);
fact.setManualStart(true);
GatewayReceiver receiver = fact.create();
try {
receiver.start();
} catch (IOException e) {
e.printStackTrace();
org.apache.geode.test.dunit.Assert.fail("Failed to start GatewayReceiver on port " + port, e);
}
return port;
}
use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class CacheCreationJUnitTest method shouldCreateGatewaySenderAfterRegions.
@Test
public void shouldCreateGatewaySenderAfterRegions() {
CacheCreation cacheCreation = new CacheCreation();
GatewayReceiver receiver = mock(GatewayReceiver.class);
cacheCreation.addGatewayReceiver(receiver);
cacheCreation.addRootRegion(new RegionCreation(cacheCreation, "region"));
InternalCache internalCache = mock(InternalCache.class);
GatewayReceiverFactory receiverFactory = mock(GatewayReceiverFactory.class);
when(internalCache.createGatewayReceiverFactory()).thenReturn(receiverFactory);
when(receiverFactory.create()).thenReturn(receiver);
InOrder inOrder = inOrder(internalCache, receiverFactory);
cacheCreation.create(internalCache);
// inOrder.verify(cache).basicCreateRegion(eq("region"), any());
inOrder.verify(internalCache).createGatewayReceiverFactory();
inOrder.verify(receiverFactory).create();
}
use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class CacheXml70GatewayDUnitTest method testGatewayReceiver.
@Test
public void testGatewayReceiver() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
GatewayReceiverFactory gatewayReceiverFactory = cache.createGatewayReceiverFactory();
gatewayReceiverFactory.setBindAddress("");
gatewayReceiverFactory.setStartPort(20000);
gatewayReceiverFactory.setEndPort(29999);
gatewayReceiverFactory.setMaximumTimeBetweenPings(2000);
gatewayReceiverFactory.setSocketBufferSize(1500);
GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter1);
GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter2);
GatewayReceiver receiver1 = gatewayReceiverFactory.create();
receiver1.start();
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Set<GatewayReceiver> receivers = c.getGatewayReceivers();
for (GatewayReceiver receiver : receivers) {
validateGatewayReceiver(receiver1, receiver);
}
}
Aggregations