geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [54/56] [abbrv] incubator-geode git commit: Dealing with some variables that need to be effectively final.
Date Tue, 16 Feb 2016 22:12:14 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/493d41b3/gemfire-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
index fcf735c..74260ed 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
@@ -83,10 +83,7 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase
{
           extraAuthProps, extraAuthzProps);
       Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
       Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-      server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(),
port1, serverProps,
-              javaProps));
-      server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(),
port2, serverProps,
-              javaProps));
+      createCacheServers(javaProps, serverProps, port1, port2);
 
       if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
           OperationCode.PUT, OperationCode.PUT}, new OperationCode[] {
@@ -359,10 +356,7 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase
{
           extraAuthProps, extraAuthzProps);
       Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
       Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-      server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(),
port1, serverProps,
-              javaProps));
-      server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(),
port2, serverProps,
-              javaProps));
+      createCacheServers(javaProps, serverProps, port1, port2);
 
       // Start client1 with valid/invalid QUERY credentials
       Properties[] client1Credentials = new Properties[] {
@@ -466,6 +460,14 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase
{
 
   }
 
+  protected void createCacheServers(Properties javaProps,
+      Properties serverProps, Integer port1, Integer port2) {
+    server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(),
port1, serverProps,
+            javaProps));
+    server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(),
port2, serverProps,
+            javaProps));
+  }
+
   public void testOpsWithClientsInDifferentModes() throws Exception {
     Iterator iter = getDummyGeneratorCombos().iterator();
     while (iter.hasNext()) {
@@ -488,10 +490,7 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase
{
           extraAuthProps, extraAuthzProps);
       Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
       Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-      server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(),
port1, serverProps,
-              javaProps));
-      server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(),
port2, serverProps,
-              javaProps));
+      createCacheServers(javaProps, serverProps, port1, port2);
 
       if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
           OperationCode.PUT, OperationCode.PUT}, new OperationCode[] {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/493d41b3/gemfire-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
index 4408901..5c184d1 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
@@ -141,10 +141,8 @@ public class DeltaClientAuthorizationDUnitTest extends
       // Start servers with all required properties
       Properties serverProps = buildProperties(authenticator, accessor, false,
           extraAuthProps, extraAuthzProps);
-      Integer port1 = ((Integer)server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-              SecurityTestUtil.getLocatorPort(), serverProps, javaProps )));
-      Integer port2 = ((Integer)server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-              SecurityTestUtil.getLocatorPort(), serverProps, javaProps )));
+      Integer port1 = createServer1(javaProps, serverProps);
+      Integer port2 = createServer2(javaProps, serverProps);
 
       // Start client1 with valid CREATE credentials
       Properties createCredentials = gen.getAllowedCredentials(
@@ -154,8 +152,7 @@ public class DeltaClientAuthorizationDUnitTest extends
       LogWriterUtils.getLogWriter().info(
           "testAllowPutsGets: For first client credentials: "
               + createCredentials);
-      client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit,
createCredentials, javaProps, port1, port2,
-              null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+      createClient1(javaProps, authInit, port1, port2, createCredentials);
 
       // Start client2 with valid GET credentials
       Properties getCredentials = gen.getAllowedCredentials(
@@ -166,8 +163,7 @@ public class DeltaClientAuthorizationDUnitTest extends
           .info(
               "testAllowPutsGets: For second client credentials: "
                   + getCredentials);
-      client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit,
getCredentials, javaProps, port1, port2,
-              null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+      createClient2(javaProps, authInit, port1, port2, getCredentials);
 
       // Perform some put operations from client1
       client1.invoke(() -> DeltaClientAuthorizationDUnitTest.doPuts(
@@ -180,6 +176,32 @@ public class DeltaClientAuthorizationDUnitTest extends
           new Integer(2), new Integer(SecurityTestUtil.NO_EXCEPTION), Boolean.FALSE  ));
   }
 
+  protected void createClient2(Properties javaProps, String authInit,
+      Integer port1, Integer port2, Properties getCredentials) {
+    client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, getCredentials,
javaProps, port1, port2,
+            null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+  }
+
+  protected void createClient1(Properties javaProps, String authInit,
+      Integer port1, Integer port2, Properties createCredentials) {
+    client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, createCredentials,
javaProps, port1, port2,
+            null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+  }
+
+  protected Integer createServer2(Properties javaProps,
+      Properties serverProps) {
+    Integer port2 = ((Integer)server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
+            SecurityTestUtil.getLocatorPort(), serverProps, javaProps )));
+    return port2;
+  }
+
+  protected Integer createServer1(Properties javaProps,
+      Properties serverProps) {
+    Integer port1 = ((Integer)server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
+            SecurityTestUtil.getLocatorPort(), serverProps, javaProps )));
+    return port1;
+  }
+
   public static void doPuts(Integer num, Integer expectedResult,
       boolean newVals) {
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/493d41b3/gemfire-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
index dd01b3b..d47b1c4 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
@@ -173,9 +173,7 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
             authInit);
     setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
             authenticator);
