You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/06/09 17:06:02 UTC
[45/51] [partial] incubator-geode git commit: GEODE-837: update tests
from JUnit3 to JUnit4
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/LikePredicateJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/LikePredicateJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/LikePredicateJUnitTest.java
index 1bb33e7..adaa365 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/LikePredicateJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/LikePredicateJUnitTest.java
@@ -21,16 +21,11 @@
*/
package com.gemstone.gemfire.cache.query.functional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.util.Collection;
import java.util.List;
-import junit.framework.Assert;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -60,9 +55,6 @@ import com.gemstone.gemfire.cache.query.internal.types.ObjectTypeImpl;
import com.gemstone.gemfire.test.dunit.ThreadUtils;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-/**
- *
- */
@Category(IntegrationTest.class)
public class LikePredicateJUnitTest {
@@ -399,7 +391,7 @@ public class LikePredicateJUnitTest {
* Tests a simple % terminated like predicate with an AND condition
* @throws Exception
*/
- public void likePercentageTerminated_4(boolean useBindPrm) throws Exception {
+ private void likePercentageTerminated_4(boolean useBindPrm) throws Exception {
Cache cache = CacheUtils.getCache();
AttributesFactory attributesFactory = new AttributesFactory();
RegionAttributes regionAttributes = attributesFactory.create();
@@ -1938,8 +1930,8 @@ public class LikePredicateJUnitTest {
public void testLikeWithNewLineWithIndex() throws Exception {
likeWithNewLine(true);
}
-
- public void likeWithNewLine(boolean useIndex) throws Exception {
+
+ private void likeWithNewLine(boolean useIndex) throws Exception {
// setup
Cache cache = CacheUtils.getCache();
AttributesFactory attributesFactory = new AttributesFactory();
@@ -1955,38 +1947,38 @@ public class LikePredicateJUnitTest {
}
Query query = qs.newQuery("select * from /pos a where a like '%bc%'");
SelectResults sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 1);
+ assertEquals(sr.size(), 1);
query = qs.newQuery("select * from /pos a where a like '%bc\n%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 1);
+ assertEquals(sr.size(), 1);
query = qs.newQuery("select * from /pos a where a like '%bcde%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 0); // no results as newline is required
+ assertEquals(sr.size(), 0); // no results as newline is required
// whitespace
query = qs.newQuery("select * from /pos a where a like '%bc\nde%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 1);
+ assertEquals(sr.size(), 1);
query = qs.newQuery("select * from /pos a where a like '%de%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 1);
+ assertEquals(sr.size(), 1);
query = qs.newQuery("select * from /pos a where a like '%\nde%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 1);
+ assertEquals(sr.size(), 1);
query = qs.newQuery("select * from /pos a where a like '%bc%de%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 1);
+ assertEquals(sr.size(), 1);
query = qs.newQuery("select * from /pos a where a like '%zyx%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 0);
+ assertEquals(sr.size(), 0);
query = qs.newQuery("select * from /pos a where a like '%\n%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 3); // find newline anywhere in string
+ assertEquals(sr.size(), 3); // find newline anywhere in string
query = qs.newQuery("select * from /pos a where a like '\n%'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 1);
+ assertEquals(sr.size(), 1);
query = qs.newQuery("select * from /pos a where a like '%\n'");
sr = (SelectResults) query.execute();
- Assert.assertEquals(sr.size(), 1);
+ assertEquals(sr.size(), 1);
}
@@ -2007,7 +1999,7 @@ public class LikePredicateJUnitTest {
removeIndexDuringQuery(true);
}
- public void removeIndexDuringQuery(boolean isPr) throws Exception {
+ private void removeIndexDuringQuery(boolean isPr) throws Exception {
String regionName = "exampleRegion";
String name = "/" + regionName;
@@ -2196,7 +2188,7 @@ public class LikePredicateJUnitTest {
executeInvalidQueryWithLike(true);
}
- public void executeInvalidQueryWithLike(boolean useBindParam) {
+ private void executeInvalidQueryWithLike(boolean useBindParam) {
Cache cache = CacheUtils.getCache();
AttributesFactory attributesFactory = new AttributesFactory();
RegionAttributes regionAttributes = attributesFactory.create();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java
index 4bd3258..4d3e31e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java
@@ -22,62 +22,54 @@
*/
package com.gemstone.gemfire.cache.query.functional;
-import com.gemstone.gemfire.cache.query.*;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import parReg.query.unittest.NewPortfolio;
+
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheWriterException;
import com.gemstone.gemfire.cache.PartitionAttributes;
import com.gemstone.gemfire.cache.PartitionAttributesFactory;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.cache.TimeoutException;
import com.gemstone.gemfire.cache.query.CacheUtils;
-import com.gemstone.gemfire.cache.query.FunctionDomainException;
import com.gemstone.gemfire.cache.query.Index;
import com.gemstone.gemfire.cache.query.IndexType;
-import com.gemstone.gemfire.cache.query.NameResolutionException;
import com.gemstone.gemfire.cache.query.Query;
-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.cache.query.TypeMismatchException;
import com.gemstone.gemfire.cache.query.data.Data;
import com.gemstone.gemfire.cache.query.data.Portfolio;
-
-//import com.gemstone.gemfire.cache.query.facets.lang.Employee;
import com.gemstone.gemfire.cache.query.types.StructType;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import parReg.query.unittest.NewPortfolio;
-import static org.junit.Assert.*;
-import junit.framework.*;
-
-/**
- */
@Category(IntegrationTest.class)
public class MiscJUnitTest {
@Before
- public void setUp() throws java.lang.Exception {
+ public void setUp() throws Exception {
CacheUtils.startCache();
}
@After
- public void tearDown() throws java.lang.Exception {
+ public void tearDown() throws Exception {
CacheUtils.closeCache();
}
- public void xtestNestQueryInFromClause() throws Exception {
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testNestQueryInFromClause() throws Exception {
Region region = CacheUtils.createRegion("Portfolios", Portfolio.class);
region.put("0", new Portfolio(0));
region.put("1", new Portfolio(1));
@@ -91,7 +83,9 @@ public class MiscJUnitTest {
if (!p.status.equals("active") || p.getID() != 0) fail(query.getQueryString());
}
- public void xtestNestQueryInWhereClause() throws Exception {
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testNestQueryInWhereClause() throws Exception {
Region region = CacheUtils.createRegion("Portfolios", Portfolio.class);
region.put("0", new Portfolio(0));
region.put("1", new Portfolio(1));
@@ -119,7 +113,9 @@ public class MiscJUnitTest {
// DISTINCT * FROM /Portfolios p where p.ID = x.ID).status
}
- public void xtestVoidMethods() throws Exception {
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testVoidMethods() throws Exception {
Region region = CacheUtils.createRegion("Data", Data.class);
region.put("0", new Data());
Query query = CacheUtils.getQueryService().newQuery("SELECT DISTINCT * FROM /Data where voidMethod");
@@ -130,7 +126,9 @@ public class MiscJUnitTest {
if (result.size() != 1) fail(query.getQueryString());
}
- public void xtestMiscQueries() throws Exception {
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testMiscQueries() throws Exception {
String testData[] = { "NULL", "UNDEFINED"};
for (int i = 0; i < testData.length; i++) {
Query query = CacheUtils.getQueryService().newQuery("SELECT DISTINCT * FROM " + testData[i]);
@@ -139,9 +137,9 @@ public class MiscJUnitTest {
}
}
- public void xtestBug32763() throws FunctionDomainException, TypeMismatchException, NameResolutionException,
- QueryInvocationTargetException, TimeoutException, CacheWriterException
- {
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testBug32763() throws Exception {
Region region = CacheUtils.createRegion("pos", Portfolio.class);
region.put("0", new Portfolio(0));
region.put("1", new Portfolio(1));
@@ -164,8 +162,7 @@ public class MiscJUnitTest {
}
@Test
- public void testBug() throws TimeoutException, CacheWriterException,
- FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException, Exception {
+ public void testBug() throws Exception {
Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
region.put("0", new Portfolio(0));
region.put("1", new Portfolio(1));
@@ -192,11 +189,10 @@ public class MiscJUnitTest {
Query q = qs.newQuery(qStr);
SelectResults result = (SelectResults) q.execute();
if(result.size()==0) fail("Test failed as size is zero");
-
}
@Test
- public void testBug37723() {
+ public void testBug37723() throws Exception {
Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
region.put("0", new Portfolio(0));
region.put("1", new Portfolio(1));
@@ -205,28 +201,22 @@ public class MiscJUnitTest {
QueryService qs = CacheUtils.getQueryService();
String qry = "select distinct getID, status from /portfolios pf where getID < 10 order by getID desc";
Query q = qs.newQuery(qry);
- try {
- SelectResults result = (SelectResults) q.execute();
- Iterator itr = result.iterator();
- int j = 3;
- while ( itr.hasNext()) {
- Struct struct = (Struct)itr.next();
- assertEquals(j--, ((Integer)struct.get("getID")).intValue());
- }
- qry = "select distinct getID, status from /portfolios pf where getID < 10 order by getID asc";
- q = qs.newQuery(qry);
- result = (SelectResults) q.execute();
- itr = result.iterator();
- j = 0;
- while ( itr.hasNext()) {
- Struct struct = (Struct)itr.next();
- assertEquals(j++, ((Integer)struct.get("getID")).intValue());
- }
+ SelectResults result = (SelectResults) q.execute();
+ Iterator itr = result.iterator();
+ int j = 3;
+ while ( itr.hasNext()) {
+ Struct struct = (Struct)itr.next();
+ assertEquals(j--, ((Integer)struct.get("getID")).intValue());
+ }
+ qry = "select distinct getID, status from /portfolios pf where getID < 10 order by getID asc";
+ q = qs.newQuery(qry);
+ result = (SelectResults) q.execute();
+ itr = result.iterator();
+ j = 0;
+ while ( itr.hasNext()) {
+ Struct struct = (Struct)itr.next();
+ assertEquals(j++, ((Integer)struct.get("getID")).intValue());
}
- catch (Exception e) {
- e.printStackTrace();
- fail ("Test failed because of exception="+e);
- }
}
@Test
@@ -276,14 +266,10 @@ public class MiscJUnitTest {
SelectResults rs = (SelectResults)query.execute();
assertEquals(rs.size(), 2);
-
}
-
-
-
@Test
- public void testMultipleOrderByClauses() {
+ public void testMultipleOrderByClauses() throws Exception {
Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
region.put("2", new Portfolio(2));
region.put("3", new Portfolio(3));
@@ -294,44 +280,27 @@ public class MiscJUnitTest {
QueryService qs = CacheUtils.getQueryService();
String qry = "select distinct status, getID from /portfolios pf where getID < 10 order by status asc, getID desc";
Query q = qs.newQuery(qry);
- try {
- SelectResults result = (SelectResults) q.execute();
- Iterator itr = result.iterator();
- int j = 6;
- while ( itr.hasNext() && j >0) {
- Struct struct = (Struct)itr.next();
- assertEquals("active", struct.get("status"));
- assertEquals(j, ((Integer)struct.get("getID")).intValue());
-
- j-=2;
- }
- j =7;
- while ( itr.hasNext()) {
- Struct struct = (Struct)itr.next();
- assertEquals(j, ((Integer)struct.get("getID")).intValue());
- assertEquals("inactive", struct.get("status"));
- j-=2;
- }
- /*
- qry = "select distinct getID, status from /portfolios pf where getID < 10 order by getID asc";
- q = qs.newQuery(qry);
- result = (SelectResults) q.execute();
- itr = result.iterator();
- j = 0;
- while ( itr.hasNext()) {
- Struct struct = (Struct)itr.next();
- assertIndexDetailsEquals(j++, ((Integer)struct.get("getID")).intValue());
- }*/
+ SelectResults result = (SelectResults) q.execute();
+ Iterator itr = result.iterator();
+ int j = 6;
+ while ( itr.hasNext() && j >0) {
+ Struct struct = (Struct)itr.next();
+ assertEquals("active", struct.get("status"));
+ assertEquals(j, ((Integer)struct.get("getID")).intValue());
+
+ j-=2;
+ }
+ j =7;
+ while ( itr.hasNext()) {
+ Struct struct = (Struct)itr.next();
+ assertEquals(j, ((Integer)struct.get("getID")).intValue());
+ assertEquals("inactive", struct.get("status"));
+ j-=2;
}
- catch (Exception e) {
- e.printStackTrace();
- fail ("Test failed because of exception="+e);
- }
}
/**
* Tests the where clause formed with CompiledComparison nesting
- * @throws Exception
*/
@Test
public void testBug40333_InLocalRegion_1() throws Exception {
@@ -350,9 +319,10 @@ public class MiscJUnitTest {
* Commented the test as it is for some reason causing OOM when run in the suite.
* It is due to presence of PR
* Tests the where clause formed with CompiledComparison nesting
- * @throws Exception
*/
- public void _testBug40333_InPartitionedRegion_1() throws Exception {
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testBug40333_InPartitionedRegion_1() throws Exception {
CacheUtils.startCache();
final Cache cache = CacheUtils.getCache();
AttributesFactory attributesFactory = new AttributesFactory();
@@ -370,7 +340,6 @@ public class MiscJUnitTest {
/**
* Tests the where clause formed with CompiledComparison nesting with CompiledIN
- * @throws Exception
*/
@Test
public void testBug40333_InLocalRegion_2() throws Exception {
@@ -389,9 +358,10 @@ public class MiscJUnitTest {
* Commented the test as it is for some reason causing OOM when run in the suite.
* It is due to presence of PR
* Tests the where clause formed with CompiledComparison nesting with CompiledIN
- * @throws Exception
*/
- public void _testBug40333_InPartitionedRegion_2() throws Exception {
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testBug40333_InPartitionedRegion_2() throws Exception {
CacheUtils.startCache();
final Cache cache = CacheUtils.getCache();
AttributesFactory attributesFactory = new AttributesFactory();
@@ -545,14 +515,9 @@ public class MiscJUnitTest {
"undefinedTestField.toString", "/new_pos");
final Query q1 = qs.newQuery(queryStr1);
final Query q2 = qs.newQuery(queryStr2);
- try {
- SelectResults sr1 = (SelectResults)q1.execute();
- SelectResults sr2 = (SelectResults)q2.execute();
- }catch(Throwable e) {
- e.printStackTrace();
- fail("Test failed due to = " +e.toString());
- }
- }
+ SelectResults sr1 = (SelectResults)q1.execute();
+ SelectResults sr2 = (SelectResults)q2.execute();
+ }
@Test
public void testBug37119() throws Exception {
@@ -599,126 +564,4 @@ public class MiscJUnitTest {
pf = (Portfolio)result.iterator().next();
assertEquals(pf.getID(),3);
}
-
-
- /*
- @Test
- public void testBug37119() throws Exception {
- Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
- region.put("0", new Portfolio(0));
- region.put("1", new Portfolio(1));
- region.put("2", new Portfolio(2));
- region.put("3", new Portfolio(3));
- QueryService qs = CacheUtils.getQueryService();
-
- String qStr = "Select distinct * from /portfolios pf where pf.getID() > Integer.MIN_VALUE";
- Query q = qs.newQuery(qStr);
- SelectResults result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),4);
-
- qStr = "Select distinct * from /portfolios pf where pf.getID() > Integer.MAX_VALUE";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),0);
-
- qStr = "Select distinct * from /portfolios pf where pf.getID() > \"Long\".MAX_VALUE";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),0);
-
- qStr = "Select distinct * from /portfolios pf where pf.getID() > \"Long\".MIN_VALUE";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),4);
-
- qStr = "Select distinct * from /portfolios pf where pf.getID() > integer.MIN_VALUE";
- q = qs.newQuery(qStr);
- try {
- result = (SelectResults) q.execute();
- fail("Expected QueryException as integer.MIN_VALUE will not be resolved");
- }catch(TypeMismatchException tme) {
- //Ok
- }
-
- qStr = "Select distinct * from /portfolios pf where pf.intFunction(Integer.MIN_VALUE) = Integer.MIN_VALUE";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),4);
-
- qStr = "Select distinct * from /portfolios pf where pf.intFunction(Integer.MAX_VALUE) = Integer.MAX_VALUE";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),4);
-
- qStr = "Select distinct * from /portfolios pf where pf.longFunction( \"Long\".MAX_VALUE) = \"Long\".MAX_VALUE";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),4);
-
- qStr = "Select distinct * from /portfolios pf where pf.longFunction(\"Long\".MIN_VALUE) = \"Long\".MIN_VALUE";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),4);
-
- qStr = "Select distinct * from /portfolios pf where pf.Integer.MAX_VALUE = Integer.MAX_VALUE";
- q = qs.newQuery(qStr);
- try {
- result = (SelectResults) q.execute();
- fail("Query should have thrown Exception as attribute Integer.MAX_VALUE is not present");
- }catch(NameNotFoundException nfe) {
- //Ok;
- }
-
- qStr = "Select distinct Integer.MAX_VALUE from /portfolios pf where Integer.MAX_VALUE = Integer.MAX_VALUE";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),1);
- assertIndexDetailsEquals(result.iterator().next(),Integer.valueOf(Integer.MAX_VALUE));
-
-
- }
-
- @Test
- public void testBu37119_1() throws Exception {
- Region region = CacheUtils.createRegion("tempdata",null);
- region.put("1", new TempData1());
- QueryService qs = CacheUtils.getQueryService();
-
- String qStr = "Select distinct * from /tempdata td where td.Integer.MAX_VALUE > Integer.MAX_VALUE";
- Query q = qs.newQuery(qStr);
- SelectResults result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),0);
-
- qStr = "Select distinct * from /tempdata td where td.Integer.MAX_VALUE = 2 ";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),1);
-
- qStr = "Select distinct * from /tempdata td where Integer.MAX_VALUE = 2 ";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),0);
-
- qStr = "Select distinct * from /tempdata td where Integer.MAX_VALUE.intValue = Integer.MAX_VALUE ";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),0);
-
- qStr = "Select distinct * from /tempdata td where Integer.test = 'test'";
- q = qs.newQuery(qStr);
- result = (SelectResults) q.execute();
- assertIndexDetailsEquals(result.size(),1);
- }
-
-
- static class TempData1 {
- public TempData2 Integer = new TempData2();
-
- }
-
- static class TempData2 {
- public Integer MAX_VALUE = new Integer(2);
- public String test ="test";
- } */
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NestedQueryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NestedQueryJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NestedQueryJUnitTest.java
index 11dcb0e..c7ed9d7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NestedQueryJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NestedQueryJUnitTest.java
@@ -22,23 +22,20 @@
*/
package com.gemstone.gemfire.cache.query.functional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-import junit.framework.AssertionFailedError;
-
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.rules.ErrorCollector;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.query.CacheUtils;
@@ -53,29 +50,28 @@ import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
import com.gemstone.gemfire.cache.query.internal.StructImpl;
import com.gemstone.gemfire.cache.query.types.ObjectType;
-//import com.gemstone.gemfire.internal.util.DebuggerSupport;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-/**
- *
- */
@Category(IntegrationTest.class)
public class NestedQueryJUnitTest {
- ObjectType resType1=null;
- ObjectType resType2= null;
- int resSize1=0;
- int resSize2=0;
+ private ObjectType resType1=null;
+ private ObjectType resType2= null;
+
+ private int resSize1=0;
+ private int resSize2=0;
- Iterator itert1=null;
- Iterator itert2=null;
+ private Iterator itert1=null;
+ private Iterator itert2=null;
- Set set1=null;
- Set set2=null;
+ private Set set1=null;
+ private Set set2=null;
- String s1;
- String s2;
+ private String s1;
+ private String s2;
+ @Rule
+ public ErrorCollector errorCollector = new ErrorCollector(); // used by testQueries
@Before
public void setUp() throws java.lang.Exception {
@@ -90,7 +86,9 @@ public class NestedQueryJUnitTest {
CacheUtils.closeCache();
}
- public void atestQueries() throws Exception{
+ @Ignore("TODO: this test was disabled")
+ @Test
+ public void testQueries2() throws Exception{
String queryString;
Query query;
Object result;
@@ -119,14 +117,14 @@ public class NestedQueryJUnitTest {
query = CacheUtils.getQueryService().newQuery(queryString);
result = query.execute();
CacheUtils.log(Utils.printResult(result));
-
}
+
@Test
public void testQueries() throws Exception {
String queries[]={
"SELECT DISTINCT * FROM /Portfolios WHERE NOT(SELECT DISTINCT * FROM positions.values p WHERE p.secId = 'IBM').isEmpty",
"SELECT DISTINCT * FROM /Portfolios where NOT(SELECT DISTINCT * FROM /Portfolios p where p.ID = 0).isEmpty",
- "SELECT DISTINCT * FROM /Portfolios where status = ELEMENT(SELECT DISTINCT * FROM /Portfolios p where ID = 0).status",
+ "SELECT DISTINCT * FROM /Portfolios where status = ELEMENT(SELECT DISTINCT * FROM /Portfolios p where p.ID = 0).status",
"SELECT DISTINCT * FROM /Portfolios where status = ELEMENT(SELECT DISTINCT * FROM /Portfolios p where p.ID = 0).status",
"SELECT DISTINCT * FROM /Portfolios x where status = ELEMENT(SELECT DISTINCT * FROM /Portfolios p where x.ID = p.ID).status",
"SELECT DISTINCT * FROM /Portfolios x where status = ELEMENT(SELECT DISTINCT * FROM /Portfolios p where p.ID = x.ID).status",
@@ -136,19 +134,14 @@ public class NestedQueryJUnitTest {
try{
Query query = CacheUtils.getQueryService().newQuery(queries[i]);
query.execute();
- //CacheUtils.log(Utils.printResult(result));
- CacheUtils.log("OK "+queries[i]);
}catch(Exception e){
- CacheUtils.log("FAILED "+queries[i]);
- CacheUtils.log(e.getMessage());
- //e.printStackTrace();
+ errorCollector.addError(e);
}
}
}
+
@Test
public void testNestedQueriesEvaluation() throws Exception {
-
-
QueryService qs;
qs = CacheUtils.getQueryService();
String queries[] = {
@@ -187,8 +180,7 @@ public class NestedQueryJUnitTest {
// Iterator iter=set1.iterator();
} catch (Exception e) {
- e.printStackTrace();
- fail(q.getQueryString());
+ throw new AssertionError(q.getQueryString(), e);
}
}
@@ -220,8 +212,7 @@ public class NestedQueryJUnitTest {
set2=((r[i][1]).asSet());
} catch (Exception e) {
- e.printStackTrace();
- fail(q.getQueryString());
+ throw new AssertionError(q.getQueryString(), e);
}
}
for(int j=0;j<=1;j++){
@@ -246,12 +237,10 @@ public class NestedQueryJUnitTest {
fail("FAILED: In both the Cases the members of ResultsSet are different.");
}
CacheUtils.compareResultsOfWithAndWithoutIndex(r, this);
-
}
@Test
- public void testNestedQueriesResultsasStructSet() throws Exception {
-
+ public void testNestedQueriesResultsAsStructSet() throws Exception {
QueryService qs;
qs = CacheUtils.getQueryService();
String queries[] = {
@@ -309,9 +298,7 @@ public class NestedQueryJUnitTest {
// Iterator iter=set1.iterator();
} catch (Exception e) {
- AssertionFailedError afe = new AssertionFailedError(q.getQueryString());
- afe.initCause(e);
- throw afe;
+ throw new AssertionError(e);
}
}
@@ -336,8 +323,7 @@ public class NestedQueryJUnitTest {
set2=((r[i][1]).asSet());
} catch (Exception e) {
- e.printStackTrace();
- fail(q.getQueryString());
+ throw new AssertionError(q.getQueryString(), e);
}
}
for(int j=0;j<queries.length;j++){
@@ -436,7 +422,6 @@ public class NestedQueryJUnitTest {
* Tests a nested query with shorts converted to integer types in the result
* set of the inner query. The short field in the outer query should be
* evaluated against the integer types and match.
- * @throws Exception
*/
@Test
public void testNestedQueryWithShortTypesFromInnerQuery() throws Exception {
@@ -456,8 +441,6 @@ public class NestedQueryJUnitTest {
/**
* Tests a nested query that has duplicate results in the inner query
* Results should not be duplicated in the final result set
- *
- * @throws Exception
*/
@Test
public void testNestedQueryWithMultipleMatchingResultsWithIn() throws Exception {
@@ -474,10 +457,8 @@ public class NestedQueryJUnitTest {
helpTestIndexForQuery("<trace>SELECT * FROM /portfolios1 p where p.ID in (SELECT p.ID FROM /portfolios1 p WHERE p.ID = 1)", "p.ID", "/portfolios1 p");
}
- /*
+ /**
* helper method to test against a compact range index
- * @param query
- * @throws Exception
*/
private void helpTestIndexForQuery(String query, String indexedExpression, String regionPath) throws Exception {
QueryService qs = CacheUtils.getQueryService();
@@ -492,14 +473,17 @@ public class NestedQueryJUnitTest {
assertTrue(observer.isIndexesUsed);
}
- class QueryObserverImpl extends QueryObserverAdapter{
- boolean isIndexesUsed = false;
- ArrayList indexesUsed = new ArrayList();
+ private static class QueryObserverImpl extends QueryObserverAdapter {
+
+ private boolean isIndexesUsed = false;
+ private ArrayList indexesUsed = new ArrayList();
+ @Override
public void beforeIndexLookup(Index index, int oper, Object key) {
indexesUsed.add(index.getName());
}
+ @Override
public void afterIndexLookup(Collection results) {
if(results != null){
isIndexesUsed = true;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NumericQueryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NumericQueryJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NumericQueryJUnitTest.java
index 017816d..08c48b3 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NumericQueryJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NumericQueryJUnitTest.java
@@ -16,20 +16,7 @@
*/
package com.gemstone.gemfire.cache.query.functional;
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.cache.query.CacheUtils;
-import com.gemstone.gemfire.cache.query.Index;
-import com.gemstone.gemfire.cache.query.QueryService;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.cache.query.data.Numbers;
-import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
-import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-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 static org.junit.Assert.*;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -39,12 +26,27 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+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.DataPolicy;
+import com.gemstone.gemfire.cache.PartitionAttributesFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.query.CacheUtils;
+import com.gemstone.gemfire.cache.query.Index;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.data.Numbers;
+import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
+import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-/**
- *
- *
- */
@Category(IntegrationTest.class)
public class NumericQueryJUnitTest {
@@ -52,13 +54,11 @@ public class NumericQueryJUnitTest {
private static Region testRegion;
private static int numElem = 100;
-
private static String EQ = "=";
private static String LT = "<";
private static String GT = ">";
private static String GTE = ">=";
private static String LTE = "<=";
-
@Before
public void setUp() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/StructSetOrResultsSet.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/StructSetOrResultsSet.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/StructSetOrResultsSet.java
index fe5aa4f..a93a87c 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/StructSetOrResultsSet.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/StructSetOrResultsSet.java
@@ -19,9 +19,10 @@
* Utlity Class : Can be used to compare the results (StructSet OR ResultsSet) under the scenario without/with Index Usage.
* Created on June 13, 2005, 11:16 AM
*/
-
package com.gemstone.gemfire.cache.query.functional;
+import static org.junit.Assert.*;
+
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -32,8 +33,6 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.cache.query.CacheUtils;
import com.gemstone.gemfire.cache.query.FunctionDomainException;
@@ -52,23 +51,49 @@ import com.gemstone.gemfire.cache.query.internal.ExecutionContext;
import com.gemstone.gemfire.cache.query.internal.OrderByComparator;
import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
-import com.gemstone.gemfire.cache.query.internal.parse.OQLLexerTokenTypes;
import com.gemstone.gemfire.cache.query.types.ObjectType;
import com.gemstone.gemfire.internal.util.ArrayUtils;
/**
+ * Used by these tests:
+ *
+ * <li/>EquiJoinIntegrationTest
+ * <li/>IUMRCompositeIteratorJUnitTest
+ * <li/>IUMRMultiIndexesMultiRegionJUnitTest
+ * <li/>IUMRShuffleIteratorsJUnitTest
+ * <li/>IUMRSingleRegionJUnitTest
+ * <li/>IndexCreationJUnitTest
+ * <li/>IndexHintJUnitTest
+ * <li/>IndexMaintainceJUnitTest
+ * <li/>IndexUseJUnitTest
+ * <li/>IndexedMergeEquiJoinScenariosJUnitTest
+ * <li/>MultiRegionIndexUsageJUnitTest
+ * <li/>NonDistinctOrderByPartitionedJUnitTest
+ * <li/>NonDistinctOrderByReplicatedJUnitTest
+ * <li/>NonDistinctOrderByTestImplementation
+ * <li/>OrderByPartitionedJUnitTest
+ * <li/>OrderByReplicatedJUnitTest
+ * <li/>OrderByTestImplementation
+ * <li/>QueryIndexUsingXMLDUnitTest
+ * <li/>QueryREUpdateInProgressJUnitTest
+ * <li/>QueryUsingFunctionContextDUnitTest
+ * <li/>QueryUsingPoolDUnitTest
+ * <li/>TestNewFunctionSSorRSIntegrationTest
+ *
+ * Also used by:
+ *
+ * <li/>GroupByTestImpl
+ * <li/>PdxGroupByTestImpl
+ * <li/>PRQueryDUnitHelper
*/
-public class StructSetOrResultsSet extends TestCase {
+public class StructSetOrResultsSet {
-
- public void CompareQueryResultsWithoutAndWithIndexes(Object[][] r, int len,
- String queries[]) {
+ public void CompareQueryResultsWithoutAndWithIndexes(Object[][] r, int len, String queries[]) {
CompareQueryResultsWithoutAndWithIndexes(r, len, false, queries);
}
/** Creates a new instance of StructSetOrResultsSet */
- public void CompareQueryResultsWithoutAndWithIndexes(Object[][] r, int len,
- boolean checkOrder, String queries[]) {
+ public void CompareQueryResultsWithoutAndWithIndexes(Object[][] r, int len, boolean checkOrder, String queries[]) {
Collection coll1 = null;
Collection coll2 = null;
@@ -87,8 +112,7 @@ public class StructSetOrResultsSet extends TestCase {
}
}
- public void compareExternallySortedQueriesWithOrderBy(String[] queries,
- Object[][] baseResults) throws Exception {
+ public void compareExternallySortedQueriesWithOrderBy(String[] queries, Object[][] baseResults) throws Exception {
for (int i = 0; i < queries.length; i++) {
Query q = null;
try {
@@ -126,15 +150,12 @@ public class StructSetOrResultsSet extends TestCase {
}
} catch (Exception e) {
e.printStackTrace();
- fail("query with index=" + i + " has failed. failed query="
- + queries[i]);
+ throw new AssertionError("query with index=" + i + " has failed. failed query=" + queries[i], e);
}
-
}
}
- private void compareQueryResultsWithExternallySortedResults(SelectResults sr,
- Object[] externallySorted, String query, Wrapper wrapper) {
+ private void compareQueryResultsWithExternallySortedResults(SelectResults sr, Object[] externallySorted, String query, Wrapper wrapper) {
if (sr.size() == externallySorted.length) {
CacheUtils.log("Both SelectResults are of Same Size i.e. Size= "
@@ -187,11 +208,8 @@ public class StructSetOrResultsSet extends TestCase {
}
}
- public Wrapper getOrderByComparatorAndLimitForQuery(String orderByQuery,
- int unorderedResultSize) throws FunctionDomainException,
- TypeMismatchException, NameResolutionException,
- QueryInvocationTargetException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ public Wrapper getOrderByComparatorAndLimitForQuery(String orderByQuery, int unorderedResultSize)
+ throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
DefaultQuery q = (DefaultQuery) CacheUtils.getQueryService().newQuery(
orderByQuery);
CompiledSelect cs = q.getSimpleSelect();
@@ -272,7 +290,6 @@ public class StructSetOrResultsSet extends TestCase {
}
}
return new Wrapper(finalComparator, limit, validationLevel);
-
}
enum ValidationLevel {
@@ -292,8 +309,7 @@ public class StructSetOrResultsSet extends TestCase {
}
/** Creates a new instance of StructSetOrResultsSet */
- public void CompareCountStarQueryResultsWithoutAndWithIndexes(Object[][] r,
- int len, boolean checkOrder, String queries[]) {
+ public void CompareCountStarQueryResultsWithoutAndWithIndexes(Object[][] r, int len, boolean checkOrder, String queries[]) {
Integer count1, count2;
Iterator<Integer> itert1, itert2;
@@ -305,7 +321,6 @@ public class StructSetOrResultsSet extends TestCase {
assertEquals(queries[j], 1, result1.size());
assertEquals(queries[j], 1, result2.size());
-
checkSelectResultTypes((SelectResults) r[j][0], (SelectResults) r[j][1], queries[j]);
checkResultSizes((SelectResults) r[j][0], (SelectResults) r[j][1], queries[j]);
compareResults(result1, result2, queries[j], true);
@@ -314,22 +329,13 @@ public class StructSetOrResultsSet extends TestCase {
/**
* Compares two ArrayLists containing query results with/without order.
- *
- * @param r
- * Array of ArrayLists
- * @param len
- * Length of array of ArrayLists
- * @param checkOrder
- * @param queries
*/
- public void CompareQueryResultsAsListWithoutAndWithIndexes(Object[][] r,
- int len, boolean checkOrder, String queries[]) {
+ public void CompareQueryResultsAsListWithoutAndWithIndexes(Object[][] r, int len, boolean checkOrder, String queries[]) {
CompareQueryResultsAsListWithoutAndWithIndexes(r, len, checkOrder, true,
queries);
}
- public void CompareQueryResultsAsListWithoutAndWithIndexes(Object[][] r,
- int len, boolean checkOrder, boolean checkClass, String queries[]) {
+ public void CompareQueryResultsAsListWithoutAndWithIndexes(Object[][] r, int len, boolean checkOrder, boolean checkClass, String queries[]) {
Integer count1, count2;
Iterator<Integer> itert1, itert2;
ArrayList result1, result2;
@@ -344,8 +350,7 @@ public class StructSetOrResultsSet extends TestCase {
}
}
- public void compareQueryResultLists(List r1, List r2,
- int len, boolean checkOrder, boolean checkClass, String query) {
+ public void compareQueryResultLists(List r1, List r2, int len, boolean checkOrder, boolean checkClass, String query) {
if (checkClass) {
if ((r1.get(0).getClass().getName()).equals(r2.get(0)
.getClass().getName())) {
@@ -380,8 +385,7 @@ public class StructSetOrResultsSet extends TestCase {
+ r2.size() + "; failed query=" + query);
}
}
-
-
+
private void compareResults(Collection result1, Collection result2, String query, boolean checkOrder) {
Iterator itert1 = result1.iterator();
Iterator itert2 = result2.iterator();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/TestNewFunctionSSorRS.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/TestNewFunctionSSorRS.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/TestNewFunctionSSorRS.java
deleted file mode 100755
index 38b4a07..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/TestNewFunctionSSorRS.java
+++ /dev/null
@@ -1,128 +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.
- */
-/*
- * TestNewFunction.java
- *
- * Created on June 16, 2005, 3:55 PM
- */
-package com.gemstone.gemfire.cache.query.functional;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.query.CacheUtils;
-import com.gemstone.gemfire.cache.query.Index;
-import com.gemstone.gemfire.cache.query.IndexType;
-import com.gemstone.gemfire.cache.query.Query;
-import com.gemstone.gemfire.cache.query.QueryService;
-import com.gemstone.gemfire.cache.query.Utils;
-import com.gemstone.gemfire.cache.query.data.Portfolio;
-import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
-import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
-import java.util.ArrayList;
-import java.util.Collection;
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class TestNewFunctionSSorRS extends TestCase {
-
- /** Creates a new instance of TestNewFunction */
- public TestNewFunctionSSorRS(String testName) {
- super(testName);
- }
- protected void setUp() throws java.lang.Exception {
- CacheUtils.startCache();
- }
-
- protected void tearDown() throws java.lang.Exception {
- CacheUtils.closeCache();
- }
-
- public void testNewFunc() throws Exception {
- Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
- for(int i=0; i<4; i++){
- region.put(""+i, new Portfolio(i));
- // CacheUtils.log(new Portfolio(i));
- }
-
- Object r[][] = new Object[2][2];
- QueryService qs;
- qs = CacheUtils.getQueryService();
-
- String queries[] = {
- "SELECT DISTINCT * from /portfolios pf , pf.positions.values pos where status = 'inactive'",
- "select distinct * from /portfolios where ID > 1 ",
-
- };
-
- for (int i = 0; i < queries.length; i++) {
- Query q = null;
- try {
- q = CacheUtils.getQueryService().newQuery(queries[i]);
- QueryObserverImpl observer1 = new QueryObserverImpl();
- QueryObserverHolder.setInstance(observer1);
- r[i][0] = q.execute();
- if(!observer1.isIndexesUsed){
- CacheUtils.log("NO INDEX IS USED!");
- }
- CacheUtils.log(Utils.printResult(r[i][0]));
- } catch(Exception e) {
- fail("Caught exception");
- e.printStackTrace();
- }
- }
-
- qs.createIndex("sIndex", IndexType.FUNCTIONAL,"status","/portfolios");
- qs.createIndex("iIndex", IndexType.FUNCTIONAL,"ID","/portfolios");
- for (int i = 0; i < queries.length; i++) {
- Query q = null;
- try {
- q = CacheUtils.getQueryService().newQuery(queries[i]);
- QueryObserverImpl observer2 = new QueryObserverImpl();
- QueryObserverHolder.setInstance(observer2);
- r[i][1] = q.execute();
- if(observer2.isIndexesUsed){
- CacheUtils.log("YES INDEX IS USED!");
- } else {
- fail("Index NOT Used");
- }
- CacheUtils.log(Utils.printResult(r[i][1]));
- } catch(Exception e) {
- fail("Caught exception");
- e.printStackTrace();
- }
- }
-
- StructSetOrResultsSet ssORrs = new StructSetOrResultsSet();
- ssORrs.CompareQueryResultsWithoutAndWithIndexes(r, queries.length,queries);
- }
- class QueryObserverImpl extends QueryObserverAdapter{
- boolean isIndexesUsed = false;
- ArrayList indexesUsed = new ArrayList();
-
- public void beforeIndexLookup(Index index, int oper, Object key) {
- indexesUsed.add(index.getName());
- }
-
- public void afterIndexLookup(Collection results) {
- if(results != null){
- isIndexesUsed = true;
- }
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/TestNewFunctionSSorRSIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/TestNewFunctionSSorRSIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/TestNewFunctionSSorRSIntegrationTest.java
new file mode 100755
index 0000000..98da823
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/TestNewFunctionSSorRSIntegrationTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+/*
+ * TestNewFunction.java
+ *
+ * Created on June 16, 2005, 3:55 PM
+ */
+package com.gemstone.gemfire.cache.query.functional;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.query.CacheUtils;
+import com.gemstone.gemfire.cache.query.Index;
+import com.gemstone.gemfire.cache.query.IndexType;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.Utils;
+import com.gemstone.gemfire.cache.query.data.Portfolio;
+import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
+import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * TODO: does this test provide any valuable coverage?
+ */
+@Category(IntegrationTest.class)
+public class TestNewFunctionSSorRSIntegrationTest {
+
+ @Before
+ public void setUp() throws Exception {
+ CacheUtils.startCache();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ CacheUtils.closeCache();
+ }
+
+ @Test
+ public void testNewFunc() throws Exception {
+ Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
+ for (int i = 0; i < 4; i++) {
+ region.put("" + i, new Portfolio(i));
+ // CacheUtils.log(new Portfolio(i));
+ }
+
+ Object r[][] = new Object[2][2];
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+
+ String queries[] = {
+ "SELECT DISTINCT * from /portfolios pf , pf.positions.values pos where status = 'inactive'",
+ "select distinct * from /portfolios where ID > 1 ",
+
+ };
+
+ for (int i = 0; i < queries.length; i++) {
+ Query q = null;
+ q = CacheUtils.getQueryService().newQuery(queries[i]);
+ QueryObserverImpl observer1 = new QueryObserverImpl();
+ QueryObserverHolder.setInstance(observer1);
+ r[i][0] = q.execute();
+ if (!observer1.isIndexesUsed) {
+ CacheUtils.log("NO INDEX IS USED!");
+ }
+ CacheUtils.log(Utils.printResult(r[i][0]));
+ }
+
+ qs.createIndex("sIndex", IndexType.FUNCTIONAL, "status", "/portfolios");
+ qs.createIndex("iIndex", IndexType.FUNCTIONAL, "ID", "/portfolios");
+ for (int i = 0; i < queries.length; i++) {
+ Query q = null;
+ q = CacheUtils.getQueryService().newQuery(queries[i]);
+ QueryObserverImpl observer2 = new QueryObserverImpl();
+ QueryObserverHolder.setInstance(observer2);
+ r[i][1] = q.execute();
+ if (observer2.isIndexesUsed) {
+ CacheUtils.log("YES INDEX IS USED!");
+ } else {
+ fail("Index NOT Used");
+ }
+ CacheUtils.log(Utils.printResult(r[i][1]));
+ }
+
+ StructSetOrResultsSet ssORrs = new StructSetOrResultsSet();
+ ssORrs.CompareQueryResultsWithoutAndWithIndexes(r, queries.length, queries);
+ }
+
+ private static class QueryObserverImpl extends QueryObserverAdapter {
+
+ boolean isIndexesUsed = false;
+ ArrayList indexesUsed = new ArrayList();
+
+ public void beforeIndexLookup(Index index, int oper, Object key) {
+ indexesUsed.add(index.getName());
+ }
+
+ public void afterIndexLookup(Collection results) {
+ if (results != null) {
+ isIndexesUsed = true;
+ }
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/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 49270bc..af4ed74 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
@@ -19,6 +19,17 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.CyclicBarrier;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.query.CacheUtils;
@@ -31,45 +42,26 @@ import com.gemstone.gemfire.test.dunit.ThreadUtils;
import com.gemstone.gemfire.test.dunit.Wait;
import com.gemstone.gemfire.test.dunit.WaitCriterion;
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.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.CyclicBarrier;
-
-import static org.junit.Assert.assertFalse;
-
-/**
- *
- */
@Category(IntegrationTest.class)
public class AsynchIndexMaintenanceJUnitTest {
+
private QueryService qs;
- protected Region region;
+ private Region region;
- protected boolean indexUsed = false;
- protected volatile boolean exceptionOccured = false;
+ private boolean indexUsed = false;
+ private volatile boolean exceptionOccured = false;
private Set idSet ;
- private void init() {
+ private void init() throws Exception {
idSet = new HashSet();
- try {
- CacheUtils.startCache();
- Cache cache = CacheUtils.getCache();
- region = CacheUtils.createRegion("portfolio", Portfolio.class, false);
-
- qs = cache.getQueryService();
-
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+ CacheUtils.startCache();
+ Cache cache = CacheUtils.getCache();
+ region = CacheUtils.createRegion("portfolio", Portfolio.class, false);
+ qs = cache.getQueryService();
}
@Before
@@ -196,9 +188,7 @@ public class AsynchIndexMaintenanceJUnitTest {
region.put(""+(i+1), new Portfolio(i+1));
idSet.add((i+1) + "");
}
- Thread.sleep(10000);
- //assertIndexDetailsEquals(0, this.getIndexSize(ri));
-
+ Thread.sleep(10000); // TODO: delete this sleep
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java
index f5e7f8d..395405a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java
@@ -16,6 +16,23 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.query.Index;
import com.gemstone.gemfire.cache.query.QueryService;
@@ -26,25 +43,10 @@ import com.gemstone.gemfire.cache.query.internal.DefaultQuery;
import com.gemstone.gemfire.cache.query.internal.DefaultQuery.TestHook;
import com.gemstone.gemfire.internal.cache.persistence.query.CloseableIterator;
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 util.TestException;
-
-import java.util.*;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
-import static org.junit.Assert.*;
-
-/**
- *
- *
- */
@Category(IntegrationTest.class)
public class CompactRangeIndexJUnitTest {
+
private QueryTestUtils utils;
private Index index;
@@ -76,7 +78,7 @@ public class CompactRangeIndexJUnitTest {
executeRangeQueryWithoutDistinct(9);
}
- /*
+ /**
* Tests adding entries to compact range index where the key is null
* fixes bug 47151 where null keyed entries would be removed after being added
*/
@@ -97,10 +99,12 @@ public class CompactRangeIndexJUnitTest {
SelectResults results = (SelectResults) qs.newQuery("Select * from /exampleRegion r where r.status = null").execute();
assertEquals("Null matched Results expected", numObjects, results.size());
}
-
- //Tests race condition where we possibly were missing remove calls due to transitioning
- //to an empty index elem before adding the entries
- //the fix is to add the entries to the elem and then transition to that elem
+
+ /**
+ * Tests race condition where we possibly were missing remove calls due to transitioning
+ * to an empty index elem before adding the entries
+ * the fix is to add the entries to the elem and then transition to that elem
+ */
@Test
public void testCompactRangeIndexMemoryIndexStoreMaintenance() throws Exception {
try {
@@ -155,9 +159,11 @@ public class CompactRangeIndexJUnitTest {
}
}
- //Tests race condition when we are transitioning index collection from elem array to concurrent hash set
- //The other thread could remove from the empty concurrent hash set.
- //Instead we now set a token, do all the puts into a collection and then unsets the token to the new collection
+ /**
+ * Tests race condition when we are transitioning index collection from elem array to concurrent hash set
+ * The other thread could remove from the empty concurrent hash set.
+ * Instead we now set a token, do all the puts into a collection and then unsets the token to the new collection
+ */
@Test
public void testMemoryIndexStoreMaintenanceTransitionFromElemArrayToTokenToConcurrentHashSet() throws Exception {
try {
@@ -270,7 +276,7 @@ public class CompactRangeIndexJUnitTest {
}
}
- private class MemoryIndexStoreREToIndexElemTestHook implements TestHook {
+ private static class MemoryIndexStoreREToIndexElemTestHook implements TestHook {
private CountDownLatch readyToStartRemoveLatch;
private CountDownLatch waitForRemoveLatch;
@@ -289,19 +295,19 @@ public class CompactRangeIndexJUnitTest {
try {
if (description.equals("ATTEMPT_REMOVE")) {
if (!readyToStartRemoveLatch.await(21, TimeUnit.SECONDS)) {
- throw new TestException("Time ran out waiting for other thread to initiate put");
+ throw new AssertionError("Time ran out waiting for other thread to initiate put");
}
}
else if (description.equals("TRANSITIONED_FROM_REGION_ENTRY_TO_ELEMARRAY")) {
readyToStartRemoveLatch.countDown();
if (!waitForRemoveLatch.await(21, TimeUnit.SECONDS)) {
- throw new TestException("Time ran out waiting for other thread to initiate remove");
+ throw new AssertionError("Time ran out waiting for other thread to initiate remove");
}
}
else if (description.equals("BEGIN_REMOVE_FROM_ELEM_ARRAY")) {
waitForRemoveLatch.countDown();
if (waitForTransitioned.await(21, TimeUnit.SECONDS)) {
- throw new TestException("Time ran out waiting for transition from region entry to elem array");
+ throw new AssertionError("Time ran out waiting for transition from region entry to elem array");
}
}
else if (description.equals("TRANSITIONED_FROM_REGION_ENTRY_TO_ELEMARRAY")) {
@@ -311,16 +317,17 @@ public class CompactRangeIndexJUnitTest {
}
}
catch (InterruptedException e) {
- throw new TestException("Interrupted while waiting for test to complete");
+ throw new AssertionError("Interrupted while waiting for test to complete");
}
}
}
-
-
- //Test hook that waits for another thread to begin removing
- //The current thread should then continue to set the token
- //then continue and convert to chs while holding the lock to the elem array still
- //After the conversion of chs, the lock is released and then remove can proceed
+
+ /**
+ * Test hook that waits for another thread to begin removing
+ * The current thread should then continue to set the token
+ * then continue and convert to chs while holding the lock to the elem array still
+ * After the conversion of chs, the lock is released and then remove can proceed
+ */
private class MemoryIndexStoreIndexElemToTokenToConcurrentHashSetTestHook implements TestHook {
private CountDownLatch waitForRemoveLatch;
@@ -334,27 +341,29 @@ public class CompactRangeIndexJUnitTest {
waitForRetry = new CountDownLatch(1);
readyToStartRemoveLatch = new CountDownLatch(1);
}
+
+ @Override
public void doTestHook(int spot) {
-
}
+ @Override
public void doTestHook(String description) {
try {
if (description.equals("ATTEMPT_REMOVE")) {
if (!readyToStartRemoveLatch.await(21, TimeUnit.SECONDS)) {
- throw new TestException("Time ran out waiting for other thread to initiate put");
+ throw new AssertionError("Time ran out waiting for other thread to initiate put");
}
}
else if (description.equals("BEGIN_TRANSITION_FROM_ELEMARRAY_TO_CONCURRENT_HASH_SET")) {
readyToStartRemoveLatch.countDown();
if (!waitForRemoveLatch.await(21, TimeUnit.SECONDS)) {
- throw new TestException("Time ran out waiting for other thread to initiate remove");
+ throw new AssertionError("Time ran out waiting for other thread to initiate remove");
}
}
else if (description.equals("BEGIN_REMOVE_FROM_ELEM_ARRAY")) {
waitForRemoveLatch.countDown();
if (!waitForTransitioned.await(21, TimeUnit.SECONDS)) {
- throw new TestException("Time ran out waiting for transition from elem array to token");
+ throw new AssertionError("Time ran out waiting for transition from elem array to token");
}
}
else if (description.equals("TRANSITIONED_FROM_ELEMARRAY_TO_TOKEN")) {
@@ -362,13 +371,11 @@ public class CompactRangeIndexJUnitTest {
}
}
catch (InterruptedException e) {
- throw new TestException("Interrupted while waiting for test to complete");
+ throw new AssertionError("Interrupted while waiting for test to complete");
}
}
}
-
-
private void putValues(int num) {
Region region = utils.getRegion("exampleRegion");
for (int i = 1; i <= num; i++) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexInitOnOverflowRegionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexInitOnOverflowRegionDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexInitOnOverflowRegionDUnitTest.java
index 4dc2890..1d044a6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexInitOnOverflowRegionDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexInitOnOverflowRegionDUnitTest.java
@@ -19,6 +19,15 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
+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.cache.AttributesFactory;
@@ -55,7 +64,8 @@ import com.gemstone.gemfire.test.dunit.Wait;
/**
*
*/
-public class ConcurrentIndexInitOnOverflowRegionDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class ConcurrentIndexInitOnOverflowRegionDUnitTest extends JUnit4CacheTestCase {
String name;
@@ -72,13 +82,14 @@ public class ConcurrentIndexInitOnOverflowRegionDUnitTest extends CacheTestCase
/**
* @param name
*/
- public ConcurrentIndexInitOnOverflowRegionDUnitTest(String name) {
- super(name);
+ public ConcurrentIndexInitOnOverflowRegionDUnitTest() {
+ super();
}
/**
*
*/
+ @Test
public void testAsyncIndexInitDuringEntryDestroyAndQueryOnRR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -187,6 +198,7 @@ public class ConcurrentIndexInitOnOverflowRegionDUnitTest extends CacheTestCase
/**
*
*/
+ @Test
public void testAsyncIndexInitDuringEntryPutUsingClientOnRR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -338,6 +350,7 @@ public class ConcurrentIndexInitOnOverflowRegionDUnitTest extends CacheTestCase
* This tests if index updates are blocked while region.clear() is
* called and indexes are being reinitialized.
*/
+ @Test
public void testIndexUpdateWithRegionClear() {
Host host = Host.getHost(0);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexOperationsOnOverflowRegionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexOperationsOnOverflowRegionDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexOperationsOnOverflowRegionDUnitTest.java
index 466483d..535840b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexOperationsOnOverflowRegionDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexOperationsOnOverflowRegionDUnitTest.java
@@ -19,6 +19,15 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
+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 java.util.Set;
@@ -56,23 +65,18 @@ import com.gemstone.gemfire.test.dunit.Wait;
*
*
*/
+@Category(DistributedTest.class)
public class ConcurrentIndexOperationsOnOverflowRegionDUnitTest extends
- CacheTestCase {
+ JUnit4CacheTestCase {
String name;
public static volatile boolean hooked = false;
/**
- * @param name
- */
- public ConcurrentIndexOperationsOnOverflowRegionDUnitTest(String name) {
- super(name);
- }
-
- /**
*
*/
+ @Test
public void testAsyncIndexInitDuringEntryDestroyAndQueryOnRR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -175,6 +179,7 @@ public class ConcurrentIndexOperationsOnOverflowRegionDUnitTest extends
/**
*
*/
+ @Test
public void testAsyncIndexInitDuringEntryDestroyAndQueryOnPR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -277,6 +282,7 @@ public class ConcurrentIndexOperationsOnOverflowRegionDUnitTest extends
/**
*
*/
+ @Test
public void testAsyncIndexInitDuringEntryDestroyAndQueryOnPersistentRR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -382,6 +388,7 @@ public class ConcurrentIndexOperationsOnOverflowRegionDUnitTest extends
/**
*
*/
+ @Test
public void testAsyncIndexInitDuringEntryDestroyAndQueryOnPersistentPR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -487,7 +494,8 @@ public class ConcurrentIndexOperationsOnOverflowRegionDUnitTest extends
/**
*
*/
- public void testAsyncIndexInitDuringEntryDestroyAndQueryOnNonOverflowRR() {
+ @Test
+ public void testAsyncIndexInitDuringEntryDestroyAndQueryOnNonOverflowRR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
hooked = false;
@@ -580,7 +588,8 @@ public class ConcurrentIndexOperationsOnOverflowRegionDUnitTest extends
/**
*
*/
- public void testAsyncIndexInitDuringEntryDestroyAndQueryOnOnNonOverflowPR() {
+ @Test
+ public void testAsyncIndexInitDuringEntryDestroyAndQueryOnOnNonOverflowPR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
hooked = false;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest.java
index de87304..0061ec3 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest.java
@@ -19,7 +19,18 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
-import com.gemstone.gemfire.cache.*;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+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.Region;
import com.gemstone.gemfire.cache.query.Index;
import com.gemstone.gemfire.cache.query.IndexStatistics;
import com.gemstone.gemfire.cache.query.data.Portfolio;
@@ -31,13 +42,24 @@ import com.gemstone.gemfire.cache.query.partitioned.PRQueryDUnitHelper;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.cache.*;
+import com.gemstone.gemfire.internal.cache.CachedDeserializable;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.RegionEntry;
+import com.gemstone.gemfire.internal.cache.Token;
import com.gemstone.gemfire.internal.cache.persistence.query.CloseableIterator;
-import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.SerializableRunnableIF;
+import com.gemstone.gemfire.test.dunit.ThreadUtils;
+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 java.util.Collection;
/**
* This test is similar to {@link ConcurrentIndexUpdateWithoutWLDUnitTest} except
@@ -47,7 +69,8 @@ import java.util.Collection;
* During validation all region operations are paused for a while. Validation
* happens multiple time during one test run on a fixed time interval.
*/
-public class ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest extends DistributedTestCase {
+@Category(DistributedTest.class)
+public class ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest extends JUnit4DistributedTestCase {
PRQueryDUnitHelper helper = new PRQueryDUnitHelper();
private static String regionName = "Portfolios";
@@ -92,13 +115,6 @@ public class ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest extends Dis
}
}
- /**
- * @param name
- */
- public ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest(String name) {
- super(name);
- }
-
@Override
public final void preSetUp() throws Exception {
Invoke.invokeInEveryVM(new CacheSerializableRunnable("Set INPLACE_OBJECT_MODIFICATION false") {
@@ -138,6 +154,7 @@ public class ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest extends Dis
}
// Tests on Local/Replicated Region
+ @Test
public void testCompactRangeIndex() {
// Create a Local Region.
Host host = Host.getHost(0);
@@ -184,6 +201,7 @@ public class ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest extends Dis
}
@Category(FlakyTest.class) // GEODE-431: time sensitive, uses PRQueryDUnitHelper whcih eats exceptions, async actions, uses Random
+ @Test
public void testRangeIndex() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -212,6 +230,7 @@ public class ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest extends Dis
}
// Tests on Partition Region
+ @Test
public void testCompactRangeIndexOnPR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -275,6 +294,7 @@ public class ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest extends Dis
}
+ @Test
public void testRangeIndexOnPR() {
Host host = Host.getHost(0);
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/cache/query/internal/index/ConcurrentIndexUpdateWithoutWLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithoutWLDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithoutWLDUnitTest.java
index cd18314..791327c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithoutWLDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/ConcurrentIndexUpdateWithoutWLDUnitTest.java
@@ -19,7 +19,19 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
-import com.gemstone.gemfire.cache.*;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+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.Region;
import com.gemstone.gemfire.cache.query.Index;
import com.gemstone.gemfire.cache.query.IndexStatistics;
import com.gemstone.gemfire.cache.query.data.Portfolio;
@@ -31,22 +43,30 @@ import com.gemstone.gemfire.cache.query.partitioned.PRQueryDUnitHelper;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.cache.*;
+import com.gemstone.gemfire.internal.cache.CachedDeserializable;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.RegionEntry;
+import com.gemstone.gemfire.internal.cache.Token;
import com.gemstone.gemfire.internal.cache.persistence.query.CloseableIterator;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.util.ArrayList;
-import java.util.Collection;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.SerializableRunnableIF;
+import com.gemstone.gemfire.test.dunit.ThreadUtils;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
- *
* During validation all region operations are paused for a while. Validation
* happens multiple time during one test run on a fixed time interval.
- *
- *
*/
-public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
- DistributedTestCase {
+@Category(DistributedTest.class)
+public class ConcurrentIndexUpdateWithoutWLDUnitTest extends JUnit4DistributedTestCase {
PRQueryDUnitHelper helper = new PRQueryDUnitHelper();
private static String regionName = "Portfolios";
@@ -66,13 +86,6 @@ public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
int stepSize = 10;
private int totalDataSize = 50;
- /**
- * @param name
- */
- public ConcurrentIndexUpdateWithoutWLDUnitTest(String name) {
- super(name);
- }
-
public void setCacheInVMs(VM... vms) {
for (VM vm : vms) {
vm.invoke(() -> getAvailableCacheElseCreateCache());
@@ -115,7 +128,9 @@ public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
if (region != null) region.destroyRegion();
}
}
+
// Tests on Local/Replicated Region
+ @Test
public void testCompactRangeIndex() {
// Create a Local Region.
Host host = Host.getHost(0);
@@ -145,6 +160,7 @@ public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
}
+ @Test
public void testMultiIndexCreation() {
// Create a Local Region.
Host host = Host.getHost(0);
@@ -201,6 +217,7 @@ public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
};
}
+ @Test
public void testRangeIndex() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -229,6 +246,7 @@ public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
}
// Tests on Partition Region
+ @Test
public void testCompactRangeIndexOnPR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -291,6 +309,7 @@ public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
vm3.invoke(getCacheSerializableRunnableForIndexValidation(regionName, indexName));
}
+ @Test
public void testRangeIndexOnPR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -352,6 +371,7 @@ public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
vm3.invoke(getCacheSerializableRunnableForIndexValidation(regionName, rindexName));
}
+ @Test
public void testMultiIndexOnPR() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@ -427,13 +447,10 @@ public class ConcurrentIndexUpdateWithoutWLDUnitTest extends
/**
* This validator will iterate over RegionEntries and verify their corresponding
* index key and entry presence in index valuesToEntriesMap.
- *
- *
*/
- public class IndexValidator {
+ private static class IndexValidator {
public IndexValidator() {
-
}
private boolean isValidationInProgress;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java
index 5f8080b..790421e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java
@@ -16,35 +16,58 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
-import com.gemstone.gemfire.cache.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheTransactionManager;
+import com.gemstone.gemfire.cache.CommitConflictException;
+import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
-import com.gemstone.gemfire.cache.query.*;
+import com.gemstone.gemfire.cache.query.Index;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.QueryTestUtils;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.Struct;
import com.gemstone.gemfire.cache.query.data.Portfolio;
import com.gemstone.gemfire.cache.query.data.Position;
import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
-import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.internal.AvailablePortHelper;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.internal.cache.PartitionedRegion;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
+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.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-public class CopyOnReadIndexDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class CopyOnReadIndexDUnitTest extends JUnit4CacheTestCase {
VM vm0;
VM vm1;
VM vm2;
- public CopyOnReadIndexDUnitTest(String name) {
- super(name);
+ public CopyOnReadIndexDUnitTest() {
+ super();
}
@Override
@@ -67,6 +90,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase {
}
//test different queries against partitioned region
+ @Test
public void testPRQueryOnLocalNode() throws Exception {
QueryTestUtils utils = new QueryTestUtils();
configureServers();
@@ -84,6 +108,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase {
}
//tests different queries with a transaction for replicated region
+ @Test
public void testTransactionsOnReplicatedRegion() throws Exception {
QueryTestUtils utils = new QueryTestUtils();
configureServers();