Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D24D18F9C for ; Fri, 5 Feb 2016 00:16:26 +0000 (UTC) Received: (qmail 79790 invoked by uid 500); 5 Feb 2016 00:16:26 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 79761 invoked by uid 500); 5 Feb 2016 00:16:25 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 79727 invoked by uid 99); 5 Feb 2016 00:16:25 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2016 00:16:25 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1CC8CC0E4F for ; Fri, 5 Feb 2016 00:16:25 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.649 X-Spam-Level: X-Spam-Status: No, score=-3.649 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.429] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id kD_oVtR9ZJGu for ; Fri, 5 Feb 2016 00:16:11 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id D7A1B31AFA for ; Fri, 5 Feb 2016 00:16:08 +0000 (UTC) Received: (qmail 78135 invoked by uid 99); 5 Feb 2016 00:16:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2016 00:16:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D7EB8DFC3C; Fri, 5 Feb 2016 00:16:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.incubator.apache.org Date: Fri, 05 Feb 2016 00:16:15 -0000 Message-Id: <62cea2ddc12d4210930dd54e0d348900@git.apache.org> In-Reply-To: <831c0cedc5cd47058b412d936a7ef0f8@git.apache.org> References: <831c0cedc5cd47058b412d936a7ef0f8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/33] incubator-geode git commit: Cleanup http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java b/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java index 6e07919..6e24398 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java @@ -80,8 +80,8 @@ import com.gemstone.gemfire.internal.logging.PureLogWriter; import com.gemstone.gemfire.internal.util.Callable; import com.gemstone.gemfire.test.dunit.Assert; import com.gemstone.gemfire.test.dunit.DistributedTestCase; -import com.gemstone.gemfire.test.dunit.DistributedTestSupport; -import com.gemstone.gemfire.test.dunit.NetworkSupport; +import com.gemstone.gemfire.test.dunit.DistributedTestUtils; +import com.gemstone.gemfire.test.dunit.NetworkUtils; import com.gemstone.gemfire.test.dunit.Wait; import com.gemstone.gemfire.test.dunit.WaitCriterion; @@ -212,7 +212,7 @@ public class SecurityTestUtil extends DistributedTestCase { Integer locatorPort = new Integer(AvailablePort .getRandomAvailablePort(AvailablePort.SOCKET)); - String addr = NetworkSupport.getIPLiteral(); + String addr = NetworkUtils.getIPLiteral(); if (locatorString == null) { locatorString = addr + "[" + locatorPort + ']'; } @@ -292,14 +292,14 @@ public class SecurityTestUtil extends DistributedTestCase { authProps.setProperty(DistributionConfig.LOCATORS_NAME, locatorString); if (locatorPort != null) { authProps.setProperty(DistributionConfig.START_LOCATOR_NAME, - NetworkSupport.getIPLiteral() + "[" + locatorPort.toString() + ']'); + NetworkUtils.getIPLiteral() + "[" + locatorPort.toString() + ']'); } } else { - authProps.setProperty("locators", "localhost["+DistributedTestSupport.getDUnitLocatorPort()+"]"); + authProps.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]"); } authProps.setProperty(DistributionConfig.SECURITY_LOG_LEVEL_NAME, "finest"); - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Set the server properties to: " + authProps); - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Set the java properties to: " + javaProps); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Set the server properties to: " + authProps); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Set the java properties to: " + javaProps); SecurityTestUtil tmpInstance = new SecurityTestUtil("temp"); try { @@ -310,7 +310,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (AuthenticationRequiredException ex) { if (expectedResult.intValue() == AUTHREQ_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when starting peer: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when starting peer: " + ex); return new Integer(0); } else { @@ -319,7 +319,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (AuthenticationFailedException ex) { if (expectedResult.intValue() == AUTHFAIL_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when starting peer: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when starting peer: " + ex); return new Integer(0); } else { @@ -427,7 +427,7 @@ public class SecurityTestUtil extends DistributedTestCase { //poolFactory.setSubscriptionEnabled(false); } pool = ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory, - NetworkSupport.getIPLiteral(), portsI, subscriptionEnabled, 0, + NetworkUtils.getIPLiteral(), portsI, subscriptionEnabled, 0, numConnections == null ? -1 : numConnections.intValue(), null, null, poolFactory); @@ -436,14 +436,14 @@ public class SecurityTestUtil extends DistributedTestCase { } tmpInstance.openCache(); try { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("multi-user mode " + multiUserAuthMode); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("multi-user mode " + multiUserAuthMode); proxyCaches[0] = (ProxyCache)((PoolImpl) pool).createAuthenticatedCacheView(authProps); if (!multiUserAuthMode) { fail("Expected a UnsupportedOperationException but got none in single-user mode"); } } catch (UnsupportedOperationException uoe) { if (!multiUserAuthMode) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected UnsupportedOperationException in single-user mode"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected UnsupportedOperationException in single-user mode"); } else { Assert.fail("Got unexpected exception in multi-user mode ", uoe); @@ -467,7 +467,7 @@ public class SecurityTestUtil extends DistributedTestCase { catch (AuthenticationRequiredException ex) { if (expectedResult.intValue() == AUTHREQ_EXCEPTION || expectedResult.intValue() == NOFORCE_AUTHREQ_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when starting client: " + ex); } else { @@ -476,7 +476,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (AuthenticationFailedException ex) { if (expectedResult.intValue() == AUTHFAIL_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when starting client: " + ex); } else { @@ -485,7 +485,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (ServerRefusedConnectionException ex) { if (expectedResult.intValue() == CONNREFUSED_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when starting client: " + ex); } else { @@ -569,7 +569,7 @@ public class SecurityTestUtil extends DistributedTestCase { poolFactory.setMultiuserAuthentication(multiUserAuthMode); poolFactory.setSubscriptionEnabled(true); pool = ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory, - NetworkSupport.getIPLiteral(), portsI, true, 1, + NetworkUtils.getIPLiteral(), portsI, true, 1, numConnections == null ? -1 : numConnections.intValue(), null, null, poolFactory); @@ -596,7 +596,7 @@ public class SecurityTestUtil extends DistributedTestCase { catch (AuthenticationRequiredException ex) { if (expectedResult.intValue() == AUTHREQ_EXCEPTION || expectedResult.intValue() == NOFORCE_AUTHREQ_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when starting client: " + ex); } else { @@ -605,7 +605,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (AuthenticationFailedException ex) { if (expectedResult.intValue() == AUTHFAIL_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when starting client: " + ex); } else { @@ -614,7 +614,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (ServerRefusedConnectionException ex) { if (expectedResult.intValue() == CONNREFUSED_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when starting client: " + ex); } else { @@ -669,7 +669,7 @@ public class SecurityTestUtil extends DistributedTestCase { } authProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); authProps.setProperty(DistributionConfig.LOCATORS_NAME, - NetworkSupport.getIPLiteral() + "[" + port + "]"); + NetworkUtils.getIPLiteral() + "[" + port + "]"); authProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false"); clearStaticSSLContext(); setJavaProps((Properties)javaProps); @@ -762,7 +762,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing puts: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex); } else { Assert.fail("Got unexpected exception when doing puts", ex); @@ -782,7 +782,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch(NoAvailableServersException ex) { if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when doing puts: " + ex.getCause()); continue; @@ -794,27 +794,27 @@ public class SecurityTestUtil extends DistributedTestCase { catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing puts: " + ex.getCause()); continue; } if ((expectedResult.intValue() == AUTHREQ_EXCEPTION) && (ex.getCause() instanceof AuthenticationRequiredException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected AuthenticationRequiredException when doing puts: " + ex.getCause()); continue; } if ((expectedResult.intValue() == AUTHFAIL_EXCEPTION) && (ex.getCause() instanceof AuthenticationFailedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected AuthenticationFailedException when doing puts: " + ex.getCause()); continue; } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing puts: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex); } else { Assert.fail("Got unexpected exception when doing puts", ex); @@ -822,7 +822,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing puts: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex); } else { Assert.fail("Got unexpected exception when doing puts", ex); @@ -845,7 +845,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing getAll: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex); } else { Assert.fail("Got unexpected exception when doing getAll", ex); @@ -874,7 +874,7 @@ public class SecurityTestUtil extends DistributedTestCase { } } catch (NoAvailableServersException ex) { if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when doing getAll: " + ex.getCause()); } else { @@ -883,17 +883,17 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing getAll: " + ex.getCause()); } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing getAll: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex); } else { Assert.fail("Got unexpected exception when doing getAll", ex); } } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing getAll: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex); } else { Assert.fail("Got unexpected exception when doing getAll", ex); } @@ -921,7 +921,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing gets: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex); } else { Assert.fail("Got unexpected exception when doing gets", ex); @@ -942,7 +942,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch(NoAvailableServersException ex) { if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when doing gets: " + ex.getCause()); continue; @@ -954,13 +954,13 @@ public class SecurityTestUtil extends DistributedTestCase { catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing gets: " + ex.getCause()); continue; } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing gets: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex); } else { Assert.fail("Got unexpected exception when doing gets", ex); @@ -968,7 +968,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing gets: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex); } else { Assert.fail("Got unexpected exception when doing gets", ex); @@ -1022,7 +1022,7 @@ public class SecurityTestUtil extends DistributedTestCase { assertNotNull(region); } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when doing region destroy: " + ex); } else { Assert.fail("Got unexpected exception when doing region destroy", ex); @@ -1042,7 +1042,7 @@ public class SecurityTestUtil extends DistributedTestCase { assertNull(region); } catch (NoAvailableServersException ex) { if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when doing region destroy: " + ex.getCause()); } else { @@ -1051,18 +1051,18 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing region destroy: " + ex.getCause()); } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when doing region destroy: " + ex); } else { Assert.fail("Got unexpected exception when doing region destroy", ex); } } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when doing region destroy: " + ex); } else { Assert.fail("Got unexpected exception when doing region destroy", ex); @@ -1086,7 +1086,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing destroys: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex); } else { Assert.fail("Got unexpected exception when doing destroys", ex); @@ -1101,7 +1101,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch(NoAvailableServersException ex) { if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when doing destroys: " + ex.getCause()); continue; @@ -1113,13 +1113,13 @@ public class SecurityTestUtil extends DistributedTestCase { catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing destroys: " + ex.getCause()); continue; } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing destroys: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex); } else { Assert.fail("Got unexpected exception when doing destroys", ex); @@ -1127,7 +1127,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing destroys: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex); } else { Assert.fail("Got unexpected exception when doing destroys", ex); @@ -1152,7 +1152,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing invalidates: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex); } else { Assert.fail("Got unexpected exception when doing invalidates", ex); @@ -1167,7 +1167,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch(NoAvailableServersException ex) { if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when doing invalidates: " + ex.getCause()); continue; @@ -1179,13 +1179,13 @@ public class SecurityTestUtil extends DistributedTestCase { catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing invalidates: " + ex.getCause()); continue; } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing invalidates: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex); } else { Assert.fail("Got unexpected exception when doing invalidates", ex); @@ -1193,7 +1193,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing invalidates: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex); } else { Assert.fail("Got unexpected exception when doing invalidates", ex); @@ -1218,7 +1218,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing containsKey: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex); } else { Assert.fail("Got unexpected exception when doing containsKey", ex); @@ -1234,7 +1234,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch(NoAvailableServersException ex) { if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when doing containsKey: " + ex.getCause()); continue; @@ -1246,13 +1246,13 @@ public class SecurityTestUtil extends DistributedTestCase { catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing containsKey: " + ex.getCause()); continue; } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing containsKey: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex); } else { Assert.fail("Got unexpected exception when doing containsKey", ex); @@ -1260,7 +1260,7 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing containsKey: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex); } else { Assert.fail("Got unexpected exception when doing containsKey", ex); @@ -1282,7 +1282,7 @@ public class SecurityTestUtil extends DistributedTestCase { assertNotNull(region); } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing queries: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex); } else { Assert.fail("Got unexpected exception when doing queries", ex); } @@ -1297,7 +1297,7 @@ public class SecurityTestUtil extends DistributedTestCase { } } catch (NoAvailableServersException ex) { if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when doing queries: " + ex.getCause()); } else { @@ -1306,28 +1306,28 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing queries: " + ex.getCause()); } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing queries: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex); } else { Assert.fail("Got unexpected exception when doing queries", ex); } } catch (QueryInvocationTargetException qite) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (qite.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when doing queries: " + qite.getCause()); } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing queries: " + qite); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + qite); } else { Assert.fail("Got unexpected exception when doing queries", qite); } } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Got expected exception when doing queries: " + ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex); } else { Assert.fail("Got unexpected exception when doing queries", ex); } @@ -1347,7 +1347,7 @@ public class SecurityTestUtil extends DistributedTestCase { assertNotNull(region); } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when executing function: " + ex); } else { Assert.fail("Got unexpected exception when executing function", ex); @@ -1377,7 +1377,7 @@ public class SecurityTestUtil extends DistributedTestCase { } } catch (NoAvailableServersException ex) { if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when executing function: " + ex.getCause()); } else { @@ -1386,11 +1386,11 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when executing function: " + ex.getCause()); } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when executing function: " + ex); } else { Assert.fail("Got unexpected exception when executing function", ex); @@ -1400,18 +1400,18 @@ public class SecurityTestUtil extends DistributedTestCase { && ((ex.getCause() instanceof NotAuthorizedException) || ((ex .getCause() instanceof ServerOperationException) && (((ServerOperationException)ex .getCause()).getCause() instanceof NotAuthorizedException)))) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when executing function: " + ex.getCause()); } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when executing function: " + ex); } else { Assert.fail("Got unexpected exception when executing function", ex); } } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when executing function: " + ex); } else { Assert.fail("Got unexpected exception when executing function", ex); @@ -1431,7 +1431,7 @@ public class SecurityTestUtil extends DistributedTestCase { assertNotNull(region); } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when executing query: " + ex); } else { Assert.fail("Got unexpected exception when executing query", ex); @@ -1453,7 +1453,7 @@ public class SecurityTestUtil extends DistributedTestCase { assertEquals(expectedValue.intValue(), result.asList().size()); } catch (NoAvailableServersException ex) { if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NoAvailableServers when executing query: " + ex.getCause()); } else { @@ -1462,18 +1462,18 @@ public class SecurityTestUtil extends DistributedTestCase { } catch (ServerConnectivityException ex) { if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected NotAuthorizedException when executing query: " + ex.getCause()); } else if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when executing query: " + ex); } else { Assert.fail("Got unexpected exception when executing query", ex); } } catch (Exception ex) { if (expectedResult.intValue() == OTHER_EXCEPTION) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "Got expected exception when executing query: " + ex); } else { Assert.fail("Got unexpected exception when executing query", ex); @@ -1498,7 +1498,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but expected results " + expectedResults.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("PUT: MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("PUT: MultiUser# " + i); doPutsP(num, Integer.valueOf(i), expectedResults[i], false); } } @@ -1524,7 +1524,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but expected results " + expectedResults.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info( "GET_ALL" + (useTX ? " in TX" : "") + ": MultiUser# " + i); doGetAllP(Integer.valueOf(i), expectedResults[i], useTX); } @@ -1537,7 +1537,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but expected results " + expectedResults.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("GET: MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("GET: MultiUser# " + i); doGetsP(num, Integer.valueOf(i), expectedResults[i], false); } } @@ -1549,7 +1549,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but expected results " + expectedResults.length); } for (int i = numOfUsers-1; i >= 0; i--) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("DESTROY: MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("DESTROY: MultiUser# " + i); doRegionDestroysP(Integer.valueOf(i), expectedResults[i]); } } @@ -1561,7 +1561,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but expected results " + expectedResults.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("DESTROY: MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("DESTROY: MultiUser# " + i); doDestroysP(num, Integer.valueOf(i), expectedResults[i], false); } } @@ -1573,7 +1573,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but expected results " + expectedResults.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("INVALIDATE: MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("INVALIDATE: MultiUser# " + i); doInvalidatesP(num, Integer.valueOf(i), expectedResults[i], false); } } @@ -1589,7 +1589,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but #expected output " + results.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("CONTAINS_KEY: MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("CONTAINS_KEY: MultiUser# " + i); doContainsKeysP(num, Integer.valueOf(i), expectedResults[i], false, results[i]); } } @@ -1601,7 +1601,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but #expected results " + expectedResults.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("QUERY: MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("QUERY: MultiUser# " + i); doQueriesP(Integer.valueOf(i), expectedResults[i], valueSize); } } @@ -1617,16 +1617,16 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but #expected output " + results.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("FunctionExecute:onRegion MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("FunctionExecute:onRegion MultiUser# " + i); doFunctionExecuteP(Integer.valueOf(i), function, expectedResults[i], results[i], "region"); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("FunctionExecute:onServer MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("FunctionExecute:onServer MultiUser# " + i); doFunctionExecuteP(Integer.valueOf(i), function, expectedResults[i], results[i], "server"); } if (!isFailoverCase) { for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("FunctionExecute:onServers MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("FunctionExecute:onServers MultiUser# " + i); doFunctionExecuteP(Integer.valueOf(i), function, expectedResults[i], results[i], "servers"); } @@ -1640,7 +1640,7 @@ public class SecurityTestUtil extends DistributedTestCase { + ", but #expected results " + expectedResults.length); } for (int i = 0; i < numOfUsers; i++) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("QueryExecute: MultiUser# " + i); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("QueryExecute: MultiUser# " + i); doQueryExecuteP(Integer.valueOf(i), expectedResults[i], result); } } @@ -1687,7 +1687,7 @@ public class SecurityTestUtil extends DistributedTestCase { fail("Expected " + expectedResult + " but found " + e.getClass().getSimpleName() + " in doSimpleGet()"); } else { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().fine( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().fine( "Got expected " + e.getClass().getSimpleName() + " in doSimpleGet()"); } @@ -1707,7 +1707,7 @@ public class SecurityTestUtil extends DistributedTestCase { Assert.fail("Expected " + expectedResult + " but found " + e.getClass().getSimpleName() + " in doSimplePut()", e); } else { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().fine( + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().fine( "Got expected " + e.getClass().getSimpleName() + " in doSimplePut()"); } @@ -1735,11 +1735,11 @@ public class SecurityTestUtil extends DistributedTestCase { } } catch (IllegalAccessException ex) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter() + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter() .warning("Exception while clearing static SSL field.", ex); } catch (ClassCastException ex) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter() + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter() .warning("Exception while clearing static SSL field.", ex); } } @@ -1759,7 +1759,7 @@ public class SecurityTestUtil extends DistributedTestCase { assertNull(field.get(obj)); } catch (IllegalAccessException ex) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().warning("Exception while clearing SSL fields.", ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().warning("Exception while clearing SSL fields.", ex); } } } @@ -1784,7 +1784,7 @@ public class SecurityTestUtil extends DistributedTestCase { } } catch (IllegalAccessException ex) { - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().warning("Exception while getting SSL fields.", ex); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().warning("Exception while getting SSL fields.", ex); } } return resultFields; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Assert.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Assert.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Assert.java index 10c62da..5d927eb 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Assert.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Assert.java @@ -17,17 +17,45 @@ package com.gemstone.gemfire.test.dunit; /** - * Extracted from DistributedTestCase + * Extends org.junit.Assert with additional assertion and fail + * methods. + * + * These methods can be used directly: Assert.assertEquals(...), + * however, they are intended to be referenced through static import: + * + *
+ * import static com.gemstone.gemfire.test.dunit.Assert.*;
+ *    ...
+ *    fail(...);
+ * 
+ * + * Extracted from DistributedTestCase. + * + * @see java.lang.AssertionError */ public class Assert extends org.junit.Assert { protected Assert() { } + /** + * Fails a test by throwing a new {@code AssertionError} with the specified + * detail message and cause. + * + *

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this error's detail message. + * + * @param message the detail message, may be {@code null} + * @param cause the cause, may be {@code null} + * + * @see java.lang.AssertionError + */ public static void fail(final String message, final Throwable cause) { if (message == null && cause == null) { throw new AssertionError(); - } if (message == null) { + } + if (message == null) { throw new AssertionError(cause); } if (cause == null) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java index e589863..544638e 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java @@ -158,20 +158,22 @@ public class AsyncInvocation extends Thread { ////////////////////// Inner Classes ////////////////////// /** - * A ThreadGroup that notices when an exception occurrs + * A ThreadGroup that notices when an exception occurs * during an AsyncInvocation. + * + * TODO: reimplement using Futures */ private static class AsyncInvocationGroup extends ThreadGroup { AsyncInvocationGroup() { super("Async Invocations"); } - public void uncaughtException(Thread t, Throwable e) { - if (e instanceof VirtualMachineError) { - SystemFailure.setFailure((VirtualMachineError)e); // don't throw + public void uncaughtException(Thread thread, Throwable throwable) { + if (throwable instanceof VirtualMachineError) { + SystemFailure.setFailure((VirtualMachineError)throwable); // don't throw } - if (t instanceof AsyncInvocation) { - ((AsyncInvocation) t).exception = e; + if (thread instanceof AsyncInvocation) { + ((AsyncInvocation) thread).exception = throwable; } } } @@ -202,8 +204,7 @@ public class AsyncInvocation extends Thread { return this.returnedObj; } - public void run() - { + public void run() { super.run(); this.returnedObj = (T) returnValue.get(); returnValue.set(null); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java index eea2d65..d662779 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java @@ -35,7 +35,6 @@ import com.gemstone.gemfire.test.dunit.standalone.BounceResult; * and run them on a different VM launching system. * * @author dsmith - * */ public abstract class DUnitEnv { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DebuggerSupport.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DebuggerSupport.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DebuggerSupport.java deleted file mode 100755 index 9de33e5..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DebuggerSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 com.gemstone.gemfire.test.dunit; - -public class DebuggerSupport { - - protected DebuggerSupport() { - } - - public static void attachDebugger(VM vm, final String msg) { - vm.invoke(new SerializableRunnable("Attach Debugger") { - public void run() { - com.gemstone.gemfire.internal.util.DebuggerSupport. - waitForJavaDebugger(msg); - } - }); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DebuggerUtils.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DebuggerUtils.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DebuggerUtils.java new file mode 100755 index 0000000..534eab2 --- /dev/null +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DebuggerUtils.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.test.dunit; + +import com.gemstone.gemfire.internal.util.DebuggerSupport; + +/** + * DebuggerUtils provides static utility methods that facilitate + * runtime debugging. + * + * These methods can be used directly: DebuggerUtils.attachDebugger(...), + * however, they are intended to be referenced through static import: + * + *

+ * import static com.gemstone.gemfire.test.dunit.DebuggerUtils.*;
+ *    ...
+ *    attachDebugger(...);
+ * 
+ * + * Extracted from DistributedTestCase. + * + * @see com.gemstone.gemfire.internal.util.DebuggerSupport + */ +public class DebuggerUtils { + + protected DebuggerUtils() { + } + + @SuppressWarnings("serial") + public static void attachDebugger(final VM vm, final String message) { + vm.invoke(new SerializableRunnable(DebuggerSupport.class.getSimpleName()+" waitForJavaDebugger") { + public void run() { + DebuggerSupport.waitForJavaDebugger(message); + } + }); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedSystemSupport.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedSystemSupport.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedSystemSupport.java deleted file mode 100755 index 4356646..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedSystemSupport.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 com.gemstone.gemfire.test.dunit; - -import java.io.File; - -import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.distributed.internal.membership.gms.MembershipManagerHelper; - -public class DistributedSystemSupport { - - /** - * Crash the cache in the given VM in such a way that it immediately stops communicating with - * peers. This forces the VM's membership manager to throw a ForcedDisconnectException by - * forcibly terminating the JGroups protocol stack with a fake EXIT event.

- * - * NOTE: if you use this method be sure that you clean up the VM before the end of your - * test with disconnectFromDS() or disconnectAllFromDS(). - */ - public static void crashDistributedSystem(final DistributedSystem msys) { - MembershipManagerHelper.crashDistributedSystem(msys); - MembershipManagerHelper.inhibitForcedDisconnectLogging(false); - WaitCriterion wc = new WaitCriterion() { - public boolean done() { - return !msys.isConnected(); - } - public String description() { - return "waiting for distributed system to finish disconnecting: " + msys; - } - }; - Wait.waitForCriterion(wc, 10000, 1000, true); - } - - /** - * Crash the cache in the given VM in such a way that it immediately stops communicating with - * peers. This forces the VM's membership manager to throw a ForcedDisconnectException by - * forcibly terminating the JGroups protocol stack with a fake EXIT event.

- * - * NOTE: if you use this method be sure that you clean up the VM before the end of your - * test with disconnectFromDS() or disconnectAllFromDS(). - */ - public static boolean crashDistributedSystem(VM vm) { - return (Boolean)vm.invoke(new SerializableCallable("crash distributed system") { - public Object call() throws Exception { - DistributedSystem msys = InternalDistributedSystem.getAnyInstance(); - crashDistributedSystem(msys); - return true; - } - }); - } - - /** - * delete locator state files. Use this after getting a random port - * to ensure that an old locator state file isn't picked up by the - * new locator you're starting. - * @param ports - */ - public static void deleteLocatorStateFile(int... ports) { - for (int i=0; i testHistory = new LinkedHashSet(); @@ -129,7 +130,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se } if (system == null || !system.isConnected()) { // Figure out our distributed system properties - Properties p = DistributedTestSupport.getAllDistributedSystemProperties(props); + Properties p = DistributedTestUtils.getAllDistributedSystemProperties(props); lastSystemCreatedInTest = getClass(); // used to be getDeclaringClass() if (logPerTest) { String testMethod = getTestMethodName(); @@ -146,10 +147,10 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se } else { boolean needNewSystem = false; if(!getClass().equals(lastSystemCreatedInTest)) { // used to be getDeclaringClass() - Properties newProps = DistributedTestSupport.getAllDistributedSystemProperties(props); + Properties newProps = DistributedTestUtils.getAllDistributedSystemProperties(props); needNewSystem = !newProps.equals(lastSystemProperties); if(needNewSystem) { - LogWriterSupport.getLogWriter().info( + LogWriterUtils.getLogWriter().info( "Test class has changed and the new DS properties are not an exact match. " + "Forcing DS disconnect. Old props = " + lastSystemProperties + "new props=" + newProps); @@ -163,7 +164,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se String value = (String) entry.getValue(); if (!value.equals(activeProps.getProperty(key))) { needNewSystem = true; - LogWriterSupport.getLogWriter().info("Forcing DS disconnect. For property " + key + LogWriterUtils.getLogWriter().info("Forcing DS disconnect. For property " + key + " old value = " + activeProps.getProperty(key) + " new value = " + value); break; @@ -173,7 +174,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se if(needNewSystem) { // the current system does not meet our needs to disconnect and // call recursively to get a new system. - LogWriterSupport.getLogWriter().info("Disconnecting from current DS in order to make a new one"); + LogWriterUtils.getLogWriter().info("Disconnecting from current DS in order to make a new one"); disconnectFromDS(); getSystem(props); } @@ -458,7 +459,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se Invoke.invokeInEveryVM(()->tearDownVM()); Invoke.invokeInLocator(()->{ DistributionMessageObserver.setInstance(null); - DistributedTestSupport.unregisterInstantiatorsInThisVM(); + DistributedTestUtils.unregisterInstantiatorsInThisVM(); }); DUnitLauncher.closeAndCheckForSuspects(); } @@ -473,7 +474,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se ClientServerTestCase.AUTO_LOAD_BALANCE = false; ClientStatsManager.cleanupForTests(); DiskStoreObserver.setInstance(null); - DistributedTestSupport.unregisterInstantiatorsInThisVM(); + DistributedTestUtils.unregisterInstantiatorsInThisVM(); DistributionMessageObserver.setInstance(null); GlobalLockingDUnitTest.region_testBug32356 = null; InitialImageOperation.slowImageProcessing = 0; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestSupport.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestSupport.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestSupport.java deleted file mode 100755 index 4e8546f..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestSupport.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 com.gemstone.gemfire.test.dunit; - -import static org.junit.Assert.assertEquals; - -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; - -import com.gemstone.gemfire.distributed.internal.DistributionConfig; -import com.gemstone.gemfire.internal.InternalDataSerializer; -import com.gemstone.gemfire.internal.InternalInstantiator; -import com.gemstone.gemfire.internal.cache.tier.sockets.DataSerializerPropogationDUnitTest; - -public class DistributedTestSupport { - - protected DistributedTestSupport() { - } - - /** - * Fetches the GemFireDescription for this test and adds its - * DistributedSystem properties to the provided props parameter. - * - * @param config the properties to add hydra's test properties to - */ - public static void addHydraProperties(Properties config) { - Properties p = DUnitEnv.get().getDistributedSystemProperties(); - for (Iterator iter = p.entrySet().iterator(); - iter.hasNext(); ) { - Map.Entry entry = (Map.Entry) iter.next(); - String key = (String) entry.getKey(); - String value = (String) entry.getValue(); - if (config.getProperty(key) == null) { - config.setProperty(key, value); - } - } - } - - public final static Properties getAllDistributedSystemProperties(Properties props) { - Properties p = DUnitEnv.get().getDistributedSystemProperties(); - - // our tests do not expect auto-reconnect to be on by default - if (!p.contains(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME)) { - p.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true"); - } - - for (Iterator iter = props.entrySet().iterator(); - iter.hasNext(); ) { - Map.Entry entry = (Map.Entry) iter.next(); - String key = (String) entry.getKey(); - Object value = entry.getValue(); - p.put(key, value); - } - return p; - } - - /** - * Get the port that the standard dunit locator is listening on. - */ - public static int getDUnitLocatorPort() { - return DUnitEnv.get().getLocatorPort(); - } - - public static void unregisterAllDataSerializersFromAllVms() { - DistributedTestSupport.unregisterDataSerializerInThisVM(); - Invoke.invokeInEveryVM(new SerializableRunnable() { - public void run() { - DistributedTestSupport.unregisterDataSerializerInThisVM(); - } - }); - Invoke.invokeInLocator(new SerializableRunnable() { - public void run() { - DistributedTestSupport.unregisterDataSerializerInThisVM(); - } - }); - } - - public static void unregisterDataSerializerInThisVM() { - DataSerializerPropogationDUnitTest.successfullyLoadedTestDataSerializer = false; - // unregister all the Dataserializers - InternalDataSerializer.reinitialize(); - // ensure that all are unregistered - assertEquals(0, InternalDataSerializer.getSerializers().length); - } - - public static void unregisterInstantiatorsInThisVM() { - // unregister all the instantiators - InternalInstantiator.reinitialize(); - assertEquals(0, InternalInstantiator.getInstantiators().length); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java new file mode 100755 index 0000000..39c8ab3 --- /dev/null +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.test.dunit; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; + +import com.gemstone.gemfire.distributed.DistributedSystem; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; +import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; +import com.gemstone.gemfire.distributed.internal.membership.gms.MembershipManagerHelper; +import com.gemstone.gemfire.internal.InternalDataSerializer; +import com.gemstone.gemfire.internal.InternalInstantiator; + +/** + * DistributedTestUtils provides static utility methods that + * affect the runtime environment or artifacts generated by a DistributedTest. + * + * These methods can be used directly: DistributedTestUtils.crashDistributedSystem(...), + * however, they are intended to be referenced through static import: + * + *

+ * import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.*;
+ *    ...
+ *    crashDistributedSystem(...);
+ * 
+ * + * Extracted from DistributedTestCase. + */ +public class DistributedTestUtils { + + protected DistributedTestUtils() { + } + + /** + * Fetches the GemFireDescription for this test and adds its + * DistributedSystem properties to the provided props parameter. + * + * @param properties the properties to add hydra's test properties to + */ + public static void addHydraProperties(final Properties properties) { + Properties dsProperties = DUnitEnv.get().getDistributedSystemProperties(); + for (Iterator> iter = dsProperties.entrySet().iterator(); iter.hasNext();) { + Map.Entry entry = iter.next(); + String key = (String) entry.getKey(); + String value = (String) entry.getValue(); + if (properties.getProperty(key) == null) { + properties.setProperty(key, value); + } + } + } + + /** + * Crash the cache in the given VM in such a way that it immediately stops communicating with + * peers. This forces the VM's membership manager to throw a ForcedDisconnectException by + * forcibly terminating the JGroups protocol stack with a fake EXIT event.

+ * + * NOTE: if you use this method be sure that you clean up the VM before the end of your + * test with disconnectFromDS() or disconnectAllFromDS(). + */ + public static void crashDistributedSystem(final DistributedSystem system) { + MembershipManagerHelper.crashDistributedSystem(system); + MembershipManagerHelper.inhibitForcedDisconnectLogging(false); + WaitCriterion wc = new WaitCriterion() { + public boolean done() { + return !system.isConnected(); + } + public String description() { + return "Waiting for distributed system to finish disconnecting: " + system; + } + }; + Wait.waitForCriterion(wc, 10000, 1000, true); + } + + /** + * Crash the cache in the given VM in such a way that it immediately stops communicating with + * peers. This forces the VM's membership manager to throw a ForcedDisconnectException by + * forcibly terminating the JGroups protocol stack with a fake EXIT event.

+ * + * NOTE: if you use this method be sure that you clean up the VM before the end of your + * test with disconnectFromDS() or disconnectAllFromDS(). + */ + @SuppressWarnings("serial") + public static boolean crashDistributedSystem(final VM vm) { + return vm.invoke(new SerializableCallable(DistributedTestUtils.class.getSimpleName() + " crashDistributedSystem") { + public Boolean call() throws Exception { + DistributedSystem system = InternalDistributedSystem.getAnyInstance(); + crashDistributedSystem(system); + return true; + } + }); + } + + /** + * Delete locator state files. Use this after getting a random port + * to ensure that an old locator state file isn't picked up by the + * new locator you're starting. + */ + public static void deleteLocatorStateFile(final int... ports) { + for (int index = 0; index < ports.length; index++) { + File stateFile = new File("locator"+ports[index]+"view.dat"); + if (stateFile.exists()) { + stateFile.delete(); + } + } + } + + public final static Properties getAllDistributedSystemProperties(final Properties properties) { + Properties dsProperties = DUnitEnv.get().getDistributedSystemProperties(); + + // our tests do not expect auto-reconnect to be on by default + if (!dsProperties.contains(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME)) { + dsProperties.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true"); + } + + for (Iterator> iterator = properties.entrySet().iterator(); iterator.hasNext();) { + Map.Entry entry = iterator.next(); + String key = (String) entry.getKey(); + Object value = entry.getValue(); + dsProperties.put(key, value); + } + return dsProperties; + } + + /** + * Get the port that the standard dunit locator is listening on. + */ + public static int getDUnitLocatorPort() { + return DUnitEnv.get().getLocatorPort(); + } + + public static void unregisterAllDataSerializersFromAllVms() { + DistributedTestUtils.unregisterDataSerializerInThisVM(); + Invoke.invokeInEveryVM(()->unregisterDataSerializerInThisVM()); + Invoke.invokeInLocator(()->unregisterDataSerializerInThisVM()); + } + + public static void unregisterDataSerializerInThisVM() { + // TODO:KIRK: delete DataSerializerPropogationDUnitTest.successfullyLoadedTestDataSerializer = false; + // unregister all the Dataserializers + InternalDataSerializer.reinitialize(); + // ensure that all are unregistered + assertEquals(0, InternalDataSerializer.getSerializers().length); + } + + public static void unregisterInstantiatorsInThisVM() { + // unregister all the instantiators + InternalInstantiator.reinitialize(); + assertEquals(0, InternalInstantiator.getInstantiators().length); + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Host.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Host.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Host.java index 4ec6165..95d6f0d 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Host.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Host.java @@ -16,6 +16,7 @@ */ package com.gemstone.gemfire.test.dunit; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -33,9 +34,9 @@ import com.gemstone.gemfire.test.dunit.standalone.RemoteDUnitVMIF; * started on other hosts via additional Hydra configuration.

* * @author David Whitlock - * */ -public abstract class Host implements java.io.Serializable { +@SuppressWarnings("serial") +public abstract class Host implements Serializable { /** The available hosts */ protected static List hosts = new ArrayList(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/IgnoredException.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/IgnoredException.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/IgnoredException.java index 175543a..d0cead6 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/IgnoredException.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/IgnoredException.java @@ -19,41 +19,70 @@ package com.gemstone.gemfire.test.dunit; import java.io.Serializable; import java.util.concurrent.ConcurrentLinkedQueue; -import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.internal.logging.LogService; /** - * A class that represents an currently logged expected exception, which - * should be removed + * IgnoredException provides static utility methods that + * will log messages to add or remove IgnoredExceptions. + * Each IgnoredException allows you to specify a suspect string + * that will be ignored by the GrepLogs utility which is run + * after each DistributedTest test method. + * + * These methods can be used directly: + * IgnoredException.addIgnoredException(...), + * however, they are intended to be referenced through static import: + * + *
+ * import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
+ *    ...
+ *    addIgnoredException(...);
+ * 
+ * + * A test should use addIgnoredException(...) before executing + * the code that will potentially log the suspect string. The test should + * then remove() the IgnoredException immediately + * after. Note that DistributedTestCase.tearDown() will + * automatically remove all current IgnoredExceptions by + * invoking removeAllIgnoredExceptions. + * + * A suspect string is typically an Exception class and/or message string. + * + * The GrepLogs utility is part of Hydra which is not included + * in Apache Geode. The Hydra class which consumes logs and reports suspect + * strings is batterytest.greplogs.GrepLogs. + * + * Extracted from DistributedTestCase. * * @author Mitch Thomas * @since 5.7bugfix */ +@SuppressWarnings("serial") public class IgnoredException implements Serializable { + private static final Logger logger = LogService.getLogger(); - private static final long serialVersionUID = 1L; - private final String errorString; + private final String suspectString; private final transient VM vm; private static ConcurrentLinkedQueue ignoredExceptions = new ConcurrentLinkedQueue(); - public IgnoredException(final String errorString) { - this.errorString = errorString; + public IgnoredException(final String suspectString) { + this.suspectString = suspectString; this.vm = null; } - IgnoredException(final String errorString, final VM vm) { - this.errorString = errorString; + IgnoredException(final String suspectString, final VM vm) { + this.suspectString = suspectString; this.vm = vm; } - String errorString() { - return this.errorString; + String suspectString() { + return this.suspectString; } VM vm() { @@ -61,130 +90,111 @@ public class IgnoredException implements Serializable { } public String getRemoveMessage() { - return "" + errorString + ""; + return "" + this.suspectString + ""; } public String getAddMessage() { - return "" + errorString + ""; + return "" + this.suspectString + ""; } public void remove() { - SerializableRunnable removeRunnable = new SerializableRunnable( - "removeExpectedExceptions") { + final String removeMessage = getRemoveMessage(); + + @SuppressWarnings("serial") + SerializableRunnable removeRunnable = new SerializableRunnable(IgnoredException.class.getSimpleName()+" remove") { public void run() { - final String remove = getRemoveMessage(); - final InternalDistributedSystem sys = InternalDistributedSystem - .getConnectedInstance(); - if (sys != null) { - sys.getLogWriter().info(remove); + // TODO: delete use of system.getLogWriter + DistributedSystem system = InternalDistributedSystem.getConnectedInstance(); + if (system != null) { + system.getLogWriter().info(removeMessage); } + + // TODO: delete use of LogWriterUtils try { - LogWriterSupport.getLogWriter().info(remove); + LogWriterUtils.getLogWriter().info(removeMessage); } catch (Exception noHydraLogger) { } - logger.info(remove); + logger.info(removeMessage); } }; + removeRunnable.run(); + if (this.vm != null) { vm.invoke(removeRunnable); - } - else { + } else { Invoke.invokeInEveryVM(removeRunnable); } - String s = getRemoveMessage(); - LogManager.getLogger(LogService.BASE_LOGGER_NAME).info(s); - // log it locally - final InternalDistributedSystem sys = InternalDistributedSystem - .getConnectedInstance(); - if (sys != null) { // avoid creating a system - sys.getLogWriter().info(s); - } - LogWriterSupport.getLogWriter().info(s); } public static void removeAllExpectedExceptions() { - IgnoredException ex; - while((ex = ignoredExceptions.poll()) != null) { - ex.remove(); + IgnoredException ignoredException; + while ((ignoredException = ignoredExceptions.poll()) != null) { + ignoredException.remove(); } } /** * Log in all VMs, in both the test logger and the GemFire logger the - * expected exception string to prevent grep logs from complaining. The - * expected string is used by the GrepLogs utility and so can contain + * ignored exception string to prevent grep logs from complaining. The + * suspect string is used by the GrepLogs utility and so can contain * regular expression characters. * * @since 5.7bugfix - * @param exception - * the exception string to expect - * @param v - * the VM on which to log the expected exception or null for all VMs - * @return an ExpectedException instance for removal purposes + * @param suspectString the exception string to expect + * @param vm the VM on which to log the expected exception or null for all VMs + * @return an IgnoredException instance for removal purposes */ - public static IgnoredException addIgnoredException(final String exception, - VM v) { - final IgnoredException ret; - if (v != null) { - ret = new IgnoredException(exception, v); - } - else { - ret = new IgnoredException(exception); - } - // define the add and remove expected exceptions - final String add = ret.getAddMessage(); - SerializableRunnable addRunnable = new SerializableRunnable( - "addExpectedExceptions") { + public static IgnoredException addIgnoredException(final String suspectString, final VM vm) { + final IgnoredException ignoredException = new IgnoredException(suspectString, vm); + final String addMessage = ignoredException.getAddMessage(); + + @SuppressWarnings("serial") + SerializableRunnable addRunnable = new SerializableRunnable(IgnoredException.class.getSimpleName()+" addIgnoredException") { public void run() { - final InternalDistributedSystem sys = InternalDistributedSystem - .getConnectedInstance(); - if (sys != null) { - sys.getLogWriter().info(add); + // TODO: delete use of system.getLogWriter + DistributedSystem system = InternalDistributedSystem.getConnectedInstance(); + if (system != null) { + system.getLogWriter().info(addMessage); } + + // TODO: delete use of LogWriterUtils try { - LogWriterSupport.getLogWriter().info(add); + LogWriterUtils.getLogWriter().info(addMessage); } catch (Exception noHydraLogger) { } - logger.info(add); + logger.info(addMessage); } }; - if (v != null) { - v.invoke(addRunnable); - } - else { + + addRunnable.run(); + + if (vm != null) { + vm.invoke(addRunnable); + } else { Invoke.invokeInEveryVM(addRunnable); } - LogManager.getLogger(LogService.BASE_LOGGER_NAME).info(add); - // Log it locally too - final InternalDistributedSystem sys = InternalDistributedSystem - .getConnectedInstance(); - if (sys != null) { // avoid creating a cache - sys.getLogWriter().info(add); - } - LogWriterSupport.getLogWriter().info(add); - ignoredExceptions.add(ret); - return ret; + ignoredExceptions.add(ignoredException); + return ignoredException; } /** * Log in all VMs, in both the test logger and the GemFire logger the - * expected exception string to prevent grep logs from complaining. The - * expected string is used by the GrepLogs utility and so can contain + * ignored exception string to prevent grep logs from complaining. The + * suspect string is used by the GrepLogs utility and so can contain * regular expression characters. * - * If you do not remove the expected exception, it will be removed at the + * If you do not remove the ignored exception, it will be removed at the * end of your test case automatically. * * @since 5.7bugfix - * @param exception - * the exception string to expect - * @return an ExpectedException instance for removal + * @param suspectString the exception string to expect + * @return an IgnoredException instance for removal */ - public static IgnoredException addIgnoredException(final String exception) { - return addIgnoredException(exception, null); + public static IgnoredException addIgnoredException(final String suspectString) { + return addIgnoredException(suspectString, null); } } \ No newline at end of file