Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 77D9A200AE4 for ; Thu, 9 Jun 2016 19:05:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 76993160A59; Thu, 9 Jun 2016 17:05:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 32BFB160A58 for ; Thu, 9 Jun 2016 19:05:42 +0200 (CEST) Received: (qmail 41829 invoked by uid 500); 9 Jun 2016 17:05:41 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 41820 invoked by uid 99); 9 Jun 2016 17:05:41 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 17:05:41 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id CC3C7C1292 for ; Thu, 9 Jun 2016 17:05:40 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id MB3TT1ENiFQV for ; Thu, 9 Jun 2016 17:05:22 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id CB0005F46E for ; Thu, 9 Jun 2016 17:05:19 +0000 (UTC) Received: (qmail 38941 invoked by uid 99); 9 Jun 2016 17:05:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 17:05:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C5921E02DA; Thu, 9 Jun 2016 17:05:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.incubator.apache.org Date: Thu, 09 Jun 2016 17:05:24 -0000 Message-Id: <47e7ebdb5a144ae29de5c037dc0a611e@git.apache.org> In-Reply-To: <950410947b7f4235a05149c73b1a2447@git.apache.org> References: <950410947b7f4235a05149c73b1a2447@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [07/51] [partial] incubator-geode git commit: GEODE-837: update tests from JUnit3 to JUnit4 archived-at: Thu, 09 Jun 2016 17:05:44 -0000 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONPdxClientServerDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONPdxClientServerDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONPdxClientServerDUnitTest.java index 0800dde..d249fb9 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONPdxClientServerDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONPdxClientServerDUnitTest.java @@ -16,15 +16,33 @@ */ package com.gemstone.gemfire.pdx; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Properties; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gemstone.gemfire.cache.*; +import org.json.JSONException; +import org.json.JSONObject; +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.CacheFactory; +import com.gemstone.gemfire.cache.DataPolicy; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.Scope; import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientCacheFactory; import com.gemstone.gemfire.cache.client.ClientRegionShortcut; import com.gemstone.gemfire.cache.server.CacheServer; -import com.gemstone.gemfire.cache30.CacheTestCase; import com.gemstone.gemfire.internal.Assert; import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; @@ -33,26 +51,13 @@ 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.VM; +import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; import com.gemstone.gemfire.util.test.TestUtil; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Properties; -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; -/** - * - */ -public class JSONPdxClientServerDUnitTest extends CacheTestCase { +@Category(DistributedTest.class) +public class JSONPdxClientServerDUnitTest extends JUnit4CacheTestCase { - public JSONPdxClientServerDUnitTest(String name) { - super(name); - } - @Override public final void preTearDownCacheTestCase() { // this test creates client caches in some VMs and so @@ -61,6 +66,7 @@ public class JSONPdxClientServerDUnitTest extends CacheTestCase { disconnectAllFromDS(); } + @Test public void testSimplePut() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -90,6 +96,7 @@ public class JSONPdxClientServerDUnitTest extends CacheTestCase { } //this is for unquote fielnames in json string + @Test public void testSimplePut2() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -112,6 +119,7 @@ public class JSONPdxClientServerDUnitTest extends CacheTestCase { } + @Test public void testPdxInstanceAndJSONConversion() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -153,43 +161,43 @@ public class JSONPdxClientServerDUnitTest extends CacheTestCase { //Testcase-1: Validate json string against the pdxInstance. //validation for primitive types - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Int type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Int type values are not matched", testObject.getP_int(), jsonObject.getInt(testObject.getP_intFN())); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: long type values are not matched", + assertEquals("VerifyPdxInstanceToJson: long type values are not matched", testObject.getP_long(), jsonObject.getLong(testObject.getP_longFN())); //validation for wrapper types - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Boolean type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Boolean type values are not matched", testObject.getW_bool().booleanValue(), jsonObject.getBoolean(testObject.getW_boolFN())); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Float type values are not matched", - testObject.getW_double().doubleValue(), jsonObject.getDouble(testObject.getW_doubleFN())); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: bigDec type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Float type values are not matched", + testObject.getW_double().doubleValue(), jsonObject.getDouble(testObject.getW_doubleFN()), 0); + assertEquals("VerifyPdxInstanceToJson: bigDec type values are not matched", testObject.getW_bigDec().longValue(), jsonObject.getLong(testObject.getW_bigDecFN())); //vlidation for array types - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Byte[] type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Byte[] type values are not matched", (int)testObject.getW_byteArray()[1], jsonObject.getJSONArray(testObject.getW_byteArrayFN()).getInt(1)); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Double[] type values are not matched", - testObject.getW_doubleArray()[0], jsonObject.getJSONArray(testObject.getW_doubleArrayFN()).getDouble(0)); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: String[] type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Double[] type values are not matched", + testObject.getW_doubleArray()[0], jsonObject.getJSONArray(testObject.getW_doubleArrayFN()).getDouble(0), 0); + assertEquals("VerifyPdxInstanceToJson: String[] type values are not matched", testObject.getW_strArray()[2], jsonObject.getJSONArray(testObject.getW_strArrayFN()).getString(2)); //validation for collection types - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: list type values are not matched", + assertEquals("VerifyPdxInstanceToJson: list type values are not matched", testObject.getC_list().get(0), jsonObject.getJSONArray(testObject.getC_listFN()).getString(0)); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: stack type values are not matched", + assertEquals("VerifyPdxInstanceToJson: stack type values are not matched", testObject.getC_stack().get(2), jsonObject.getJSONArray(testObject.getC_stackFN()).getString(2)); //validation for Map - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Map type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Map type values are not matched", testObject.getM_empByCity().get("Ahmedabad").get(0).getFname(), jsonObject.getJSONObject(testObject.getM_empByCityFN()).getJSONArray("Ahmedabad").getJSONObject(0).getString("fname")); //validation Enum - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Enum type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Enum type values are not matched", testObject.getDay().toString(), jsonObject.getString(testObject.getDayFN())); } catch (JSONException e) { @@ -323,11 +331,11 @@ public class JSONPdxClientServerDUnitTest extends CacheTestCase { String o1 = jsonParse(jd.getJsonString()); String o2 = jsonParse(getJsonString); - junit.framework.Assert.assertEquals("Json Strings are not equal " + jd.getFileName() + " " + Boolean.getBoolean("pdxToJson.unqouteFieldNames"), o1, o2); + assertEquals("Json Strings are not equal " + jd.getFileName() + " " + Boolean.getBoolean("pdxToJson.unqouteFieldNames"), o1, o2); PdxInstance pdx2 = JSONFormatter.fromJSON(getJsonString); - junit.framework.Assert.assertEquals("Pdx are not equal; json filename " + jd.getFileName(), pdx, pdx2); + assertEquals("Pdx are not equal; json filename " + jd.getFileName(), pdx, pdx2); } protected final static int INT_TAB = '\t'; @@ -367,13 +375,12 @@ public class JSONPdxClientServerDUnitTest extends CacheTestCase { byte[] o1 = jsonParse(jd.getJsonByteArray()); byte[] o2 = jsonParse(jsonByteArray); - // junit.framework.Assert.assertIndexDetailsEquals("Pdx byte aray are not equal after fetching from cache " + jd.getFileName(), o1, o2); compareByteArray(o1, o2); PdxInstance pdx2 = JSONFormatter.fromJSON(jsonByteArray); boolean pdxequals = pdx.equals(pdx2); - junit.framework.Assert.assertEquals("Pdx are not equal for byte array ; json filename " + jd.getFileName(), pdx, pdx2 ); + assertEquals("Pdx are not equal for byte array ; json filename " + jd.getFileName(), pdx, pdx2 ); } public void compareByteArray(byte[] b1, byte[] b2) { if(b1.length != b2.length) http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/PDXAsyncEventQueueDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PDXAsyncEventQueueDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PDXAsyncEventQueueDUnitTest.java index a4b81cb..6854361 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PDXAsyncEventQueueDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PDXAsyncEventQueueDUnitTest.java @@ -16,6 +16,15 @@ */ package com.gemstone.gemfire.pdx; +import org.junit.experimental.categories.Category; +import org.junit.Test; + +import static org.junit.Assert.*; + +import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + import java.util.List; import java.util.Properties; @@ -37,10 +46,11 @@ import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.SerializableCallable; import com.gemstone.gemfire.test.dunit.VM; -public class PDXAsyncEventQueueDUnitTest extends CacheTestCase { +@Category(DistributedTest.class) +public class PDXAsyncEventQueueDUnitTest extends JUnit4CacheTestCase { - public PDXAsyncEventQueueDUnitTest(String name) { - super(name); + public PDXAsyncEventQueueDUnitTest() { + super(); } /** @@ -48,6 +58,7 @@ public class PDXAsyncEventQueueDUnitTest extends CacheTestCase { * type registry. */ + @Test public void testNonPersistentPDXCreateQueueFirst() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -61,6 +72,7 @@ public class PDXAsyncEventQueueDUnitTest extends CacheTestCase { * Test that an async queue doesn't require a persistent PDX * type registry. */ + @Test public void testNonPersistentPDXCreatePDXFirst() { Host host = Host.getHost(0); VM vm0 = host.getVM(1); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java index d029557..309cbdc 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java @@ -16,35 +16,53 @@ */ package com.gemstone.gemfire.pdx; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.util.Properties; + +import org.junit.Test; +import org.junit.experimental.categories.Category; + import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.cache.client.*; +import com.gemstone.gemfire.cache.AttributesFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.DataPolicy; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.Scope; +import com.gemstone.gemfire.cache.client.ClientCache; +import com.gemstone.gemfire.cache.client.ClientCacheFactory; +import com.gemstone.gemfire.cache.client.ClientRegionShortcut; +import com.gemstone.gemfire.cache.client.PoolFactory; +import com.gemstone.gemfire.cache.client.PoolManager; import com.gemstone.gemfire.cache.client.internal.PoolImpl; import com.gemstone.gemfire.cache.query.internal.DefaultQuery; import com.gemstone.gemfire.cache.server.CacheServer; -import com.gemstone.gemfire.cache30.CacheTestCase; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.HeapDataOutputStream; import com.gemstone.gemfire.internal.PdxSerializerObject; import com.gemstone.gemfire.internal.Version; -import com.gemstone.gemfire.test.dunit.*; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.util.Properties; - -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; - -/** - * - */ -public class PdxClientServerDUnitTest extends CacheTestCase { - - public PdxClientServerDUnitTest(String name) { - super(name); +import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.Invoke; +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.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + +@Category(DistributedTest.class) +public class PdxClientServerDUnitTest extends JUnit4CacheTestCase { + + public PdxClientServerDUnitTest() { + super(); } + @Test public void testSimplePut() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -83,6 +101,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { * registry if the server is restarted and PDX serialization * for a class has changed. This was reported in Pivotal bug #47338 */ + @Test public void testNonPersistentServerRestart() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -168,6 +187,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { * Test of bug 47338 - what happens to the client type * registry if the server is restarted. */ + @Test public void testNonPersistentServerRestartAutoSerializer() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -255,6 +275,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { * Test that we through an exception if one of the servers has persistent * regions but not a persistent registry. */ + @Test public void testServersWithPersistence() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -292,6 +313,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { }); } + @Test public void testPutThreadLocalConnections() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -326,6 +348,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { } + @Test public void testSimplePdxInstancePut() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -377,6 +400,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { * in multiple distributed systems. * @throws Exception */ + @Test public void testMultipleServerDSes() throws Exception { Host host = Host.getHost(0); final VM vm0 = host.getVM(0); @@ -444,6 +468,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { assertEquals(new SimpleClass(57, (byte) 3), r.get(1)); } + @Test public void testUserSerializesObject() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -485,6 +510,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { * Test that we still use the client * type registry, even if pool is created late. */ + @Test public void testLatePoolCreation() { Host host = Host.getHost(0); final VM vm0 = host.getVM(0); @@ -537,6 +563,7 @@ public class PdxClientServerDUnitTest extends CacheTestCase { * tries to create a pool after we were forced to use a peer * type registry. */ + @Test public void testExceptionWithPoolAfterTypeRegistryCreation() { Host host = Host.getHost(0); final VM vm0 = host.getVM(0); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxDeserializationDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxDeserializationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxDeserializationDUnitTest.java index fde1a27..380dfe0 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxDeserializationDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxDeserializationDUnitTest.java @@ -16,6 +16,15 @@ */ package com.gemstone.gemfire.pdx; +import org.junit.experimental.categories.Category; +import org.junit.Test; + +import static org.junit.Assert.*; + +import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + import java.io.IOException; import com.gemstone.gemfire.SerializationException; @@ -54,16 +63,18 @@ import com.gemstone.gemfire.test.dunit.WaitCriterion; * * */ -public class PdxDeserializationDUnitTest extends CacheTestCase { +@Category(DistributedTest.class) +public class PdxDeserializationDUnitTest extends JUnit4CacheTestCase { - public PdxDeserializationDUnitTest(String name) { - super(name); + public PdxDeserializationDUnitTest() { + super(); } /** * Test that we don't deserialize objects on a remote peer * when performing operations. */ + @Test public void testP2P() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); @@ -77,6 +88,7 @@ public class PdxDeserializationDUnitTest extends CacheTestCase { * Test to make sure we don't deserialize * objects on a server that is a datastore */ + @Test public void testClientToDataStore() { Host host = Host.getHost(0); VM vm1 = host.getVM(1); @@ -89,6 +101,7 @@ public class PdxDeserializationDUnitTest extends CacheTestCase { * Test to make sure we don't deserialize * objects on a server that is an accessor. */ + @Test public void testClientToAccessor() { Host host = Host.getHost(0); VM vm1 = host.getVM(1); @@ -101,6 +114,7 @@ public class PdxDeserializationDUnitTest extends CacheTestCase { * Test to make sure we don't deserialize * objects on a client that has registered interest. */ + @Test public void testAccessorToClient() { Host host = Host.getHost(0); VM vm1 = host.getVM(1); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableDUnitTest.java index 3621016..ca407b7 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableDUnitTest.java @@ -16,6 +16,15 @@ */ package com.gemstone.gemfire.pdx; +import org.junit.experimental.categories.Category; +import org.junit.Test; + +import static org.junit.Assert.*; + +import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + import java.util.List; import com.gemstone.gemfire.cache.AttributesFactory; @@ -39,12 +48,14 @@ import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.SerializableCallable; import com.gemstone.gemfire.test.dunit.VM; -public class PdxSerializableDUnitTest extends CacheTestCase { +@Category(DistributedTest.class) +public class PdxSerializableDUnitTest extends JUnit4CacheTestCase { - public PdxSerializableDUnitTest(String name) { - super(name); + public PdxSerializableDUnitTest() { + super(); } + @Test public void testSimplePut() { Host host = Host.getHost(0); VM vm1 = host.getVM(0); @@ -93,6 +104,7 @@ public class PdxSerializableDUnitTest extends CacheTestCase { }); } + @Test public void testTransactionCallbacksNotInvoked() { Host host = Host.getHost(0); VM vm1 = host.getVM(0); @@ -135,6 +147,7 @@ public class PdxSerializableDUnitTest extends CacheTestCase { }); } + @Test public void testPersistenceDefaultDiskStore() throws Throwable { SerializableCallable createRegion = new SerializableCallable() { @@ -154,6 +167,7 @@ public class PdxSerializableDUnitTest extends CacheTestCase { persistenceTest(createRegion); } + @Test public void testPersistenceExplicitDiskStore() throws Throwable { SerializableCallable createRegion = new SerializableCallable() { public Object call() throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableJUnitTest.java index 418a819..f38a2eb 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxSerializableJUnitTest.java @@ -16,37 +16,60 @@ */ package com.gemstone.gemfire.pdx; -import com.gemstone.gemfire.*; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.File; +import java.io.IOException; +import java.io.NotSerializableException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import com.gemstone.gemfire.CopyHelper; +import com.gemstone.gemfire.DataSerializable; +import com.gemstone.gemfire.DataSerializer; +import com.gemstone.gemfire.DeltaTestImpl; +import com.gemstone.gemfire.ToDataException; import com.gemstone.gemfire.cache.CacheFactory; import com.gemstone.gemfire.cache.DiskStoreFactory; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.RegionShortcut; import com.gemstone.gemfire.cache.query.internal.DefaultQuery; -import com.gemstone.gemfire.internal.*; +import com.gemstone.gemfire.internal.DSCODE; +import com.gemstone.gemfire.internal.FileUtil; +import com.gemstone.gemfire.internal.HeapDataOutputStream; +import com.gemstone.gemfire.internal.PdxSerializerObject; +import com.gemstone.gemfire.internal.SystemAdmin; +import com.gemstone.gemfire.internal.Version; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSourceFactory; import com.gemstone.gemfire.internal.util.ArrayUtils; -import com.gemstone.gemfire.pdx.internal.*; +import com.gemstone.gemfire.pdx.internal.DataSize; +import com.gemstone.gemfire.pdx.internal.PdxReaderImpl; +import com.gemstone.gemfire.pdx.internal.PdxType; +import com.gemstone.gemfire.pdx.internal.PdxWriterImpl; +import com.gemstone.gemfire.pdx.internal.TypeRegistry; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.*; -import java.nio.ByteBuffer; -import java.util.*; - -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT; -import static org.junit.Assert.*; @Category(IntegrationTest.class) public class PdxSerializableJUnitTest { - public PdxSerializableJUnitTest() { - super(); - } - private GemFireCacheImpl c; @Before http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxStringJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxStringJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxStringJUnitTest.java index f8b3806..a2d3204 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxStringJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxStringJUnitTest.java @@ -16,28 +16,29 @@ */ package com.gemstone.gemfire.pdx; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.pdx.internal.PdxInstanceFactoryImpl; -import com.gemstone.gemfire.pdx.internal.PdxInstanceImpl; -import com.gemstone.gemfire.pdx.internal.PdxString; -import com.gemstone.gemfire.test.junit.categories.IntegrationTest; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import static org.junit.Assert.*; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; +import com.gemstone.gemfire.pdx.internal.PdxInstanceFactoryImpl; +import com.gemstone.gemfire.pdx.internal.PdxInstanceImpl; +import com.gemstone.gemfire.pdx.internal.PdxString; +import com.gemstone.gemfire.test.junit.categories.IntegrationTest; @Category(IntegrationTest.class) public class PdxStringJUnitTest { + private GemFireCacheImpl c; @Before http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxTypeExportDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxTypeExportDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxTypeExportDUnitTest.java index 58f2128..48a6511 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxTypeExportDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxTypeExportDUnitTest.java @@ -16,6 +16,15 @@ */ package com.gemstone.gemfire.pdx; +import org.junit.experimental.categories.Category; +import org.junit.Test; + +import static org.junit.Assert.*; + +import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + import java.util.Collection; import com.examples.snapshot.MyObjectPdx; @@ -39,12 +48,14 @@ import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.NetworkUtils; import com.gemstone.gemfire.test.dunit.SerializableCallable; -public class PdxTypeExportDUnitTest extends CacheTestCase { - public PdxTypeExportDUnitTest(String name) { - super(name); +@Category(DistributedTest.class) +public class PdxTypeExportDUnitTest extends JUnit4CacheTestCase { + public PdxTypeExportDUnitTest() { + super(); } + @Test public void testPeer() throws Exception { Region r = getCache().getRegion("pdxtest"); r.get(1); @@ -57,6 +68,7 @@ public class PdxTypeExportDUnitTest extends CacheTestCase { assertEquals(MyEnumPdx.const1.name(), enums.iterator().next().getEnum().name()); } + @Test public void testClient() throws Exception { SerializableCallable test = new SerializableCallable() { @Override http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java deleted file mode 100644 index f2e6b5a..0000000 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** Class containing pdx tests. - * - */ -package com.gemstone.gemfire.pdx; - -import java.io.File; -import java.lang.reflect.Constructor; -import java.net.URL; -import java.net.URLClassLoader; - -import com.gemstone.gemfire.test.dunit.LogWriterUtils; - -public class VersionClassLoader { - - /** If PdxPrms.initClassLoader is true, then randomly choose a versioned - * class path and create and install a class loader for it on this thread. - * - * @return The installed class loader (which includes a versioned class path) - * or null if this call did not install a new class loader. - */ - public static ClassLoader initClassLoader(long classVersion) throws Exception { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - cl = ClassLoader.getSystemClassLoader(); - - String alternateVersionClassPath = System.getProperty("JTESTS") + - File.separator + ".." + File.separator + ".." + File.separator + - "classes" + File.separator + "version" + classVersion; - LogWriterUtils.getLogWriter().info("Initializing the class loader :" + alternateVersionClassPath); - ClassLoader versionCL = null; - try { - versionCL = new URLClassLoader(new URL[]{new File(alternateVersionClassPath).toURI().toURL()}, cl); - Thread.currentThread().setContextClassLoader(versionCL); - } catch (Exception e) { - LogWriterUtils.getLogWriter().info("error", e); - throw new Exception("Failed to initialize the class loader. " + e.getMessage()); - } - LogWriterUtils.getLogWriter().info("Setting/adding class loader with " + alternateVersionClassPath); - return versionCL; - } - - - /** Use reflection to create a new instance of a versioned class whose - * name is specified by className. - * - * Since versioned classes are compled outside outside the /tests - * directory, code within /tests cannot directly reference - * versioned classes, however the versioned class should be available at - * runtime if the test has installed the correct class loader. - * - * @param className The name of the versioned class to create. - * @return A new instance of className. - */ - public static Object getVersionedInstance(String className, Object[] args) throws Exception { - Object newObj = null; - try { - Class aClass = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); - if (args != null && args.length > 0) { - if (className.endsWith("PdxTestObject")){ - Constructor constructor = aClass.getConstructor(int.class, String.class); - newObj = constructor.newInstance(((Integer)args[0]).intValue(), args[1]); - } else if (className.endsWith("PortfolioPdxVersion1")) { - Constructor constructor = aClass.getConstructor(int.class, int.class); - newObj = constructor.newInstance(((Integer)args[0]).intValue(), ((Integer)args[1]).intValue()); - } else if (className.endsWith("PdxVersionedNewPortfolio")) { - Constructor constructor = aClass.getConstructor(String.class, int.class); - newObj = constructor.newInstance(((String)args[0]), ((Integer)args[1]).intValue()); - } else if (className.endsWith("PdxVersionedFieldType")) { - Constructor constructor = aClass.getConstructor( int.class); - newObj = constructor.newInstance(((Integer)args[0]).intValue()); - } - } else { - Constructor constructor = aClass.getConstructor(); - newObj = constructor.newInstance(); - } - } catch (Exception e) { - LogWriterUtils.getLogWriter().info("error", e); - throw new Exception("Failed to get the class instance. ClassName: " + className + " error: ", e); - } - return newObj; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java index f4a7308..a55b687 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java @@ -16,20 +16,32 @@ */ package com.gemstone.gemfire.redis; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import static org.junit.Assert.*; + +import java.util.Random; + +import org.junit.Test; +import org.junit.experimental.categories.Category; +import redis.clients.jedis.Jedis; + import com.gemstone.gemfire.cache.CacheFactory; import com.gemstone.gemfire.distributed.DistributedSystemConfigProperties; import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.SocketCreator; -import com.gemstone.gemfire.test.dunit.*; +import com.gemstone.gemfire.test.dunit.AsyncInvocation; +import com.gemstone.gemfire.test.dunit.DistributedTestUtils; +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.SerializableCallable; +import com.gemstone.gemfire.test.dunit.VM; +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; import com.gemstone.gemfire.test.junit.categories.FlakyTest; -import org.junit.experimental.categories.Category; -import redis.clients.jedis.Jedis; -import java.util.Random; - -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; - -public class RedisDistDUnitTest extends DistributedTestCase { +@Category(DistributedTest.class) +public class RedisDistDUnitTest extends JUnit4DistributedTestCase { public static final String TEST_KEY = "key"; public static int pushes = 200; @@ -43,26 +55,25 @@ public class RedisDistDUnitTest extends DistributedTestCase { private int server1Port; private int server2Port; - private String localHost = SocketCreator.getLocalHost().getHostName(); + private String localHost; private static final int JEDIS_TIMEOUT = 20 * 1000; private abstract class ClientTestBase extends SerializableCallable { int port; + protected ClientTestBase (int port) { this.port = port; } - - } - - public RedisDistDUnitTest() throws Throwable { - super("RedisDistTest"); } @Override public final void postSetUp() throws Exception { disconnectAllFromDS(); + + localHost = SocketCreator.getLocalHost().getHostName(); + host = Host.getHost(0); server1 = host.getVM(0); server2 = host.getVM(1); @@ -72,8 +83,6 @@ public class RedisDistDUnitTest extends DistributedTestCase { final int locatorPort = DistributedTestUtils.getDUnitLocatorPort(); final SerializableCallable startRedisAdapter = new SerializableCallable() { - private static final long serialVersionUID = 1978017907725504294L; - @Override public Object call() throws Exception { int port = ports[VM.getCurrentVMNum()]; @@ -90,11 +99,7 @@ public class RedisDistDUnitTest extends DistributedTestCase { }; AsyncInvocation i = server1.invokeAsync(startRedisAdapter); server2Port = (Integer) server2.invoke(startRedisAdapter); - try { - server1Port = (Integer) i.getResult(); - } catch (Throwable e) { - throw new Exception(e); - } + server1Port = (Integer) i.getResult(); } @Override @@ -103,7 +108,8 @@ public class RedisDistDUnitTest extends DistributedTestCase { } @Category(FlakyTest.class) // GEODE-1092: random ports, failure stack involves TCPTransport ConnectionHandler (are we eating BindExceptions somewhere?), uses Random, async actions - public void testConcListOps() throws Throwable { + @Test + public void testConcListOps() throws Exception { final Jedis jedis1 = new Jedis(localHost, server1Port, JEDIS_TIMEOUT); final Jedis jedis2 = new Jedis(localHost, server2Port, JEDIS_TIMEOUT); final int pushes = 20; @@ -138,7 +144,8 @@ public class RedisDistDUnitTest extends DistributedTestCase { } @Category(FlakyTest.class) // GEODE-717: random ports, BindException in failure stack, async actions - public void testConcCreateDestroy() throws Throwable { + @Test + public void testConcCreateDestroy() throws Exception { IgnoredException.addIgnoredException("RegionDestroyedException"); IgnoredException.addIgnoredException("IndexInvalidException"); final int ops = 40; @@ -196,9 +203,9 @@ public class RedisDistDUnitTest extends DistributedTestCase { /** * Just make sure there are no unexpected server crashes - * @throws Throwable */ - public void testConcOps() throws Throwable { + @Test + public void testConcOps() throws Exception { final int ops = 100; final String hKey = TEST_KEY+"hash"; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java index 56dbd14..b5a088b 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java @@ -18,12 +18,44 @@ */ package com.gemstone.gemfire.security; -import com.gemstone.gemfire.cache.*; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import static com.gemstone.gemfire.internal.AvailablePort.*; +import static com.gemstone.gemfire.security.SecurityTestUtils.*; +import static com.gemstone.gemfire.test.dunit.Assert.*; +import static com.gemstone.gemfire.test.dunit.Host.*; +import static com.gemstone.gemfire.test.dunit.Wait.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.Callable; + +import com.gemstone.gemfire.cache.DynamicRegionFactory; +import com.gemstone.gemfire.cache.InterestResultPolicy; +import com.gemstone.gemfire.cache.Operation; +import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.Region.Entry; +import com.gemstone.gemfire.cache.RegionDestroyedException; import com.gemstone.gemfire.cache.client.ServerConnectivityException; import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; -import com.gemstone.gemfire.cache.query.*; -import com.gemstone.gemfire.internal.AvailablePort.Keeper; +import com.gemstone.gemfire.cache.query.CqAttributes; +import com.gemstone.gemfire.cache.query.CqAttributesFactory; +import com.gemstone.gemfire.cache.query.CqEvent; +import com.gemstone.gemfire.cache.query.CqException; +import com.gemstone.gemfire.cache.query.CqListener; +import com.gemstone.gemfire.cache.query.CqQuery; +import com.gemstone.gemfire.cache.query.QueryInvocationTargetException; +import com.gemstone.gemfire.cache.query.QueryService; +import com.gemstone.gemfire.cache.query.SelectResults; +import com.gemstone.gemfire.cache.query.Struct; +import com.gemstone.gemfire.internal.AvailablePort.*; import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.cache.AbstractRegionEntry; import com.gemstone.gemfire.internal.cache.LocalRegion; @@ -36,17 +68,6 @@ import com.gemstone.gemfire.test.dunit.VM; import com.gemstone.gemfire.test.dunit.WaitCriterion; import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; -import java.util.*; -import java.util.concurrent.Callable; - -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; -import static com.gemstone.gemfire.internal.AvailablePort.SOCKET; -import static com.gemstone.gemfire.internal.AvailablePort.getRandomAvailablePort; -import static com.gemstone.gemfire.security.SecurityTestUtils.*; -import static com.gemstone.gemfire.test.dunit.Assert.*; -import static com.gemstone.gemfire.test.dunit.Host.getHost; -import static com.gemstone.gemfire.test.dunit.Wait.waitForCriterion; - /** * Base class for tests for authorization from client to server. It contains * utility functions for the authorization tests from client to server. http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/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 fd572ba..ff8d23d 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 @@ -18,7 +18,6 @@ */ package com.gemstone.gemfire.security; -import static com.gemstone.gemfire.internal.AvailablePort.*; import static com.gemstone.gemfire.security.SecurityTestUtils.*; import static com.gemstone.gemfire.test.dunit.Assert.*; import static com.gemstone.gemfire.test.dunit.IgnoredException.*; @@ -30,12 +29,12 @@ import java.util.List; import java.util.Properties; import java.util.Random; -import com.gemstone.gemfire.internal.AvailablePortHelper; import org.junit.Test; import org.junit.experimental.categories.Category; import com.gemstone.gemfire.DeltaTestImpl; import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; +import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest; import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator; import com.gemstone.gemfire.security.generator.CredentialGenerator; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java index 71a0e55..c5bfa4c 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java @@ -18,8 +18,54 @@ */ package com.gemstone.gemfire.security; -import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.cache.client.*; +import static com.gemstone.gemfire.cache30.ClientServerTestCase.*; +import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*; +import static com.gemstone.gemfire.internal.AvailablePort.*; +import static com.gemstone.gemfire.test.dunit.Assert.*; +import static com.gemstone.gemfire.test.dunit.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.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.Callable; +import javax.net.ServerSocketFactory; +import javax.net.SocketFactory; +import javax.net.ssl.KeyManager; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLContextSpi; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; + +import com.gemstone.gemfire.cache.AttributesFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.DataPolicy; +import com.gemstone.gemfire.cache.DynamicRegionFactory; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.cache.Scope; +import com.gemstone.gemfire.cache.client.NoAvailableServersException; +import com.gemstone.gemfire.cache.client.Pool; +import com.gemstone.gemfire.cache.client.PoolFactory; +import com.gemstone.gemfire.cache.client.PoolManager; +import com.gemstone.gemfire.cache.client.ServerConnectivityException; +import com.gemstone.gemfire.cache.client.ServerOperationException; +import com.gemstone.gemfire.cache.client.ServerRefusedConnectionException; import com.gemstone.gemfire.cache.client.internal.PoolImpl; import com.gemstone.gemfire.cache.client.internal.ProxyCache; import com.gemstone.gemfire.cache.execute.Execution; @@ -36,32 +82,9 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.pdx.PdxReader; import com.gemstone.gemfire.pdx.PdxSerializable; import com.gemstone.gemfire.pdx.PdxWriter; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.WaitCriterion; import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; -import javax.net.ServerSocketFactory; -import javax.net.SocketFactory; -import javax.net.ssl.*; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.*; -import java.util.concurrent.Callable; - -import static com.gemstone.gemfire.cache30.ClientServerTestCase.configureConnectionPoolWithNameAndFactory; -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; -import static com.gemstone.gemfire.internal.AvailablePort.SOCKET; -import static com.gemstone.gemfire.internal.AvailablePort.getRandomAvailablePort; -import static com.gemstone.gemfire.test.dunit.Assert.*; -import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.getDUnitLocatorPort; -import static com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter; -import static com.gemstone.gemfire.test.dunit.NetworkUtils.getIPLiteral; -import static com.gemstone.gemfire.test.dunit.Wait.waitForCriterion; - /** * Contains utility methods for setting up servers/clients for authentication * and authorization tests. @@ -70,7 +93,7 @@ import static com.gemstone.gemfire.test.dunit.Wait.waitForCriterion; */ public final class SecurityTestUtils { - private final JUnit4DistributedTestCase distributedTestCase = new JUnit4DistributedTestCase() {}; // TODO: delete + private final JUnit4DistributedTestCase distributedTestCase = new JUnit4DistributedTestCase() {}; protected static final int NO_EXCEPTION = 0; protected static final int AUTHREQ_EXCEPTION = 1; @@ -818,7 +841,7 @@ public final class SecurityTestUtils { cache = null; } - DistributedTestCase.disconnectFromDS(); + disconnectFromDS(); } protected static void closeCache(final Boolean keepAlive) { @@ -831,7 +854,7 @@ public final class SecurityTestUtils { cache = null; } - DistributedTestCase.disconnectFromDS(); + disconnectFromDS(); } // ------------------------- private static methods ------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java index b7d33b0..466b379 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java @@ -18,7 +18,7 @@ package com.gemstone.gemfire.test.dunit; import org.junit.experimental.categories.Category; -import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase; +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; import com.gemstone.gemfire.test.junit.categories.DistributedTest; /** @@ -26,12 +26,5 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest; */ @Category(DistributedTest.class) @SuppressWarnings("serial") -public abstract class DistributedTestCase extends JUnit3DistributedTestCase { - - /** - * Creates a new {@code DistributedTestCase} test with the given name. - */ - public DistributedTestCase(final String name) { - super(name); - } +public abstract class DistributedTestCase extends JUnit4DistributedTestCase { } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java index 8391ffa..7abfc4f 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java @@ -322,9 +322,9 @@ public class VM implements Serializable { /** * Invokes the {@code run} method of a {@link Runnable} in this {@code VM}. - * If the invocation throws AssertionFailedError, and repeatTimeoutMs + * If the invocation throws AssertionError, and repeatTimeoutMs * is >0, the {@code run} method is invoked repeatedly until it - * either succeeds, or repeatTimeoutMs has passed. The AssertionFailedError + * either succeeds, or repeatTimeoutMs has passed. The AssertionError * is thrown back to the sender of this method if {@code run} has not * completed successfully before repeatTimeoutMs has passed. * http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java index ce32320..868d59f 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java @@ -39,7 +39,7 @@ import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase; */ public abstract class JUnit3CacheTestCase extends JUnit3DistributedTestCase implements CacheTestFixture { - private final JUnit4CacheTestCase delegate = new JUnit4CacheTestCase(this); + private final JUnit4CacheTestCase delegate = new JUnit4CacheTestCase(this){}; public JUnit3CacheTestCase(final String name) { super(name); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java index bc74ec1..db5be9c 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java @@ -16,7 +16,27 @@ */ package com.gemstone.gemfire.test.dunit.cache.internal; -import com.gemstone.gemfire.cache.*; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Map; +import java.util.Properties; + +import org.apache.logging.log4j.Logger; + +import com.gemstone.gemfire.cache.AttributesFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheException; +import com.gemstone.gemfire.cache.CacheExistsException; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.CacheTransactionManager; +import com.gemstone.gemfire.cache.ExpirationAttributes; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.cache.RegionExistsException; +import com.gemstone.gemfire.cache.TimeoutException; import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientCacheFactory; import com.gemstone.gemfire.cache.client.PoolManager; @@ -30,17 +50,14 @@ import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation; import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator; import com.gemstone.gemfire.internal.logging.LogService; -import com.gemstone.gemfire.test.dunit.*; +import com.gemstone.gemfire.test.dunit.Assert; +import com.gemstone.gemfire.test.dunit.IgnoredException; +import com.gemstone.gemfire.test.dunit.Invoke; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; +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; -import org.apache.logging.log4j.Logger; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.Map; -import java.util.Properties; import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT; @@ -50,7 +67,7 @@ import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties * * TODO: make this class abstract when JUnit3CacheTestCase is deleted */ -public class JUnit4CacheTestCase extends JUnit4DistributedTestCase implements CacheTestFixture { +public abstract class JUnit4CacheTestCase extends JUnit4DistributedTestCase implements CacheTestFixture { private static final Logger logger = LogService.getLogger(); @@ -66,7 +83,7 @@ public class JUnit4CacheTestCase extends JUnit4DistributedTestCase implements Ca private final CacheTestFixture cacheTestFixture; public JUnit4CacheTestCase() { - this((CacheTestFixture)null); + this(null); } JUnit4CacheTestCase(final CacheTestFixture cacheTestFixture) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java index 705fa4e..cdabd42 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java @@ -324,6 +324,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur * name of the class as well as the name of the method. */ public final String getUniqueName() { + assertNotNull(getName()); return getTestClass().getSimpleName() + "_" + getName(); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/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 a5663e5..f858d8e 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,22 +16,23 @@ */ 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 static org.junit.Assert.*; import java.util.Properties; +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.DistributedTestCase; 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; /** @@ -39,7 +40,8 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest; * test framework. */ @SuppressWarnings("unused") -public class BasicDUnitTest extends DistributedTestCase { +@Category(DistributedTest.class) +public class BasicDUnitTest extends JUnit4DistributedTestCase { private static final String MESSAGE_FOR_remoteThrowException = "Test exception. Please ignore."; @@ -48,8 +50,8 @@ public class BasicDUnitTest extends DistributedTestCase { private VM vm0; private VM vm1; - public BasicDUnitTest(String name) { - super(name); + public BasicDUnitTest() { + super(); } @Override @@ -66,41 +68,51 @@ public class BasicDUnitTest extends DistributedTestCase { invokeInEveryVM(() -> bindings = null); } + @Test public void testPreconditions() throws Exception { 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(BasicDUnitTest.class, "booleanValue", new Object[] {}), is(true)); } + @Test public void testInvokeOnObjectTargetWithEmptyArgs() throws Exception { - assertThat(this.vm0.invoke(new BasicDUnitTest(""), "booleanValue", new Object[] {}), is(true)); + assertThat(this.vm0.invoke(new BasicDUnitTest(), "booleanValue", new Object[] {}), is(true)); } + @Test public void testInvokeAsyncOnClassTargetWithEmptyArgs() throws Exception { AsyncInvocation async = this.vm0.invokeAsync(BasicDUnitTest.class, "booleanValue", new Object[] {}).join(); assertThat(async.getResult(), is(true)); } + @Test public void testInvokeAsyncOnObjectTargetWithEmptyArgs() throws Exception { - AsyncInvocation async = this.vm0.invokeAsync(new BasicDUnitTest(""), "booleanValue", new Object[] {}).join(); + AsyncInvocation async = this.vm0.invokeAsync(new BasicDUnitTest(), "booleanValue", new Object[] {}).join(); assertThat(async.getResult(), is(true)); } + @Test public void testInvokeOnClassTargetWithNullArgs() throws Exception { assertThat(this.vm0.invoke(BasicDUnitTest.class, "booleanValue", null), is(true)); } + @Test public void testInvokeOnObjectTargetWithNullArgs() throws Exception { - assertThat(this.vm0.invoke(new BasicDUnitTest(""), "booleanValue", null), is(true)); + assertThat(this.vm0.invoke(new BasicDUnitTest(), "booleanValue", null), is(true)); } + @Test public void testInvokeAsyncOnClassTargetWithNullArgs() throws Exception { AsyncInvocation async = this.vm0.invokeAsync(BasicDUnitTest.class, "booleanValue", null).join(); assertThat(async.getResult(), is(true)); } + @Test public void testInvokeAsyncOnObjectTargetWithNullArgs() throws Exception { - AsyncInvocation async = this.vm0.invokeAsync(new BasicDUnitTest(""), "booleanValue", null).join(); + AsyncInvocation async = this.vm0.invokeAsync(new BasicDUnitTest(), "booleanValue", null).join(); assertThat(async.getResult(), is(true)); } + @Test public void testRemoteInvocationWithException() throws Exception { catchException(this.vm0).invoke(() -> remoteThrowException()); @@ -110,24 +122,29 @@ public class BasicDUnitTest extends DistributedTestCase { 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"; @@ -136,6 +153,7 @@ public class BasicDUnitTest extends DistributedTestCase { this.vm0.invokeAsync(() -> remoteValidateBind(name, value )).join().checkException(); } + @Test public void testRemoteInvokeAsyncWithException() throws Exception { AsyncInvocation async = this.vm0.invokeAsync(() -> remoteThrowException()).join(); @@ -150,6 +168,7 @@ public class BasicDUnitTest extends DistributedTestCase { assertThat(caughtThrowable().getCause().getMessage(), is(MESSAGE_FOR_remoteThrowException)); } + @Test public void testInvokeNamedRunnableLambdaAsync() throws Exception { catchThrowable(this.vm0.invokeAsync("throwSomething", () -> throwException()).join()).checkException(); @@ -158,6 +177,7 @@ public class BasicDUnitTest extends DistributedTestCase { assertThat(caughtThrowable().getCause(), instanceOf(BasicDUnitException.class)); } + @Test public void testInvokeNamedRunnableLambda() throws Exception { catchException(this.vm0).invoke("throwSomething", () -> throwException()); @@ -188,7 +208,7 @@ public class BasicDUnitTest extends DistributedTestCase { assertNotNull("value must not be null", value); assertNotNull("bindings must not be null", bindings); - new BasicDUnitTest("").getSystem(); // forces connection + new BasicDUnitTest().getSystem(); // forces connection bindings.setProperty(name, value); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java index c4f6160..d0ced0a 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java @@ -18,30 +18,31 @@ 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.DistributedTestCase; 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) @SuppressWarnings("serial") -public class GetDefaultDiskStoreNameDUnitTest extends DistributedTestCase { - - public GetDefaultDiskStoreNameDUnitTest(final String name) { - super(name); - } +public class GetDefaultDiskStoreNameDUnitTest 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); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetTestMethodNameDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetTestMethodNameDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetTestMethodNameDUnitTest.java index 2e9b1fd..22fe213 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetTestMethodNameDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/GetTestMethodNameDUnitTest.java @@ -18,27 +18,28 @@ 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.DistributedTestCase; 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) @SuppressWarnings("serial") -public class GetTestMethodNameDUnitTest extends DistributedTestCase { - - public GetTestMethodNameDUnitTest(final String name) { - super(name); - } +public class GetTestMethodNameDUnitTest extends JUnit4DistributedTestCase { + @Test public void testGetTestMethodName() { assertGetTestMethodName("testGetTestMethodName"); } + @Test public void testGetTestMethodNameChanges() { assertGetTestMethodName("testGetTestMethodNameChanges"); } + @Test public void testGetTestMethodNameInAllVMs() { assertGetTestMethodName("testGetTestMethodNameInAllVMs"); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java index 2bd1f75..0a4b5d7 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/OverridingGetPropertiesDisconnectsAllDUnitTest.java @@ -16,22 +16,24 @@ */ package com.gemstone.gemfire.test.dunit.tests; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import static com.gemstone.gemfire.test.dunit.Invoke.*; +import static org.junit.Assert.*; import java.util.Properties; -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT; -import static com.gemstone.gemfire.test.dunit.Invoke.invokeInEveryVM; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; /** * Verifies that overriding {@code getDistributedSystemProperties} results * in {@code disconnectAllFromDS} during tear down. */ -public class OverridingGetPropertiesDisconnectsAllDUnitTest extends DistributedTestCase { - - public OverridingGetPropertiesDisconnectsAllDUnitTest(final String name) { - super(name); - } +@Category(DistributedTest.class) +public class OverridingGetPropertiesDisconnectsAllDUnitTest extends JUnit4DistributedTestCase { @Override public final void preTearDownAssertions() throws Exception { @@ -50,6 +52,7 @@ public class OverridingGetPropertiesDisconnectsAllDUnitTest extends DistributedT 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/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java index c0275d2..50f2877 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java @@ -16,20 +16,27 @@ */ package com.gemstone.gemfire.test.dunit.tests; +import static org.junit.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.DistributedTestCase; 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. */ -public class VMDUnitTest extends DistributedTestCase { +@Category(DistributedTest.class) +public class VMDUnitTest extends JUnit4DistributedTestCase { private static final AtomicInteger COUNTER = new AtomicInteger(); private static final boolean BOOLEAN_VALUE = true; @@ -37,34 +44,39 @@ public class VMDUnitTest extends DistributedTestCase { private static final long LONG_VALUE = 42L; private static final String STRING_VALUE = "BLAH BLAH BLAH"; - public VMDUnitTest(String name) { - super(name); + public VMDUnitTest() { + super(); } + @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); @@ -76,6 +88,7 @@ public class VMDUnitTest extends DistributedTestCase { } } + @Test public void testReturnValue() throws Exception { final Host host = Host.getHost(0); final VM vm = host.getVM(0); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromEndOfOutputJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromEndOfOutputJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromEndOfOutputJUnitTest.java index f645213..1fb3ff5 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromEndOfOutputJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromEndOfOutputJUnitTest.java @@ -27,7 +27,6 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest; /** * Verifies that test output missing an expected line (at the end of * the golden file) will fail with that line as the failure message. - * */ @Category(IntegrationTest.class) public class FailWithLineMissingFromEndOfOutputJUnitTest extends FailOutputTestCase { @@ -63,7 +62,7 @@ public class FailWithLineMissingFromEndOfOutputJUnitTest extends FailOutputTestC assertOutputMatchesGoldenFile(process.getOutput(), goldenString); fail("assertOutputMatchesGoldenFile should have failed due to " + problem()); } catch (AssertionError expected) { - assertTrue("AssertionFailedError message should contain \"" + problem() + "\"", + assertTrue("AssertionError message should contain \"" + problem() + "\"", expected.getMessage().contains(problem())); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromMiddleOfOutputJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromMiddleOfOutputJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromMiddleOfOutputJUnitTest.java index 4b7897f..b92e6ec 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromMiddleOfOutputJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/golden/FailWithLineMissingFromMiddleOfOutputJUnitTest.java @@ -27,7 +27,6 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest; /** * Verifies that test output missing an expected line (at the middle * of the golden file) will fail with that line as the failure message. - * */ @Category(IntegrationTest.class) public class FailWithLineMissingFromMiddleOfOutputJUnitTest extends FailOutputTestCase { @@ -62,7 +61,7 @@ public class FailWithLineMissingFromMiddleOfOutputJUnitTest extends FailOutputTe assertOutputMatchesGoldenFile(process.getOutput(), goldenString); fail("assertOutputMatchesGoldenFile should have failed due to " + problem()); } catch (AssertionError expected) { - assertTrue("AssertionFailedError message should contain \"" + problem() + "\"", + assertTrue("AssertionError message should contain \"" + problem() + "\"", expected.getMessage().contains(problem())); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/util/JSR166TestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/util/JSR166TestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/util/JSR166TestCase.java index a4d8c1a..8098e9a 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/util/JSR166TestCase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/util/JSR166TestCase.java @@ -23,13 +23,16 @@ */ package com.gemstone.gemfire.util; +import static org.junit.Assert.*; + import java.security.CodeSource; import java.security.Permission; import java.security.PermissionCollection; import java.security.Permissions; import java.security.ProtectionDomain; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; /** * Base class for JSR166 Junit TCK tests. Defines some constants, @@ -49,7 +52,7 @@ import junit.framework.TestCase; * Only the most typically used JUnit assertion methods are defined * this way, but enough to live with. * - *
  • If you override {@link junit.framework.TestCase#setUp} or {@link junit.framework.TestCase#tearDown}, make sure + *
  • If you override {@link #setUp} or {@link #tearDown}, make sure * to invoke super.setUp and super.tearDown within * them. These methods are used to clear and check for thread * assertion failures.
  • @@ -107,19 +110,15 @@ import junit.framework.TestCase; * * @version Based on JSR166 TCK version 1.8 */ -public class JSR166TestCase extends TestCase { +public class JSR166TestCase { // TODO: reformat + public static long SHORT_DELAY_MS; public static long SMALL_DELAY_MS; public static long MEDIUM_DELAY_MS; public static long LONG_DELAY_MS; - public static Class MAP_CLASS = - com.gemstone.gemfire.internal.util.concurrent.CustomEntryConcurrentHashMap.class; + public static Class MAP_CLASS = com.gemstone.gemfire.internal.util.concurrent.CustomEntryConcurrentHashMap.class; - public JSR166TestCase(String name) { - super(name); - } - /** * Return the shortest timed delay. This could * be reimplmented to use for example a Property. @@ -147,7 +146,8 @@ public class JSR166TestCase extends TestCase { /** * Initialize test to indicate that no thread assertions have failed */ - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { setDelays(); threadFailed = false; } @@ -155,7 +155,8 @@ public class JSR166TestCase extends TestCase { /** * Trigger test case failure if any thread assertions have failed */ - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { assertFalse(threadFailed); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/CQJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/CQJUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/CQJUnitTest.java index ce67542..0cb1c14 100644 --- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/CQJUnitTest.java +++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/CQJUnitTest.java @@ -16,6 +16,16 @@ */ package com.gemstone.gemfire.cache.query.cq; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import static org.junit.Assert.*; + +import java.util.Properties; + +import org.junit.After; +import org.junit.Before; +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.CacheFactory; @@ -26,27 +36,15 @@ import com.gemstone.gemfire.cache.query.QueryInvalidException; import com.gemstone.gemfire.cache.query.QueryService; import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; -import junit.framework.TestCase; -import org.junit.experimental.categories.Category; - -import java.util.Properties; - -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; @Category(IntegrationTest.class) -public class CQJUnitTest extends TestCase { +public class CQJUnitTest { + private DistributedSystem ds; private Cache cache; private QueryService qs; - ///////////////////////////////////// - // Methods for setUp and tearDown - ///////////////////////////////////// - - public CQJUnitTest(String name) { - super(name); - } - + @Before public void setUp() throws Exception { Properties props = new Properties(); props.setProperty(MCAST_PORT, "0"); @@ -55,22 +53,19 @@ public class CQJUnitTest extends TestCase { this.cache = CacheFactory.create(ds); this.qs = cache.getQueryService(); } - + + @After public void tearDown() throws Exception { this.cache.close(); this.ds.disconnect(); } - ///////////////////////////////////// - // Test Methods - ///////////////////////////////////// - - /** * Test to make sure CQs that have invalid syntax * throw QueryInvalidException, and CQs that have unsupported * CQ features throw UnsupportedOperationException */ + @Test public void testValidateCQ() throws Exception { AttributesFactory attributesFactory = new AttributesFactory(); @@ -132,18 +127,4 @@ public class CQJUnitTest extends TestCase { } } - /* would need to make the constructServerSideQuery method package - * accessible and move this to the internal package in order - * to test that method - * - public void testConstructServerSideQuery() throws Exception { - // default attributes - CqAttributes attrs = new CqAttributesFactory().create(); - - // valid CQ - CqQuery cq = this.qs.newCq("SELECT * FROM /region WHERE status = 'active'", - attrs); - Query serverSideQuery = ((CqQueryImpl)cq).constructServerSideQuery(); - } - */ }