Search in sources :

Example 21 with RMIException

use of org.apache.geode.test.dunit.RMIException in project geode by apache.

the class SystemFailureDUnitTest method doCreateEntry.

protected void doCreateEntry(String name) {
    LogWriter log = org.apache.geode.test.dunit.LogWriterUtils.getLogWriter();
    log.info("<ExpectedException action=add>" + "dunit.RMIException" + "</ExpectedException>");
    Object[] args = new Object[] { name };
    Host host = Host.getHost(0);
    VM vm = host.getVM(0);
    try {
        vm.invoke(this.getClass(), "createEntry", args);
    } catch (RMIException e) {
    // expected
    }
    log.info("<ExpectedException action=add>" + "dunit.RMIException" + "</ExpectedException>");
}
Also used : RMIException(org.apache.geode.test.dunit.RMIException) LogWriter(org.apache.geode.LogWriter) VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host)

Example 22 with RMIException

use of org.apache.geode.test.dunit.RMIException in project geode by apache.

the class CqQueryUsingPoolDUnitTest method testCQCreateClose.

/**
   * Test for CQ register and UnRegister.
   */
@Test
public void testCQCreateClose() throws Exception {
    final Host host = Host.getHost(0);
    VM server = host.getVM(0);
    VM client = host.getVM(1);
    /* Init Server and Client */
    createServer(server);
    final int thePort = server.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
    final String host0 = NetworkUtils.getServerHostName(server.getHost());
    String poolName = "testCQCreateClose";
    System.out.println("##### Pool Name :" + poolName + " host :" + host0 + " port :" + thePort);
    createPool(client, poolName, host0, thePort);
    /* Create CQs. */
    createCQ(client, poolName, "testCQCreateClose_0", cqs[0]);
    validateCQCount(client, 1);
    executeCQ(client, "testCQCreateClose_0", false, null);
    /* Init values at server. */
    int size = 10;
    createValues(server, regions[0], size);
    // Wait for client to Synch.
    waitForCreated(client, "testCQCreateClose_0", KEY + size);
    // Check if Client and Server in sync.
    // validateServerClientRegionEntries(server, client, regions[0]);
    validateQuery(server, cqs[0], 10);
    // validate CQs.
    validateCQ(client, "testCQCreateClose_0", /* resultSize: */
    noTest, /* creates: */
    size, /* updates: */
    0, /* deletes; */
    0, /* queryInserts: */
    size, /* queryUpdates: */
    0, /* queryDeletes: */
    0, /* totalEvents: */
    size);
    // Test CQ stop
    stopCQ(client, "testCQCreateClose_0");
    // Test CQ re-enable
    executeCQ(client, "testCQCreateClose_0", false, null);
    // Test CQ Close
    closeCQ(client, "testCQCreateClose_0");
    // Create CQs with no name, execute, and close.
    // UNCOMMENT....
    createAndExecCQNoName(client, poolName, cqs[0]);
    // Accessing the closed CQ.
    failIfCQExists(client, "testCQCreateClose_0");
    // re-Create the cq which is closed.
    createCQ(client, poolName, "testCQCreateClose_0", cqs[0]);
    /* Test CQ Count */
    validateCQCount(client, 1);
    // Registering CQ with same name from same client.
    try {
        createCQ(client, poolName, "testCQCreateClose_0", cqs[0]);
        fail("Trying to create CQ with same name. Should have thrown CQExistsException");
    } catch (RMIException rmiExc) {
        Throwable cause = rmiExc.getCause();
        assertTrue("unexpected cause: " + cause.getClass().getName(), cause instanceof AssertionError);
        // should be a CQExistsException
        Throwable causeCause = cause.getCause();
        assertTrue("Got wrong exception: " + causeCause.getClass().getName(), causeCause instanceof CqExistsException);
    }
    // Getting values from non-existent CQ.
    failIfCQExists(client, "testCQCreateClose_NO");
    // Server Registering CQ.
    try {
        createCQ(server, "testCQCreateClose_1", cqs[0]);
        fail("Trying to create CQ on Cache Server. Should have thrown Exception.");
    } catch (RMIException rmiExc) {
        Throwable cause = rmiExc.getCause();
        assertTrue("unexpected cause: " + cause.getClass().getName(), cause instanceof AssertionError);
        // should be a IllegalStateException
        Throwable causeCause = cause.getCause();
        assertTrue("Got wrong exception: " + causeCause.getClass().getName(), causeCause instanceof IllegalStateException);
    }
    validateCQCount(client, 1);
    createCQ(client, poolName, "testCQCreateClose_3", cqs[2]);
    validateCQCount(client, 2);
    /* Test for closeAllCQs() */
    client.invoke(new CacheSerializableRunnable("CloseAll CQ :") {

        @Override
        public void run2() throws CacheException {
            LogWriterUtils.getLogWriter().info("### Close All CQ. ###");
            // Get CQ Service.
            QueryService cqService = null;
            try {
                cqService = getCache().getQueryService();
            } catch (Exception cqe) {
                LogWriterUtils.getLogWriter().info("Failed to getCQService.", cqe);
                Assert.fail("Failed to getCQService.", cqe);
            }
            // Close CQ.
            try {
                cqService.closeCqs();
            } catch (Exception ex) {
                LogWriterUtils.getLogWriter().info("Failed to close All CQ.", ex);
                Assert.fail("Failed to close All CQ. ", ex);
            }
        }
    });
    validateCQCount(client, 0);
    // Initialize.
    createCQ(client, poolName, "testCQCreateClose_2", cqs[1]);
    createCQ(client, poolName, "testCQCreateClose_4", cqs[1]);
    createCQ(client, poolName, "testCQCreateClose_5", cqs[1]);
    // Execute few of the initialized cqs
    executeCQ(client, "testCQCreateClose_4", false, null);
    executeCQ(client, "testCQCreateClose_5", false, null);
    // Call close all CQ.
    client.invoke(new CacheSerializableRunnable("CloseAll CQ 2 :") {

        @Override
        public void run2() throws CacheException {
            LogWriterUtils.getLogWriter().info("### Close All CQ 2. ###");
            // Get CQ Service.
            QueryService cqService = null;
            try {
                cqService = getCache().getQueryService();
            } catch (Exception cqe) {
                Assert.fail("Failed to getCQService.", cqe);
            }
            // Close CQ.
            try {
                cqService.closeCqs();
            } catch (Exception ex) {
                Assert.fail("Failed to close All CQ  . ", ex);
            }
        }
    });
    // Close.
    closeClient(client);
    closeServer(server);
}
Also used : RMIException(org.apache.geode.test.dunit.RMIException) CacheException(org.apache.geode.cache.CacheException) Host(org.apache.geode.test.dunit.Host) CqExistsException(org.apache.geode.cache.query.CqExistsException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) RMIException(org.apache.geode.test.dunit.RMIException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) QueryService(org.apache.geode.cache.query.QueryService) VM(org.apache.geode.test.dunit.VM) CqExistsException(org.apache.geode.cache.query.CqExistsException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Example 23 with RMIException

use of org.apache.geode.test.dunit.RMIException in project geode by apache.

the class LoginTimeOutDUnitTest method preTearDown.

@Override
public final void preTearDown() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    try {
        vm0.invoke(() -> LoginTimeOutDUnitTest.destroyTable());
    } catch (Exception e) {
        if ((e instanceof RMIException) || (e instanceof SQLException)) {
            // sometimes we have lock timeout problems destroying the table in
            // this test
            vm0.invoke(() -> disconnectFromDS());
        }
    }
}
Also used : RMIException(org.apache.geode.test.dunit.RMIException) SQLException(java.sql.SQLException) VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) NamingException(javax.naming.NamingException) RMIException(org.apache.geode.test.dunit.RMIException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Aggregations

RMIException (org.apache.geode.test.dunit.RMIException)23 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)20 Test (org.junit.Test)20 VM (org.apache.geode.test.dunit.VM)17 Host (org.apache.geode.test.dunit.Host)16 IgnoredException (org.apache.geode.test.dunit.IgnoredException)14 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)10 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)9 IOException (java.io.IOException)6 PartitionOfflineException (org.apache.geode.cache.persistence.PartitionOfflineException)6 Cache (org.apache.geode.cache.Cache)5 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)5 RevokedPersistentDataException (org.apache.geode.cache.persistence.RevokedPersistentDataException)4 AttributesFactory (org.apache.geode.cache.AttributesFactory)3 CacheClosedException (org.apache.geode.cache.CacheClosedException)3 DiskStore (org.apache.geode.cache.DiskStore)3 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)3 PartitionedRegionStorageException (org.apache.geode.cache.PartitionedRegionStorageException)3 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)3 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)3