geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [05/18] incubator-geode git commit: Add SecurityTest and FlakyTest. Convert CLI tests to JUnit 4.
Date Tue, 12 Apr 2016 21:16:30 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
index ea83a66..83bf532 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
@@ -18,11 +18,13 @@
  */
 package com.gemstone.gemfire.security;
 
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
 /**
  * Test for authentication from client to server. This tests for both valid and
  * invalid credentials/modules. It also checks for authentication
@@ -30,7 +32,7 @@ import org.junit.experimental.categories.Category;
  * 
  * @since 5.5
  */
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
 public class ClientAuthenticationDUnitTest extends ClientAuthenticationTestCase {
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java
index b633865..24fcc3f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java
@@ -18,16 +18,18 @@
  */
 package com.gemstone.gemfire.security;
 
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
 /**
  * this class contains test methods that used to be in its superclass but
  * that test started taking too long and caused dunit runs to hang
  */
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
 public class ClientAuthenticationPart2DUnitTest extends ClientAuthenticationTestCase {
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
index 191ea3e..381bc33 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
@@ -17,8 +17,11 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.createCacheClient;
+import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.createCacheServer;
 import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.*;
 import static com.gemstone.gemfire.security.SecurityTestUtils.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.createCacheClient;
 import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
index eeb2c39..961e844 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
@@ -19,8 +19,6 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.AvailablePort.*;
-//import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.*;
-//import static com.gemstone.gemfire.security.ClientAuthorizationTestCase.*;
 import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
@@ -31,6 +29,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
@@ -39,8 +40,7 @@ import com.gemstone.gemfire.security.generator.XmlAuthzCredentialGenerator;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
 
 /**
  * Tests for authorization from client to server. This tests for authorization
@@ -50,7 +50,7 @@ import org.junit.experimental.categories.Category;
  * 
  * @since 5.5
  */
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
 public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestCase {
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
index 088dec4..4cc8155 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
@@ -55,7 +55,7 @@ import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
 import com.gemstone.gemfire.cache.query.QueryService;
 import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.query.Struct;
-import com.gemstone.gemfire.internal.AvailablePort.Keeper;
+import com.gemstone.gemfire.internal.AvailablePort.*;
 import com.gemstone.gemfire.internal.cache.AbstractRegionEntry;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
index 441d52c..38f9988 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
@@ -18,14 +18,15 @@
  */
 package com.gemstone.gemfire.security;
 
-//import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.*;
-//import static com.gemstone.gemfire.security.ClientAuthorizationTestCase.*;
 import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.Iterator;
 import java.util.Properties;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
@@ -36,10 +37,9 @@ import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
 
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
 public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestCase {
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
index 904a53c..3e399b7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
@@ -18,13 +18,16 @@
  */
 package com.gemstone.gemfire.security;
 
-import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.*;
+import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.createCacheClient;
 import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.Properties;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.DeltaTestImpl;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
@@ -32,13 +35,12 @@ import com.gemstone.gemfire.internal.cache.PartitionedRegionLocalMaxMemoryDUnitT
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
 
 /**
  * @since 6.1
  */
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
 public final class DeltaClientAuthorizationDUnitTest extends ClientAuthorizationTestCase {
 
   private DeltaTestImpl[] deltas = new DeltaTestImpl[8];

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
index 222ea00..61ff55a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
@@ -30,6 +30,9 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.DeltaTestImpl;
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest;
@@ -37,13 +40,12 @@ import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
 
 /**
  * @since 6.1
  */
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
 public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCase {
 
   private static final int PAUSE = 5 * 1000; // TODO: replace with Awaitility

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/GemFireSecurityExceptionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/GemFireSecurityExceptionTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/GemFireSecurityExceptionTest.java
index 0c048d3..5aa01ff 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/GemFireSecurityExceptionTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/GemFireSecurityExceptionTest.java
@@ -23,7 +23,6 @@ import java.io.NotSerializableException;
 import java.io.Serializable;
 import javax.naming.NamingException;
 
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Before;
 import org.junit.Rule;
@@ -31,10 +30,13 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TestName;
 
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
 /**
  * Unit tests for {@link GemFireSecurityException}.
  */
-@Category(UnitTest.class)
+@Category({ UnitTest.class, SecurityTest.class })
 public class GemFireSecurityExceptionTest {
 
   private String message;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/NotAuthorizedExceptionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/NotAuthorizedExceptionTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/NotAuthorizedExceptionTest.java
index c5e0ba5..ec054d7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/NotAuthorizedExceptionTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/NotAuthorizedExceptionTest.java
@@ -25,7 +25,6 @@ import java.io.Serializable;
 import java.security.Principal;
 import javax.naming.NamingException;
 
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Before;
 import org.junit.Rule;
@@ -33,10 +32,13 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TestName;
 
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
 /**
  * Unit tests for {@link NotAuthorizedException}.
  */
-@Category(UnitTest.class)
+@Category({ UnitTest.class, SecurityTest.class })
 public class NotAuthorizedExceptionTest {
 
   private String message;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
index 1db599f..179f29d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
@@ -29,6 +29,10 @@ import static com.gemstone.gemfire.test.dunit.Wait.*;
 import java.util.Properties;
 import javax.net.ssl.SSLHandshakeException;
 
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
@@ -44,16 +48,14 @@ import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
 
 /**
  * Tests peer to peer authentication in Gemfire
  * 
  * @since 5.5
  */
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
 public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
 
   private static VM locatorVM = null;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
index 663a17d..10ac68a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
@@ -18,16 +18,20 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.cache30.ClientServerTestCase.*;
 import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
 import static com.gemstone.gemfire.internal.AvailablePort.*;
-import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Assert.assertEquals;
+import static com.gemstone.gemfire.test.dunit.Assert.assertFalse;
+import static com.gemstone.gemfire.test.dunit.Assert.assertNotNull;
+import static com.gemstone.gemfire.test.dunit.Assert.assertNull;
+import static com.gemstone.gemfire.test.dunit.Assert.assertTrue;
+import static com.gemstone.gemfire.test.dunit.Assert.fail;
 import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.NetworkUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;
 
-import static com.gemstone.gemfire.cache30.ClientServerTestCase.configureConnectionPoolWithNameAndFactory;
-
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -84,6 +88,7 @@ import com.gemstone.gemfire.pdx.PdxSerializable;
 import com.gemstone.gemfire.pdx.PdxWriter;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 
 /**
  * Contains utility methods for setting up servers/clients for authentication
@@ -93,7 +98,7 @@ import com.gemstone.gemfire.test.dunit.WaitCriterion;
  */
 public final class SecurityTestUtils {
 
-  private final DistributedTestCase distributedTestCase = new DistributedTestCase(getClass().getSimpleName()) {}; // TODO: delete
+  private final JUnit4DistributedTestCase distributedTestCase = new JUnit4DistributedTestCase() {}; // TODO: delete
 
   protected static final int NO_EXCEPTION = 0;
   protected static final int AUTHREQ_EXCEPTION = 1;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/generator/AuthzCredentialGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/AuthzCredentialGenerator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/AuthzCredentialGenerator.java
index f39fc84..a561de0 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/AuthzCredentialGenerator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/AuthzCredentialGenerator.java
@@ -16,13 +16,6 @@
  */
 package com.gemstone.gemfire.security.generator;
 
-import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.security.AccessControl;
-import com.gemstone.gemfire.security.templates.DummyAuthorization;
-import com.gemstone.gemfire.security.templates.XmlAuthorization;
-import org.apache.logging.log4j.Logger;
-
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -31,6 +24,14 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.logging.log4j.Logger;
+
+import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.security.AccessControl;
+import com.gemstone.gemfire.security.templates.DummyAuthorization;
+import com.gemstone.gemfire.security.templates.XmlAuthorization;
+
 /**
  * Encapsulates obtaining authorized and unauthorized credentials for a given
  * operation in a region. Implementations will be for different kinds of

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/generator/CredentialGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/CredentialGenerator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/CredentialGenerator.java
index aee7ebb..fd079a2 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/CredentialGenerator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/CredentialGenerator.java
@@ -24,13 +24,14 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.logging.log4j.Logger;
+
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.security.AuthInitialize;
 import com.gemstone.gemfire.security.Authenticator;
 import com.gemstone.gemfire.security.templates.DummyAuthenticator;
 import com.gemstone.gemfire.security.templates.LdapUserAuthenticator;
 import com.gemstone.gemfire.security.templates.PKCSAuthenticator;
-import org.apache.logging.log4j.Logger;
 
 /**
  * Encapsulates obtaining valid and invalid credentials. Implementations will be

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/generator/DummyCredentialGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/DummyCredentialGenerator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/DummyCredentialGenerator.java
index b709dbc..77ffbd9 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/DummyCredentialGenerator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/DummyCredentialGenerator.java
@@ -16,12 +16,12 @@
  */
 package com.gemstone.gemfire.security.generator;
 
-import com.gemstone.gemfire.security.templates.DummyAuthenticator;
-import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-
 import java.security.Principal;
 import java.util.Properties;
 
+import com.gemstone.gemfire.security.templates.DummyAuthenticator;
+import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
+
 public class DummyCredentialGenerator extends CredentialGenerator {
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/generator/LdapUserCredentialGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/LdapUserCredentialGenerator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/LdapUserCredentialGenerator.java
index bbd9528..7bdcd9a 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/LdapUserCredentialGenerator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/LdapUserCredentialGenerator.java
@@ -16,18 +16,19 @@
  */
 package com.gemstone.gemfire.security.generator;
 
+import java.security.Principal;
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.logging.log4j.Logger;
+
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.internal.cache.tier.sockets.HandShake;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.util.test.TestUtil;
 import com.gemstone.gemfire.security.templates.LdapUserAuthenticator;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-import org.apache.logging.log4j.Logger;
-
-import java.security.Principal;
-import java.util.Properties;
-import java.util.Random;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.util.test.TestUtil;
 
 public class LdapUserCredentialGenerator extends CredentialGenerator {
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/generator/PKCSCredentialGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/PKCSCredentialGenerator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/PKCSCredentialGenerator.java
index 6d33493..09381b8 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/PKCSCredentialGenerator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/PKCSCredentialGenerator.java
@@ -16,15 +16,15 @@
  */
 package com.gemstone.gemfire.security.generator;
 
-import com.gemstone.gemfire.util.test.TestUtil;
-import com.gemstone.gemfire.security.templates.PKCSAuthInit;
-import com.gemstone.gemfire.security.templates.PKCSAuthenticator;
-
 import java.security.Principal;
 import java.security.Provider;
 import java.security.Security;
 import java.util.Properties;
 
+import com.gemstone.gemfire.security.templates.PKCSAuthInit;
+import com.gemstone.gemfire.security.templates.PKCSAuthenticator;
+import com.gemstone.gemfire.util.test.TestUtil;
+
 public class PKCSCredentialGenerator extends CredentialGenerator {
 
   public static String keyStoreDir = getKeyStoreDir();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java
index ff23f78..6f7cf29 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java
@@ -16,15 +16,16 @@
  */
 package com.gemstone.gemfire.security.generator;
 
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.security.AuthenticationFailedException;
-import org.apache.logging.log4j.Logger;
-
 import java.io.File;
 import java.io.IOException;
 import java.security.Principal;
 import java.util.Properties;
 
+import org.apache.logging.log4j.Logger;
+
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.security.AuthenticationFailedException;
+
 public class SSLCredentialGenerator extends CredentialGenerator {
 
   private static final Logger logger = LogService.getLogger();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/generator/UserPasswordWithExtraPropsAuthInit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/UserPasswordWithExtraPropsAuthInit.java b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/UserPasswordWithExtraPropsAuthInit.java
index b29f16b..6d0c583 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/UserPasswordWithExtraPropsAuthInit.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/UserPasswordWithExtraPropsAuthInit.java
@@ -16,14 +16,14 @@
  */
 package com.gemstone.gemfire.security.generator;
 
+import java.util.Iterator;
+import java.util.Properties;
+
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.security.AuthInitialize;
 import com.gemstone.gemfire.security.AuthenticationFailedException;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
 
-import java.util.Iterator;
-import java.util.Properties;
-
 /**
  * An {@link AuthInitialize} implementation that obtains the user name and
  * password as the credentials from the given set of properties. If 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/generator/XmlAuthzCredentialGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/XmlAuthzCredentialGenerator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/XmlAuthzCredentialGenerator.java
index 5d07004..7dcf5ae 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/XmlAuthzCredentialGenerator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/XmlAuthzCredentialGenerator.java
@@ -16,16 +16,16 @@
  */
 package com.gemstone.gemfire.security.generator;
 
-import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
-import com.gemstone.gemfire.util.test.TestUtil;
-import com.gemstone.gemfire.security.templates.UsernamePrincipal;
-import com.gemstone.gemfire.security.templates.XmlAuthorization;
-
 import java.security.Principal;
 import java.util.HashSet;
 import java.util.Properties;
 import java.util.Set;
 
+import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
+import com.gemstone.gemfire.security.templates.UsernamePrincipal;
+import com.gemstone.gemfire.security.templates.XmlAuthorization;
+import com.gemstone.gemfire.util.test.TestUtil;
+
 public class XmlAuthzCredentialGenerator extends AuthzCredentialGenerator {
 
   private static final String dummyXml = "authz-dummy.xml";

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/DummyAuthorization.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/DummyAuthorization.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/DummyAuthorization.java
index a76a46f..17bc5e1 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/DummyAuthorization.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/DummyAuthorization.java
@@ -16,6 +16,10 @@
  */
 package com.gemstone.gemfire.security.templates;
 
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Set;
+
 import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.operations.OperationContext;
@@ -24,10 +28,6 @@ import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.security.AccessControl;
 import com.gemstone.gemfire.security.NotAuthorizedException;
 
-import java.security.Principal;
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * A dummy implementation of the {@code AccessControl} interface that
  * allows authorization depending on the format of the {@code Principal}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/LdapUserAuthenticator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/LdapUserAuthenticator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/LdapUserAuthenticator.java
index fd2286e..b92a08a 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/LdapUserAuthenticator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/LdapUserAuthenticator.java
@@ -22,12 +22,13 @@ import javax.naming.Context;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.InitialDirContext;
 
+import org.apache.logging.log4j.Logger;
+
 import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.security.AuthenticationFailedException;
 import com.gemstone.gemfire.security.Authenticator;
-import org.apache.logging.log4j.Logger;
 
 /**
  * An implementation of {@link Authenticator} that uses LDAP.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthInit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthInit.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthInit.java
index 0b38a7b..9f1ccec 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthInit.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthInit.java
@@ -24,12 +24,13 @@ import java.security.Signature;
 import java.security.cert.X509Certificate;
 import java.util.Properties;
 
+import org.apache.logging.log4j.Logger;
+
 import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.security.AuthInitialize;
 import com.gemstone.gemfire.security.AuthenticationFailedException;
-import org.apache.logging.log4j.Logger;
 
 /**
  * An {@link AuthInitialize} implementation that obtains the digital signature

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthenticator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthenticator.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthenticator.java
index 971cf60..ac5939d 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthenticator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSAuthenticator.java
@@ -29,12 +29,13 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.logging.log4j.Logger;
+
 import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.security.AuthenticationFailedException;
 import com.gemstone.gemfire.security.Authenticator;
-import org.apache.logging.log4j.Logger;
 
 /**
  * An implementation of {@link Authenticator} that uses PKCS.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSPrincipalTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSPrincipalTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSPrincipalTest.java
index e0bc1e4..677e2d4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSPrincipalTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/PKCSPrincipalTest.java
@@ -16,14 +16,15 @@
  */
 package com.gemstone.gemfire.security.templates;
 
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.Serializable;
+
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.io.Serializable;
-
-import static org.assertj.core.api.Assertions.assertThat;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 /**
  * Unit tests for {@link PKCSPrincipal}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UserPasswordAuthInit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UserPasswordAuthInit.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UserPasswordAuthInit.java
index 34161ac..6c05090 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UserPasswordAuthInit.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UserPasswordAuthInit.java
@@ -16,13 +16,13 @@
  */
 package com.gemstone.gemfire.security.templates;
 
+import java.util.Properties;
+
 import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.security.AuthInitialize;
 import com.gemstone.gemfire.security.AuthenticationFailedException;
 
-import java.util.Properties;
-
 /**
  * An {@link AuthInitialize} implementation that obtains the user name and
  * password as the credentials from the given set of properties.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UsernamePrincipalTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UsernamePrincipalTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UsernamePrincipalTest.java
index e762d06..bce19b4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UsernamePrincipalTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/UsernamePrincipalTest.java
@@ -16,14 +16,15 @@
  */
 package com.gemstone.gemfire.security.templates;
 
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.Serializable;
+
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.io.Serializable;
-
-import static org.assertj.core.api.Assertions.assertThat;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 /**
  * Unit tests for {@link UsernamePrincipal}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlAuthorization.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlAuthorization.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlAuthorization.java
index b8f2e50..2153fb4 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlAuthorization.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlAuthorization.java
@@ -29,15 +29,6 @@ import java.util.regex.Pattern;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import com.gemstone.gemfire.LogWriter;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.operations.ExecuteFunctionOperationContext;
-import com.gemstone.gemfire.cache.operations.OperationContext;
-import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
-import com.gemstone.gemfire.cache.operations.QueryOperationContext;
-import com.gemstone.gemfire.distributed.DistributedMember;
-import com.gemstone.gemfire.security.AccessControl;
-import com.gemstone.gemfire.security.NotAuthorizedException;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
@@ -48,6 +39,16 @@ import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.operations.ExecuteFunctionOperationContext;
+import com.gemstone.gemfire.cache.operations.OperationContext;
+import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
+import com.gemstone.gemfire.cache.operations.QueryOperationContext;
+import com.gemstone.gemfire.distributed.DistributedMember;
+import com.gemstone.gemfire.security.AccessControl;
+import com.gemstone.gemfire.security.NotAuthorizedException;
+
 /**
  * An implementation of the {@link AccessControl} interface that allows
  * authorization using the permissions as specified in the given XML

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlErrorHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlErrorHandler.java b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlErrorHandler.java
index 19d10c6..e2b286b 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlErrorHandler.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/templates/XmlErrorHandler.java
@@ -16,13 +16,14 @@
  */
 package com.gemstone.gemfire.security.templates;
 
-import com.gemstone.gemfire.LogWriter;
-import com.gemstone.gemfire.internal.logging.LogService;
 import org.apache.logging.log4j.Logger;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.internal.logging.LogService;
+
 /**
  * Implementation of {@link ErrorHandler} interface to handle validation errors
  * while XML parsing.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
index a612f87..d407934 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
@@ -16,21 +16,21 @@
  */
 package com.gemstone.gemfire.test.dunit;
 
+import java.util.concurrent.Callable;
 import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicReference;
 
-import com.gemstone.gemfire.InternalGemFireError;
 import com.gemstone.gemfire.SystemFailure;
 
 /**
- * <P>An <code>AsyncInvocation</code> represents the invocation of a
- * remote invocation that executes asynchronously from its caller.  An
- * instanceof <code>AsyncInvocation</code> provides information about
- * the invocation such as any exception that it may have thrown.</P>
+ * An {@code AsyncInvocation} represents the invocation of a remote invocation
+ * that executes asynchronously from its caller.  An instance of
+ * {@code AsyncInvocation} provides information about the invocation such as
+ * any exception that it may have thrown.
  *
- * <P>Because it is a <code>Thread</code>, an
- * <code>AsyncInvocation</code> can be used as follows:</P>
+ * <p>{@code AsyncInvocation} can be used as follows:
  *
- * <PRE>
+ * <pre>
  *   AsyncInvocation ai1 = vm.invokeAsync(() -> Test.method1());
  *   AsyncInvocation ai2 = vm.invokeAsync(() -> Test.method2());
  *
@@ -42,175 +42,361 @@ import com.gemstone.gemfire.SystemFailure;
  *   if (ai2.exceptionOccurred()) {
  *     throw ai2.getException();
  *   }
- * </PRE>
+ * </pre>
  *
  * @see VM#invokeAsync(Class, String)
  */
-public class AsyncInvocation<T> extends Thread {
-  //@todo davidw Add the ability to get a return value back from the
-  //async method call.  (Use a static ThreadLocal field that is
-  //accessible from the Runnable used in VM#invoke)
-  
-  private static final ThreadLocal returnValue = new ThreadLocal();
+public class AsyncInvocation<T> {
+  // TODO: davidw Add the ability to get a return value back from the
+  // async method call.  (Use a static ThreadLocal field that is
+  // accessible from the Runnable used in VM#invoke)
+  // TODO: reimplement using Futures
+
+  private static final long DEFAULT_JOIN_MILLIS = 60 * 1000;
 
-  /** The singleton the thread group */
-  private static final ThreadGroup GROUP = new AsyncInvocationGroup();
+  private final Thread thread;
 
-  ///////////////////// Instance Fields  /////////////////////
+  private final AtomicReference<T> resultValue = new AtomicReference<>();
 
-  /** An exception thrown while this async invocation ran */
-  protected volatile Throwable exception;
+  /** An exception thrown while this {@code AsyncInvocation} ran */
+  private final AtomicReference<Throwable> resultThrowable = new AtomicReference<>();
 
-  /** The object (or class) that is the receiver of this asyn method
-   * invocation */
-  private Object receiver;
+  /** The object (or class) that is the target of this {@code AsyncInvocation} */
+  private Object target;
 
   /** The name of the method being invoked */
   private String methodName;
   
-  /** The returned object if any */
-  public volatile T returnedObj = null;
-
-  //////////////////////  Constructors  //////////////////////
-
   /**
-   * Creates a new <code>AsyncInvocation</code>
+   * Creates a new {@code AsyncInvocation}.
    *
-   * @param receiver
-   *        The object or {@link Class} on which the remote method was
-   *        invoked
-   * @param methodName
-   *        The name of the method being invoked
-   * @param work
-   *        The actual invocation of the method
+   * @param  target
+   *         The object or {@link Class} on which the remote method was
+   *         invoked
+   * @param  methodName
+   *         The name of the method being invoked
+   * @param  work
+   *         The actual invocation of the method
    */
-  public AsyncInvocation(Object receiver, String methodName, Runnable work) {
-    super(GROUP, work, getName(receiver, methodName));
-    this.receiver = receiver;
+  public AsyncInvocation(final Object target, final String methodName, final Callable<T> work) {
+    this.target = target;
     this.methodName = methodName;
-    this.exception = null;
+    this.thread = new Thread(new AsyncInvocationGroup(), runnable(work), getName(target, methodName));
   }
 
-  //////////////////////  Static Methods  /////////////////////
+  /**
+   * Returns the target of this async method invocation.
+   */
+  public Object getTarget() {
+    return this.target;
+  }
 
   /**
-   * Returns the name of a <code>AsyncInvocation</code> based on its
-   * receiver and method name.
+   * Returns the name of the method being invoked remotely.
    */
-  private static String getName(Object receiver, String methodName) {
-    StringBuffer sb = new StringBuffer(methodName);
-    sb.append(" invoked on ");
-    if (receiver instanceof Class) {
-      sb.append("class ");
-      sb.append(((Class) receiver).getName());
+  public String getMethodName() {
+    return this.methodName;
+  }
+
+  /**
+   * Returns whether or not an exception occurred during this async
+   * method invocation.
+   *
+   * @throws AssertionError if this {@code AsyncInvocation} is not done.
+   */
+  public boolean exceptionOccurred() {
+    return getException() != null;
+  }
+
+  /**
+   * Returns the exception that was thrown during this async method
+   * invocation.
+   *
+   * @throws AssertionError if this {@code AsyncInvocation} is not done.
+   */
+  public Throwable getException() {
+    checkIsDone("Exception status not available while thread is alive.");
+
+    if (this.resultThrowable.get() instanceof RMIException) {
+      return this.resultThrowable.get().getCause();
 
     } else {
-      sb.append("an instance of ");
-      sb.append(receiver.getClass().getName());
+      return this.resultThrowable.get();
     }
+  }
 
-    return sb.toString();
+  /**
+   * Throws {@code AssertionError} wrapping any {@code Exception} thrown by
+   * this {@code AsyncInvocation}.
+   *
+   * @return this {@code AsyncInvocation}
+   *
+   * @throws AssertionError wrapping any {@code Exception} thrown by this
+   *         {@code AsyncInvocation}.
+   */
+  public AsyncInvocation<T> checkException() {
+    if (exceptionOccurred()) {
+      throw new AssertionError("An exception occurred during asynchronous invocation.", getException());
+    }
+    return this;
   }
 
-  /////////////////////  Instance Methods  ////////////////////
+  /**
+   * Returns the result of this {@code AsyncInvocation}.
+   *
+   * @return the result of this {@code AsyncInvocation}
+   *
+   * @throws AssertionError wrapping any {@code Exception} thrown by this
+   *         {@code AsyncInvocation}.
+   *
+   * @throws AssertionError wrapping a {@code TimeoutException} if this
+   *         {@code AsyncInvocation} fails to complete within the default
+   *         timeout of 60 seconds as defined by {@link #DEFAULT_JOIN_MILLIS}.
+   *
+   * @throws InterruptedException if the current thread is interrupted.
+   */
+  public T getResult() throws InterruptedException {
+    join();
+    checkException();
+    return getReturnValue();
+  }
 
   /**
-   * Returns the receiver of this async method invocation
+   * Returns the result of this {@code AsyncInvocation}.
+   *
+   * @param  millis
+   *         the time to wait in milliseconds
+   *
+   * @return the result of this {@code AsyncInvocation}
+   *
+   * @throws AssertionError wrapping any {@code Exception} thrown by this
+   *         {@code AsyncInvocation}.
+   *
+   * @throws AssertionError wrapping a {@code TimeoutException} if this
+   *         {@code AsyncInvocation} fails to complete within the specified
+   *         timeout of {@code millis}.
+   *
+   * @throws InterruptedException if the current thread is interrupted.
    */
-  public Object getReceiver() {
-    return this.receiver;
+  public T getResult(final long millis) throws InterruptedException {
+    join(millis);
+    timeoutIfAlive(millis);
+    checkException();
+    return getReturnValue();
   }
 
   /**
-   * Returns the name of the method being invoked remotely
+   * Returns the result of this {@code AsyncInvocation}.
+   *
+   * @return the result of this {@code AsyncInvocation}
+   *
+   * @throws AssertionError if this {@code AsyncInvocation} is not done.
+   *
+   * @deprecated Please use {@link #getResult()} instead.
    */
-  public String getMethodName() {
-    return this.methodName;
+  public T getReturnValue() {
+    checkIsDone("Return value not available while thread is alive.");
+    return this.resultValue.get();
   }
 
   /**
-   * Returns whether or not an exception occurred during this async
-   * method invocation.
+   * Waits at most {@code millis} milliseconds for this
+   * {@code AsyncInvocation} to complete. A timeout of {@code 0} means to wait
+   * forever.
+   *
+   * @param  millis
+   *         the time to wait in milliseconds
+   *
+   * @return this {@code AsyncInvocation}
+   *
+   * @throws AssertionError wrapping a {@code TimeoutException} if this
+   *         {@code AsyncInvocation} fails to complete within the specified
+   *         timeout of {@code millis}.
+   *
+   * @throws IllegalArgumentException if the value of {@code millis} is
+   *         negative.
+   *
+   * @throws InterruptedException if the current thread is interrupted.
    */
-  public boolean exceptionOccurred() {
-    if (this.isAlive()) {
-      throw new InternalGemFireError("Exception status not available while thread is alive.");
+  public synchronized AsyncInvocation<T> join(final long millis) throws InterruptedException {
+    this.thread.join(millis);
+    timeoutIfAlive(millis);
+    return this;
+  }
+
+  /**
+   * Waits at most {@code millis} milliseconds plus {@code nanos} nanoseconds
+   * for this {@code AsyncInvocation} to complete.
+   *
+   * @param  millis
+   *         the time to wait in milliseconds
+   * @param  nanos
+   *         {@code 0-999999} additional nanoseconds to wait
+   *
+   * @return this {@code AsyncInvocation}
+   *
+   * @throws AssertionError wrapping a {@code TimeoutException} if this
+   *         {@code AsyncInvocation} fails to complete within the specified
+   *         timeout of {@code millis}.
+   *
+   * @throws IllegalArgumentException
+   *         if the value of {@code millis} is negative, or the value
+   *         of {@code nanos} is not in the range {@code 0-999999}.
+   *
+   * @throws InterruptedException if the current thread is interrupted.
+   */
+  public synchronized AsyncInvocation<T> join(final long millis, final int nanos) throws InterruptedException {
+    this.thread.join(millis, nanos);
+    timeoutIfAlive(millis);
+    return this;
+  }
+
+  /**
+   * Waits for this thread to die up to a default of 60 seconds as defined by
+   * {@link #DEFAULT_JOIN_MILLIS}.
+   *
+   * @return this {@code AsyncInvocation}
+   *
+   * @throws AssertionError wrapping a {@code TimeoutException} if this
+   *         {@code AsyncInvocation} fails to complete within the default
+   *         timeout of 60 seconds as defined by {@link #DEFAULT_JOIN_MILLIS}.
+   *
+   * @throws InterruptedException if the current thread is interrupted.
+   */
+  public AsyncInvocation<T> join() throws InterruptedException {
+    // do NOT invoke Thread#join() without a timeout
+    join(DEFAULT_JOIN_MILLIS);
+    timeoutIfAlive(DEFAULT_JOIN_MILLIS);
+    return this;
+  }
+
+  /**
+   * Start this {@code AsyncInvocation}.
+   *
+   * @return this {@code AsyncInvocation}
+   */
+  public synchronized AsyncInvocation<T> start() {
+    this.thread.start();
+    return this;
+  }
+
+  /**
+   * Return this {@code AsyncInvocation}'s work thread.
+   *
+   * @return this {@code AsyncInvocation}'s work thread.
+   */
+  public synchronized Thread getThread() {
+    return this.thread;
+  }
+
+  /**
+   * Tests if this {@code AsyncInvocation}'s thread is alive. A thread is alive
+   * if it has been started and has not yet died.
+   *
+   * @return {@code true} if this {@code AsyncInvocation}'s thread is alive;
+   *         {@code false} otherwise.
+   */
+  public synchronized boolean isAlive() {
+    return this.thread.isAlive();
+  }
+
+  /**
+   * Returns the identifier of this {@code AsyncInvocation}'s thread. The
+   * thread ID is a positive <tt>long</tt> number generated when this thread
+   * was created. The thread ID is unique and remains unchanged during its
+   * lifetime. When a thread is terminated, this thread ID may be reused.
+   *
+   * @return this {@code AsyncInvocation}'s thread's ID.
+   */
+  public long getId() {
+    return this.thread.getId();
+  }
+
+  @Override
+  public String toString() {
+    return "AsyncInvocation{" + "target=" + target + ", methodName='" + methodName + '\'' + '}';
+  }
+
+  /**
+   * Throws {@code AssertionError} if this {@code AsyncInvocation} is not done.
+   *
+   * @param  message
+   *         The value to be used in constructing detail message
+   *
+   * @return this {@code AsyncInvocation}
+   *
+   * @throws AssertionError if this {@code AsyncInvocation} is not done.
+   */
+  private AsyncInvocation<T> checkIsDone(final String message) {
+    if (this.thread.isAlive()) {
+      throw new AssertionError(message);
     }
-    return this.exception != null;
+    return this;
   }
 
   /**
-   * Returns the exception that was thrown during this async method
-   * invocation.
+   * Throws {@code AssertionError} wrapping a {@code TimeoutException} if this
+   * {@code AsyncInvocation} fails to complete within the default timeout of 60
+   * seconds as defined by {@link #DEFAULT_JOIN_MILLIS}.
+   *
+   * @return this {@code AsyncInvocation}
+   *
+   * @throws AssertionError wrapping a {@code TimeoutException} if this
+   *         {@code AsyncInvocation} fails to complete within the default
+   *         timeout of 60 seconds as defined by {@link #DEFAULT_JOIN_MILLIS}.
    */
-  public Throwable getException() {
-    if (this.isAlive()) {
-      throw new InternalGemFireError("Exception status not available while thread is alive.");
+  private AsyncInvocation<T> timeoutIfAlive(final long timeout) {
+    if (this.thread.isAlive()) {
+      throw new AssertionError(new TimeoutException("Timed out waiting " + timeout + " milliseconds for AsyncInvocation to complete."));
     }
-    if (this.exception instanceof RMIException) {
-      return ((RMIException) this.exception).getCause();
+    return this;
+  }
+
+  private Runnable runnable(final Callable<T> work) {
+    return () -> {
+        try {
+          resultValue.set(work.call());
+        } catch (Throwable throwable) {
+          resultThrowable.set(throwable);
+        }
+    };
+  }
+
+  /**
+   * Returns the name of a {@code AsyncInvocation} based on its
+   * {@code targetObject} and {@code methodName}.
+   */
+  private static String getName(final Object target, final String methodName) {
+    StringBuilder sb = new StringBuilder(methodName);
+    sb.append(" invoked on ");
+    if (target instanceof Class) {
+      sb.append("class ");
+      sb.append(((Class) target).getName());
 
     } else {
-      return this.exception;
+      sb.append("an instance of ");
+      sb.append(target.getClass().getName());
     }
-  }
 
-  //////////////////////  Inner Classes  //////////////////////
+    return sb.toString();
+  }
 
   /**
-   * A <code>ThreadGroup</code> that notices when an exception occurs
-   * during an <code>AsyncInvocation</code>.
-   * 
-   * TODO: reimplement using Futures
+   * A {@code ThreadGroup} that notices when an exception occurs
+   * during an {@code AsyncInvocation}.
    */
-  private static class AsyncInvocationGroup extends ThreadGroup {
-    AsyncInvocationGroup() {
+  private class AsyncInvocationGroup extends ThreadGroup {
+
+    private AsyncInvocationGroup() {
       super("Async Invocations");
     }
 
+    @Override
     public void uncaughtException(Thread thread, Throwable throwable) {
       if (throwable instanceof VirtualMachineError) {
         SystemFailure.setFailure((VirtualMachineError)throwable); // don't throw
       }
-      if (thread instanceof AsyncInvocation) {
-        ((AsyncInvocation) thread).exception = throwable;
-      }
-    }
-  }
-  
-  public T getResult() throws Throwable {
-    join();
-    if(this.exceptionOccurred()) {
-      throw new Exception("An exception occured during async invocation", this.exception);
-    }
-    return this.returnedObj;
-  }
-  
-  public T getResult(long waitTime) throws Throwable {
-    join(waitTime);
-    if(this.isAlive()) {
-      throw new TimeoutException();
-    }
-    if(this.exceptionOccurred()) {
-      throw new Exception("An exception occured during async invocation", this.exception);
+      resultThrowable.set(throwable);
     }
-    return this.returnedObj;
-  }
-
-  public T getReturnValue() {
-    if (this.isAlive()) {
-      throw new InternalGemFireError("Return value not available while thread is alive.");
-    }
-    return this.returnedObj;
-  }
-  
-  public void run() {
-    super.run();
-    this.returnedObj = (T) returnValue.get();
-    returnValue.set(null);
-  }
-
-  static void setReturnValue(Object v) {
-    returnValue.set(v);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
index c0245f2..b7d33b0 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
@@ -16,24 +16,22 @@
  */
 package com.gemstone.gemfire.test.dunit;
 
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.standalone.DUnitLauncher;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.experimental.categories.Category;
 
 /**
  * This class is the superclass of all distributed unit tests.
- *
  */
 @Category(DistributedTest.class)
 @SuppressWarnings("serial")
 public abstract class DistributedTestCase extends JUnit3DistributedTestCase {
   
   /**
-   * Creates a new <code>DistributedTestCase</code> test with the given name.
+   * Creates a new {@code DistributedTestCase} test with the given name.
    */
   public DistributedTestCase(final String name) {
     super(name);
-    DUnitLauncher.launchIfNeeded();
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java
index c1850de..9f69dab 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestUtils.java
@@ -16,7 +16,7 @@
  */
 package com.gemstone.gemfire.test.dunit;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 import java.io.File;
 import java.util.Iterator;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java
index fe8f260..6ac6449 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java
@@ -16,8 +16,8 @@
  */
 package com.gemstone.gemfire.test.dunit;
 
-import static org.junit.Assert.fail;
 import static com.gemstone.gemfire.test.dunit.Jitter.*;
+import static org.junit.Assert.*;
 
 import org.apache.logging.log4j.Logger;
 
@@ -108,6 +108,17 @@ public class ThreadUtils {
 
   /**
    * Wait for a thread to join.
+   *
+   * @param async async invocation to wait on
+   * @param timeoutMilliseconds maximum time to wait
+   * @throws AssertionError if the thread does not terminate
+   */
+  public static void join(final AsyncInvocation<?> async, final long timeoutMilliseconds) {
+    join(async.getThread(), timeoutMilliseconds);
+  }
+
+  /**
+   * Wait for a thread to join.
    * 
    * @param thread thread to wait on
    * @param timeoutMilliseconds maximum time to wait


Mime
View raw message