-    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
-            getUniqueName(), new Integer(port), props, javaProps,
-            expectedExceptions));
+    startLocator(props, javaProps, port);
 
     LogWriter dsLogger = LogWriterUtils.createLogWriter(props);
     SecurityTestUtil.addExpectedExceptions(expectedExceptions, dsLogger);
@@ -192,6 +190,13 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
 
   }
 
+  protected void startLocator(Properties props, Properties javaProps,
+      int port) {
+    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
+            getUniqueName(), new Integer(port), props, javaProps,
+            expectedExceptions));
+  }
+
   // Authenticator is incorrect
   public void testP2PAuthenticationWithInvalidAuthenticator() throws Exception {
     disconnectAllFromDS();
@@ -211,9 +216,7 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
             authInit);
     setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
             authenticator);
-    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
-            getUniqueName(), new Integer(port), props, javaProps,
-            expectedExceptions ));
+    startLocator(props, javaProps, port);
 
     LogWriter dsLogger = LogWriterUtils.createLogWriter(props);
     SecurityTestUtil.addExpectedExceptions(expectedExceptions, dsLogger);
@@ -251,9 +254,7 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
             authInit);
     setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
             authenticator);
-    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
-            getUniqueName(), new Integer(port), props, javaProps,
-            expectedExceptions ));
+    startLocator(props, javaProps, port);
 
     LogWriter dsLogger = LogWriterUtils.createLogWriter(props);
     SecurityTestUtil.addExpectedExceptions(expectedExceptions, dsLogger);
@@ -292,9 +293,7 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     Properties credentials = gen.getValidCredentials(1);
     Properties javaProps = gen.getJavaProperties();
     props.putAll(credentials);
-    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
-            getUniqueName(), new Integer(port), props, javaProps,
-            expectedExceptions ));
+    startLocator(props, javaProps, port);
     try {
       createDS(props, javaProps);
       verifyMembers(new Integer(2));
@@ -331,9 +330,7 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     Properties credentials = gen.getValidCredentials(1);
     Properties javaProps = gen.getJavaProperties();
     props.putAll(credentials);
-    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
-            getUniqueName(), new Integer(port), props, javaProps,
-            expectedExceptions ));
+    startLocator(props, javaProps, port);
     try {
       // invalid credentials for the peer
       credentials = gen.getInvalidCredentials(1);
@@ -411,9 +408,7 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     Properties javaProps = gen.getJavaProperties();
     props.putAll(credentials);
     props.putAll(extraProps);
-    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
-        getUniqueName(), new Integer(port), props, javaProps,
-        expectedExceptions ));
+    startLocator(props, javaProps, port);
     try {
 
     // Start the first peer with different authenticator
@@ -442,12 +437,9 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     javaProps = gen.getJavaProperties();
     props.putAll(credentials);
     props.putAll(extraProps);
-    peer2.invoke(() -> P2PAuthenticationDUnitTest.createDS(
-        props, javaProps ));
+    createDS(peer2, props, javaProps);
 
-    // Start the third peer with the same authenticator as locator
-    peer3.invoke(() -> P2PAuthenticationDUnitTest.createDS(
-        props, javaProps ));
+    createDS(peer3, props, javaProps);
 
     // wait for view propagation
     Wait.pause(2000);
@@ -481,6 +473,12 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     }
   }
 
