Search in sources :

Example 11 with GatewayReceiverFactory

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;
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) IOException(java.io.IOException) Properties(java.util.Properties) CacheConfig(org.apache.geode.internal.cache.CacheConfig) File(java.io.File)

Example 12 with GatewayReceiverFactory

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);
    }
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) CacheServer(org.apache.geode.cache.server.CacheServer) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) IOException(java.io.IOException) Properties(java.util.Properties)

Example 13 with GatewayReceiverFactory

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;
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) IOException(java.io.IOException)

Example 14 with GatewayReceiverFactory

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();
}
Also used : InOrder(org.mockito.InOrder) GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) InternalCache(org.apache.geode.internal.cache.InternalCache) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 15 with GatewayReceiverFactory

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);
    }
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

GatewayReceiverFactory (org.apache.geode.cache.wan.GatewayReceiverFactory)18 GatewayReceiver (org.apache.geode.cache.wan.GatewayReceiver)14 IOException (java.io.IOException)10 Properties (java.util.Properties)8 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)8 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)5 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)4 Test (org.junit.Test)3 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)2 CacheXml70DUnitTest (org.apache.geode.cache30.CacheXml70DUnitTest)2 MyGatewayTransportFilter1 (org.apache.geode.cache30.MyGatewayTransportFilter1)2 MyGatewayTransportFilter2 (org.apache.geode.cache30.MyGatewayTransportFilter2)2 WANTestBase (org.apache.geode.internal.cache.wan.WANTestBase)2 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)2 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 CacheXmlException (org.apache.geode.cache.CacheXmlException)1 Declarable (org.apache.geode.cache.Declarable)1