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/03 19:56:50 UTC
[4/7] incubator-geode git commit: Convert junit3 to junit4 and
cleanup tests.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/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/7e9d4a62/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/7e9d4a62/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 3487ab9..1e47bc0 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,6 +16,8 @@
*/
package com.gemstone.gemfire.cache.query.functional;
+import static org.junit.Assert.*;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.ParseException;
@@ -29,10 +31,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.DataPolicy;
@@ -48,10 +46,6 @@ import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-/**
- *
- *
- */
@Category(IntegrationTest.class)
public class NumericQueryJUnitTest {
@@ -59,7 +53,6 @@ public class NumericQueryJUnitTest {
private static Region testRegion;
private static int numElem = 100;
-
private static String EQ = "=";
private static String LT = "<";
private static String GT = ">";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/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/7e9d4a62/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/7e9d4a62/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/7e9d4a62/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 cb32555..230a17f 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,12 +19,21 @@
*/
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.query.Index;
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.QueryService;
import com.gemstone.gemfire.cache.query.data.Portfolio;
@@ -33,46 +42,25 @@ import com.gemstone.gemfire.test.dunit.Wait;
import com.gemstone.gemfire.test.dunit.WaitCriterion;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import static org.junit.Assert.*;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
@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
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java
index e22129c..c9106f6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java
@@ -20,11 +20,11 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
+import static org.junit.Assert.*;
+
import java.util.Collection;
import java.util.Properties;
-import junit.framework.Assert;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -36,14 +36,9 @@ import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.cache.query.CacheUtils;
import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.util.test.TestUtil;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.test.TestUtil;
-/**
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
@Category(IntegrationTest.class)
public class DeclarativeIndexCreationJUnitTest {
@@ -76,13 +71,12 @@ public class DeclarativeIndexCreationJUnitTest {
IndexManager im = IndexUtils.getIndexManager(root, true);
Collection coll = im.getIndexes();
if (coll.size() > 0) {
- Assert.assertTrue(true);
+ assertTrue(true);
CacheUtils.log("List of indexes= " + im.toString());
RegionAttributes ra = root.getAttributes();
- Assert.assertTrue(!ra.getIndexMaintenanceSynchronous());
+ assertTrue(!ra.getIndexMaintenanceSynchronous());
} else
- Assert
- .fail("DeclarativeIndexCreationJUnitTest::testAsynchronousIndexCreatedOnRoot_PortfoliosRegion:No index found in the root region");
+ fail("DeclarativeIndexCreationJUnitTest::testAsynchronousIndexCreatedOnRoot_PortfoliosRegion:No index found in the root region");
}
@Test
@@ -91,18 +85,16 @@ public class DeclarativeIndexCreationJUnitTest {
IndexManager im = IndexUtils.getIndexManager(root, true);
Collection coll = im.getIndexes();
if (coll.size() > 0) {
- Assert.assertTrue(true);
+ assertTrue(true);
CacheUtils.log("List of indexes= " + im.toString());
RegionAttributes ra = root.getAttributes();
- Assert.assertTrue(ra.getIndexMaintenanceSynchronous());
+ assertTrue(ra.getIndexMaintenanceSynchronous());
} else
- Assert
- .fail("DeclarativeIndexCreationJUnitTest::testSynchronousIndexCreatedOnRoot_StringRegion Region:No index found in the root region");
+ fail("DeclarativeIndexCreationJUnitTest::testSynchronousIndexCreatedOnRoot_StringRegion Region:No index found in the root region");
root = cache.getRegion("/root/string1");
im = IndexUtils.getIndexManager(root, true);
if (!im.isIndexMaintenanceTypeSynchronous())
- Assert
- .fail("DeclarativeIndexCreationJUnitTest::testSynchronousIndexCreatedOnRoot_StringRegion: The index update type not synchronous if no index-update-type attribuet specified in cache.cml");
+ fail("DeclarativeIndexCreationJUnitTest::testSynchronousIndexCreatedOnRoot_StringRegion: The index update type not synchronous if no index-update-type attribuet specified in cache.cml");
}
@Test
@@ -111,12 +103,11 @@ public class DeclarativeIndexCreationJUnitTest {
IndexManager im = IndexUtils.getIndexManager(root, true);
Collection coll = im.getIndexes();
if (coll.size() > 0) {
- Assert.assertTrue(true);
+ assertTrue(true);
CacheUtils.log("List of indexes= " + im.toString());
RegionAttributes ra = root.getAttributes();
- Assert.assertTrue(ra.getIndexMaintenanceSynchronous());
+ assertTrue(ra.getIndexMaintenanceSynchronous());
} else
- Assert
- .fail("DeclarativeIndexCreationJUnitTest::testAsynchronousIndexCreatedOnRoot_PortfoliosRegion:No index found in the root region");
+ fail("DeclarativeIndexCreationJUnitTest::testAsynchronousIndexCreatedOnRoot_PortfoliosRegion:No index found in the root region");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PdxCopyOnReadQueryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PdxCopyOnReadQueryJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PdxCopyOnReadQueryJUnitTest.java
index 74abe21..beae31e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PdxCopyOnReadQueryJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PdxCopyOnReadQueryJUnitTest.java
@@ -16,18 +16,14 @@
*/
package com.gemstone.gemfire.cache.query.internal.index;
-import java.sql.Timestamp;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.List;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Region;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml57DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml57DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml57DUnitTest.java
index 6412587..8a31e35 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml57DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml57DUnitTest.java
@@ -16,15 +16,8 @@
*/
package com.gemstone.gemfire.cache30;
-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 java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -32,6 +25,9 @@ import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Properties;
+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.CustomExpiry;
@@ -62,53 +58,33 @@ import com.gemstone.gemfire.internal.cache.xmlcache.Declarable2;
import com.gemstone.gemfire.internal.cache.xmlcache.RegionAttributesCreation;
import com.gemstone.gemfire.internal.cache.xmlcache.RegionCreation;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.IgnoredException;
import com.gemstone.gemfire.test.dunit.NetworkUtils;
-import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.VM;
-
-import junit.framework.Assert;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
* Tests 5.7 cache.xml features.
*
* @since 5.7
*/
-
@Category(DistributedTest.class)
-public class CacheXml57DUnitTest extends CacheXml55DUnitTest
-{
- //
+public class CacheXml57DUnitTest extends CacheXml55DUnitTest {
+
private final static String ALIAS1;
private final static String ALIAS2;
static {
String tmp_alias1 = "localhost";
String tmp_alias2 = "localhost";
-// try {
-// tmp_alias1 = getServerHostName(Host.getHost(0));
-// InetSocketAddress addr = createINSA(tmp_alias1, 10000);
-// tmp_alias2 = addr.getHostName();
-// } catch (IllegalArgumentException suppress) {
-// //The runnables dont have a Host object initialized, but they dont need
-// //access to the aliases so its ok to suppress this.
-// } finally {
- ALIAS1 = tmp_alias1;
- ALIAS2 = tmp_alias2;
-// }
+ ALIAS1 = tmp_alias1;
+ ALIAS2 = tmp_alias2;
}
- // ////// Constructors
-
- public CacheXml57DUnitTest() {
- super();
- }
-
- // ////// Helper methods
-
- protected String getGemFireVersion()
- {
+ @Override
+ protected String getGemFireVersion() {
return CacheXml.VERSION_5_7;
}
@@ -128,6 +104,7 @@ public class CacheXml57DUnitTest extends CacheXml55DUnitTest
assertNotNull(server);
assertEquals(CacheServer.DEFAULT_GROUPS, server.getGroups());
}
+
@Test
public void testOneCacheServerGroups() throws CacheException {
CacheCreation cache = new CacheCreation();
@@ -472,7 +449,7 @@ public class CacheXml57DUnitTest extends CacheXml55DUnitTest
Cache c= getCache();
server = c.getCacheServers().get(0);
- Assert.assertEquals(MyLoadProbe.class,server.getLoadProbe().getClass());
+ assertEquals(MyLoadProbe.class,server.getLoadProbe().getClass());
}
@Test
@@ -486,7 +463,7 @@ public class CacheXml57DUnitTest extends CacheXml55DUnitTest
Cache c = getCache();
server = c.getCacheServers().get(0);
- Assert.assertEquals(12345, server.getLoadPollInterval());
+ assertEquals(12345, server.getLoadPollInterval());
}
public static class MyLoadProbe extends ServerLoadProbeAdapter implements Declarable {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckPersistentRegionCCEDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckPersistentRegionCCEDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckPersistentRegionCCEDUnitTest.java
index 1d4a393..d87fe4b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckPersistentRegionCCEDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckPersistentRegionCCEDUnitTest.java
@@ -19,53 +19,24 @@
*
*/
package com.gemstone.gemfire.cache30;
-
-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 org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.cache.AttributesFactory;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheException;
import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.cache.RegionFactory;
import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.cache.DistributedCacheOperation;
-import com.gemstone.gemfire.internal.cache.DistributedRegion;
-import com.gemstone.gemfire.internal.cache.LocalRegion;
-import com.gemstone.gemfire.internal.cache.tier.sockets.Part;
import com.gemstone.gemfire.internal.cache.versions.VersionTag;
-import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.test.dunit.AsyncInvocation;
-import com.gemstone.gemfire.test.dunit.Host;
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.junit.categories.DistributedTest;
-import java.io.IOException;
-import java.util.Map;
-
-import junit.framework.Assert;
-
-@Category(DistributedTest.class)
+@Category(DistributedTest.class)
public class DistributedAckPersistentRegionCCEDUnitTest extends DistributedAckRegionCCEDUnitTest {
- public DistributedAckPersistentRegionCCEDUnitTest() {
- super();
- }
-
- /**
- * Returns region attributes for a <code>GLOBAL</code> region
- */
+ @Override
protected RegionAttributes getRegionAttributes() {
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -74,29 +45,24 @@ public class DistributedAckPersistentRegionCCEDUnitTest extends DistributedAckRe
return factory.create();
}
-// public void testClearWithConcurrentEventsAsync() throws Exception {
-// int end = 100;
-// for (int i=0; i<end; i++) {
-// System.out.println("Starting run #" + i);
-// super.testClearWithConcurrentEventsAsync();
-// if (i<(end-1)) {
-// tearDown();
-// setUp();
-// }
-// }
-// }
-
- @Test
+ @Ignore("Skip test for this configuration")
+ @Override
+ @Test
public void testClearOnNonReplicateWithConcurrentEvents() {}
-
- @Test
+
+ @Ignore("Skip test for this configuration")
+ @Override
+ @Test
public void testConcurrentEventsOnNonReplicatedRegion() {}
-
- @Test
+
+ @Ignore("Skip test for this configuration")
+ @Override
+ @Test
public void testGetAllWithVersions() {}
private VersionTag getVersionTag(VM vm, final String key) {
SerializableCallable getVersionTag = new SerializableCallable("verify recovered entry") {
+ @Override
public Object call() {
VersionTag tag = CCRegion.getVersionTag(key);
return tag;
@@ -105,7 +71,8 @@ public class DistributedAckPersistentRegionCCEDUnitTest extends DistributedAckRe
};
return (VersionTag)vm.invoke(getVersionTag);
}
-
+
+ // TODO: resurrect dead test or delete the following dead code
// protected void do_version_recovery_if_necessary(final VM vm0, final VM vm1, final VM vm2, final Object[] params) {
// final String name = (String)params[0];
// final String hostName = (String)params[1];
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/ClassAndMethodDetails.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/ClassAndMethodDetails.java b/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/ClassAndMethodDetails.java
index a5dfb12..7e87621 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/ClassAndMethodDetails.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/ClassAndMethodDetails.java
@@ -1,20 +1,21 @@
-/*
- * 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.
- */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.gemstone.gemfire.codeAnalysis;
+
import java.io.IOException;
import java.io.LineNumberReader;
import java.util.ArrayList;
@@ -23,21 +24,18 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.Assert;
-
import com.gemstone.gemfire.codeAnalysis.decode.CompiledClass;
import com.gemstone.gemfire.codeAnalysis.decode.CompiledCode;
import com.gemstone.gemfire.codeAnalysis.decode.CompiledMethod;
-
/**
* A class used to store the names of dataserializable classes and the sizes
* of their toData/fromData methods.
- *
- *
*/
public class ClassAndMethodDetails implements Comparable {
+
static String[] hexChars;
+
public String className;
public Map<String, byte[]> methodCode = new HashMap<String, byte[]>();
@@ -150,4 +148,4 @@ public class ClassAndMethodDetails implements Comparable {
public int compareTo(Object other) {
return this.className.compareTo(((ClassAndMethodDetails)other).className);
}
-}
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
index 2ad970b..76374e2 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
@@ -17,7 +17,8 @@
package com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
import static org.junit.Assert.*;
-import static org.mockito.Matchers.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.*;
import java.io.ByteArrayInputStream;
@@ -25,19 +26,16 @@ import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import org.apache.commons.lang.SerializationException;
import org.jgroups.Address;
import org.jgroups.Event;
import org.jgroups.JChannel;
import org.jgroups.Message;
-import org.jgroups.Message.Flag;
import org.jgroups.conf.ClassConfigurator;
import org.jgroups.protocols.UNICAST3;
import org.jgroups.protocols.pbcast.NAKACK2;
@@ -51,7 +49,6 @@ import com.gemstone.gemfire.ForcedDisconnectException;
import com.gemstone.gemfire.GemFireIOException;
import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
import com.gemstone.gemfire.distributed.internal.DM;
-import com.gemstone.gemfire.distributed.internal.DMStats;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
import com.gemstone.gemfire.distributed.internal.DistributionManager;
@@ -83,10 +80,9 @@ import com.gemstone.gemfire.internal.cache.DistributedCacheOperation;
import com.gemstone.gemfire.internal.logging.log4j.AlertAppender;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.Assert;
-
@Category(IntegrationTest.class)
public class JGroupsMessengerJUnitTest {
+
private Services services;
private JGroupsMessenger messenger;
private JoinLeave joinLeave;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerJUnitTest.java
index 9b1b8d3..425b391 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerJUnitTest.java
@@ -16,20 +16,19 @@
*/
package com.gemstone.gemfire.distributed.internal.tcpserver;
+import static org.junit.Assert.*;
+
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.net.ConnectException;
import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import junit.framework.Assert;
-
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -44,12 +43,12 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
public class TcpServerJUnitTest {
- protected/*GemStoneAddition*/ InetAddress localhost;
- protected/*GemStoneAddition*/ int port;
+ private/*GemStoneAddition*/ InetAddress localhost;
+ private/*GemStoneAddition*/ int port;
private SimpleStats stats;
private TcpServer server;
- public void start(TcpHandler handler) throws IOException {
+ private void start(TcpHandler handler) throws IOException {
localhost = InetAddress.getLocalHost();
port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
@@ -59,18 +58,18 @@ public class TcpServerJUnitTest {
}
@Test
- public void test() throws UnknownHostException, IOException, ClassNotFoundException, InterruptedException {
+ public void test() throws Exception {
EchoHandler handler = new EchoHandler();
start(handler);
TestObject test = new TestObject();
test.id = 5;
TestObject result = (TestObject) TcpClient.requestToServer(localhost, port, test, 60 * 1000 );
- Assert.assertEquals(test.id, result.id);
+ assertEquals(test.id, result.id);
String[] info = TcpClient.getInfo(localhost, port);
- Assert.assertNotNull(info);
- Assert.assertTrue(info.length > 1);
+ assertNotNull(info);
+ assertTrue(info.length > 1);
try {
TcpClient.stop(localhost, port);
@@ -78,16 +77,16 @@ public class TcpServerJUnitTest {
// must not be running
}
server.join(60 * 1000);
- Assert.assertFalse(server.isAlive());
- Assert.assertTrue(handler.shutdown);
+ assertFalse(server.isAlive());
+ assertTrue(handler.shutdown);
- Assert.assertEquals(4, stats.started.get());
- Assert.assertEquals(4, stats.ended.get());
+ assertEquals(4, stats.started.get());
+ assertEquals(4, stats.ended.get());
}
@Test
- public void testConcurrency() throws UnknownHostException, IOException, ClassNotFoundException, InterruptedException {
+ public void testConcurrency() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
DelayHandler handler = new DelayHandler(latch);
start(handler);
@@ -109,17 +108,17 @@ public class TcpServerJUnitTest {
delayedThread.start();
try {
Thread.sleep(500);
- Assert.assertFalse(done.get());
+ assertFalse(done.get());
TcpClient.requestToServer(localhost, port, Boolean.valueOf(false), 60 * 1000 );
- Assert.assertFalse(done.get());
+ assertFalse(done.get());
latch.countDown();
Thread.sleep(500);
- Assert.assertTrue(done.get());
+ assertTrue(done.get());
} finally {
latch.countDown();
delayedThread.join(60 * 1000);
- Assert.assertTrue(!delayedThread.isAlive()); // GemStoneAddition
+ assertTrue(!delayedThread.isAlive()); // GemStoneAddition
try {
TcpClient.stop(localhost, port);
} catch ( ConnectException ignore ) {
@@ -128,8 +127,8 @@ public class TcpServerJUnitTest {
server.join(60 * 1000);
}
}
-
- public static class TestObject implements DataSerializable {
+
+ private static class TestObject implements DataSerializable {
int id;
public TestObject() {
@@ -146,7 +145,7 @@ public class TcpServerJUnitTest {
}
- protected/*GemStoneAddition*/ static class EchoHandler implements TcpHandler {
+ private/*GemStoneAddition*/ static class EchoHandler implements TcpHandler {
protected/*GemStoneAddition*/ boolean shutdown;
@@ -202,8 +201,8 @@ public class TcpServerJUnitTest {
public void endRequest(Object request,long startTime) { }
public void endResponse(Object request,long startTime) { }
}
-
- protected/*GemStoneAddition*/ static class SimpleStats implements PoolStatHelper {
+
+ private/*GemStoneAddition*/ static class SimpleStats implements PoolStatHelper {
AtomicInteger started = new AtomicInteger();
AtomicInteger ended = new AtomicInteger();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java
index e4db285..c16587e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java
@@ -16,31 +16,27 @@
*/
package com.gemstone.gemfire.disttx;
+import static org.junit.Assert.*;
+
import java.util.Properties;
-import com.gemstone.gemfire.internal.cache.TXManagerImpl;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.CacheTransactionManager;
import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.internal.cache.TXManagerImpl;
import com.gemstone.gemfire.internal.cache.TXManagerImplJUnitTest;
import com.gemstone.gemfire.test.junit.categories.DistributedTransactionsTest;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import static junit.framework.TestCase.assertTrue;
-
/**
* Same tests as that of {@link TXManagerImplJUnitTest} after setting
* "distributed-transactions" property to true
- *
*/
@Category({IntegrationTest.class, DistributedTransactionsTest.class })
public class DistTXManagerImplJUnitTest extends TXManagerImplJUnitTest {
- public DistTXManagerImplJUnitTest() {
- }
-
@Override
protected void createCache() {
Properties props = new Properties();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/JarClassLoaderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/JarClassLoaderJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/JarClassLoaderJUnitTest.java
index 56b715f..dbcd795 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/JarClassLoaderJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/JarClassLoaderJUnitTest.java
@@ -16,12 +16,7 @@
*/
package com.gemstone.gemfire.internal;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -60,34 +55,10 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* TODO: Need to fix this testDeclarableFunctionsWithParms and testClassOnClasspath on Windows:
- *
- * java.io.IOException: The process cannot access the file because another process has locked a portion of the file
- at java.io.FileOutputStream.writeBytes(Native Method)
- at java.io.FileOutputStream.write(FileOutputStream.java:325)
- at com.gemstone.gemfire.internal.JarClassLoaderJUnitTest.writeJarBytesToFile(JarClassLoaderJUnitTest.java:704)
- at com.gemstone.gemfire.internal.JarClassLoaderJUnitTest.testDeclarableFunctionsWithParms(JarClassLoaderJUnitTest.java:412)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:606)
- at junit.framework.TestCase.runTest(TestCase.java:176)
- at junit.framework.TestCase.runBare(TestCase.java:141)
- at junit.framework.TestResult$1.protect(TestResult.java:122)
- at junit.framework.TestResult.runProtected(TestResult.java:142)
- at junit.framework.TestResult.run(TestResult.java:125)
- at junit.framework.TestCase.run(TestCase.java:129)
- at junit.framework.TestSuite.runTest(TestSuite.java:255)
- at junit.framework.TestSuite.run(TestSuite.java:250)
- at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
- at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
- at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
*/
@Category(IntegrationTest.class)
public class JarClassLoaderJUnitTest {
+
private static final String JAR_PREFIX = "vf.gf#";
private final ClassBuilder classBuilder = new ClassBuilder();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/Bug40632DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/Bug40632DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/Bug40632DUnitTest.java
index 4305a90..e35a357 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/Bug40632DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/Bug40632DUnitTest.java
@@ -16,71 +16,25 @@
*/
package com.gemstone.gemfire.internal.cache;
-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.Collections;
-import java.util.Set;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import junit.framework.TestCase;
+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.CacheLoader;
-import com.gemstone.gemfire.cache.CacheLoaderException;
-import com.gemstone.gemfire.cache.CacheWriterException;
-import com.gemstone.gemfire.cache.EntryEvent;
import com.gemstone.gemfire.cache.ExpirationAction;
import com.gemstone.gemfire.cache.ExpirationAttributes;
-import com.gemstone.gemfire.cache.LoaderHelper;
import com.gemstone.gemfire.cache.PartitionAttributes;
import com.gemstone.gemfire.cache.PartitionAttributesFactory;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.control.RebalanceOperation;
-import com.gemstone.gemfire.cache.control.RebalanceResults;
-import com.gemstone.gemfire.cache.control.ResourceManager;
-import com.gemstone.gemfire.cache.partition.PartitionMemberInfo;
-import com.gemstone.gemfire.cache.partition.PartitionRebalanceInfo;
-import com.gemstone.gemfire.cache.partition.PartitionRegionInfo;
-import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
-import com.gemstone.gemfire.cache30.CacheTestCase;
-import com.gemstone.gemfire.distributed.DistributedMember;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.cache.PRHARedundancyProvider;
-import com.gemstone.gemfire.internal.cache.PartitionedRegion;
-import com.gemstone.gemfire.internal.cache.control.InternalResourceManager;
-import com.gemstone.gemfire.internal.cache.control.ResourceManagerStats;
-import com.gemstone.gemfire.internal.cache.control.InternalResourceManager.ResourceObserverAdapter;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-/**
- *
- */
@Category(DistributedTest.class)
public class Bug40632DUnitTest extends JUnit4CacheTestCase {
- /**
- * @param name
- */
- public Bug40632DUnitTest() {
- super();
- }
-
@Test
- public void testLocalDestroyIdleTimeout() {
+ public void testLocalDestroyIdleTimeout() throws Exception {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
@@ -95,12 +49,11 @@ public class Bug40632DUnitTest extends JUnit4CacheTestCase {
cache.createRegion("region1", attr.create());
fail("We should not have been able to create the region");
} catch(IllegalStateException expected) {
-
}
}
@Test
- public void testLocalDestroyTimeToLive() {
+ public void testLocalDestroyTimeToLive() throws Exception {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
@@ -112,15 +65,14 @@ public class Bug40632DUnitTest extends JUnit4CacheTestCase {
attr.setEntryTimeToLive(new ExpirationAttributes(1000, ExpirationAction.LOCAL_DESTROY));
attr.setPartitionAttributes(prAttr);
try {
- cache.createRegion("region1", attr.create());
- fail("We should not have been able to create the region");
+ cache.createRegion("region1", attr.create());
+ fail("We should not have been able to create the region");
} catch(IllegalStateException expected) {
-
}
}
@Test
- public void testLocalInvalidateIdleTimeout() {
+ public void testLocalInvalidateIdleTimeout() throws Exception {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
@@ -132,15 +84,14 @@ public class Bug40632DUnitTest extends JUnit4CacheTestCase {
attr.setEntryIdleTimeout(new ExpirationAttributes(1000, ExpirationAction.LOCAL_INVALIDATE));
attr.setPartitionAttributes(prAttr);
try {
- cache.createRegion("region1", attr.create());
- fail("We should not have been able to create the region");
+ cache.createRegion("region1", attr.create());
+ fail("We should not have been able to create the region");
} catch(IllegalStateException expected) {
-
}
}
@Test
- public void testLocalInvalidateTimeToLive() {
+ public void testLocalInvalidateTimeToLive() throws Exception {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
@@ -152,10 +103,9 @@ public class Bug40632DUnitTest extends JUnit4CacheTestCase {
attr.setEntryTimeToLive(new ExpirationAttributes(1000, ExpirationAction.LOCAL_INVALIDATE));
attr.setPartitionAttributes(prAttr);
try {
- cache.createRegion("region1", attr.create());
- fail("We should not have been able to create the region");
+ cache.createRegion("region1", attr.create());
+ fail("We should not have been able to create the region");
} catch(IllegalStateException expected) {
-
}
}
}