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 B15F4200B31 for ; Tue, 24 May 2016 20:54:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id AFCA5160A39; Tue, 24 May 2016 18:54:07 +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 5780016098E for ; Tue, 24 May 2016 20:54:05 +0200 (CEST) Received: (qmail 11772 invoked by uid 500); 24 May 2016 18:54:04 -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 11763 invoked by uid 99); 24 May 2016 18:54:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 May 2016 18:54:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id ABDC6180481 for ; Tue, 24 May 2016 18:54:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.221 X-Spam-Level: X-Spam-Status: No, score=-3.221 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=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 5UdGRvSIwrDX for ; Tue, 24 May 2016 18:53:47 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 94CC960E64 for ; Tue, 24 May 2016 18:53:43 +0000 (UTC) Received: (qmail 7401 invoked by uid 99); 24 May 2016 18:53:42 -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; Tue, 24 May 2016 18:53:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 60AB0E9E9B; Tue, 24 May 2016 18:53:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sai_boorlagadda@apache.org To: commits@geode.incubator.apache.org Date: Tue, 24 May 2016 18:53:57 -0000 Message-Id: In-Reply-To: <5a31d59ae60d443ea8b3494d800eb9be@git.apache.org> References: <5a31d59ae60d443ea8b3494d800eb9be@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [16/55] [abbrv] incubator-geode git commit: GEODE-1276: Change UnitTests file system to IntegrationTest category GEODE-1307: Rename HeterogenousLuceneSerializer to HeterogeneousLuceneSerializer GEODE-1279: Tests for old TRAC bugs should be renamed to use archived-at: Tue, 24 May 2016 18:54:07 -0000 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NonDistinctOrderByTestImplementation.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NonDistinctOrderByTestImplementation.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NonDistinctOrderByTestImplementation.java index 41e0413..4feadaf 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NonDistinctOrderByTestImplementation.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NonDistinctOrderByTestImplementation.java @@ -164,7 +164,7 @@ public abstract class NonDistinctOrderByTestImplementation { if (!(itr.next().toString()).equals("IDIndexPf1")) { fail(" was expected but found " + itr.next().toString()); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -255,7 +255,7 @@ public abstract class NonDistinctOrderByTestImplementation { limit = Integer.parseInt(queries[i].substring(indexLimit + 5).trim()); } assertTrue(!limitQuery || rcw.size() <= limit); - // assertEquals("Set",rcw.getCollectionType().getSimpleClassName()); + // assertIndexDetailsEquals("Set",rcw.getCollectionType().getSimpleClassName()); if (!rcw.getCollectionType().isOrdered()) { fail("The collection type="+rcw.getCollectionType().getSimpleClassName()+" is not ordered"); } @@ -269,7 +269,7 @@ public abstract class NonDistinctOrderByTestImplementation { if (!(itr.next().toString()).equals("IDIndexPf1")) { fail(" was expected but found " + itr.next().toString()); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -368,7 +368,7 @@ public abstract class NonDistinctOrderByTestImplementation { if (!(itr.next().toString()).equals("IDIndexPf1")) { fail(" was expected but found " + itr.next().toString()); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -468,7 +468,7 @@ public abstract class NonDistinctOrderByTestImplementation { if (!(itr.next().toString()).equals("IDIndexPf1")) { fail(" was expected but found " + itr.next().toString()); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -571,7 +571,7 @@ public abstract class NonDistinctOrderByTestImplementation { if (!(indexUsed).equals("IDIndexPf1")) { fail(" was expected but found " + indexUsed); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -674,7 +674,7 @@ public abstract class NonDistinctOrderByTestImplementation { if (!(indexUsed).equals("IDIndexPf1")) { fail(" was expected but found " + indexUsed); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -775,7 +775,7 @@ public abstract class NonDistinctOrderByTestImplementation { if (!(indexUsed).equals("PKIDIndexPf1")) { fail(" was expected but found " + indexUsed); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByReplicatedJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByReplicatedJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByReplicatedJUnitTest.java index 84f9350..e1372e9 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByReplicatedJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByReplicatedJUnitTest.java @@ -491,7 +491,7 @@ public class OrderByReplicatedJUnitTest extends OrderByTestImplementation { if (!(indexUsed).equals("PKIDIndexPf1")) { fail(" was expected but found " + indexUsed); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -624,7 +624,7 @@ public class OrderByReplicatedJUnitTest extends OrderByTestImplementation { if (!(indexUsed).equals("PKIDIndexPf1")) { fail(" was expected but found " + indexUsed); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByTestImplementation.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByTestImplementation.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByTestImplementation.java index 71e2c6d..206346e 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByTestImplementation.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/OrderByTestImplementation.java @@ -164,7 +164,7 @@ public abstract class OrderByTestImplementation { fail(" was expected but found " + itr.next().toString()); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -314,7 +314,7 @@ public abstract class OrderByTestImplementation { limit = Integer.parseInt(queries[i].substring(indexLimit+5).trim()); } assertTrue(!limitQuery || rcw.size() <= limit); - //assertEquals("Set",rcw.getCollectionType().getSimpleClassName()); + //assertIndexDetailsEquals("Set",rcw.getCollectionType().getSimpleClassName()); String colType = rcw.getCollectionType().getSimpleClassName(); if (!(colType.equals("Ordered") || colType.equals("LinkedHashSet"))) { fail("The collection type " + colType + " is not expexted"); @@ -329,7 +329,7 @@ public abstract class OrderByTestImplementation { fail(" was expected but found " + itr.next().toString()); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -429,7 +429,7 @@ public abstract class OrderByTestImplementation { fail(" was expected but found " + itr.next().toString()); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -512,7 +512,7 @@ public abstract class OrderByTestImplementation { fail(" was expected but found " + itr.next().toString()); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -615,7 +615,7 @@ public abstract class OrderByTestImplementation { fail(" was expected but found " + indexUsed); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -699,7 +699,7 @@ public abstract class OrderByTestImplementation { fail(" was expected but found " + indexUsed); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); @@ -783,7 +783,7 @@ public abstract class OrderByTestImplementation { fail(" was expected but found " + indexUsed); } - // assertEquals("statusIndexPf1",itr.next().toString()); + // assertIndexDetailsEquals("statusIndexPf1",itr.next().toString()); } int indxs = observer.indexesUsed.size(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/PdxOrderByJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/PdxOrderByJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/PdxOrderByJUnitTest.java index a1cbff4..2f0327c 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/PdxOrderByJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/PdxOrderByJUnitTest.java @@ -306,7 +306,7 @@ public class PdxOrderByJUnitTest { if (p1 instanceof Struct) { Object[] values1 = ((Struct) p1).getFieldValues(); Object[] values2 = ((Struct) p2).getFieldValues(); - // test.assertEquals(values1.length, values2.length); + // test.assertIndexDetailsEquals(values1.length, values2.length); if (values1.length != values2.length) { ok = false; break ; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledAggregateFunctionJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledAggregateFunctionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledAggregateFunctionJUnitTest.java index fc793bf..c7d83b3 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledAggregateFunctionJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledAggregateFunctionJUnitTest.java @@ -16,13 +16,14 @@ */ package com.gemstone.gemfire.cache.query.internal; +import static org.junit.Assert.*; + import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; -import junit.framework.TestCase; - import org.jmock.Mockery; +import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -45,20 +46,19 @@ import com.gemstone.gemfire.cache.query.internal.aggregate.SumDistinctPRQueryNod import com.gemstone.gemfire.cache.query.internal.parse.OQLLexerTokenTypes; import com.gemstone.gemfire.test.junit.categories.UnitTest; -/** - * - * - */ @Category(UnitTest.class) -public class CompiledAggregateFunctionJUnitTest extends TestCase { +public class CompiledAggregateFunctionJUnitTest { - Mockery context = new Mockery(); - private Cache cache = context.mock(Cache.class) ; - private List bucketList = new ArrayList(); + private Mockery context; + private Cache cache; + private List bucketList; - public CompiledAggregateFunctionJUnitTest(String testName) { - super(testName); - bucketList.add(Integer.valueOf(1)); + @Before + public void setUp() throws Exception { + context = new Mockery(); + cache = context.mock(Cache.class); + bucketList = new ArrayList(); + bucketList.add(Integer.valueOf(1)); } @Test @@ -194,6 +194,4 @@ public class CompiledAggregateFunctionJUnitTest extends TestCase { MaxMin maxMin1 = (MaxMin) agg1; assertFalse(((Boolean) findMax.get(maxMin1)).booleanValue()); } - - } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledInJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledInJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledInJUnitTest.java index 4ee2299..b20b365 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledInJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/CompiledInJUnitTest.java @@ -16,15 +16,13 @@ */ package com.gemstone.gemfire.cache.query.internal; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collection; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -56,7 +54,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -67,7 +65,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -78,7 +76,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -89,7 +87,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -125,7 +123,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -136,7 +134,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -147,7 +145,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -158,7 +156,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -169,7 +167,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -180,7 +178,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -191,7 +189,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -202,7 +200,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -213,7 +211,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -224,7 +222,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -235,7 +233,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -246,7 +244,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -257,7 +255,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -268,7 +266,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -279,7 +277,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -290,7 +288,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -301,7 +299,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -312,7 +310,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -323,7 +321,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -334,7 +332,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -360,7 +358,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -373,7 +371,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -385,7 +383,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } // String form @@ -399,7 +397,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -412,7 +410,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertFalse((Boolean) result); + assertFalse((Boolean) result); } @Test @@ -425,7 +423,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -437,7 +435,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertTrue((Boolean) result); + assertTrue((Boolean) result); } @Test @@ -446,7 +444,7 @@ public class CompiledInJUnitTest { CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); - Assert.assertNotNull(result); + assertNotNull(result); } private PdxInstanceEnumInfo createPdxInstanceEnumInfo(Enum e, int enumId) { @@ -455,6 +453,4 @@ public class CompiledInJUnitTest { } private enum EnumForTest {ONE, TWO, THREE}; - - } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/NWayMergeResultsJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/NWayMergeResultsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/NWayMergeResultsJUnitTest.java index a4043f0..a39cd8e 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/NWayMergeResultsJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/NWayMergeResultsJUnitTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.cache.query.internal; +import static org.junit.Assert.*; + import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -28,10 +30,7 @@ import java.util.NoSuchElementException; import java.util.SortedSet; import java.util.TreeSet; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - +import org.junit.Test; import org.junit.experimental.categories.Category; import com.gemstone.gemfire.cache.query.Struct; @@ -40,22 +39,10 @@ import com.gemstone.gemfire.cache.query.internal.types.StructTypeImpl; import com.gemstone.gemfire.cache.query.types.ObjectType; import com.gemstone.gemfire.test.junit.categories.UnitTest; -/** - * - * - */ @Category(UnitTest.class) -public class NWayMergeResultsJUnitTest extends TestCase { - - public NWayMergeResultsJUnitTest(String testName) { - super(testName); - } - - public static Test suite() { - TestSuite suite = new TestSuite(NWayMergeResultsJUnitTest.class); - return suite; - } +public class NWayMergeResultsJUnitTest { + @Test public void testNonDistinct() throws Exception { final int numSortedLists = 40; Collection> listOfSortedLists = new ArrayList>(); @@ -100,6 +87,7 @@ public class NWayMergeResultsJUnitTest extends TestCase { assertEquals(combinedArray.length, mergedResults.size()); } + @Test public void testDistinct() throws Exception { final int numSortedLists = 40; Collection> listOfSortedLists = new ArrayList>(); @@ -141,8 +129,8 @@ public class NWayMergeResultsJUnitTest extends TestCase { assertEquals(sortedSet.size(), mergedResults.size()); } + @Test public void testLimitNoDistinct() throws Exception { - final int numSortedLists = 40; final int limit = 53; Collection> listOfSortedLists = new ArrayList>(); @@ -193,6 +181,7 @@ public class NWayMergeResultsJUnitTest extends TestCase { assertEquals(limit, mergedResults.size()); } + @Test public void testLimitDistinct() throws Exception { final int numSortedLists = 40; final int limit = 53; @@ -241,6 +230,7 @@ public class NWayMergeResultsJUnitTest extends TestCase { assertEquals(limit, mergedResults.size()); } + @Test public void testNonDistinctStruct() throws Exception { final int numSortedLists = 40; StructTypeImpl structType = new StructTypeImpl(new String[] { "a", "b" }, @@ -304,6 +294,7 @@ public class NWayMergeResultsJUnitTest extends TestCase { } } + @Test public void testDistinctStruct() throws Exception { final int numSortedLists = 40; StructTypeImpl structType = new StructTypeImpl(new String[] { "a", "b" }, @@ -363,8 +354,8 @@ public class NWayMergeResultsJUnitTest extends TestCase { } } + @Test public void testOccurenceNonDistinct() throws Exception { - final int numSortedLists = 40; Collection> listOfSortedLists = new ArrayList>(); for (int i = 0; i < numSortedLists; ++i) { @@ -411,8 +402,8 @@ public class NWayMergeResultsJUnitTest extends TestCase { assertEquals(num75, mergedResults.occurrences(Integer.valueOf(75))); } + @Test public void testOccurenceDistinct() throws Exception { - final int numSortedLists = 40; Collection> listOfSortedLists = new ArrayList>(); for (int i = 0; i < numSortedLists; ++i) { @@ -484,6 +475,7 @@ public class NWayMergeResultsJUnitTest extends TestCase { orderByAttribs, context, structType); } + @Test public void testCombination() throws Exception { List results1 = new ArrayList(); results1.add("IBM"); @@ -542,9 +534,6 @@ public class NWayMergeResultsJUnitTest extends TestCase { sortedLists1, true, -1); assertEquals(12, netMergedResults.size()); - } - - } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryFromClauseCanonicalizationJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryFromClauseCanonicalizationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryFromClauseCanonicalizationJUnitTest.java index 22bdf39..8226363 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryFromClauseCanonicalizationJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryFromClauseCanonicalizationJUnitTest.java @@ -201,7 +201,7 @@ public class QueryFromClauseCanonicalizationJUnitTest //// context.setBindArguments(new Object[]{"bindkey"}); // sbuff = new StringBuffer(); // cop.generateCanonicalizedExpression(sbuff, context); -// assertEquals(sbuff.toString(),"iter1.positions.get('bindkey')"); +// assertIndexDetailsEquals(sbuff.toString(),"iter1.positions.get('bindkey')"); // // cp = new CompiledPath(new CompiledID("pf"), "getPositions()"); @@ -211,7 +211,7 @@ public class QueryFromClauseCanonicalizationJUnitTest // cop = new CompiledOperation(cp, "get", args); // sbuff = new StringBuffer(); // cop.generateCanonicalizedExpression(sbuff, context); -// assertEquals(sbuff.toString(),"iter1.positions().get('bindkey')"); +// assertIndexDetailsEquals(sbuff.toString(),"iter1.positions().get('bindkey')"); // // // cp = new CompiledPath(new CompiledID("pf"), "getPositions"); @@ -221,7 +221,7 @@ public class QueryFromClauseCanonicalizationJUnitTest // cop = new CompiledOperation(cp, "get", args); // sbuff = new StringBuffer(); // cop.generateCanonicalizedExpression(sbuff, context); -// assertEquals(sbuff.toString(),"iter1.positions.get('bindkey')"); +// assertIndexDetailsEquals(sbuff.toString(),"iter1.positions.get('bindkey')"); cp = new CompiledPath(new CompiledID("pf"), "getPositions"); CompiledPath cp1 = new CompiledPath(new CompiledID("pf"),"pkid"); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryObjectSerializationJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryObjectSerializationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryObjectSerializationJUnitTest.java index 8da72df..b593da5 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryObjectSerializationJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/QueryObjectSerializationJUnitTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.cache.query.internal; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInput; @@ -26,8 +28,9 @@ import java.io.IOException; import java.io.Serializable; import java.util.Collection; -import junit.framework.TestCase; - +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import com.gemstone.gemfire.DataSerializer; @@ -42,36 +45,21 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest; * @since 3.0 */ @Category(UnitTest.class) -public class QueryObjectSerializationJUnitTest extends TestCase implements Serializable { +public class QueryObjectSerializationJUnitTest implements Serializable { /** A ByteArrayOutputStream that data is serialized to */ private transient ByteArrayOutputStream baos; - public QueryObjectSerializationJUnitTest(String name) { - super(name); - } - - //////// Helper Class - public static class SimpleObjectType implements ObjectType { - public SimpleObjectType() {} - public boolean isCollectionType() { return false; } - public boolean isMapType() { return false; } - public boolean isStructType() { return false; } - public String getSimpleClassName() { return "java.lang.Object"; } - public Class resolveClass() { return Object.class; } - public void toData(DataOutput out) {} - public void fromData(DataInput in) {} - public boolean equals(Object o) { return o instanceof SimpleObjectType; } - } - /** * Creates a new ByteArrayOutputStream for this test to * work with. */ + @Before public void setUp() { this.baos = new ByteArrayOutputStream(); } + @After public void tearDown() { this.baos = null; } @@ -79,14 +67,14 @@ public class QueryObjectSerializationJUnitTest extends TestCase implements Seria /** * Returns a DataOutput to write to */ - protected DataOutputStream getDataOutput() { + private DataOutputStream getDataOutput() { return new DataOutputStream(this.baos); } /** * Returns a DataInput to read from */ - protected DataInputStream getDataInput() { + private DataInputStream getDataInput() { ByteArrayInputStream bais = new ByteArrayInputStream(this.baos.toByteArray()); return new DataInputStream(bais); } @@ -96,7 +84,6 @@ public class QueryObjectSerializationJUnitTest extends TestCase implements Seria * asserts that the two objects satisfy o1.equals(o2) */ private void checkRoundTrip(Object o1) throws IOException, ClassNotFoundException { - DataOutputStream out = getDataOutput(); DataSerializer.writeObject(o1, out); out.flush(); @@ -108,6 +95,7 @@ public class QueryObjectSerializationJUnitTest extends TestCase implements Seria /** * Tests the serialization of many, but not all of the possible ResultSets */ + @Test public void testSerializationOfQueryResults() throws IOException, ClassNotFoundException { Collection data = new java.util.ArrayList(); data.add(null); @@ -147,4 +135,16 @@ public class QueryObjectSerializationJUnitTest extends TestCase implements Seria //SortedStructSet sssWithoutData = new SortedStructSet(); //checkRoundTrip(sssWithoutData); } + + private static class SimpleObjectType implements ObjectType { + public SimpleObjectType() {} + public boolean isCollectionType() { return false; } + public boolean isMapType() { return false; } + public boolean isStructType() { return false; } + public String getSimpleClassName() { return "java.lang.Object"; } + public Class resolveClass() { return Object.class; } + public void toData(DataOutput out) {} + public void fromData(DataInput in) {} + public boolean equals(Object o) { return o instanceof SimpleObjectType; } + } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagJUnitTest.java index 181bb82..865651c 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagJUnitTest.java @@ -16,30 +16,30 @@ */ package com.gemstone.gemfire.cache.query.internal; -import java.util.*; -import java.io.*; +import static org.junit.Assert.*; -import org.junit.experimental.categories.Category; +import java.io.DataInputStream; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Set; -import junit.framework.*; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import com.gemstone.gemfire.DataSerializer; import com.gemstone.gemfire.cache.query.SelectResults; import com.gemstone.gemfire.cache.query.internal.types.ObjectTypeImpl; import com.gemstone.gemfire.internal.HeapDataOutputStream; import com.gemstone.gemfire.internal.Version; -import com.gemstone.gemfire.DataSerializer; import com.gemstone.gemfire.test.junit.categories.UnitTest; /** * Test ResultsBag, including null elements */ @Category(UnitTest.class) -public class ResultsBagJUnitTest extends TestCase { +public class ResultsBagJUnitTest { - public ResultsBagJUnitTest(String testName) { - super(testName); - } - + @Test public void testDuplicates() { ResultsBag bag = new ResultsBag(); bag.add("one"); @@ -56,9 +56,9 @@ public class ResultsBagJUnitTest extends TestCase { assertEquals(0, bag.occurrences("one")); assertTrue(!bag.remove("one")); assertEquals(0, bag.occurrences("one")); - } - + + @Test public void testIteration() { ResultsBag bag = new ResultsBag(); bag.add(new Integer(1)); @@ -84,9 +84,9 @@ public class ResultsBagJUnitTest extends TestCase { assertEquals(1, numOnes); assertEquals(2, numTwos); } - - public void testSerializingSetViewWithNulls() - throws ClassNotFoundException, IOException { + + @Test + public void testSerializingSetViewWithNulls() throws Exception { ResultsBag bag = new ResultsBag(); bag.add(new Integer(4)); bag.add(new Integer(2)); @@ -117,7 +117,8 @@ public class ResultsBagJUnitTest extends TestCase { assertTrue(setCopy.contains(new Integer(4))); assertTrue(setCopy.contains(null)); } - + + @Test public void testNulls() { ResultsBag bag = new ResultsBag(); assertTrue(bag.isEmpty()); @@ -172,7 +173,8 @@ public class ResultsBagJUnitTest extends TestCase { assertTrue(!bag.remove(null)); assertEquals(0, bag.occurrences(null)); } - + + @Test public void testIterationNullRemoval() { ResultsBag bag = new ResultsBag(); bag.add(null); @@ -192,7 +194,8 @@ public class ResultsBagJUnitTest extends TestCase { assertEquals(3, bag.size()); assertEquals(0, bag.occurrences(null)); } - + + @Test public void testIterationRemoval() { ResultsBag bag = new ResultsBag(); @@ -205,8 +208,6 @@ public class ResultsBagJUnitTest extends TestCase { assertEquals(6, bag.size()); -// Integer one = new Integer(1); -// Integer two = new Integer(2); Iterator itr = bag.iterator(); for (int i = 0 ; i < 3; i++) { itr.next(); @@ -221,7 +222,8 @@ public class ResultsBagJUnitTest extends TestCase { assertTrue(bag.isEmpty()); assertEquals(0, bag.size()); } - + + @Test public void testNoSuchElementException() { ResultsBag bag = new ResultsBag(); @@ -242,7 +244,7 @@ public class ResultsBagJUnitTest extends TestCase { itr.next(); fail("should have thrown a NoSuchElementException"); } - catch (NoSuchElementException e) { + catch (NoSuchElementException expected) { // pass } @@ -257,7 +259,7 @@ public class ResultsBagJUnitTest extends TestCase { itr.next(); fail("should have thrown a NoSuchElementException"); } - catch (NoSuchElementException e) { + catch (NoSuchElementException expected) { // pass } @@ -284,7 +286,7 @@ public class ResultsBagJUnitTest extends TestCase { itr.next(); fail("should have thrown a NoSuchElementException"); } - catch (NoSuchElementException e) { + catch (NoSuchElementException expected) { // pass } @@ -299,7 +301,7 @@ public class ResultsBagJUnitTest extends TestCase { itr.next(); fail("should have thrown a NoSuchElementException"); } - catch (NoSuchElementException e) { + catch (NoSuchElementException expected) { // pass } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagLimitBehaviourJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagLimitBehaviourJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagLimitBehaviourJUnitTest.java index aacb00e..e92797d 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagLimitBehaviourJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsBagLimitBehaviourJUnitTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.cache.query.internal; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; @@ -26,8 +28,7 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.Set; -import junit.framework.TestCase; - +import org.junit.Test; import org.junit.experimental.categories.Category; import com.gemstone.gemfire.cache.query.Struct; @@ -36,19 +37,15 @@ import com.gemstone.gemfire.cache.query.types.ObjectType; import com.gemstone.gemfire.cache.query.types.StructType; import com.gemstone.gemfire.test.junit.categories.UnitTest; -// TODO:Asif: Test for null behaviour in various functions - /** * Test ResultsBag Limit behaviour - * + * + * TODO: Test for null behaviour in various functions */ @Category(UnitTest.class) -public class ResultsBagLimitBehaviourJUnitTest extends TestCase { - - public ResultsBagLimitBehaviourJUnitTest(String testName) { - super(testName); - } +public class ResultsBagLimitBehaviourJUnitTest { + @Test public void testAsListAndAsSetMethod() { ResultsBag bag = getBagObject(String.class); bag.add(wrap("one", bag.getCollectionType().getElementType())); @@ -63,6 +60,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertEquals(2, set.size()); } + @Test public void testOccurence() { ResultsBag bag = getBagObject(String.class); bag.add(wrap(null, bag.getCollectionType().getElementType())); @@ -87,6 +85,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertEquals(6, total); } + @Test public void testIteratorType() { ResultsBag bag = getBagObject(String.class); bag.add(wrap("one", bag.getCollectionType().getElementType())); @@ -114,6 +113,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { } } + @Test public void testContains() { ResultsBag bag = getBagObject(Integer.class); bag.add(wrap(new Integer(1), bag.getCollectionType().getElementType())); @@ -144,6 +144,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertTrue(temp.contains(wrap(null, bag.getCollectionType().getElementType())) == bag.contains(wrap(null, bag.getCollectionType().getElementType()))); } + @Test public void testAddExceptionIfLimitApplied() { ResultsBag bag = getBagObject(String.class); bag.add(wrap("one", bag.getCollectionType().getElementType())); @@ -161,6 +162,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { // Internal method AddAndGetOccurence used for iter evaluating // only up till the limit + @Test public void testAddAndGetOccurence() { ResultsBag bag = getBagObject(String.class); bag = getBagObject(String.class); @@ -176,6 +178,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertEquals(3, bag.addAndGetOccurence(elementType instanceof StructType ? ((Struct)wrap(null, elementType)).getFieldValues() : wrap(null, elementType))); } + @Test public void testSizeWithLimitApplied() { ResultsBag bag = getBagObject(String.class); bag.add(wrap("two", bag.getCollectionType().getElementType())); @@ -194,6 +197,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertEquals(2, bag.size()); } + @Test public void testRemove() { // Test when actual size in resultset is less than the limit ResultsBag bag = getBagObject(String.class); @@ -280,6 +284,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { } + @Test public void testAddAllExceptionIfLimitApplied() { ResultsBag bag = getBagObject(Object.class); bag.applyLimit(6); @@ -292,6 +297,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { } } + @Test public void testToDataFromData() throws Exception { // Test with limit specified & limit less than internal size ResultsBag toBag = getBagObject(String.class); @@ -329,6 +335,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertFalse(toBag.asList().retainAll(fromBag.asList())); } + @Test public void testLimitResultsBagIterator_1() { ResultsBag bag = getBagObject(Integer.class); bag.add(wrap(null, bag.getCollectionType().getElementType())); @@ -380,6 +387,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { } } + @Test public void testLimitResultsBagIterator_2() { ResultsBag bag = getBagObject(Object.class); for (int i = 0; i < 20; ++i) { @@ -420,6 +428,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertEquals(i, 3); } + @Test public void testValidExceptionThrown() { ResultsBag bag = getBagObject(Integer.class); bag.add(wrap(new Integer(1), bag.getCollectionType().getElementType())); @@ -466,6 +475,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { } } + @Test public void testRemoveAll() { ResultsBag bag = getBagObject(Integer.class); // Add Integer & null Objects @@ -502,6 +512,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertFalse(itr.hasNext()); } + @Test public void testRetainAll() { ResultsBag bag = getBagObject(Integer.class); // Add Integer & null Objects @@ -540,6 +551,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertFalse(itr.hasNext()); } + @Test public void testContainAll() { ResultsBag bag = getBagObject(Integer.class); // Add Integer & null Objects @@ -557,7 +569,7 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { // asList.add(wrap(new // Integer(13),bag.getCollectionType().getElementType())); assertEquals(4, bag.size()); - // assertEquals(5,asList.size()); + // assertIndexDetailsEquals(5,asList.size()); // Remove all the elements from the list which match the // first element pf the list int occurence = bag.occurrences(asList.get(0)); @@ -572,12 +584,12 @@ public class ResultsBagLimitBehaviourJUnitTest extends TestCase { assertFalse(bag.containsAll(asList)); } - public ResultsBag getBagObject(Class clazz) { + private ResultsBag getBagObject(Class clazz) { ObjectType type = new ObjectTypeImpl(clazz); return new ResultsBag(type, null); } - public Object wrap(Object obj, ObjectType elementType) { + private Object wrap(Object obj, ObjectType elementType) { return obj; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsCollectionWrapperLimitJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsCollectionWrapperLimitJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsCollectionWrapperLimitJUnitTest.java index b24da54..04c88b6 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsCollectionWrapperLimitJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/ResultsCollectionWrapperLimitJUnitTest.java @@ -19,8 +19,7 @@ */ package com.gemstone.gemfire.cache.query.internal; -import com.gemstone.gemfire.cache.query.internal.types.ObjectTypeImpl; -import com.gemstone.gemfire.test.junit.categories.UnitTest; +import static org.junit.Assert.*; import java.util.ArrayList; import java.util.Collection; @@ -31,20 +30,16 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.TreeSet; +import org.junit.Test; import org.junit.experimental.categories.Category; -import junit.framework.TestCase; +import com.gemstone.gemfire.cache.query.internal.types.ObjectTypeImpl; +import com.gemstone.gemfire.test.junit.categories.UnitTest; -/** - * - */ @Category(UnitTest.class) -public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { - - public ResultsCollectionWrapperLimitJUnitTest(String testName) { - super(testName); - } +public class ResultsCollectionWrapperLimitJUnitTest { + @Test public void testConstructorBehaviour() { // Create a Collection of unordered data elements HashSet unordered = new HashSet(); @@ -97,6 +92,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { } } + @Test public void testContains() { // Create a Collection of unordered data elements HashSet unordered = new HashSet(); @@ -120,6 +116,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertTrue(wrapper.contains(new Integer(1))); } + @Test public void testContainsAll() { List ordered = new ArrayList(); for (int i = 1; i < 11; ++i) { @@ -135,6 +132,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertTrue(wrapper.containsAll(newList)); } + @Test public void testEmpty() { List ordered = new ArrayList(); for (int i = 1; i < 11; ++i) { @@ -145,6 +143,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertEquals(0, wrapper.size()); } + @Test public void testRemove() { List ordered = new ArrayList(); for (int i = 1; i < 11; ++i) { @@ -163,6 +162,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertTrue(wrapper.containsAll(newList)); } + @Test public void testRemoveAll() { List ordered = new ArrayList(); for (int i = 1; i < 11; ++i) { @@ -196,6 +196,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertFalse(itr.hasNext()); } + @Test public void testRetainAll() { List ordered = new ArrayList(); for (int i = 1; i < 11; ++i) { @@ -223,6 +224,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertFalse(itr.hasNext()); } + @Test public void testToArray() { List ordered = new ArrayList(); for (int i = 1; i < 11; ++i) { @@ -239,6 +241,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertFalse(itr.hasNext()); } + @Test public void testToArrayParameterized() { List ordered = new ArrayList(); for (int i = 1; i < 11; ++i) { @@ -256,6 +259,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertFalse(itr.hasNext()); } + @Test public void testAsList() { List ordered = new ArrayList(); for (int i = 1; i < 11; ++i) { @@ -286,6 +290,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertTrue(newList.containsAll(toList)); } + @Test public void testAsSet() { Collection ordered = new TreeSet(); for (int i = 1; i < 11; ++i) { @@ -315,6 +320,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { assertTrue(newSet.containsAll(toSet)); } + @Test public void testOccurences() { Collection ordered = new TreeSet(); for (int i = 1; i < 11; ++i) { @@ -338,6 +344,7 @@ public class ResultsCollectionWrapperLimitJUnitTest extends TestCase { } } + @Test public void testLimitIterator() { Collection ordered = new TreeSet(); for (int i = 1; i < 11; ++i) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/SelectResultsComparatorJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/SelectResultsComparatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/SelectResultsComparatorJUnitTest.java index d8c2913..0ff6a15 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/SelectResultsComparatorJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/SelectResultsComparatorJUnitTest.java @@ -19,34 +19,26 @@ */ package com.gemstone.gemfire.cache.query.internal; +import static org.junit.Assert.*; + +import java.util.Collections; import java.util.Iterator; import java.util.Random; -import java.util.Collections; import java.util.SortedSet; import java.util.TreeSet; +import org.junit.Test; import org.junit.experimental.categories.Category; import com.gemstone.gemfire.cache.query.SelectResults; import com.gemstone.gemfire.cache.query.internal.parse.OQLLexerTokenTypes; import com.gemstone.gemfire.test.junit.categories.UnitTest; -import junit.framework.TestCase; - -/** - * - */ @Category(UnitTest.class) -public class SelectResultsComparatorJUnitTest extends TestCase implements OQLLexerTokenTypes { - - public SelectResultsComparatorJUnitTest(String testName) { - super(testName); - } - +public class SelectResultsComparatorJUnitTest implements OQLLexerTokenTypes { + + @Test public void testComparatorForSortedSet() throws Exception { -// CompiledValue[] operands = new CompiledValue[3]; -// -// CompiledJunction cj = new CompiledJunction(operands, LITERAL_and); int sameSizeVar = 0; boolean sameSizeVarSetFlag = false; SortedSet testSet = @@ -85,6 +77,4 @@ public class SelectResultsComparatorJUnitTest extends TestCase implements OQLLex fail("This is not expected behaviour"); } } - - } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructBagLimitBehaviourJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructBagLimitBehaviourJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructBagLimitBehaviourJUnitTest.java index ea4f5f7..f32f11b 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructBagLimitBehaviourJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructBagLimitBehaviourJUnitTest.java @@ -19,27 +19,26 @@ */ package com.gemstone.gemfire.cache.query.internal; -import com.gemstone.gemfire.cache.query.Struct; -import com.gemstone.gemfire.cache.query.types.ObjectType; -import com.gemstone.gemfire.cache.query.types.StructType; -import com.gemstone.gemfire.cache.query.internal.types.*; -import com.gemstone.gemfire.test.junit.categories.UnitTest; +import static org.junit.Assert.*; import java.util.Iterator; +import org.junit.Test; import org.junit.experimental.categories.Category; +import com.gemstone.gemfire.cache.query.Struct; +import com.gemstone.gemfire.cache.query.internal.types.ObjectTypeImpl; +import com.gemstone.gemfire.cache.query.internal.types.StructTypeImpl; +import com.gemstone.gemfire.cache.query.types.ObjectType; +import com.gemstone.gemfire.cache.query.types.StructType; +import com.gemstone.gemfire.test.junit.categories.UnitTest; + /** - * Test StructsBag Limit behaviour - * + * Test StructBag Limit behaviour */ @Category(UnitTest.class) public class StructBagLimitBehaviourJUnitTest extends ResultsBagLimitBehaviourJUnitTest { - public StructBagLimitBehaviourJUnitTest(String testName) { - super(testName); - } - public ResultsBag getBagObject(Class clazz) { ObjectType[] types = new ObjectType[] { new ObjectTypeImpl(clazz), new ObjectTypeImpl(clazz) }; @@ -58,6 +57,7 @@ public class StructBagLimitBehaviourJUnitTest extends ResultsBagLimitBehaviourJU } } + @Test public void testRemoveAllStructBagSpecificMthod() { StructBag bag1 = (StructBag)getBagObject(Integer.class); // Add Integer & null Objects @@ -91,6 +91,7 @@ public class StructBagLimitBehaviourJUnitTest extends ResultsBagLimitBehaviourJU assertFalse(itr.hasNext()); } + @Test public void testRetainAllStructBagSpecific() { StructBag bag1 = (StructBag)getBagObject(Integer.class); // Add Integer & null Objects http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructSetJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructSetJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructSetJUnitTest.java index fd66df8..a1c9703 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructSetJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/StructSetJUnitTest.java @@ -22,10 +22,11 @@ */ package com.gemstone.gemfire.cache.query.internal; -import java.util.Iterator; +import static org.junit.Assert.*; -import junit.framework.TestCase; +import java.util.Iterator; +import org.junit.Test; import org.junit.experimental.categories.Category; import com.gemstone.gemfire.cache.query.SelectResults; @@ -35,16 +36,10 @@ import com.gemstone.gemfire.cache.query.internal.types.TypeUtils; import com.gemstone.gemfire.cache.query.types.ObjectType; import com.gemstone.gemfire.test.junit.categories.UnitTest; -/** - * - */ @Category(UnitTest.class) -public class StructSetJUnitTest extends TestCase { - - public StructSetJUnitTest(String testName) { - super(testName); - } +public class StructSetJUnitTest { + @Test public void testIntersectionAndRetainAll() { String names[] = {"p","pos"}; ObjectType types[] = {TypeUtils.OBJECT_TYPE, TypeUtils.OBJECT_TYPE}; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/aggregate/AggregatorJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/aggregate/AggregatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/aggregate/AggregatorJUnitTest.java index 9645b4e..9eeba95 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/aggregate/AggregatorJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/aggregate/AggregatorJUnitTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.cache.query.internal.aggregate; +import static org.junit.Assert.*; + import java.util.HashSet; import java.util.Set; @@ -24,14 +26,8 @@ import org.junit.experimental.categories.Category; import com.gemstone.gemfire.test.junit.categories.UnitTest; -import junit.framework.TestCase; - -/** - * - * - */ @Category(UnitTest.class) -public class AggregatorJUnitTest extends TestCase{ +public class AggregatorJUnitTest { @Test public void testCount() throws Exception { @@ -125,9 +121,8 @@ public class AggregatorJUnitTest extends TestCase{ avg.accumulate(null); avg.accumulate(null); float expected = (1 + 2+ 3 + 4 + 5 + 6 + 7 +7)/8.0f ; - assertEquals(expected, ((Number)avg.terminate()).floatValue()); + assertEquals(expected, ((Number)avg.terminate()).floatValue(), 0); - AvgBucketNode abn = new AvgBucketNode(); abn.accumulate(new Integer(1)); abn.accumulate(new Integer(2)); @@ -143,14 +138,13 @@ public class AggregatorJUnitTest extends TestCase{ assertEquals(8, ((Integer)arr[0]).intValue()); assertEquals(35, ((Number)arr[1]).intValue()); - AvgPRQueryNode apqn = new AvgPRQueryNode(); Object[] val1 = new Object[]{new Integer(7), new Double(43)}; Object[] val2 = new Object[]{new Integer(5), new Double(273.86)}; apqn.accumulate(val1); apqn.accumulate(val2); expected = (43+273.86f)/12.0f ; - assertEquals(expected, ((Number)apqn.terminate()).floatValue()); + assertEquals(expected, ((Number)apqn.terminate()).floatValue(), 0); } @Test @@ -170,9 +164,8 @@ public class AggregatorJUnitTest extends TestCase{ avg.accumulate(null); avg.accumulate(null); float expected = (1 + 2+ 3 + 4 + 5 + 6 + 7)/7.0f ; - assertEquals(expected, ((Number)avg.terminate()).floatValue()); - - + assertEquals(expected, ((Number)avg.terminate()).floatValue(), 0); + AvgDistinctPRQueryNode adpqn = new AvgDistinctPRQueryNode(); Set set1 = new HashSet(); @@ -191,7 +184,7 @@ public class AggregatorJUnitTest extends TestCase{ adpqn.accumulate(set2); expected = (3+4+5+6+7+8)/6.0f ; - assertEquals(expected, ((Number)adpqn.terminate()).floatValue()); + assertEquals(expected, ((Number)adpqn.terminate()).floatValue(), 0); } @Test http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/AsynchIndexMaintenanceJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/AsynchIndexMaintenanceJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/AsynchIndexMaintenanceJUnitTest.java index 18bc54c..cb32555 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/AsynchIndexMaintenanceJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/AsynchIndexMaintenanceJUnitTest.java @@ -103,7 +103,7 @@ public class AsynchIndexMaintenanceJUnitTest { region.put(""+(i+1), new Portfolio(i+1)); idSet.add((i+1) + ""); } - //assertEquals(0, getIndexSize(ri)); + //assertIndexDetailsEquals(0, getIndexSize(ri)); region.put("50", new Portfolio(50)); WaitCriterion ev = new WaitCriterion() { public boolean done() { @@ -129,7 +129,7 @@ public class AsynchIndexMaintenanceJUnitTest { idSet.add((i+1) + ""); } - //assertEquals(0, getIndexSize(ri)); + //assertIndexDetailsEquals(0, getIndexSize(ri)); WaitCriterion evSize = new WaitCriterion() { public boolean done() { @@ -160,7 +160,7 @@ public class AsynchIndexMaintenanceJUnitTest { region.put(""+(i+1), new Portfolio(i+1)); idSet.add((i+1) + ""); } - //assertEquals(0, getIndexSize(ri)); + //assertIndexDetailsEquals(0, getIndexSize(ri)); Wait.waitForCriterion(evSize, 17 * 1000, 200, true); } @@ -200,7 +200,7 @@ public class AsynchIndexMaintenanceJUnitTest { idSet.add((i+1) + ""); } Thread.sleep(10000); - //assertEquals(0, this.getIndexSize(ri)); + //assertIndexDetailsEquals(0, this.getIndexSize(ri)); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/HashIndexSetJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/HashIndexSetJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/HashIndexSetJUnitTest.java index de5cebd..7f96fde 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/HashIndexSetJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/HashIndexSetJUnitTest.java @@ -14,15 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package com.gemstone.gemfire.cache.query.internal.index; +import static org.junit.Assert.*; import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -32,7 +29,6 @@ import java.util.Map; import java.util.Set; import java.util.stream.IntStream; -import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.invocation.InvocationOnMock; @@ -49,7 +45,7 @@ public class HashIndexSetJUnitTest { Set portfolioSet; HashIndexSet his; - public void setupHashIndexSet(int numEntries) { + private void setupHashIndexSet(int numEntries) { his = createHashIndexSet(); portfoliosMap = createPortfolioObjects(numEntries, 0); portfolioSet = new HashSet(portfoliosMap.values()); @@ -81,9 +77,8 @@ public class HashIndexSetJUnitTest { * IDs are startID -> startID + numEntries * @param numToCreate how many portfolios to create * @param startID the ID value to start incrementing from - * @return */ - public Map createPortfolioObjects(int numToCreate, int startID) { + private Map createPortfolioObjects(int numToCreate, int startID) { Map portfoliosMap = new HashMap<>(); IntStream.range(0, numToCreate).forEach(e -> { Portfolio p = new Portfolio(e + startID); @@ -98,9 +93,9 @@ public class HashIndexSetJUnitTest { int numEntries = 100; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.iterator().forEachRemaining((e ->portfolioSet.remove(e))); - Assert.assertTrue(portfolioSet.isEmpty()); + assertTrue(portfolioSet.isEmpty()); } @Test @@ -108,26 +103,28 @@ public class HashIndexSetJUnitTest { int numEntries = 100; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.add(null, new Portfolio(numEntries + 1)); - Assert.assertEquals(numEntries + 1, his.size()); + assertEquals(numEntries + 1, his.size()); } - - //we have to be sure that we dont cause a compaction or growth or else - //removed tokens will be removed and a new backing array created + + /** + * we have to be sure that we dont cause a compaction or growth or else + * removed tokens will be removed and a new backing array created + */ @Test public void testHashIndexSetAddUseRemoveTokenSlot() throws Exception { int numEntries = 20; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.removeAll(portfolioSet); - Assert.assertEquals(numEntries, his._removedTokens); - Assert.assertEquals(0, his.size()); + assertEquals(numEntries, his._removedTokens); + assertEquals(0, his.size()); addPortfoliosToHashIndexSet(portfoliosMap, his); - Assert.assertEquals(0, his._removedTokens); - Assert.assertEquals(numEntries, his.size()); + assertEquals(0, his._removedTokens); + assertEquals(numEntries, his.size()); } @Test @@ -135,19 +132,19 @@ public class HashIndexSetJUnitTest { int numEntries = 100; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.removeAll(portfolioSet); - Assert.assertEquals(numEntries, his._removedTokens); + assertEquals(numEntries, his._removedTokens); - Assert.assertEquals(0, his.size()); + assertEquals(0, his.size()); //Very very bad but we fake out the number of removed tokens his._removedTokens = his._maxSize; addPortfoliosToHashIndexSet(portfoliosMap, his); //compaction should have occured, removed tokens should now be gone - Assert.assertEquals(0, his._removedTokens); - Assert.assertEquals(numEntries, his.size()); + assertEquals(0, his._removedTokens); + assertEquals(numEntries, his.size()); } @Test @@ -155,11 +152,11 @@ public class HashIndexSetJUnitTest { int numEntries = 80; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.rehash(1000); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.iterator().forEachRemaining((e ->portfolioSet.remove(e))); - Assert.assertTrue(portfolioSet.isEmpty()); + assertTrue(portfolioSet.isEmpty()); } @Test @@ -167,11 +164,11 @@ public class HashIndexSetJUnitTest { int numEntries = 20; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.rehash(64); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.iterator().forEachRemaining((e ->portfolioSet.remove(e))); - Assert.assertTrue(portfolioSet.isEmpty()); + assertTrue(portfolioSet.isEmpty()); } @Test @@ -179,9 +176,9 @@ public class HashIndexSetJUnitTest { int numEntries = 20; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.get(1).forEachRemaining((e ->portfolioSet.remove(e))); - Assert.assertEquals(numEntries - 1, portfolioSet.size()); + assertEquals(numEntries - 1, portfolioSet.size()); } @Test @@ -195,15 +192,15 @@ public class HashIndexSetJUnitTest { addPortfoliosToHashIndexSet(collectionOfPorts1, his); addPortfoliosToHashIndexSet(collectionOfPorts2, his); - Assert.assertEquals(numEntries * 2, his.size()); + assertEquals(numEntries * 2, his.size()); Iterator iterator = his.get(keyToLookup); int numIterated = 0; while (iterator.hasNext()) { numIterated ++; //verify that the returned values match what we lookedup - Assert.assertEquals(keyToLookup, ((Portfolio)iterator.next()).indexKey); + assertEquals(keyToLookup, ((Portfolio)iterator.next()).indexKey); } - Assert.assertEquals(2, numIterated); + assertEquals(2, numIterated); } @Test @@ -219,15 +216,15 @@ public class HashIndexSetJUnitTest { addPortfoliosToHashIndexSet(collectionOfPorts2, his); addPortfoliosToHashIndexSet(collectionOfPorts3, his); - Assert.assertEquals(numEntries * 3, his.size()); + assertEquals(numEntries * 3, his.size()); Iterator iterator = his.get(keyToLookup); int numIterated = 0; while (iterator.hasNext()) { numIterated ++; //verify that the returned values match what we lookedup - Assert.assertEquals(keyToLookup, ((Portfolio)iterator.next()).indexKey); + assertEquals(keyToLookup, ((Portfolio)iterator.next()).indexKey); } - Assert.assertEquals(3, numIterated); + assertEquals(3, numIterated); //let's remove the second collision his.remove(keyToLookup, collectionOfPorts2.get(keyToLookup)); @@ -237,9 +234,9 @@ public class HashIndexSetJUnitTest { while (iterator.hasNext()) { numIterated ++; //verify that the returned values match what we lookedup - Assert.assertEquals(keyToLookup, ((Portfolio)iterator.next()).indexKey); + assertEquals(keyToLookup, ((Portfolio)iterator.next()).indexKey); } - Assert.assertEquals(2, numIterated); + assertEquals(2, numIterated); //Add it back in and make sure we can iterate all 3 again his.add(keyToLookup, collectionOfPorts2.get(keyToLookup)); @@ -248,9 +245,9 @@ public class HashIndexSetJUnitTest { while (iterator.hasNext()) { numIterated ++; //verify that the returned values match what we lookedup - Assert.assertEquals(keyToLookup, ((Portfolio)iterator.next()).indexKey); + assertEquals(keyToLookup, ((Portfolio)iterator.next()).indexKey); } - Assert.assertEquals(3, numIterated); + assertEquals(3, numIterated); } @@ -264,7 +261,7 @@ public class HashIndexSetJUnitTest { addPortfoliosToHashIndexSet(collectionOfPorts1, his); addPortfoliosToHashIndexSet(collectionOfPorts2, his); - Assert.assertEquals(numEntries * 2, his.size()); + assertEquals(numEntries * 2, his.size()); List keysNotToMatch = new LinkedList<>(); keysNotToMatch.add(3); keysNotToMatch.add(4); @@ -273,10 +270,10 @@ public class HashIndexSetJUnitTest { while (iterator.hasNext()) { numIterated ++; int idFound = ((Portfolio)iterator.next()).indexKey; - Assert.assertTrue(idFound != 3 && idFound != 4); + assertTrue(idFound != 3 && idFound != 4); } //Make sure we iterated all the entries minus the entries that we decided not to match - Assert.assertEquals(numEntries * 2 - 4, numIterated); + assertEquals(numEntries * 2 - 4, numIterated); } @Test @@ -288,16 +285,18 @@ public class HashIndexSetJUnitTest { try { int index = his.add(k, portfoliosMap.get(k)); int foundIndex = his.index(portfoliosMap.get(k)); - Assert.assertEquals(index, foundIndex); + assertEquals(index, foundIndex); } catch (TypeMismatchException ex) { throw new Error(ex); } }); } - - //Add multiple portfolios with the same id - //they should collide, we should then be able to look up each one correctly + + /** + * Add multiple portfolios with the same id + * they should collide, we should then be able to look up each one correctly + */ @Test public void testIndexOfObjectWithCollision() throws Exception { int numEntries = 10; @@ -309,7 +308,7 @@ public class HashIndexSetJUnitTest { try { int index = his.add(k, portfoliosMap1.get(k)); int foundIndex = his.index(portfoliosMap1.get(k)); - Assert.assertEquals(index, foundIndex); + assertEquals(index, foundIndex); } catch (TypeMismatchException ex) { throw new Error(ex); @@ -319,65 +318,65 @@ public class HashIndexSetJUnitTest { try { int index = his.add(k, portfoliosMap2.get(k)); int foundIndex = his.index(portfoliosMap2.get(k)); - Assert.assertEquals(index, foundIndex); + assertEquals(index, foundIndex); } catch (TypeMismatchException ex) { throw new Error(ex); } }); } - - + @Test public void testIndexWhenObjectNotInSet() { int numEntries = 10; his = createHashIndexSet(); portfoliosMap = createPortfolioObjects(numEntries, 0); - Assert.assertEquals(-1, his.index(portfoliosMap.get(1))); + assertEquals(-1, his.index(portfoliosMap.get(1))); } @Test public void testIndexWhenObjectNotInSetWhenPopulated() { int numEntries = 10; this.setupHashIndexSet(numEntries); - Assert.assertEquals(-1, his.index(new Portfolio(numEntries+1))); + assertEquals(-1, his.index(new Portfolio(numEntries+1))); } - - + @Test public void testRemove() throws Exception { int numEntries = 20; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); portfoliosMap.forEach((k,v) -> his.remove(k, v)); - Assert.assertEquals(0, his.size()); + assertEquals(0, his.size()); } - - //Test remove where we look for an instance that is not at the specified index slot + + /** + * Test remove where we look for an instance that is not at the specified index slot + */ @Test public void testRemoveIgnoreSlot() throws Exception { int numEntries = 20; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); portfoliosMap.forEach((k,v) -> his.remove(k, v, his.index(v))); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); } @Test public void testRemoveAtWithNull() throws Exception { his = createHashIndexSet(); - Assert.assertTrue(his.isEmpty()); - Assert.assertFalse(his.removeAt(0)); + assertTrue(his.isEmpty()); + assertFalse(his.removeAt(0)); } @Test public void testRemoveAtWithRemoveToken() throws Exception { his = createHashIndexSet(); int index = his.add(1, new Portfolio(1)); - Assert.assertTrue(his.removeAt(index)); - Assert.assertFalse(his.removeAt(index)); + assertTrue(his.removeAt(index)); + assertFalse(his.removeAt(index)); } @Test @@ -385,21 +384,23 @@ public class HashIndexSetJUnitTest { int numEntries = 100; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.removeAll(portfolioSet); - Assert.assertTrue(his.isEmpty()); + assertTrue(his.isEmpty()); } - - //Remove all should still remove all portfolios provided, even if there are more provided then contained + + /** + * Remove all should still remove all portfolios provided, even if there are more provided then contained + */ @Test public void testHashIndexRemoveAllWithAdditionalPortfolios() throws Exception { int numEntries = 100; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); portfolioSet.add(new Portfolio(numEntries + 1)); his.removeAll(portfolioSet); - Assert.assertTrue(his.isEmpty()); + assertTrue(his.isEmpty()); } @Test @@ -407,8 +408,8 @@ public class HashIndexSetJUnitTest { int numEntries = 100; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); - Assert.assertTrue(his.containsAll(portfolioSet)); + assertEquals(numEntries, his.size()); + assertTrue(his.containsAll(portfolioSet)); } @Test @@ -417,11 +418,11 @@ public class HashIndexSetJUnitTest { setupHashIndexSet(numEntries); Set subset = new HashSet(); portfolioSet.forEach(e -> {if (e.indexKey % 2 == 0) {subset.add(e);}}); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.retainAll(subset); his.iterator().forEachRemaining((e ->subset.remove(e))); - Assert.assertTrue(subset.isEmpty()); - Assert.assertEquals(numEntries/2, his.size()); + assertTrue(subset.isEmpty()); + assertEquals(numEntries/2, his.size()); } @Test @@ -429,9 +430,9 @@ public class HashIndexSetJUnitTest { int numEntries = 100; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); portfolioSet.add(new Portfolio(numEntries + 1)); - Assert.assertFalse(his.containsAll(portfolioSet)); + assertFalse(his.containsAll(portfolioSet)); } @Test @@ -439,16 +440,16 @@ public class HashIndexSetJUnitTest { int numEntries = 100; setupHashIndexSet(numEntries); - Assert.assertEquals(numEntries, his.size()); + assertEquals(numEntries, his.size()); his.clear(); - Assert.assertTrue(his.isEmpty()); - Assert.assertTrue(his._removedTokens == 0); + assertTrue(his.isEmpty()); + assertTrue(his._removedTokens == 0); } @Test public void testAreNullObjectsEqual() throws Exception { his = createHashIndexSet(); - Assert.assertTrue(his.areObjectsEqual(null, null)); + assertTrue(his.areObjectsEqual(null, null)); } @Test @@ -460,9 +461,9 @@ public class HashIndexSetJUnitTest { addPortfoliosToHashIndexSet(portfolioMap, indexSet1); addPortfoliosToHashIndexSet(portfolioMap, indexSet2); - Assert.assertTrue(indexSet1.equals(indexSet2)); - Assert.assertTrue(indexSet2.equals(indexSet1)); - Assert.assertEquals(indexSet1.hashCode(), indexSet2.hashCode()); + assertTrue(indexSet1.equals(indexSet2)); + assertTrue(indexSet2.equals(indexSet1)); + assertEquals(indexSet1.hashCode(), indexSet2.hashCode()); } @Test @@ -474,16 +475,16 @@ public class HashIndexSetJUnitTest { addPortfoliosToHashIndexSet(portfolioMap, indexSet1); indexSet2.add(1, portfolioMap.get(1)); - Assert.assertFalse(indexSet2.equals(indexSet1)); - Assert.assertFalse(indexSet1.equals(indexSet2)); - Assert.assertNotEquals(indexSet1.hashCode(), indexSet2.hashCode()); + assertFalse(indexSet2.equals(indexSet1)); + assertFalse(indexSet1.equals(indexSet2)); + assertNotEquals(indexSet1.hashCode(), indexSet2.hashCode()); } @Test public void testIndexSetNotEqualsOtherObjectType() { HashIndexSet indexSet = createHashIndexSet(); - Assert.assertFalse(indexSet.equals("Other type")); - Assert.assertFalse(indexSet.equals(new Object())); + assertFalse(indexSet.equals("Other type")); + assertFalse(indexSet.equals(new Object())); } private static class EvaluateKeyAnswer implements Answer { @@ -499,6 +500,5 @@ public class HashIndexSetJUnitTest { } } - - + } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexElemArrayJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexElemArrayJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexElemArrayJUnitTest.java index 91dbf7b..1ac115a 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexElemArrayJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexElemArrayJUnitTest.java @@ -16,11 +16,7 @@ */ package com.gemstone.gemfire.cache.query.internal.index; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.util.Arrays; import java.util.Collection; @@ -30,7 +26,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.stream.IntStream; -import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -40,16 +36,15 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest; @Category(UnitTest.class) public class IndexElemArrayJUnitTest { - private IndexElemArray list = new IndexElemArray(7); + private IndexElemArray list; - @After - public void tearDown() { - //System.clearProperty("index_elemarray_size"); + @Before + public void setUp() throws Exception { + list = new IndexElemArray(7); } - + @Test public void testFunctionality() throws Exception { - list.clear(); boundaryCondition(); add(); clearAndAdd(); @@ -63,14 +58,13 @@ public class IndexElemArrayJUnitTest { clearAndAdd(); } - @Test /** * This tests concurrent modification of IndexElemArray and to make * sure elementData and size are updated atomically. Ticket# GEODE-106. */ + @Test public void testFunctionalityUsingMultiThread() throws Exception { - list.clear(); - Collection callables = new ConcurrentLinkedQueue<>(); + Collection callables = new ConcurrentLinkedQueue<>(); IntStream.range(0, 1000).parallel().forEach(i -> { callables.add(() -> { if (i%3 == 0) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexMaintenanceJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexMaintenanceJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexMaintenanceJUnitTest.java index 5616078..e087304 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexMaintenanceJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/IndexMaintenanceJUnitTest.java @@ -1050,18 +1050,18 @@ public class IndexMaintenanceJUnitTest // --ID; // Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL, "objs.maap[*]", // "/testRgn objs"); -// assertEquals(i1.getCanonicalizedIndexedExpression(), "index_iter1.maap[*]"); +// assertIndexDetailsEquals(i1.getCanonicalizedIndexedExpression(), "index_iter1.maap[*]"); // assertTrue(i1 instanceof CompactMapRangeIndex); // CompactMapRangeIndex mri = (CompactMapRangeIndex)i1; // // Test index maintenance // // addition of new Portfolio object // Map indxMap = mri.getRangeIndexHolderForTesting(); -// assertEquals(indxMap.size(), ID); +// assertIndexDetailsEquals(indxMap.size(), ID); // for (int j = 1; j <= ID; ++j) { // assertTrue(indxMap.containsKey("key" + j)); // CompactRangeIndex rng = indxMap.get("key" + j); // Iterator itr = rng.valueToEntriesMap.values().iterator(); -// assertEquals(rng.valueToEntriesMap.size(), 1); +// assertIndexDetailsEquals(rng.valueToEntriesMap.size(), 1); // assertTrue(rng.valueToEntriesMap.containsKey("val" + j)); // Set expectedElements = new HashSet(); // for (int k = j; k <= ID; ++k) { @@ -1075,7 +1075,7 @@ public class IndexMaintenanceJUnitTest // else if (mapValue instanceof ConcurrentHashSet) { // size = ((ConcurrentHashSet)mapValue).size(); // } -// assertEquals(expectedElements.size(), size); +// assertIndexDetailsEquals(expectedElements.size(), size); // for (Integer elem : expectedElements) { // RegionEntry re = testRgn.basicGetEntry(elem); // if (mapValue instanceof RegionEntry) { @@ -1093,18 +1093,18 @@ public class IndexMaintenanceJUnitTest // im.rerunIndexCreationQuery(); // ID =5; // i1 =im.getIndex("Index1"); -// assertEquals(i1.getCanonicalizedIndexedExpression(), "index_iter1.maap[*]"); +// assertIndexDetailsEquals(i1.getCanonicalizedIndexedExpression(), "index_iter1.maap[*]"); // assertTrue(i1 instanceof CompactMapRangeIndex); // mri = (CompactMapRangeIndex)i1; // // Test index maintenance // // addition of new Portfolio object // indxMap = mri.getRangeIndexHolderForTesting(); -// assertEquals(indxMap.size(), ID); +// assertIndexDetailsEquals(indxMap.size(), ID); // for (int j = 1; j <= ID; ++j) { // assertTrue(indxMap.containsKey("key" + j)); // CompactRangeIndex rng = indxMap.get("key" + j); // Iterator itr = rng.valueToEntriesMap.values().iterator(); -// assertEquals(rng.valueToEntriesMap.size(), 1); +// assertIndexDetailsEquals(rng.valueToEntriesMap.size(), 1); // assertTrue(rng.valueToEntriesMap.containsKey("val" + j)); // Set expectedElements = new HashSet(); // for (int k = j; k <= ID; ++k) { @@ -1118,7 +1118,7 @@ public class IndexMaintenanceJUnitTest // else if (mapValue instanceof ConcurrentHashSet) { // size = ((ConcurrentHashSet)mapValue).size(); // } -// assertEquals(expectedElements.size(), size); +// assertIndexDetailsEquals(expectedElements.size(), size); // for (Integer elem : expectedElements) { // RegionEntry re = testRgn.basicGetEntry(elem); // if (mapValue instanceof RegionEntry) {