Repository: incubator-geode Updated Branches: refs/heads/feature/GEODE-693 [created] 5fb123001
Convert to JUnit 4 Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/5fb12300 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/5fb12300 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/5fb12300 Branch: refs/heads/feature/GEODE-693 Commit: 5fb1230015dbe7d2ed73cf229224d57eec8abcf8 Parents: 822bdc1 Author: Kirk Lund <[email protected]> Authored: Mon Mar 21 18:05:31 2016 -0700 Committer: Kirk Lund <[email protected]> Committed: Mon Mar 21 18:05:31 2016 -0700 ---------------------------------------------------------------------- .../security/ClientAuthorizationDUnitTest.java | 31 ++++++++-------- .../security/ClientAuthorizationTestBase.java | 11 +++--- .../security/ClientMultiUserAuthzDUnitTest.java | 37 ++++++++++---------- .../DeltaClientAuthorizationDUnitTest.java | 23 ++++++------ .../DeltaClientPostAuthorizationDUnitTest.java | 21 ++++++----- .../ClientAuthorizationTwoDUnitTest.java | 13 +++---- .../security/ClientAuthzObjectModDUnitTest.java | 29 ++++++--------- .../ClientCQPostAuthorizationDUnitTest.java | 26 ++++++++------ .../ClientPostAuthorizationDUnitTest.java | 14 ++++---- .../gemfire/security/MultiuserAPIDUnitTest.java | 22 ++++++------ .../MultiuserDurableCQAuthzDUnitTest.java | 30 +++++++++------- 11 files changed, 126 insertions(+), 131 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/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 9271cd1..a483b9b 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 @@ -1,6 +1,3 @@ - -package com.gemstone.gemfire.security; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,9 +6,9 @@ package com.gemstone.gemfire.security; * 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 @@ -19,7 +16,9 @@ package com.gemstone.gemfire.security; * specific language governing permissions and limitations * under the License. */ +package com.gemstone.gemfire.security; +import static com.gemstone.gemfire.test.dunit.Assert.*; import java.util.ArrayList; import java.util.Iterator; @@ -32,12 +31,14 @@ import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator; import com.gemstone.gemfire.security.generator.CredentialGenerator; import com.gemstone.gemfire.security.generator.DummyCredentialGenerator; import com.gemstone.gemfire.security.generator.XmlAuthzCredentialGenerator; +import com.gemstone.gemfire.security.templates.UserPasswordAuthInit; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.IgnoredException; import com.gemstone.gemfire.test.dunit.LogWriterUtils; import com.gemstone.gemfire.test.dunit.VM; - -import com.gemstone.gemfire.security.templates.UserPasswordAuthInit; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; /** * Tests for authorization from client to server. This tests for authorization @@ -48,13 +49,9 @@ import com.gemstone.gemfire.security.templates.UserPasswordAuthInit; * @author sumedh * @since 5.5 */ +@Category(DistributedTest.class) public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { - /** constructor */ - public ClientAuthorizationDUnitTest(String name) { - super(name); - } - @Override public final void postSetUp() throws Exception { final Host host = Host.getHost(0); @@ -196,8 +193,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { } } - // Region: Tests - + @Test public void testAllowPutsGets() { AuthzCredentialGenerator gen = getXmlAuthzGenerator(); CredentialGenerator cGen = gen.getCredentialGenerator(); @@ -251,6 +247,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { new Integer(2), new Integer(SecurityTestUtil.NO_EXCEPTION) )); } + @Test public void testPutAllWithSecurity() { AuthzCredentialGenerator gen = getXmlAuthzGenerator(); CredentialGenerator cGen = gen.getCredentialGenerator(); @@ -306,6 +303,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { return port1; } + @Test public void testDisallowPutsGets() { AuthzCredentialGenerator gen = getXmlAuthzGenerator(); @@ -380,6 +378,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { new Integer(2), new Integer(SecurityTestUtil.NOTAUTHZ_EXCEPTION) )); } + @Test public void testInvalidAccessor() { AuthzCredentialGenerator gen = getXmlAuthzGenerator(); CredentialGenerator cGen = gen.getCredentialGenerator(); @@ -454,6 +453,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { javaProps )); } + @Test public void testPutsGetsWithFailover() { AuthzCredentialGenerator gen = getXmlAuthzGenerator(); CredentialGenerator cGen = gen.getCredentialGenerator(); @@ -563,6 +563,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { new Integer(4), new Integer(SecurityTestUtil.NOTAUTHZ_EXCEPTION) )); } + @Test public void testUnregisterInterestWithFailover() { OperationWithAction[] unregisterOps = { @@ -693,7 +694,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { } } - + @Test public void testAllOpsWithFailover() { IgnoredException.addIgnoredException("Read timed out"); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java index c7eed57..96c25bc 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java @@ -18,6 +18,8 @@ */ package com.gemstone.gemfire.security; +import static com.gemstone.gemfire.test.dunit.Assert.*; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -58,10 +60,10 @@ import com.gemstone.gemfire.security.generator.CredentialGenerator; import com.gemstone.gemfire.security.generator.DummyCredentialGenerator; import com.gemstone.gemfire.security.generator.XmlAuthzCredentialGenerator; import com.gemstone.gemfire.test.dunit.Assert; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.VM; import com.gemstone.gemfire.test.dunit.Wait; import com.gemstone.gemfire.test.dunit.WaitCriterion; +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; /** * Base class for tests for authorization from client to server. It contains @@ -70,12 +72,7 @@ import com.gemstone.gemfire.test.dunit.WaitCriterion; * @author sumedh * @since 5.5 */ -public class ClientAuthorizationTestBase extends DistributedTestCase { - - /** constructor */ - public ClientAuthorizationTestBase(String name) { - super(name); - } +public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase { protected static VM server1 = null; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/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 496c3a2..18da345 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 @@ -1,6 +1,3 @@ - -package com.gemstone.gemfire.security; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,9 +6,9 @@ package com.gemstone.gemfire.security; * 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 @@ -19,31 +16,29 @@ package com.gemstone.gemfire.security; * specific language governing permissions and limitations * under the License. */ - +package com.gemstone.gemfire.security; import java.util.Iterator; import java.util.Properties; -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.cache.Region; import com.gemstone.gemfire.cache.execute.Function; import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.cache.execute.PRClientServerTestBase; import com.gemstone.gemfire.internal.cache.functions.TestFunction; +import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator; +import com.gemstone.gemfire.security.generator.CredentialGenerator; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.LogWriterUtils; +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; +@Category(DistributedTest.class) public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase { - /** constructor */ - public ClientMultiUserAuthzDUnitTest(String name) { - super(name); - } - @Override public final void postSetUp() throws Exception { final Host host = Host.getHost(0); @@ -58,8 +53,11 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase { SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions); } - // Tests with one user authorized to do puts/gets/containsKey/destroys and - // another not authorized for the same. + /** + * Tests with one user authorized to do puts/gets/containsKey/destroys and + * another not authorized for the same. + */ + @Test public void testOps1() throws Exception { Iterator iter = getDummyGeneratorCombos().iterator(); while (iter.hasNext()) { @@ -335,7 +333,10 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase { region.put("key2", "value2"); } - // Test query/function execute + /** + * Test query/function execute + */ + @Test public void testOps2() throws Exception { AuthzCredentialGenerator gen = getXmlAuthzGenerator(); CredentialGenerator cGen = gen.getCredentialGenerator(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/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 8a78378..3168a21 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 @@ -1,6 +1,3 @@ - -package com.gemstone.gemfire.security; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,9 +6,9 @@ package com.gemstone.gemfire.security; * 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 @@ -19,7 +16,9 @@ package com.gemstone.gemfire.security; * specific language governing permissions and limitations * under the License. */ +package com.gemstone.gemfire.security; +import static com.gemstone.gemfire.test.dunit.Assert.*; import java.util.Properties; @@ -34,16 +33,20 @@ import com.gemstone.gemfire.security.generator.CredentialGenerator; import com.gemstone.gemfire.test.dunit.Assert; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.LogWriterUtils; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; /** * @since 6.1 */ +@Category(DistributedTest.class) public class DeltaClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { protected static final DeltaTestImpl[] deltas = new DeltaTestImpl[8]; - static { + private static final void setUpDeltas() { for (int i = 0; i < 8; i++) { deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0)); @@ -92,11 +95,6 @@ public class DeltaClientAuthorizationDUnitTest extends } - /** constructor */ - public DeltaClientAuthorizationDUnitTest(String name) { - super(name); - } - @Override public final void postSetUp() throws Exception { final Host host = Host.getHost(0); @@ -109,6 +107,8 @@ public class DeltaClientAuthorizationDUnitTest extends server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions )); client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions )); SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions); + + setUpDeltas(); } @Override @@ -122,6 +122,7 @@ public class DeltaClientAuthorizationDUnitTest extends server2.invoke(() -> SecurityTestUtil.closeCache()); } + @Test public void testAllowPutsGets() throws Exception { AuthzCredentialGenerator gen = this.getXmlAuthzGenerator(); CredentialGenerator cGen = gen.getCredentialGenerator(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/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 e0502a2..d5dfe89 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 @@ -1,6 +1,3 @@ - -package com.gemstone.gemfire.security; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,9 +6,9 @@ package com.gemstone.gemfire.security; * 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 @@ -19,7 +16,9 @@ package com.gemstone.gemfire.security; * specific language governing permissions and limitations * under the License. */ +package com.gemstone.gemfire.security; +import static com.gemstone.gemfire.test.dunit.Assert.*; import java.util.ArrayList; import java.util.Iterator; @@ -44,19 +43,18 @@ import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.IgnoredException; import com.gemstone.gemfire.test.dunit.LogWriterUtils; 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; /** * @since 6.1 - * */ +@Category(DistributedTest.class) public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTestBase { - private static final int PAUSE = 5 * 1000; - /** constructor */ - public DeltaClientPostAuthorizationDUnitTest(String name) { - super(name); - } + private static final int PAUSE = 5 * 1000; // TODO: replace with Awaitility @Override public final void postSetUp() throws Exception { @@ -83,6 +81,7 @@ public class DeltaClientPostAuthorizationDUnitTest extends server2.invoke(() -> SecurityTestUtil.closeCache()); } + @Test public void testPutPostOpNotifications() throws Exception { IgnoredException.addIgnoredException("Unexpected IOException"); IgnoredException.addIgnoredException("SocketException"); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java index f146160..0a6a85b 100644 --- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java +++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java @@ -19,6 +19,9 @@ package com.gemstone.gemfire.security; import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.IgnoredException; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; /** * Tests for authorization from client to server. This tests for authorization @@ -32,15 +35,10 @@ import com.gemstone.gemfire.test.dunit.IgnoredException; * @author sumedh * @since 5.5 */ +@Category(DistributedTest.class) public class ClientAuthorizationTwoDUnitTest extends ClientAuthorizationTestBase { - - /** constructor */ - public ClientAuthorizationTwoDUnitTest(String name) { - super(name); - } - @Override public final void postSetUp() throws Exception { final Host host = Host.getHost(0); @@ -56,8 +54,7 @@ public class ClientAuthorizationTwoDUnitTest extends SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions); } - // Region: Tests - + @Test public void testAllOpsWithFailover2() { IgnoredException.addIgnoredException("Read timed out"); IgnoredException.addIgnoredException("Connection reset"); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java index 984e5f1..aa183b1 100644 --- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java +++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java @@ -21,23 +21,24 @@ import java.util.List; import java.util.Properties; import java.util.Random; -import com.gemstone.gemfire.internal.security.FilterPostAuthorization; -import com.gemstone.gemfire.internal.security.FilterPreAuthorization; -import com.gemstone.gemfire.security.generator.CredentialGenerator; -import com.gemstone.gemfire.security.generator.DummyAuthzCredentialGenerator; -import com.gemstone.gemfire.security.generator.DummyCredentialGenerator; -import com.gemstone.gemfire.security.templates.UserPasswordAuthInit; - import com.gemstone.gemfire.DataSerializable; import com.gemstone.gemfire.Instantiator; import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.AvailablePort; +import com.gemstone.gemfire.internal.security.FilterPostAuthorization; +import com.gemstone.gemfire.internal.security.FilterPreAuthorization; import com.gemstone.gemfire.internal.security.ObjectWithAuthz; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; +import com.gemstone.gemfire.security.generator.CredentialGenerator; +import com.gemstone.gemfire.security.generator.DummyAuthzCredentialGenerator; +import com.gemstone.gemfire.security.generator.DummyCredentialGenerator; +import com.gemstone.gemfire.security.templates.UserPasswordAuthInit; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.LogWriterUtils; import com.gemstone.gemfire.test.dunit.SerializableRunnable; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; /** * Tests for authorization callback that modify objects and callbacks from @@ -56,14 +57,9 @@ import com.gemstone.gemfire.test.dunit.SerializableRunnable; * @author sumedh * @since 5.5 */ +@Category(DistributedTest.class) public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase { - - /** constructor */ - public ClientAuthzObjectModDUnitTest(String name) { - super(name); - } - private static final String preAccessor = FilterPreAuthorization.class.getName() + ".create"; private static final String postAccessor = FilterPostAuthorization.class.getName() + ".create"; @@ -182,10 +178,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase { serverPort, Boolean.FALSE, new Integer(SecurityTestUtil.NO_EXCEPTION)); } - // End Region: Utility and static functions invoked by the tests - - // Region: Tests - + @Test public void testAllOpsObjectModWithFailover() { OperationWithAction[] allOps = { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java index 1388bac..45599bf 100644 --- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java +++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.security; +import static com.gemstone.gemfire.test.dunit.Assert.*; + import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -47,28 +49,22 @@ import com.gemstone.gemfire.test.dunit.LogWriterUtils; import com.gemstone.gemfire.test.dunit.SerializableRunnable; import com.gemstone.gemfire.test.dunit.Wait; import com.gemstone.gemfire.test.dunit.WaitCriterion; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + /** * This is for multiuser-authentication * * @author ashetkar * */ +@Category(DistributedTest.class) public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestBase { -// public static final String regionName = "ClientCQPostAuthorizationDUnitTest_region"; - public static final Map<String, String> cqNameToQueryStrings = new HashMap<String, String>(); - static { - cqNameToQueryStrings.put("CQ_0", "SELECT * FROM "); - cqNameToQueryStrings.put("CQ_1", "SELECT * FROM "); - } - - public ClientCQPostAuthorizationDUnitTest(String name) { - super(name); - } - @Override public final void postSetUp() throws Exception { getSystem(); @@ -88,6 +84,9 @@ public class ClientCQPostAuthorizationDUnitTest extends server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions )); client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions )); SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions); + + cqNameToQueryStrings.put("CQ_0", "SELECT * FROM "); + cqNameToQueryStrings.put("CQ_1", "SELECT * FROM "); } @Override @@ -96,8 +95,10 @@ public class ClientCQPostAuthorizationDUnitTest extends client2.invoke(() -> SecurityTestUtil.closeCache()); server1.invoke(() -> SecurityTestUtil.closeCache()); server2.invoke(() -> SecurityTestUtil.closeCache()); + cqNameToQueryStrings.clear(); } + @Test public void testAllowCQForAllMultiusers() throws Exception { /* * Start a server @@ -110,6 +111,7 @@ public class ClientCQPostAuthorizationDUnitTest extends true}); } + @Test public void testDisallowCQForAllMultiusers() throws Exception { /* * Start a server @@ -122,6 +124,7 @@ public class ClientCQPostAuthorizationDUnitTest extends false}); } + @Test public void testDisallowCQForSomeMultiusers() throws Exception { /* * Start a server @@ -135,6 +138,7 @@ public class ClientCQPostAuthorizationDUnitTest extends false}); } + @Test public void testAllowCQForAllMultiusersWithFailover() throws Exception { /* * Start a server1 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java index ec08b22..bc71a2c 100644 --- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java +++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java @@ -28,6 +28,9 @@ import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator; import com.gemstone.gemfire.security.generator.CredentialGenerator; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.LogWriterUtils; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; /** * Tests for authorization from client to server. This tests for authorization @@ -37,15 +40,10 @@ import com.gemstone.gemfire.test.dunit.LogWriterUtils; * @author sumedh * @since 5.5 */ +@Category(DistributedTest.class) public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestBase { - - /** constructor */ - public ClientPostAuthorizationDUnitTest(String name) { - super(name); - } - @Override public final void postSetUp() throws Exception { final Host host = Host.getHost(0); @@ -60,8 +58,7 @@ public class ClientPostAuthorizationDUnitTest extends SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions); } - // Region: Tests - + @Test public void testAllPostOps() { OperationWithAction[] allOps = { @@ -180,6 +177,7 @@ public class ClientPostAuthorizationDUnitTest extends } } + @Test public void testAllOpsNotifications() { OperationWithAction[] allOps = { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java index c5a1afe..70af27a 100644 --- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java +++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java @@ -16,13 +16,10 @@ */ package com.gemstone.gemfire.security; -import com.gemstone.gemfire.security.generator.CredentialGenerator; -import com.gemstone.gemfire.security.generator.DummyCredentialGenerator; -import hydra.Log; +import static com.gemstone.gemfire.test.dunit.Assert.*; import java.io.IOException; import java.util.Properties; - import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; @@ -36,18 +33,19 @@ import com.gemstone.gemfire.cache.query.Query; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.cache.PoolManagerImpl; +import com.gemstone.gemfire.security.generator.CredentialGenerator; +import com.gemstone.gemfire.security.generator.DummyCredentialGenerator; import com.gemstone.gemfire.test.dunit.Assert; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.LogWriterUtils; 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; +@Category(DistributedTest.class) public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase { - /** constructor */ - public MultiuserAPIDUnitTest(String name) { - super(name); - } - private VM server1 = null; private VM server2 = null; @@ -162,6 +160,7 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase { multiUser, new Integer(SecurityTestUtil.NO_EXCEPTION))); } + @Test public void testSingleUserUnsupportedAPIs() { // Start servers // Start clients with multiuser-authentication set to false @@ -169,6 +168,7 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase { client1.invoke(() -> MultiuserAPIDUnitTest.verifyDisallowedOps(Boolean.FALSE)); } + @Test public void testMultiUserUnsupportedAPIs() { // Start servers. // Start clients with multiuser-authentication set to true. @@ -186,7 +186,7 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase { op = "Pool.createSecureUserCache()"; GemFireCacheImpl.getInstance().createAuthenticatedView(new Properties(), "testPool"); } catch (IllegalStateException uoe) { - Log.getLogWriter().info(op + ": Got expected exception: " + uoe); + LogWriterUtils.getLogWriter().info(op + ": Got expected exception: " + uoe); success = true; } catch (Exception e) { Assert.fail("Got unexpected exception while doing " + op, e); @@ -357,7 +357,7 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase { break; } } catch (UnsupportedOperationException uoe) { - Log.getLogWriter().info(op + ": Got expected exception: " + uoe); + LogWriterUtils.getLogWriter().info(op + ": Got expected exception: " + uoe); success = true; } catch (Exception e) { Assert.fail("Got unexpected exception while doing " + op, e); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5fb12300/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java index 68d52d9..e605765 100644 --- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java +++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.security; +import static com.gemstone.gemfire.test.dunit.Assert.*; + import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -41,25 +43,16 @@ import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.Invoke; import com.gemstone.gemfire.test.dunit.LogWriterUtils; import com.gemstone.gemfire.test.dunit.SerializableRunnable; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; -/** - * @author ashetkar - * - */ +@Category(DistributedTest.class) public class MultiuserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBase { public static final Map<String, String> cqNameToQueryStrings = new HashMap<String, String>(); - static { - cqNameToQueryStrings.put("CQ_0", "SELECT * FROM "); - cqNameToQueryStrings.put("CQ_1", "SELECT * FROM "); - } - - public MultiuserDurableCQAuthzDUnitTest(String name) { - super(name); - } - @Override public final void postSetUp() throws Exception { getSystem(); @@ -79,8 +72,17 @@ public class MultiuserDurableCQAuthzDUnitTest extends server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions )); client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions )); SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions); + + cqNameToQueryStrings.put("CQ_0", "SELECT * FROM "); + cqNameToQueryStrings.put("CQ_1", "SELECT * FROM "); + } + + @Override + public final void postTearDown() throws Exception { + cqNameToQueryStrings.clear(); } + @Test public void testCQForDurableClientsWithDefaultClose() throws Exception { /* * 1. Start a server. @@ -100,6 +102,7 @@ public class MultiuserDurableCQAuthzDUnitTest extends getXmlAuthzGenerator(), null); } + @Test public void testCQForDurableClientsWithCloseKeepAliveTrue() throws Exception { /* * 1. Start a server. @@ -119,6 +122,7 @@ public class MultiuserDurableCQAuthzDUnitTest extends getXmlAuthzGenerator(), Boolean.TRUE); } + @Test public void testCQForDurableClientsWithCloseKeepAliveFalse() throws Exception { /* * 1. Start a server.