+  protected void createDS(final VM peer2, Properties props,
+      Properties javaProps) {
+    peer2.invoke(() -> P2PAuthenticationDUnitTest.createDS(
+        props, javaProps ));
+  }
+
   /**
    * The strategy is to test credential size greater than UDP datagram size.
    * 
@@ -516,9 +514,7 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     Properties javaProps = gen.getJavaProperties();
     props.putAll(credentials);
     props.putAll(extraProps);
-    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
-        getUniqueName(), new Integer(port), props, javaProps,
-        expectedExceptions ));
+    startLocator(props, javaProps, port);
     try {
 
     // Start the first peer with huge credentials
@@ -567,12 +563,9 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     javaProps = gen.getJavaProperties();
     props.putAll(credentials);
     props.putAll(extraProps);
-    peer2.invoke(() -> P2PAuthenticationDUnitTest.createDS(
-        props, javaProps ));
+    createDS(peer2, props, javaProps);
 
-    // Start the third peer with the same authenticator as locator
-    peer3.invoke(() -> P2PAuthenticationDUnitTest.createDS(
-        props, javaProps ));
+    createDS(peer3, props, javaProps);
 
     // wait for view propagation
     Wait.pause(2000);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/493d41b3/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
b/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
index b92de53..42788d9 100644
--- a/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
+++ b/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
@@ -266,9 +266,9 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
         .invoke(() -> WANTestBase.createSecondRemoteLocator(
             2, nyLocPort1, lnLocPort1 ));
     
-    locatorToWaitFor = new InetSocketAddress("localhost", nyLocPort3);
+    InetSocketAddress locatorToWaitFor2 = new InetSocketAddress("localhost", nyLocPort3);
 
-    vm2.invoke(() -> WANTestBase.checkLocatorsinSender("ln", locatorToWaitFor ));
+    vm2.invoke(() -> WANTestBase.checkLocatorsinSender("ln", locatorToWaitFor2 ));
 
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/493d41b3/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanValidationsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanValidationsDUnitTest.java
b/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanValidationsDUnitTest.java
index 2fef83a..88696fe 100644
--- a/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanValidationsDUnitTest.java
+++ b/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanValidationsDUnitTest.java
@@ -577,7 +577,7 @@ public class WanValidationsDUnitTest extends WANTestBase {
         "ln", 2, false, 100, false, false, eventFiletrs,
         null, true, false  ));
     try {
-      eventFiletrs = new ArrayList<GatewayEventFilter>();
+      eventFiletrs.clear();
       eventFiletrs.add(new Filter70());
       vm2.invoke(() -> WANTestBase.createSenderForValidations(
           "ln", 2, false, 100, false, false,
@@ -605,7 +605,7 @@ public class WanValidationsDUnitTest extends WANTestBase {
         "ln", 2, false, 100, false, false, eventFiletrs,
         null, true, false  ));
     try {
-      eventFiletrs = new ArrayList<GatewayEventFilter>();
+      eventFiletrs.clear();
       eventFiletrs.add(new MyGatewayEventFilter());
       eventFiletrs.add(new Filter70());
       vm2.invoke(() -> WANTestBase.createSenderForValidations(
@@ -635,7 +635,7 @@ public class WanValidationsDUnitTest extends WANTestBase {
         "ln", 2, false, 100, false, false, null,
         transportFiletrs, true, false  ));
    try {
-      transportFiletrs = new ArrayList<GatewayTransportFilter>();
+      transportFiletrs.clear();
       transportFiletrs.add(new MyGatewayTransportFilter3());
       transportFiletrs.add(new MyGatewayTransportFilter4());
       vm2.invoke(() -> WANTestBase.createSenderForValidations(
@@ -665,7 +665,7 @@ public class WanValidationsDUnitTest extends WANTestBase {
         "ln", 2, false, 100, false, false, null,
         transportFiletrs, true, false  ));
    try {
-      transportFiletrs = new ArrayList<GatewayTransportFilter>();
+      transportFiletrs.clear();
       transportFiletrs.add(new MyGatewayTransportFilter2());
       transportFiletrs.add(new MyGatewayTransportFilter1());
       vm2.invoke(() -> WANTestBase.createSenderForValidations(

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/493d41b3/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueueDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueueDUnitTest.java
b/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueueDUnitTest.java
index d240696..1bf132b 100644
--- a/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueueDUnitTest.java
+++ b/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueueDUnitTest.java
@@ -121,7 +121,7 @@ public class SerialGatewaySenderQueueDUnitTest extends WANTestBase{
     primarySenderUpdates = (HashMap)vm4.invoke(() -> WANTestBase.checkQueue());
     secondarySenderUpdates = (HashMap)vm5.invoke(() -> WANTestBase.checkQueue());
     
-    vm5.invoke(() -> WANTestBase.checkQueueOnSecondary( primarySenderUpdates ));
+    checkPrimarySenderUpdatesOnVM5(primarySenderUpdates);
 //    assertEquals(primarySenderUpdates, secondarySenderUpdates);
     
     vm4.invoke(() -> WANTestBase.resumeSender( "ln"));
@@ -144,6 +144,10 @@ public class SerialGatewaySenderQueueDUnitTest extends WANTestBase{
     secondarySenderUpdates = (HashMap)vm5.invoke(() -> WANTestBase.checkQueue());
     assertEquals(secondarySenderUpdates.get("Destroy"), receiverUpdates.get("Create"));
   }
+
+  protected void checkPrimarySenderUpdatesOnVM5(HashMap primarySenderUpdates) {
+    vm5.invoke(() -> WANTestBase.checkQueueOnSecondary( primarySenderUpdates ));
+  }
   
   public void testPrimarySecondaryQueueDrainInOrder_PR() throws Exception {
     Integer lnPort = (Integer)vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(
1 ));
@@ -192,7 +196,7 @@ public class SerialGatewaySenderQueueDUnitTest extends WANTestBase{
     Wait.pause(5000);
     HashMap primarySenderUpdates = (HashMap)vm4.invoke(() -> WANTestBase.checkQueue());
     HashMap secondarySenderUpdates = (HashMap)vm5.invoke(() -> WANTestBase.checkQueue());
-    vm5.invoke(() -> WANTestBase.checkQueueOnSecondary( primarySenderUpdates ));
+    checkPrimarySenderUpdatesOnVM5(primarySenderUpdates);
     
     vm4.invoke(() -> WANTestBase.resumeSender( "ln"));
     Wait.pause(4000);


Mime
View raw message