You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/04/05 19:38:18 UTC
[3/8] incubator-geode git commit: Add SecurityTest and FlakyTest.
Convert CLI tests to JUnit 4.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
index b10f610..8ce93ad 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
@@ -16,11 +16,14 @@
*/
package com.gemstone.gemfire.test.dunit.tests;
-import static com.gemstone.gemfire.test.dunit.Invoke.invokeInEveryVM;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
+import static com.googlecode.catchexception.CatchException.*;
+import static com.googlecode.catchexception.throwable.CatchThrowable.*;
+import static org.hamcrest.Matchers.*;
import java.util.Properties;
-import com.gemstone.gemfire.test.dunit.Assert;
import com.gemstone.gemfire.test.dunit.AsyncInvocation;
import com.gemstone.gemfire.test.dunit.DUnitEnv;
import com.gemstone.gemfire.test.dunit.DistributedTestCase;
@@ -32,137 +35,149 @@ import com.gemstone.gemfire.test.dunit.VM;
* This class tests the basic functionality of the distributed unit
* test framework.
*/
+@SuppressWarnings("unused")
public class BasicDUnitTest extends DistributedTestCase {
+ private static final String MESSAGE_FOR_remoteThrowException = "Test exception. Please ignore.";
+
private static Properties bindings;
+ private VM vm0;
+ private VM vm1;
+
public BasicDUnitTest(String name) {
super(name);
}
@Override
- public final void postSetUp() throws Exception {
+ public void postSetUp() throws Exception {
bindings = new Properties();
invokeInEveryVM(() -> bindings = new Properties());
+ this.vm0 = Host.getHost(0).getVM(0);
+ this.vm1 = Host.getHost(0).getVM(1);
}
@Override
- public final void postTearDown() throws Exception {
+ public void postTearDown() throws Exception {
bindings = null;
invokeInEveryVM(() -> bindings = null);
}
- public void testPreconditions() {
- invokeInEveryVM(() -> assertNotNull("getUniqueName() must not return null", getUniqueName()));
- invokeInEveryVM(() -> assertNotNull("bindings must not be null", bindings));
+ public void testPreconditions() throws Exception {
+ invokeInEveryVM(() -> assertThat("getUniqueName() must not return null", getUniqueName(), notNullValue()));
+ invokeInEveryVM(() -> assertThat("bindings must not be null", bindings, notNullValue()));
}
- /**
- * Tests how the Hydra framework handles an error
- */
- public void ignore_testDontCatchRemoteException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- vm.invoke(() -> remoteThrowException());
+ public void testInvokeOnClassTargetWithEmptyArgs() throws Exception {
+ assertThat(this.vm0.invoke(BasicDUnitTest.class, "booleanValue", new Object[] {}), is(true));
+ }
+ public void testInvokeOnObjectTargetWithEmptyArgs() throws Exception {
+ assertThat(this.vm0.invoke(new BasicDUnitTest(""), "booleanValue", new Object[] {}), is(true));
+ }
+ public void testInvokeAsyncOnClassTargetWithEmptyArgs() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(BasicDUnitTest.class, "booleanValue", new Object[] {}).join();
+ assertThat(async.getResult(), is(true));
+ }
+ public void testInvokeAsyncOnObjectTargetWithEmptyArgs() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(new BasicDUnitTest(""), "booleanValue", new Object[] {}).join();
+ assertThat(async.getResult(), is(true));
}
- public void testRemoteInvocationWithException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- try {
- vm.invoke(() -> remoteThrowException());
- fail("Should have thrown a BasicTestException");
-
- } catch (RMIException ex) {
- assertTrue(ex.getCause() instanceof BasicTestException);
- }
+ public void testInvokeOnClassTargetWithNullArgs() throws Exception {
+ assertThat(this.vm0.invoke(BasicDUnitTest.class, "booleanValue", null), is(true));
+ }
+ public void testInvokeOnObjectTargetWithNullArgs() throws Exception {
+ assertThat(this.vm0.invoke(new BasicDUnitTest(""), "booleanValue", null), is(true));
+ }
+ public void testInvokeAsyncOnClassTargetWithNullArgs() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(BasicDUnitTest.class, "booleanValue", null).join();
+ assertThat(async.getResult(), is(true));
+ }
+ public void testInvokeAsyncOnObjectTargetWithNullArgs() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(new BasicDUnitTest(""), "booleanValue", null).join();
+ assertThat(async.getResult(), is(true));
}
- public void testInvokeWithLambda() throws Exception {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
- VM vm1 = host.getVM(1);
+ public void testRemoteInvocationWithException() throws Exception {
+ catchException(this.vm0).invoke(() -> remoteThrowException());
- int vm0Num = vm0.invoke(() -> DUnitEnv.get().getVMID());
- int vm1Num = vm1.invoke(() -> DUnitEnv.get().getVMID());
+ assertThat(caughtException(), instanceOf(RMIException.class));
+ assertThat(caughtException().getCause(), notNullValue());
+ assertThat(caughtException().getCause(), instanceOf(BasicTestException.class));
+ assertThat(caughtException().getCause().getMessage(), is(MESSAGE_FOR_remoteThrowException));
+ }
- assertEquals(0, vm0Num);
- assertEquals(1, vm1Num);
+ public void testInvokeWithLambda() throws Exception {
+ assertThat(this.vm0.invoke(() -> DUnitEnv.get().getVMID()), is(0));
+ assertThat(this.vm1.invoke(() -> DUnitEnv.get().getVMID()), is(1));
}
public void testInvokeLambdaAsync() throws Throwable {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
-
- AsyncInvocation<Integer> async0 = vm0.invokeAsync(() -> DUnitEnv.get().getVMID());
- int vm0num = async0.getResult();
-
- assertEquals(0, vm0num);
+ assertThat(this.vm0.invokeAsync(() -> DUnitEnv.get().getVMID()).getResult(), is(0));
}
public void testInvokeWithNamedLambda() {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
- VM vm1 = host.getVM(1);
-
- int vm0Num = vm0.invoke("getVMID", () -> DUnitEnv.get().getVMID());
- int vm1Num = vm1.invoke("getVMID", () -> DUnitEnv.get().getVMID());
-
- assertEquals(0, vm0Num);
- assertEquals(1, vm1Num);
+ assertThat(this.vm0.invoke("getVMID", () -> DUnitEnv.get().getVMID()), is(0));
+ assertThat(this.vm1.invoke("getVMID", () -> DUnitEnv.get().getVMID()), is(1));
}
public void testInvokeNamedLambdaAsync() throws Throwable {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
+ assertThat(this.vm0.invokeAsync("getVMID", () -> DUnitEnv.get().getVMID()).getResult(), is(0));
+ }
- AsyncInvocation<Integer> async0 = vm0.invokeAsync("getVMID", () -> DUnitEnv.get().getVMID());
- int vm0num = async0.getResult();
+ public void testRemoteInvokeAsync() throws Exception {
+ String name = getUniqueName();
+ String value = "Hello";
- assertEquals(0, vm0num);
+ this.vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
+ this.vm0.invokeAsync(() -> remoteValidateBind(name, value )).join().checkException();
}
- // Test was never implemented
- public void ignore_testRemoteInvocationBoolean() {
+ public void testRemoteInvokeAsyncWithException() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(() -> remoteThrowException()).join();
+
+ assertThat(async.exceptionOccurred(), is(true));
+ assertThat(async.getException(), instanceOf(BasicTestException.class));
+
+ catchThrowable(async).checkException();
+
+ assertThat(caughtThrowable(), instanceOf(AssertionError.class));
+ assertThat(caughtThrowable().getCause(), notNullValue());
+ assertThat(caughtThrowable().getCause(), instanceOf(BasicTestException.class));
+ assertThat(caughtThrowable().getCause().getMessage(), is(MESSAGE_FOR_remoteThrowException));
}
- public void testRemoteInvokeAsync() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- String name = getUniqueName();
- String value = "Hello";
+ public void testInvokeNamedRunnableLambdaAsync() throws Exception {
+ catchThrowable(this.vm0.invokeAsync("throwSomething", () -> throwException()).join()).checkException();
- AsyncInvocation ai = vm.invokeAsync(() -> remoteBind(name, value));
- ai.join();
- // TODO shouldn't we call fail() here?
- if (ai.exceptionOccurred()) {
- Assert.fail("remoteBind failed", ai.getException());
- }
+ assertThat(caughtThrowable(), notNullValue());
+ assertThat(caughtThrowable().getCause(), notNullValue());
+ assertThat(caughtThrowable().getCause(), instanceOf(BasicDUnitException.class));
+ }
- ai = vm.invokeAsync(() -> remoteValidateBind(name, value ));
- ai.join();
- if (ai.exceptionOccurred()) {
- Assert.fail("remoteValidateBind failed", ai.getException());
- }
+ public void testInvokeNamedRunnableLambda() throws Exception {
+ catchException(this.vm0).invoke("throwSomething", () -> throwException());
+
+ assertThat(caughtException(), notNullValue());
+ assertThat(caughtException().getCause(), notNullValue());
+ assertThat(caughtException().getCause(), instanceOf(BasicDUnitException.class));
+ assertThat(caughtException().getCause().getMessage(), nullValue());
}
- public void testRemoteInvokeAsyncWithException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
+ private static boolean booleanValue() { // invoked by reflection
+ return true;
+ }
- AsyncInvocation ai = vm.invokeAsync(() -> remoteThrowException());
- ai.join();
- assertTrue(ai.exceptionOccurred());
- Throwable ex = ai.getException();
- assertTrue(ex instanceof BasicTestException);
+ private static boolean booleanValue(final boolean value) { // invoked by reflection
+ return value;
}
- /**
- * Accessed via reflection. DO NOT REMOVE
- */
private static void remoteThrowException() {
- String s = "Test exception. Please ignore.";
- throw new BasicTestException(s);
+ throw new BasicTestException(MESSAGE_FOR_remoteThrowException);
+ }
+
+ private static void throwException() throws BasicDUnitException {
+ throw new BasicDUnitException();
}
private static void remoteBind(String name, String value) {
@@ -187,45 +202,8 @@ public class BasicDUnitTest extends DistributedTestCase {
}
}
- static class BasicDUnitException extends RuntimeException {
+ private static class BasicDUnitException extends RuntimeException {
public BasicDUnitException() {
}
}
-
- public static void throwException() throws BasicDUnitException {
- throw new BasicDUnitException();
- }
-
- public void testInvokeNamedRunnableLambdaAsync() throws Throwable {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
-
- AsyncInvocation<Integer> async0 = vm0.invokeAsync("throwSomething", () -> BasicDUnitTest.throwException());
- try {
- async0.getResult();
- throw new Error("expected an exception to be thrown");
- } catch (Exception e) {
- Throwable cause = e.getCause();
- if (cause == null) {
- throw new Error("expected an exception with a cause to be thrown", e);
- }
- if ( !(cause.getCause() instanceof BasicDUnitException) ) {
- throw new Error("expected a BasicDUnitException to be thrown", e.getCause());
- }
- }
- }
-
- public void testInvokeNamedRunnableLambda() throws Throwable {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
-
- try {
- vm0.invoke("throwSomething", () -> BasicDUnitTest.throwException());
- throw new Error("expected an exception to be thrown");
- } catch (Exception e) {
- if ( !(e.getCause() instanceof BasicDUnitException) ) {
- throw new Error("expected a BasicDUnitException to be thrown", e.getCause());
- }
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4BasicDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4BasicDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4BasicDUnitTest.java
new file mode 100644
index 0000000..01ba152
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4BasicDUnitTest.java
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.dunit.tests;
+
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
+import static com.googlecode.catchexception.CatchException.*;
+import static com.googlecode.catchexception.throwable.CatchThrowable.*;
+import static org.hamcrest.Matchers.*;
+
+import java.util.Properties;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.DUnitEnv;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.RMIException;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+/**
+ * This class tests the basic functionality of the distributed unit
+ * test framework.
+ *
+ * @see JUnit4BasicDUnitTest
+ */
+@Category(DistributedTest.class)
+@SuppressWarnings("unused")
+public class JUnit4BasicDUnitTest extends JUnit4DistributedTestCase {
+
+ private static final String MESSAGE_FOR_remoteThrowException = "Test exception. Please ignore.";
+
+ private static Properties bindings;
+
+ private VM vm0;
+ private VM vm1;
+
+ @BeforeClass
+ public static void setUpJUnit4BasicDUnitTest() throws Exception {
+ invokeInEveryVM(() -> bindings = new Properties());
+ }
+
+ @Override
+ public final void postSetUp() throws Exception {
+ this.vm0 = Host.getHost(0).getVM(0);
+ this.vm1 = Host.getHost(0).getVM(1);
+ }
+
+ @AfterClass
+ public static void tearDownJUnit4BasicDUnitTest() {
+ invokeInEveryVM(() -> bindings = null);
+ }
+
+ @Test
+ public void testPreconditions() {
+ invokeInEveryVM(() -> assertThat("getUniqueName() must not return null", getUniqueName(), notNullValue()));
+ invokeInEveryVM(() -> assertThat("bindings must not be null", bindings, notNullValue()));
+ }
+
+ @Test
+ public void testInvokeOnClassTargetWithEmptyArgs() throws Exception {
+ assertThat(this.vm0.invoke(JUnit4BasicDUnitTest.class, "booleanValue", new Object[] {}), is(true));
+ }
+ @Test
+ public void testInvokeOnObjectTargetWithEmptyArgs() throws Exception {
+ assertThat(this.vm0.invoke(new JUnit4BasicDUnitTest(), "booleanValue", new Object[] {}), is(true));
+ }
+ @Test
+ public void testInvokeAsyncOnClassTargetWithEmptyArgs() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(JUnit4BasicDUnitTest.class, "booleanValue", new Object[] {}).join();
+ assertThat(async.getResult(), is(true));
+ }
+ @Test
+ public void testInvokeAsyncOnObjectTargetWithEmptyArgs() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(new JUnit4BasicDUnitTest(), "booleanValue", new Object[] {}).join();
+ assertThat(async.getResult(), is(true));
+ }
+
+ @Test
+ public void testInvokeOnClassTargetWithNullArgs() throws Exception {
+ assertThat(this.vm0.invoke(JUnit4BasicDUnitTest.class, "booleanValue", null), is(true));
+ }
+ @Test
+ public void testInvokeOnObjectTargetWithNullArgs() throws Exception {
+ assertThat(this.vm0.invoke(new JUnit4BasicDUnitTest(), "booleanValue", null), is(true));
+ }
+ @Test
+ public void testInvokeAsyncOnClassTargetWithNullArgs() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(JUnit4BasicDUnitTest.class, "booleanValue", null).join();
+ assertThat(async.getResult(), is(true));
+ }
+ @Test
+ public void testInvokeAsyncOnObjectTargetWithNullArgs() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(new JUnit4BasicDUnitTest(), "booleanValue", null).join();
+ assertThat(async.getResult(), is(true));
+ }
+
+ @Test
+ public void testRemoteInvocationWithException() throws Exception {
+ catchException(this.vm0).invoke(() -> remoteThrowException());
+
+ assertThat(caughtException(), instanceOf(RMIException.class));
+ assertThat(caughtException().getCause(), notNullValue());
+ assertThat(caughtException().getCause(), instanceOf(BasicTestException.class));
+ assertThat(caughtException().getCause().getMessage(), is(MESSAGE_FOR_remoteThrowException));
+ }
+
+ @Test
+ public void testInvokeWithLambda() throws Exception {
+ assertThat(this.vm0.invoke(() -> DUnitEnv.get().getVMID()), is(0));
+ assertThat(this.vm1.invoke(() -> DUnitEnv.get().getVMID()), is(1));
+ }
+
+ @Test
+ public void testInvokeLambdaAsync() throws Throwable {
+ assertThat(this.vm0.invokeAsync(() -> DUnitEnv.get().getVMID()).getResult(), is(0));
+ }
+
+ @Test
+ public void testInvokeWithNamedLambda() {
+ assertThat(this.vm0.invoke("getVMID", () -> DUnitEnv.get().getVMID()), is(0));
+ assertThat(this.vm1.invoke("getVMID", () -> DUnitEnv.get().getVMID()), is(1));
+ }
+
+ @Test
+ public void testInvokeNamedLambdaAsync() throws Throwable {
+ assertThat(this.vm0.invokeAsync("getVMID", () -> DUnitEnv.get().getVMID()).getResult(), is(0));
+ }
+
+ @Test
+ public void testRemoteInvokeAsync() throws Exception {
+ String name = getUniqueName();
+ String value = "Hello";
+
+ this.vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
+ this.vm0.invokeAsync(() -> remoteValidateBind(name, value )).join().checkException();
+ }
+
+ @Test
+ public void testRemoteInvokeAsyncWithException() throws Exception {
+ AsyncInvocation<?> async = this.vm0.invokeAsync(() -> remoteThrowException()).join();
+
+ assertThat(async.exceptionOccurred(), is(true));
+ assertThat(async.getException(), instanceOf(BasicTestException.class));
+
+ catchThrowable(async).checkException();
+
+ assertThat(caughtThrowable(), instanceOf(AssertionError.class));
+ assertThat(caughtThrowable().getCause(), notNullValue());
+ assertThat(caughtThrowable().getCause(), instanceOf(BasicTestException.class));
+ assertThat(caughtThrowable().getCause().getMessage(), is(MESSAGE_FOR_remoteThrowException));
+ }
+
+ @Test
+ public void testInvokeNamedRunnableLambdaAsync() throws Exception {
+ catchThrowable(this.vm0.invokeAsync("throwSomething", () -> throwException()).join()).checkException();
+
+ assertThat(caughtThrowable(), notNullValue());
+ assertThat(caughtThrowable().getCause(), notNullValue());
+ assertThat(caughtThrowable().getCause(), instanceOf(BasicDUnitException.class));
+ }
+
+ @Test
+ public void testInvokeNamedRunnableLambda() throws Exception {
+ catchException(this.vm0).invoke("throwSomething", () -> throwException());
+
+ assertThat(caughtException(), notNullValue());
+ assertThat(caughtException().getCause(), notNullValue());
+ assertThat(caughtException().getCause(), instanceOf(BasicDUnitException.class));
+ assertThat(caughtException().getCause().getMessage(), nullValue());
+ }
+
+ private static boolean booleanValue() { // invoked by reflection
+ return true;
+ }
+
+ private static boolean booleanValue(final boolean value) { // invoked by reflection
+ return value;
+ }
+
+ private static void remoteThrowException() {
+ throw new BasicTestException(MESSAGE_FOR_remoteThrowException);
+ }
+
+ private static void throwException() throws BasicDUnitException {
+ throw new BasicDUnitException();
+ }
+
+ private static void remoteBind(String name, String value) {
+ assertNotNull("name must not be null", name);
+ assertNotNull("value must not be null", value);
+ assertNotNull("bindings must not be null", bindings);
+
+ new JUnit4BasicDUnitTest().getSystem(); // forces connection
+ bindings.setProperty(name, value);
+ }
+
+ private static void remoteValidateBind(String name, String expected) {
+ assertEquals(expected, bindings.getProperty(name));
+ }
+
+ private static class BasicTestException extends RuntimeException {
+ BasicTestException() {
+ this("Test exception. Please ignore.");
+ }
+ BasicTestException(String s) {
+ super(s);
+ }
+ }
+
+ private static class BasicDUnitException extends RuntimeException {
+ public BasicDUnitException() {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
new file mode 100644
index 0000000..cab5559
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.dunit.tests;
+
+import static org.assertj.core.api.Assertions.*;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+@Category(DistributedTest.class)
+public class JUnit4GetDefaultDiskStoreNameDUnitTest extends JUnit4DistributedTestCase {
+
+ @Test
+ public void testGetTestMethodName() {
+ String expected = createDefaultDiskStoreName(0, -1, "testGetTestMethodName");
+ assertGetDefaultDiskStoreName(expected);
+ }
+
+ @Test
+ public void testGetTestMethodNameChanges() {
+ String expected = createDefaultDiskStoreName(0, -1, "testGetTestMethodNameChanges");
+ assertGetDefaultDiskStoreName(expected);
+ }
+
+ @Test
+ public void testGetTestMethodNameInAllVMs() {
+ String expected = createDefaultDiskStoreName(0, -1, "testGetTestMethodNameInAllVMs");
+ assertGetDefaultDiskStoreName(expected);
+
+ for (int vmIndex = 0; vmIndex < Host.getHost(0).getVMCount(); vmIndex++) {
+ String expectedInVM = createDefaultDiskStoreName(0, vmIndex, "testGetTestMethodNameInAllVMs");
+ Host.getHost(0).getVM(vmIndex).invoke(()->assertGetDefaultDiskStoreName(expectedInVM));
+ }
+ }
+
+ private void assertGetDefaultDiskStoreName(final String expected) {
+ assertThat(getDefaultDiskStoreName()).isEqualTo(expected);
+ }
+
+ private String createDefaultDiskStoreName(final int hostIndex, final int vmIndex, final String methodName) {
+ return "DiskStore-" + hostIndex + "-" + vmIndex + "-" + getClass().getCanonicalName() + "." + methodName;
+ }
+
+ private String getDefaultDiskStoreName() {
+ return GemFireCacheImpl.DEFAULT_DS_NAME; // TODO: not thread safe
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4GetTestMethodNameDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4GetTestMethodNameDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4GetTestMethodNameDUnitTest.java
new file mode 100644
index 0000000..a4a9b49
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4GetTestMethodNameDUnitTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.dunit.tests;
+
+import static org.assertj.core.api.Assertions.*;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+@Category(DistributedTest.class)
+public class JUnit4GetTestMethodNameDUnitTest extends JUnit4DistributedTestCase {
+
+ @Test
+ public void testGetTestMethodName() {
+ assertGetTestMethodName("testGetTestMethodName");
+ }
+
+ @Test
+ public void testGetTestMethodNameChanges() {
+ assertGetTestMethodName("testGetTestMethodNameChanges");
+ }
+
+ @Test
+ public void testGetTestMethodNameInAllVMs() {
+ assertGetTestMethodName("testGetTestMethodNameInAllVMs");
+
+ for (int vmIndex = 0; vmIndex < Host.getHost(0).getVMCount(); vmIndex++) {
+ Host.getHost(0).getVM(vmIndex).invoke(()->assertGetTestMethodName("testGetTestMethodNameInAllVMs"));
+ }
+ }
+
+ private void assertGetTestMethodName(final String expected) {
+ assertThat(getTestMethodName()).isEqualTo(expected);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest.java
new file mode 100644
index 0000000..b03c42a
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.dunit.tests;
+
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
+
+import java.util.Properties;
+
+import org.junit.Test;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+
+/**
+ * Verifies that overriding {@code getDistributedSystemProperties} results
+ * in {@code disconnectAllFromDS} during tear down.
+ */
+public class JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest extends JUnit4DistributedTestCase {
+
+ @Override
+ public final void preTearDownAssertions() throws Exception {
+ invokeInEveryVM(() -> assertNotNull(basicGetSystem()));
+ }
+
+ @Override
+ public final void postTearDownAssertions() throws Exception {
+ invokeInEveryVM(() -> assertNull(basicGetSystem()));
+ }
+
+ @Override
+ public final Properties getDistributedSystemProperties() {
+ Properties props = new Properties();
+ props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+ return props;
+ }
+
+ @Test
+ public void testDisconnects() throws Exception {
+ invokeInEveryVM(() -> assertFalse(getDistributedSystemProperties().isEmpty()));
+ invokeInEveryVM(() -> assertNotNull(getSystem()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4VMDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4VMDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4VMDUnitTest.java
new file mode 100644
index 0000000..3861234
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/JUnit4VMDUnitTest.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.dunit.tests;
+
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.RMIException;
+import com.gemstone.gemfire.test.dunit.SerializableRunnableIF;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+/**
+ * This class tests the functionality of the {@link VM} class.
+ */
+@Category(DistributedTest.class)
+public class JUnit4VMDUnitTest extends JUnit4DistributedTestCase {
+
+ private static final AtomicInteger COUNTER = new AtomicInteger();
+ private static final boolean BOOLEAN_VALUE = true;
+ private static final byte BYTE_VALUE = (byte) 40;
+ private static final long LONG_VALUE = 42L;
+ private static final String STRING_VALUE = "BLAH BLAH BLAH";
+
+ @Test
+ public void testInvokeStaticBoolean() {
+ Host host = Host.getHost(0);
+ VM vm = host.getVM(0);
+ assertEquals(BOOLEAN_VALUE, (boolean) vm.invoke(() -> remoteBooleanMethod()));
+ }
+
+ @Test
+ public void testInvokeStaticByte() {
+ Host host = Host.getHost(0);
+ VM vm = host.getVM(0);
+ assertEquals(BYTE_VALUE, (byte) vm.invoke(() -> remoteByteMethod()));
+ }
+
+ @Test
+ public void testInvokeStaticLong() {
+ Host host = Host.getHost(0);
+ VM vm = host.getVM(0);
+ assertEquals(LONG_VALUE, (long) vm.invoke(() -> remoteLongMethod()));
+ }
+
+ @Test
+ public void testInvokeInstance() {
+ Host host = Host.getHost(0);
+ VM vm = host.getVM(0);
+ assertEquals(STRING_VALUE, vm.invoke(new ClassWithString(), "getString"));
+ }
+
+ @Test
+ public void testInvokeRunnableWithException() {
+ Host host = Host.getHost(0);
+ VM vm = host.getVM(0);
+ try {
+ vm.invoke(new InvokeRunnable());
+ fail("Should have thrown a BasicTestException");
+ } catch (RMIException ex) {
+ assertTrue(ex.getCause() instanceof BasicTestException);
+ }
+ }
+
+ @Test
+ public void testReturnValue() throws Exception {
+ final Host host = Host.getHost(0);
+ final VM vm = host.getVM(0);
+ // Assert class static invocation works
+ AsyncInvocation a1 = vm.invokeAsync(() -> getAndIncStaticCount());
+ a1.join();
+ assertEquals(new Integer(0), a1.getReturnValue());
+ // Assert class static invocation with args works
+ a1 = vm.invokeAsync(() -> incrementStaticCount(new Integer(2)));
+ a1.join();
+ assertEquals(new Integer(3), a1.getReturnValue());
+ // Assert that previous values are not returned when invoking method w/ no return val
+ a1 = vm.invokeAsync(() -> incStaticCount());
+ a1.join();
+ assertNull(a1.getReturnValue());
+ // Assert that previous null returns are over-written
+ a1 = vm.invokeAsync(() -> getAndIncStaticCount());
+ a1.join();
+ assertEquals(new Integer(4), a1.getReturnValue());
+
+ // Assert object method invocation works with zero arg method
+ final VMTestObject o = new VMTestObject(0);
+ a1 = vm.invokeAsync(o, "incrementAndGet", new Object[] {});
+ a1.join();
+ assertEquals(new Integer(1), a1.getReturnValue());
+ // Assert object method invocation works with no return
+ a1 = vm.invokeAsync(o, "set", new Object[] {new Integer(3)});
+ a1.join();
+ assertNull(a1.getReturnValue());
+ }
+
+ private static Integer getAndIncStaticCount() {
+ return new Integer(COUNTER.getAndIncrement());
+ }
+
+ private static Integer incrementStaticCount(Integer inc) {
+ return new Integer(COUNTER.addAndGet(inc.intValue()));
+ }
+
+ private static void incStaticCount() {
+ COUNTER.incrementAndGet();
+ }
+
+ /**
+ * Accessed via reflection. DO NOT REMOVE
+ */
+ private static byte remoteByteMethod() {
+ return BYTE_VALUE;
+ }
+
+ /**
+ * Accessed via reflection. DO NOT REMOVE
+ */
+ private static boolean remoteBooleanMethod() {
+ return BOOLEAN_VALUE;
+ }
+
+ /**
+ * Accessed via reflection. DO NOT REMOVE
+ */
+ private static long remoteLongMethod() {
+ return LONG_VALUE;
+ }
+
+ private static class ClassWithLong implements Serializable {
+ public long getLong() {
+ return LONG_VALUE;
+ }
+ }
+
+ private static class ClassWithByte implements Serializable {
+ public byte getByte() {
+ return BYTE_VALUE;
+ }
+ }
+
+ private static class InvokeRunnable implements SerializableRunnableIF {
+ public void run() {
+ throw new BasicTestException();
+ }
+ }
+
+ private static class ClassWithString implements Serializable {
+ public String getString() {
+ return STRING_VALUE;
+ }
+ }
+
+ private static class BasicTestException extends RuntimeException {
+ BasicTestException() {
+ this("Test exception. Please ignore.");
+ }
+ BasicTestException(String s) {
+ super(s);
+ }
+ }
+
+ private static class VMTestObject implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private final AtomicInteger val;
+ public VMTestObject(int init) {
+ this.val = new AtomicInteger(init);
+ }
+ public Integer get() {
+ return new Integer(this.val.get());
+ }
+ public Integer incrementAndGet() {
+ return new Integer(this.val.incrementAndGet());
+ }
+ public void set(Integer newVal) {
+ this.val.set(newVal.intValue());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
index f1afdaf..6fef000 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
@@ -16,16 +16,23 @@
*/
package com.gemstone.gemfire.management.internal.cli.commands;
-import hydra.Log;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+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 java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Map.Entry;
-
+import java.util.Properties;
import javax.management.ObjectName;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheException;
@@ -63,23 +70,20 @@ import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
import com.gemstone.gemfire.management.internal.cli.result.CompositeResultData;
import com.gemstone.gemfire.management.internal.cli.result.CompositeResultData.SectionResultData;
-import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
+import com.gemstone.gemfire.management.internal.cli.result.TabularResultData;
import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
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.management.internal.cli.result.TabularResultData;
-
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
/**
* Dunit class for testing gemfire Client commands : list client , describe client
* @since 8.0
*/
-
-
+@Category({ DistributedTest.class, FlakyTest.class }) // see GEODE-1034
public class ClientCommandsDUnitTest extends CliCommandTestBase {
private static final long serialVersionUID = 1L;
@@ -92,15 +96,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
int port0 = 0;
int port1= 0;
-
-
- public ClientCommandsDUnitTest(String name) {
- super(name);
-
- }
-
-
-public void waitForListClientMbean(){
+ public void waitForListClientMbean(){
final VM manager = Host.getHost(0).getVM(0);
final VM server1 = Host.getHost(0).getVM(1);
@@ -117,7 +113,7 @@ public void waitForListClientMbean(){
public boolean done() {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
if (service == null) {
- Log.getLogWriter().info("waitForListClientMbean Still probing for service");
+ getLogWriter().info("waitForListClientMbean Still probing for service");
return false;
} else {
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);
@@ -142,7 +138,7 @@ public void waitForListClientMbean(){
return "waitForListClientMbean Probing ...";
}
};
- Wait.waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
+ waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
}
});
@@ -166,7 +162,7 @@ public void waitForListClientMbean2(){
public boolean done() {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
if (service == null) {
- Log.getLogWriter().info("waitForListClientMbean2 Still probing for service");
+ getLogWriter().info("waitForListClientMbean2 Still probing for service");
return false;
} else {
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);
@@ -191,7 +187,7 @@ public void waitForListClientMbean2(){
return "waitForListClientMbean2 Probing ...";
}
};
- Wait.waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
+ waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
}
});
@@ -216,7 +212,7 @@ public void waitForListClientMbean2(){
public boolean done() {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
if (service == null) {
- Log.getLogWriter().info("waitForMbean Still probing for service");
+ getLogWriter().info("waitForMbean Still probing for service");
return false;
} else {
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);
@@ -251,7 +247,7 @@ public void waitForListClientMbean2(){
return "waitForMbean Probing for ";
}
};
- Wait.waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
+ waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
}
});
@@ -276,7 +272,7 @@ public void waitForListClientMbean2(){
public boolean done() {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
if (service == null) {
- Log.getLogWriter().info("waitForListClientMbean3 Still probing for service");
+ getLogWriter().info("waitForListClientMbean3 Still probing for service");
return false;
} else {
final ObjectName cacheServerMBeanName1 = service.getCacheServerMBeanName(port0,serverMember1);
@@ -303,13 +299,15 @@ public void waitForListClientMbean2(){
return "waitForListClientMbean3 Probing ...";
}
};
- Wait.waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
+ waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
}
});
}
-
- /*public void testDescribeClientWithServers3() throws Exception {
+
+ @Ignore("disabled for unknown reason")
+ @Test
+ public void testDescribeClientWithServers3() throws Exception {
setupSystem3();
String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId + "\"" ;
final VM server1 = Host.getHost(0).getVM(1);
@@ -350,7 +348,7 @@ public void waitForListClientMbean2(){
for(String str : clientIds){
clientId1 = str;
- Log.getLogWriter().info("testDescribeClientWithServers clientIds for server1 ="+str);
+ getLogWriter().info("testDescribeClientWithServers clientIds for server1 ="+str);
}
final DistributedMember serverMember2 = getMember(server2);
@@ -373,21 +371,21 @@ public void waitForListClientMbean2(){
for(String str : clientIds2){
clientId2 = str;
- Log.getLogWriter().info("testDescribeClientWithServers clientIds for server2 ="+str);
+ getLogWriter().info("testDescribeClientWithServers clientIds for server2 ="+str);
}
commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId1 + "\"" ;
- Log.getLogWriter().info("testDescribeClientWithServers commandStr clientId1 ="+commandString);
+ getLogWriter().info("testDescribeClientWithServers commandStr clientId1 ="+commandString);
CommandResult commandResultForClient1 = executeCommand(commandString);
- Log.getLogWriter().info("testDescribeClientWithServers commandStr clientId1="+commandResultForClient1);
+ getLogWriter().info("testDescribeClientWithServers commandStr clientId1="+commandResultForClient1);
String resultAsString = commandResultToString(commandResultForClient1);
- Log.getLogWriter().info("testDescribeClientWithServers commandStr clientId1 ="+resultAsString);
+ getLogWriter().info("testDescribeClientWithServers commandStr clientId1 ="+resultAsString);
assertTrue(Status.OK.equals(commandResultForClient1.getStatus()));
verifyClientStats(commandResultForClient1, serverName1);
@@ -396,15 +394,15 @@ public void waitForListClientMbean2(){
commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId2 + "\"" ;
- Log.getLogWriter().info("testDescribeClientWithServers commandStr1="+commandString);
+ getLogWriter().info("testDescribeClientWithServers commandStr1="+commandString);
CommandResult commandResultForClient2 = executeCommand(commandString);
- Log.getLogWriter().info("testDescribeClientWithServers commandResult1="+commandResultForClient2);
+ getLogWriter().info("testDescribeClientWithServers commandResult1="+commandResultForClient2);
resultAsString = commandResultToString(commandResultForClient2);
- Log.getLogWriter().info("testDescribeClientWithServers resultAsString1="+resultAsString);
+ getLogWriter().info("testDescribeClientWithServers resultAsString1="+resultAsString);
assertTrue(Status.OK.equals(commandResultForClient2.getStatus()));
verifyClientStats(commandResultForClient2, serverName2);
@@ -414,15 +412,15 @@ public void waitForListClientMbean2(){
closeCacheServer(Host.getHost(0).getVM(3));
closeCacheServer(Host.getHost(0).getVM(1));
- } */
+ }
-public void verifyClientStats(CommandResult commandResultForClient, String serverName){
+ public void verifyClientStats(CommandResult commandResultForClient, String serverName){
CompositeResultData resultData = (CompositeResultData) commandResultForClient.getResultData();
SectionResultData section =resultData.retrieveSection("InfoSection");
assertNotNull(section);
for(int i = 0 ; i < 1 ; i++){
TabularResultData tableRsultData = section.retrieveTableByIndex(i);
- Log.getLogWriter().info("testDescribeClientWithServers getHeader="+tableRsultData.getHeader());
+ getLogWriter().info("testDescribeClientWithServers getHeader="+tableRsultData.getHeader());
assertNotNull(tableRsultData);
List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
@@ -431,7 +429,7 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
- Log.getLogWriter().info("testDescribeClientWithServers getHeader numCqs ="+ numCqs);
+ getLogWriter().info("testDescribeClientWithServers getHeader numCqs ="+ numCqs);
assertTrue(minConn.contains("1"));
assertTrue(maxConn.contains("-1"));
@@ -458,15 +456,17 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
}
}
-
- public void disabled_testDescribeClient() throws Exception {
+
+ @Ignore("disabled for unknown reason")
+ @Test
+ public void testDescribeClient() throws Exception {
setupSystem();
- Log.getLogWriter().info("testDescribeClient clientId="+clientId);
+ getLogWriter().info("testDescribeClient clientId="+clientId);
assertNotNull(clientId);
String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId + "\"" ;
- Log.getLogWriter().info("testDescribeClient commandStr="+commandString);
+ getLogWriter().info("testDescribeClient commandStr="+commandString);
final VM server1 = Host.getHost(0).getVM(1);
String serverName = (String) server1.invoke(new SerializableCallable(){
@@ -480,11 +480,11 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
CommandResult commandResult = executeCommand(commandString);
- Log.getLogWriter().info("testDescribeClient commandResult="+commandResult);
+ getLogWriter().info("testDescribeClient commandResult="+commandResult);
String resultAsString = commandResultToString(commandResult);
- Log.getLogWriter().info("testDescribeClient resultAsString="+resultAsString);
+ getLogWriter().info("testDescribeClient resultAsString="+resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
@@ -527,13 +527,14 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
closeCacheServer(Host.getHost(0).getVM(3));
- }
-
+ }
+
+ @Test
public void testDescribeClientWithServers() throws Exception {
setupSystem2();
String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId + "\"" ;
- Log.getLogWriter().info("testDescribeClientWithServers commandStr="+commandString);
+ getLogWriter().info("testDescribeClientWithServers commandStr="+commandString);
final VM server1 = Host.getHost(0).getVM(1);
@@ -547,11 +548,11 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
CommandResult commandResult = executeCommand(commandString);
- Log.getLogWriter().info("testDescribeClientWithServers commandResult="+commandResult);
+ getLogWriter().info("testDescribeClientWithServers commandResult="+commandResult);
String resultAsString = commandResultToString(commandResult);
- Log.getLogWriter().info("testDescribeClientWithServers resultAsString="+resultAsString);
+ getLogWriter().info("testDescribeClientWithServers resultAsString="+resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
@@ -592,9 +593,9 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
closeNonDurableClient(Host.getHost(0).getVM(3));
closeCacheServer(Host.getHost(0).getVM(1));
- }
-
-
+ }
+
+ @Test
public void testListClient() throws Exception {
setupSystemForListClient();
@@ -602,7 +603,7 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
final VM manager = Host.getHost(0).getVM(0);
String commandString = CliStrings.LIST_CLIENTS ;
- Log.getLogWriter().info("testListClient commandStr="+commandString);
+ getLogWriter().info("testListClient commandStr="+commandString);
waitForListClientMbean();
@@ -632,11 +633,11 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
});
CommandResult commandResult = executeCommand(commandString);
- Log.getLogWriter().info("testListClient commandResult="+commandResult);
+ getLogWriter().info("testListClient commandResult="+commandResult);
String resultAsString = commandResultToString(commandResult);
- Log.getLogWriter().info("testListClient resultAsString="+resultAsString);
+ getLogWriter().info("testListClient resultAsString="+resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
@@ -650,14 +651,14 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
List<String> clientNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
- Log.getLogWriter().info("testListClients serverNames : " + serverNames);
- Log.getLogWriter().info("testListClients clientNames : " + clientNames);
+ getLogWriter().info("testListClients serverNames : " + serverNames);
+ getLogWriter().info("testListClients clientNames : " + clientNames);
assertEquals(2, serverNames.size());
assertEquals(2, clientNames.size());
assertTrue(clientNames.contains(clientIds[0]));
assertTrue(clientNames.contains(clientIds[1]));
serverName = serverName.replace(":", "-");
- Log.getLogWriter().info("testListClients serverName : " + serverName);
+ getLogWriter().info("testListClients serverName : " + serverName);
for(String str : serverNames){
assertTrue(str.contains(serverName));
}
@@ -666,17 +667,17 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
closeCacheServer(Host.getHost(0).getVM(3));
- }
-
-
- public void testListClientForServers() throws Exception {
+ }
+
+ @Test
+ public void testListClientForServers() throws Exception {
setupSystem3();
final VM manager = Host.getHost(0).getVM(0);
String commandString = CliStrings.LIST_CLIENTS ;
- Log.getLogWriter().info("testListClientForServers commandStr="+commandString);
+ getLogWriter().info("testListClientForServers commandStr="+commandString);
@@ -716,11 +717,11 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
});
CommandResult commandResult = executeCommand(commandString);
- Log.getLogWriter().info("testListClientForServers commandResult="+commandResult);
+ getLogWriter().info("testListClientForServers commandResult="+commandResult);
String resultAsString = commandResultToString(commandResult);
- Log.getLogWriter().info("testListClientForServers resultAsString="+resultAsString);
+ getLogWriter().info("testListClientForServers resultAsString="+resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
@@ -737,10 +738,10 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
serverName2 = serverName2.replace(":", "-");
- Log.getLogWriter().info("testListClientForServers serverNames : " + serverNames);
- Log.getLogWriter().info("testListClientForServers serverName1 : " + serverName1);
- Log.getLogWriter().info("testListClientForServers serverName2 : " + serverName2);
- Log.getLogWriter().info("testListClientForServers clientNames : " + clientNames);
+ getLogWriter().info("testListClientForServers serverNames : " + serverNames);
+ getLogWriter().info("testListClientForServers serverName1 : " + serverName1);
+ getLogWriter().info("testListClientForServers serverName2 : " + serverName2);
+ getLogWriter().info("testListClientForServers clientNames : " + clientNames);
for(String client : clientIds){
assertTrue(clientNames.contains(client));
@@ -983,7 +984,7 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
getSystem(props);
final ClientCacheFactory ccf = new ClientCacheFactory(props);
- ccf.addPoolServer(NetworkUtils.getServerHostName(server.getHost()), port);
+ ccf.addPoolServer(getServerHostName(server.getHost()), port);
ccf.setPoolSubscriptionEnabled(true);
ccf.setPoolPingInterval(1);
ccf.setPoolStatisticInterval(1);
@@ -1003,7 +1004,7 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
}else{
String poolName = "new_pool_" + System.currentTimeMillis();
try{
- PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(NetworkUtils.getServerHostName(server.getHost()), port)
+ PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(getServerHostName(server.getHost()), port)
.setThreadLocalConnections(true)
.setMinConnections(1)
.setSubscriptionEnabled(true)
@@ -1056,7 +1057,7 @@ public void verifyClientStats(CommandResult commandResultForClient, String serve
protected Properties getServerProperties() {
Properties p = new Properties();
- p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
+ p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+getDUnitLocatorPort()+"]");
return p;
}
@@ -1077,14 +1078,14 @@ public void waitForNonSubCliMBean(){
try {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
if (service == null) {
- Log.getLogWriter().info("waitForNonSubScribedClientMBean Still probing for service");
+ getLogWriter().info("waitForNonSubScribedClientMBean Still probing for service");
return false;
} else {
- Log.getLogWriter().info("waitForNonSubScribedClientMBean 1");
+ getLogWriter().info("waitForNonSubScribedClientMBean 1");
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);
- Log.getLogWriter().info("waitForNonSubScribedClientMBean 2 cacheServerMBeanName " + cacheServerMBeanName);
+ getLogWriter().info("waitForNonSubScribedClientMBean 2 cacheServerMBeanName " + cacheServerMBeanName);
CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
- Log.getLogWriter().info("waitForNonSubScribedClientMBean 2 bean " + bean);
+ getLogWriter().info("waitForNonSubScribedClientMBean 2 bean " + bean);
if(bean.getClientIds().length > 0){
return true;
}
@@ -1100,7 +1101,7 @@ public void waitForNonSubCliMBean(){
return "waitForNonSubScribedClientMBean Probing for ";
}
};
- Wait.waitForCriterion(waitForMaangerMBean, 5* 60 * 1000, 2000, true);
+ waitForCriterion(waitForMaangerMBean, 5* 60 * 1000, 2000, true);
}
});
@@ -1125,14 +1126,14 @@ public void waitForMixedClients(){
try {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
if (service == null) {
- Log.getLogWriter().info("waitForMixedClients Still probing for service");
+ getLogWriter().info("waitForMixedClients Still probing for service");
return false;
} else {
- Log.getLogWriter().info("waitForMixedClients 1");
+ getLogWriter().info("waitForMixedClients 1");
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);
- Log.getLogWriter().info("waitForMixedClients 2 cacheServerMBeanName " + cacheServerMBeanName);
+ getLogWriter().info("waitForMixedClients 2 cacheServerMBeanName " + cacheServerMBeanName);
CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
- Log.getLogWriter().info("waitForMixedClients 2 bean " + bean);
+ getLogWriter().info("waitForMixedClients 2 bean " + bean);
if(bean.getClientIds().length > 1){
return true;
}
@@ -1148,22 +1149,21 @@ public void waitForMixedClients(){
return "waitForMixedClients Probing for ";
}
};
- Wait.waitForCriterion(waitForMaangerMBean, 5* 60 * 1000, 2000, true);
+ waitForCriterion(waitForMaangerMBean, 5* 60 * 1000, 2000, true);
}
});
}
-
-
+ @Test
public void testDescribeClientForNonSubscribedClient() throws Exception {
setUpNonSubscribedClient();
- Log.getLogWriter().info("testDescribeClientForNonSubscribedClient clientId="+clientId);
+ getLogWriter().info("testDescribeClientForNonSubscribedClient clientId="+clientId);
assertNotNull(clientId);
String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId + "\"" ;
- Log.getLogWriter().info("testDescribeClientForNonSubscribedClient commandStr="+commandString);
+ getLogWriter().info("testDescribeClientForNonSubscribedClient commandStr="+commandString);
final VM server1 = Host.getHost(0).getVM(1);
String serverName = (String) server1.invoke(new SerializableCallable(){
@@ -1176,11 +1176,11 @@ public void waitForMixedClients(){
CommandResult commandResult = executeCommand(commandString);
- Log.getLogWriter().info("testDescribeClientForNonSubscribedClient commandResult="+commandResult);
+ getLogWriter().info("testDescribeClientForNonSubscribedClient commandResult="+commandResult);
String resultAsString = commandResultToString(commandResult);
- Log.getLogWriter().info("testDescribeClientForNonSubscribedClient resultAsString="+resultAsString);
+ getLogWriter().info("testDescribeClientForNonSubscribedClient resultAsString="+resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
@@ -1228,8 +1228,9 @@ public void waitForMixedClients(){
closeCacheServer(Host.getHost(0).getVM(3));
- }
-
+ }
+
+ @Test
public void testDescribeMixClientWithServers() throws Exception {
String[] clientIds = setupSystemWithSubAndNonSubClient();
@@ -1243,13 +1244,13 @@ public void waitForMixedClients(){
});
String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientIds[0] + "\"" ;
- Log.getLogWriter().info("testDescribeMixClientWithServers commandStr="+commandString);
+ getLogWriter().info("testDescribeMixClientWithServers commandStr="+commandString);
executeAndVerifyResultsForMixedClients(commandString, serverName );
String commandString2 = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientIds[1] + "\"" ;
- Log.getLogWriter().info("testDescribeMixClientWithServers commandString2="+commandString2);
+ getLogWriter().info("testDescribeMixClientWithServers commandString2="+commandString2);
executeAndVerifyResultsForMixedClients(commandString2,serverName );
@@ -1262,11 +1263,11 @@ public void waitForMixedClients(){
void executeAndVerifyResultsForMixedClients(String commandString, String serverName){
CommandResult commandResult = executeCommand(commandString);
- Log.getLogWriter().info("testDescribeMixClientWithServers commandResult="+commandResult);
+ getLogWriter().info("testDescribeMixClientWithServers commandResult="+commandResult);
String resultAsString = commandResultToString(commandResult);
- Log.getLogWriter().info("testDescribeMixClientWithServers resultAsString="+resultAsString);
+ getLogWriter().info("testDescribeMixClientWithServers resultAsString="+resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
@@ -1396,7 +1397,7 @@ private void setUpNonSubscribedClient() throws Exception {
getSystem(props);
final ClientCacheFactory ccf = new ClientCacheFactory(props);
- ccf.addPoolServer(NetworkUtils.getServerHostName(server.getHost()), port);
+ ccf.addPoolServer(getServerHostName(server.getHost()), port);
ccf.setPoolSubscriptionEnabled(false);
ccf.setPoolPingInterval(1);
ccf.setPoolStatisticInterval(1);
@@ -1416,7 +1417,7 @@ private void setUpNonSubscribedClient() throws Exception {
}else{
String poolName = "new_pool_" + System.currentTimeMillis();
try{
- PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(NetworkUtils.getServerHostName(server.getHost()), port)
+ PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(getServerHostName(server.getHost()), port)
.setThreadLocalConnections(true)
.setMinConnections(1)
.setSubscriptionEnabled(false)
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DurableClientCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DurableClientCommandsDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DurableClientCommandsDUnitTest.java
index 0a1f433..b35538d 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DurableClientCommandsDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DurableClientCommandsDUnitTest.java
@@ -16,13 +16,21 @@
*/
package com.gemstone.gemfire.management.internal.cli.commands;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+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 java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.CacheException;
import com.gemstone.gemfire.cache.DataPolicy;
import com.gemstone.gemfire.cache.PartitionAttributesFactory;
import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
@@ -44,15 +52,12 @@ import com.gemstone.gemfire.management.cli.Result.Status;
import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
-import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-
-
+@Category(DistributedTest.class)
public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
private static final long serialVersionUID = 1L;
@@ -61,11 +66,8 @@ public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
final String cq2 = "cq2";
final String cq3 = "cq3";
final String clientName = "dc1";
-
- public DurableClientCommandsDUnitTest(String name) {
- super(name);
- }
-
+
+ @Test
public void testListDurableClientCqs() throws Exception {
setupSystem();
setupCqs();
@@ -98,6 +100,7 @@ public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
assertTrue(resultAsString.contains(errorMessage));
}
+ @Test
public void testCloseDurableClients() throws Exception {
setupSystem();
setupCqs();
@@ -127,8 +130,8 @@ public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
String errorMessage = CliStrings.format(CliStrings.NO_CLIENT_FOUND_WITH_CLIENT_ID, clientName);
assertTrue(resultAsString.contains(errorMessage));
}
-
-
+
+ @Test
public void testCloseDurableCQ() throws Exception{
setupSystem();
setupCqs();
@@ -156,17 +159,8 @@ public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
assertTrue(Status.ERROR.equals(commandResult.getStatus()));
}
-
-// public void testRepeat() throws Exception {
-// long endTime = System.currentTimeMillis() + (75 * 60000);
-// while (endTime > System.currentTimeMillis()) {
-// testCountSubscriptionQueueSize();
-// tearDown();
-// setUp();
-// }
-// testCountSubscriptionQueueSize();
-// }
-//
+
+ @Test
public void testCountSubscriptionQueueSize() throws Exception {
setupSystem();
setupCqs();
@@ -250,7 +244,7 @@ public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
}
private void writeToLog(String text, String resultAsString) {
- LogWriterUtils.getLogWriter().info(getUniqueName() + ": " + text + "\n" + resultAsString);
+ getLogWriter().info(getUniqueName() + ": " + text + "\n" + resultAsString);
}
private void setupSystem() throws Exception {
@@ -360,7 +354,7 @@ public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
getSystem(props);
final ClientCacheFactory ccf = new ClientCacheFactory(props);
- ccf.addPoolServer(NetworkUtils.getServerHostName(server.getHost()), port);
+ ccf.addPoolServer(getServerHostName(server.getHost()), port);
ccf.setPoolSubscriptionEnabled(true);
ClientCache cache = (ClientCache)getClientCache(ccf);
@@ -368,10 +362,9 @@ public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
});
}
- /* Does few puts on the region on the server
- *
+ /**
+ * Does few puts on the region on the server
*/
-
private void doPuts(final String regionName, VM server) {
server.invoke(new SerializableCallable() {
public Object call() throws Exception {
@@ -423,7 +416,7 @@ public class DurableClientCommandsDUnitTest extends CliCommandTestBase {
protected Properties getServerProperties() {
Properties p = new Properties();
- p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
+ p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+getDUnitLocatorPort()+"]");
return p;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/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 e2950c2..f268c8f 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,11 +19,13 @@ package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.security.SecurityTestUtils.*;
import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
-import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
/**
* Tests for authorization from client to server. This tests for authorization
* of all operations with both valid and invalid credentials/modules with
@@ -35,7 +37,7 @@ import org.junit.experimental.categories.Category;
*
* @since 5.5
*/
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
public class ClientAuthorizationTwoDUnitTest extends ClientAuthorizationTestCase {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/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 0e8e57f..fe0e4c3 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
@@ -26,6 +26,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.DataSerializable;
import com.gemstone.gemfire.Instantiator;
import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
@@ -38,8 +41,7 @@ import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
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;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
/**
* Tests for authorization callback that modify objects and callbacks from
@@ -57,7 +59,7 @@ import org.junit.experimental.categories.Category;
*
* @since 5.5
*/
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
private static final String preAccessor = FilterPreAuthorization.class.getName() + ".create";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/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 dfa89f9..e3e7886 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
@@ -29,6 +29,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.Random;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
import com.gemstone.gemfire.cache.query.CqAttributes;
@@ -50,13 +53,12 @@ import com.gemstone.gemfire.security.generator.CredentialGenerator;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
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;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
/**
* This is for multiuser-authentication
*/
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestCase {
private Map<String, String> cqNameToQueryStrings = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/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 ce03ac6..5db15f0 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
@@ -26,15 +26,18 @@ import java.util.List;
import java.util.Properties;
import java.util.Random;
+import org.junit.Rule;
+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;
import com.gemstone.gemfire.test.junit.Retry;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
import com.gemstone.gemfire.test.junit.rules.RetryRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
/**
* Tests for authorization from client to server. This tests for authorization
@@ -43,14 +46,14 @@ import org.junit.experimental.categories.Category;
*
* @since 5.5
*/
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class, FlakyTest.class}) // GEODE-693, GEODE-1009: getRandomAvailablePort
public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCase {
@Rule
public RetryRule retryRule = new RetryRule();
@Test
- @Retry(2)
+ @Retry(2) // GEODE-693: getRandomAvailablePort
public void testAllPostOps() throws Exception {
OperationWithAction[] allOps = allOpsForTestAllPostOps();
@@ -112,6 +115,7 @@ public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCas
}
@Test
+ @Retry(2) // GEODE-1009: getRandomAvailablePort
public void testAllOpsNotifications() throws Exception {
OperationWithAction[] allOps = allOpsForTestAllOpsNotifications();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/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 9e04f5f..9bbceff 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
@@ -26,6 +26,9 @@ import java.util.Properties;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.execute.FunctionService;
@@ -38,10 +41,9 @@ 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.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 MultiUserAPIDUnitTest extends ClientAuthorizationTestCase {
private static final String[] serverIgnoredExceptions = {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/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 632a997..3a97b7c 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
@@ -27,6 +27,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.Random;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
import com.gemstone.gemfire.cache.query.CqAttributes;
@@ -45,10 +48,9 @@ import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
import com.gemstone.gemfire.security.generator.CredentialGenerator;
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;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-@Category(DistributedTest.class)
+@Category({ DistributedTest.class, SecurityTest.class })
public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestCase {
private final Map<String, String> cqNameToQueryStrings = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/FlakyTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/FlakyTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/FlakyTest.java
new file mode 100644
index 0000000..b1e9b18
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/FlakyTest.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.categories;
+
+/**
+ * JUnit Test Category that specifies a flickering test that fails
+ * intermittently.
+ */
+public interface FlakyTest {
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/SecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/SecurityTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/SecurityTest.java
new file mode 100644
index 0000000..3af739e
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/SecurityTest.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.categories;
+
+/**
+ * JUnit Test Category that specifies a test involving security.
+ */
+public class SecurityTest {
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/categories/CategoryOne.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/categories/CategoryOne.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/categories/CategoryOne.java
new file mode 100644
index 0000000..8d3549b
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/categories/CategoryOne.java
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.categories;
+
+public interface CategoryOne {
+}