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:53 UTC
[7/7] incubator-geode git commit: Convert junit3 to junit4 and
cleanup tests.
Convert junit3 to junit4 and cleanup tests.
* remove unused junit3 classes
* rename misnamed test
* fixup imports, delete empty or worthless javadocs, remove deadcode
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/7e9d4a62
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/7e9d4a62
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/7e9d4a62
Branch: refs/heads/feature/GEODE-837
Commit: 7e9d4a62a1f7569e0d4fb4f1fb26b7fc14f2f5a6
Parents: 497208f
Author: Kirk Lund <kl...@apache.org>
Authored: Fri Jun 3 12:55:24 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Fri Jun 3 12:55:24 2016 -0700
----------------------------------------------------------------------
.../gemstone/gemfire/modules/SecondVMTest.java | 24 +-
.../session/internal/filter/CommonTests.java | 16 +-
.../modules/session/TestSessionsBase.java | 25 +-
.../RestAPIsQueryAndFEJUnitTest.java | 16 +-
.../com/gemstone/gemfire/JUnitTestSetup.java | 143 --
.../com/gemstone/gemfire/TimingTestCase.java | 77 -
.../com/gemstone/gemfire/UnitTestDoclet.java | 263 ----
.../cache/ConnectionPoolAndLoaderDUnitTest.java | 168 +--
.../mapInterface/PutAllGlobalLockJUnitTest.java | 4 +-
.../gemfire/cache/query/QueryTestUtils.java | 12 -
.../query/dunit/CloseCacheAuthorization.java | 11 +-
.../cache/query/dunit/QueryAuthorization.java | 18 +-
.../query/functional/ConstantsJUnitTest.java | 21 +-
.../query/functional/CountStarJUnitTest.java | 513 +++----
.../query/functional/FunctionJUnitTest.java | 10 +-
.../IUMRShuffleIteratorsJUnitTest.java | 369 ++---
.../IndexCreationDeadLockJUnitTest.java | 79 +-
.../functional/IndexCreationJUnitTest.java | 1405 ++++++++----------
.../IndexUsageWithAliasAsProjAtrbt.java | 176 ---
...IndexUsageWithAliasAsProjAtrbtJUnitTest.java | 92 +-
.../functional/LikePredicateJUnitTest.java | 42 +-
.../cache/query/functional/MiscJUnitTest.java | 305 +---
.../query/functional/NumericQueryJUnitTest.java | 11 +-
.../query/functional/StructSetOrResultsSet.java | 86 +-
.../query/functional/TestNewFunctionSSorRS.java | 128 --
.../TestNewFunctionSSorRSIntegrationTest.java | 128 ++
.../index/AsynchIndexMaintenanceJUnitTest.java | 50 +-
.../DeclarativeIndexCreationJUnitTest.java | 35 +-
.../index/PdxCopyOnReadQueryJUnitTest.java | 8 +-
.../gemfire/cache30/CacheXml57DUnitTest.java | 51 +-
...tributedAckPersistentRegionCCEDUnitTest.java | 75 +-
.../codeAnalysis/ClassAndMethodDetails.java | 42 +-
.../messenger/JGroupsMessengerJUnitTest.java | 10 +-
.../internal/tcpserver/TcpServerJUnitTest.java | 47 +-
.../disttx/DistTXManagerImplJUnitTest.java | 10 +-
.../internal/JarClassLoaderJUnitTest.java | 33 +-
.../internal/cache/Bug40632DUnitTest.java | 78 +-
.../cache/CacheLifecycleListenerJUnitTest.java | 27 +-
.../cache/ConcurrentMapLocalJUnitTest.java | 11 +-
...rentRollingAndRegionOperationsJUnitTest.java | 145 +-
.../cache/DiskOfflineCompactionJUnitTest.java | 62 +-
.../internal/cache/DiskOldAPIsJUnitTest.java | 39 +-
.../cache/DiskRegCacheXmlJUnitTest.java | 77 +-
.../cache/DiskRegionClearJUnitTest.java | 139 +-
.../DiskRegionIllegalArguementsJUnitTest.java | 17 +-
...iskRegionIllegalCacheXMLvaluesJUnitTest.java | 52 +-
.../cache/DiskStoreFactoryJUnitTest.java | 44 +-
.../cache/OfflineSnapshotJUnitTest.java | 16 +-
.../gemfire/internal/cache/OplogJUnitTest.java | 24 +-
.../cache/PRDataStoreMemoryJUnitTest.java | 21 +-
...tionedRegionSerializableObjectJUnitTest.java | 51 +-
.../cache/RegionEntryFlagsJUnitTest.java | 9 +-
.../cache/ha/BlockingHARegionJUnitTest.java | 257 ++--
.../cache/ha/ThreadIdentifierJUnitTest.java | 2 -
.../internal/cache/lru/LRUClockJUnitTest.java | 270 ++--
.../GFSnapshotJUnitPerformanceTest.java | 32 +-
.../CacheServerMaxConnectionsJUnitTest.java | 117 +-
.../sockets/UpdatePropagationDUnitTest.java | 84 +-
.../sockets/UpdatePropagationPRDUnitTest.java | 8 +-
.../AsyncEventQueueValidationsJUnitTest.java | 17 +-
.../datasource/AbstractPoolCacheJUnitTest.java | 232 ++-
.../datasource/DataSourceFactoryJUnitTest.java | 72 +-
.../internal/jta/ExceptionJUnitTest.java | 14 +-
.../jta/GlobalTransactionJUnitTest.java | 33 +-
.../jta/TransactionTimeOutJUnitTest.java | 387 +++--
.../logging/LocatorLogFileJUnitTest.java | 13 +-
.../statistics/ValueMonitorJUnitTest.java | 23 +-
.../ConcurrentHashMapIteratorJUnitTest.java | 18 +-
.../concurrent/CopyOnWriteHashMapJUnitTest.java | 48 +-
.../cm/ConcurrentHashMapJUnitTest.java | 73 +-
.../concurrent/cm/CountedMapLoopsJUnitTest.java | 10 +-
.../concurrent/cm/IntMapCheckJUnitTest.java | 26 +-
.../util/concurrent/cm/MapCheckJUnitTest.java | 26 +-
.../util/concurrent/cm/MapLoopsJUnitTest.java | 12 +-
.../util/concurrent/cm/RLJBarJUnitTest.java | 13 +-
.../concurrent/cm/StringMapLoopsJUnitTest.java | 10 +-
.../DomainObjectsAsValuesJUnitTest.java | 16 +-
.../gemfire/memcached/IntegrationJUnitTest.java | 14 +-
.../gemfire/pdx/PdxSerializableJUnitTest.java | 11 +-
.../gemfire/pdx/PdxStringJUnitTest.java | 10 +-
.../gemstone/gemfire/util/JSR166TestCase.java | 23 +-
.../gemfire/cache/query/cq/CQJUnitTest.java | 23 +-
.../cache/query/cq/dunit/CqStateDUnitTest.java | 26 +-
83 files changed, 2819 insertions(+), 4416 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/extensions/geode-modules-hibernate/src/test/java/com/gemstone/gemfire/modules/SecondVMTest.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/java/com/gemstone/gemfire/modules/SecondVMTest.java b/extensions/geode-modules-hibernate/src/test/java/com/gemstone/gemfire/modules/SecondVMTest.java
index e3b6480..7c64c3c 100644
--- a/extensions/geode-modules-hibernate/src/test/java/com/gemstone/gemfire/modules/SecondVMTest.java
+++ b/extensions/geode-modules-hibernate/src/test/java/com/gemstone/gemfire/modules/SecondVMTest.java
@@ -21,11 +21,9 @@ import java.util.Iterator;
import java.util.Properties;
import java.util.logging.Level;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.TestCase;
-
import org.hibernate.Session;
import org.junit.Ignore;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,17 +34,17 @@ import com.gemstone.gemfire.cache.GemFireCache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.Region.Entry;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-@Ignore("Can this test be deleted?")
@Category(IntegrationTest.class)
-public class SecondVMTest extends TestCase {
+@Ignore("Can this test be deleted?")
+public class SecondVMTest {
private Logger log = LoggerFactory.getLogger(getClass());
-
- public void testNoop() {
-
- }
- public void _testStartEmptyVM() throws IOException {
+
+ @Ignore
+ @Test
+ public void testStartEmptyVM() throws IOException {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("mcast-port", "5555");
gemfireProperties.setProperty("log-level", "fine");
@@ -63,8 +61,10 @@ public class SecondVMTest extends TestCase {
}
}
}
-
- public void _testStartVM() throws Exception {
+
+ @Ignore
+ @Test
+ public void testStartVM() throws Exception {
java.util.logging.Logger.getLogger("org.hibernate").setLevel(Level.ALL);
Session session = HibernateJUnitTest.getSessionFactory(null).openSession();
log.info("SWAP:new session open");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CommonTests.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CommonTests.java b/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CommonTests.java
index 4a37d36..c341c6f 100644
--- a/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CommonTests.java
+++ b/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CommonTests.java
@@ -14,15 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.modules.session.internal.filter;
-import com.mockrunner.mock.web.MockHttpServletRequest;
-import com.mockrunner.mock.web.MockHttpServletResponse;
-import com.mockrunner.mock.web.MockHttpSession;
-import com.mockrunner.servlet.BasicServletTestCaseAdapter;
-import org.junit.Ignore;
-import org.junit.Test;
+import static org.junit.Assert.*;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.Cookie;
@@ -31,8 +25,12 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionAttributeListener;
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockHttpServletResponse;
+import com.mockrunner.mock.web.MockHttpSession;
+import com.mockrunner.servlet.BasicServletTestCaseAdapter;
+import org.junit.Ignore;
+import org.junit.Test;
/**
* This servlet tests the effects of the downstream SessionCachingFilter filter.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/extensions/geode-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java b/extensions/geode-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
index 194a7c7..1d4d643 100644
--- a/extensions/geode-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
+++ b/extensions/geode-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
@@ -16,10 +16,15 @@
*/
package com.gemstone.gemfire.modules.session;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.modules.session.catalina.DeltaSessionManager;
-import com.gemstone.gemfire.modules.session.catalina.PeerToPeerCacheLifecycleListener;
+import static org.junit.Assert.*;
+
+import java.beans.PropertyChangeEvent;
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
@@ -29,14 +34,10 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.beans.PropertyChangeEvent;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import static junit.framework.Assert.*;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.modules.session.catalina.DeltaSessionManager;
+import com.gemstone.gemfire.modules.session.catalina.PeerToPeerCacheLifecycleListener;
public abstract class TestSessionsBase {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java
index d6889a7..7003b50 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java
@@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.rest.internal.web.controllers;
+import static org.junit.Assert.*;
+
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -25,8 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
@@ -55,6 +55,9 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -67,7 +70,7 @@ import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
@Category(IntegrationTest.class)
-public class RestAPIsQueryAndFEJUnitTest extends TestCase {
+public class RestAPIsQueryAndFEJUnitTest {
private Cache c;
@@ -1318,8 +1321,7 @@ public class RestAPIsQueryAndFEJUnitTest extends TestCase {
queryResultByIndex.put(48, qIndex48_resultData);
}
- @Override
- @SuppressWarnings("deprecation")
+ @Before
public void setUp() throws Exception {
AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
@@ -1424,7 +1426,7 @@ public class RestAPIsQueryAndFEJUnitTest extends TestCase {
FunctionService.registerFunction(new AddFreeItemToOrders());
}
- @Override
+ @After
public void tearDown() {
// shutdown and clean up the manager node.
//this.c.close();
@@ -1441,7 +1443,7 @@ public class RestAPIsQueryAndFEJUnitTest extends TestCase {
return headers;
}
-
+ @Test
public void testCreateAsJson() {
executeQueryTestCases();
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/JUnitTestSetup.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/JUnitTestSetup.java b/geode-core/src/test/java/com/gemstone/gemfire/JUnitTestSetup.java
deleted file mode 100644
index deba960..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/JUnitTestSetup.java
+++ /dev/null
@@ -1,143 +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.
- */
-package com.gemstone.gemfire;
-
-import junit.extensions.TestDecorator;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.TestResult;
-import java.util.ArrayList;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-
-/*
- * This class is a decorator for junit.framework.Test to enable class wide setUp() and tearDown()
- * In order to use this decorator, the Testcase must contain this code:
- * <code>
- * public static Test suite() {
- * return JUnitTestSetup.createJUnitTestSetup(ExampleTestCase.class);
- * }
- * </code>
- * If a class being added to this suite has any static methods like this
- * <code>static void caseSetUp()</code>
- * then it will be called once for that test case before any of its test methods are invoked.
- * If a class being added to this suite has any static methods like this
- * <code>static void caseTearDown()</code>
- * then it will be called once for that test case after all of its test methods are invoked.
- * For both of these <em>case</em> methods the subclass one is called first
- * followed by any found in the parent classes.
- *
- * @see Test
- * @deprecated use @BeforeClass and @AfterClass instead
- */
-public class JUnitTestSetup extends TestDecorator {
-
- /** * List of Method instances to call once on a testCase before any of its test methods
- */
- private ArrayList fCaseSetUp = null;
- /**
- * List of Method instances to call once on a testCase after all of its test methods
- */
- private ArrayList fCaseTearDown = null;
-
- /**
- * Find a static method on the specified class with the specified name
- * and puts it in the specified list
- * given class
- */
- private void findCaseMethod(Class c, String methName, ArrayList l) {
- Method m = null;
- try {
- m = c.getDeclaredMethod(methName, new Class[]{});
- if (!Modifier.isStatic(m.getModifiers())) {
- m = null;
- }
- } catch (NoSuchMethodException ex) {
- }
- if (m != null) {
- l.add(m);
- }
- }
-
- /*
- * Factory method to use this Junit TestDecorator
- * @params theClass this is the test you want to decorate
- */
- public static Test createJUnitTestSetup(final Class theClass) {
- TestSuite ts = new TestSuite();
- ts.addTestSuite(theClass);
- return new JUnitTestSetup(ts, theClass);
- }
-
- public JUnitTestSetup(Test ts, Class theClass) {
- super(ts);
- Class superClass = theClass;
- ArrayList caseSetUp = new ArrayList();
- ArrayList caseTearDown = new ArrayList();
- while (Test.class.isAssignableFrom(superClass)) {
-// Method[] methods= superClass.getDeclaredMethods();
- //for (int i= 0; i < methods.length; i++) {
- // addTestMethod(methods[i], names, theClass);
- //}
- findCaseMethod(superClass, "caseSetUp", caseSetUp);
- findCaseMethod(superClass, "caseTearDown", caseTearDown);
- superClass= superClass.getSuperclass();
- if (this.countTestCases() != 0) {
- if (caseSetUp.size() > 0) {
- fCaseSetUp = caseSetUp;
- }
- if (caseTearDown.size() > 0) {
- fCaseTearDown = caseTearDown;
- }
- }
- }
- }
-
- public void run(TestResult result) {
- try {
- callCaseMethods(fCaseSetUp, result);
- basicRun(result);
- //getTest().run(result);
- //for (Enumeration e= tests(); e.hasMoreElements(); ) {
- // if (result.shouldStop() )
- // break;
- // Test test= (Test)e.nextElement();
- // test.run(result);
- // }
- } finally {
- callCaseMethods(fCaseTearDown, result);
- }
- }
-
- /**
- * Used to invoke a caseSetUp method once, if one exists,
- * before all the test methods have been invoked
- */
- private void callCaseMethods(ArrayList l, TestResult result) {
- if (l != null) {
- for (int i=0; i < l.size(); i++) {
- try {
- Method m = (Method)l.get(i);
- m.invoke(null, new Object[]{});
- } catch (Exception ex) {
- result.addError(this, ex);
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/TimingTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/TimingTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/TimingTestCase.java
deleted file mode 100644
index 00d268c..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/TimingTestCase.java
+++ /dev/null
@@ -1,77 +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.
- */
-package com.gemstone.gemfire;
-
-import junit.framework.TestCase;
-
-/**
- * TimingTestCase provides a nanosecond timing framework. Extend
- * this class instead of TestCase to implement GemFire timing tests.
- */
-public abstract class TimingTestCase extends TestCase {
-
- static private long nanosPerMilli = 1000000;
-
- public TimingTestCase(String name) {
- super(name);
- }
-
- /**
- * backward compatibility
- */
- protected void time(String opDescription, int numPasses, int opsPerPass, final Runnable runnable) {
- try {
- time(opDescription, numPasses, opsPerPass, new RunBlock() {
- public void run() {
- runnable.run();
- }});
- } catch (Exception ex) {
- ex.printStackTrace();
- fail(ex.toString());
- }
- }
-
- /**
- * Invoke the Runnable numPasses times, then compute and display
- * the duration of each operation in nanoseconds.
- * @param opDescription a short description of the operation being timed
- * @param numPasses the number of times to run runnable
- * @param opsPerPass the number of operations occurring in each execution
- * of runnable. This is used to compute the time of each operation -
- * invoking this method will execute the operation numPasses * opsPerPass
- * times.
- * @param runnable contains the code to execute in the run() method
- */
- protected void time(String opDescription, int numPasses, int opsPerPass, RunBlock runnable)
- throws Exception {
-
- // Measure elapsed time to invoke runnable numPasses times
- long start = System.currentTimeMillis();
- for (int pass=numPasses; pass > 0; pass--) {
- runnable.run();
- }
- long elapsed = System.currentTimeMillis() - start;
-
- // Compute time per operationS
- long nanosPerOp = (long)((float)(elapsed * nanosPerMilli) / (float)(opsPerPass * numPasses));
- System.out.println("Timing " + opDescription + ": " + nanosPerOp + " nanoseconds per operation");
- }
-
- public static interface RunBlock {
- public void run() throws Exception;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java b/geode-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java
deleted file mode 100644
index e238e32..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java
+++ /dev/null
@@ -1,263 +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.
- */
-package com.gemstone.gemfire;
-
-import java.io.*;
-import java.text.BreakIterator;
-import java.util.*;
-
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.DocErrorReporter;
-import com.sun.javadoc.MethodDoc;
-import com.sun.javadoc.RootDoc;
-
-import junit.framework.TestCase;
-import perffmwk.Formatter;
-
-/**
- * This class is a Javadoc <A
- * href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/javadoc/overview.html">doclet</A>
- * that generates a text file that summarizes unit test classes and
- * methods.
- *
- * @see com.sun.javadoc.Doclet
- *
- *
- * @since 3.0
- */
-public class UnitTestDoclet {
-
- /**
- * Returns the number of arguments for the given command option
- * (include the option itself)
- */
- public static int optionLength(String option) {
- if (option.equals("-output")) {
- return 2;
-
- } else {
- // Unknown option
- return 0;
- }
- }
-
- public static boolean validOptions(String[][] options,
- DocErrorReporter reporter) {
- boolean sawOutput = false;
-
- for (int i = 0; i < options.length; i++) {
- String[] option = options[i];
-
- if (option[0].equals("-output")) {
- File output = new File(option[1]);
- if (output.exists() && output.isDirectory()) {
- reporter.printError("Output file " + output +
- " is a directory");
- return false;
-
- } else {
- sawOutput = true;
- }
- }
- }
-
- if (!sawOutput) {
- reporter.printError("Missing -output");
- return false;
- }
-
- return true;
- }
-
- /**
- * The entry point for the doclet
- */
- public static boolean start(RootDoc root) {
- String[][] options = root.options();
-
- File outputFile = null;
- for (int i = 0; i < options.length; i++) {
- String[] option = options[i];
- if (option[0].equals("-output")) {
- outputFile = new File(option[1]);
- }
- }
-
- if (outputFile == null) {
- root.printError("Internal Error: No output file");
- return false;
-
- } else {
- root.printNotice("Generating " + outputFile);
- }
-
- try {
- PrintWriter pw =
- new PrintWriter(new FileWriter(outputFile));
- Formatter.center("GemFire Unit Test Summary", pw);
- Formatter.center(new Date().toString(), pw);
- pw.println("");
-
- ClassDoc[] classes = root.classes();
- Arrays.sort(classes, new Comparator() {
- public int compare(Object o1, Object o2) {
- ClassDoc c1 = (ClassDoc) o1;
- ClassDoc c2 = (ClassDoc) o2;
- return c1.qualifiedName().compareTo(c2.qualifiedName());
- }
- });
- for (int i = 0; i < classes.length; i++) {
- ClassDoc c = classes[i];
- if (!c.isAbstract() && isUnitTest(c)) {
- document(c, pw);
- }
- }
-
- pw.flush();
- pw.close();
-
- } catch (IOException ex) {
- StringWriter sw = new StringWriter();
- ex.printStackTrace(new PrintWriter(sw, true));
- root.printError(sw.toString());
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns whether or not a class is a unit test. That is, whether
- * or not it is a subclass of {@link junit.framework.TestCase}.
- */
- private static boolean isUnitTest(ClassDoc c) {
- if (c == null) {
- return false;
-
- } else if (c.qualifiedName().equals(TestCase.class.getName())) {
- return true;
-
- } else {
- return isUnitTest(c.superclass());
- }
- }
-
- /**
- * Summarizes the test methods of the given class
- */
- public static void document(ClassDoc c, PrintWriter pw)
- throws IOException {
-
- pw.println(c.qualifiedName());
-
- {
- String comment = c.commentText();
- if (comment != null && !comment.equals("")) {
- pw.println("");
- indent(comment, 4, pw);
- pw.println("");
- }
- }
-
- MethodDoc[] methods = getTestMethods(c);
- for (int i = 0; i < methods.length; i++) {
- MethodDoc method = methods[i];
- pw.print(" ");
- pw.println(method.name());
-
- String comment = method.commentText();
- if (comment != null && !comment.equals("")) {
- pw.println("");
- indent(comment, 6, pw);
- pw.println("");
- }
- }
-
- pw.println("");
- }
-
- /**
- * Returns an array containing all of the "test" methods (including
- * those that are inherited) for the given class.
- */
- private static MethodDoc[] getTestMethods(ClassDoc c) {
- Set set = new TreeSet();
- while (c != null) {
- MethodDoc[] methods = c.methods();
- for (int i = 0; i < methods.length; i++) {
- MethodDoc method = methods[i];
- if (method.isPublic() && method.parameters().length == 0 &&
- method.name().startsWith("test")) {
- set.add(method);
- }
- }
-
- c = c.superclass();
- }
-
- return (MethodDoc[]) set.toArray(new MethodDoc[0]);
- }
-
- /**
- * Indents a block of text a given amount.
- */
- private static void indent(String text, final int indent,
- PrintWriter pw) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < indent; i++) {
- sb.append(" ");
- }
- String spaces = sb.toString();
-
- pw.print(spaces);
-
- int printed = indent;
- boolean firstWord = true;
-
- BreakIterator boundary = BreakIterator.getWordInstance();
- boundary.setText(text);
- int start = boundary.first();
- for (int end = boundary.next(); end != BreakIterator.DONE;
- start = end, end = boundary.next()) {
-
- String word = text.substring(start, end);
-
- if (printed + word.length() > 72) {
- pw.println("");
- pw.print(spaces);
- printed = indent;
- firstWord = true;
- }
-
- if (word.charAt(word.length() - 1) == '\n') {
- pw.write(word, 0, word.length() - 1);
-
- } else if (firstWord &&
- Character.isWhitespace(word.charAt(0))) {
- pw.write(word, 1, word.length() - 1);
-
- } else {
- pw.print(word);
- }
- printed += (end - start);
- firstWord = false;
- }
-
- pw.println("");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/ConnectionPoolAndLoaderDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/ConnectionPoolAndLoaderDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/ConnectionPoolAndLoaderDUnitTest.java
index df76fcb..90dfd39 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/ConnectionPoolAndLoaderDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/ConnectionPoolAndLoaderDUnitTest.java
@@ -16,54 +16,39 @@
*/
package com.gemstone.gemfire.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.io.IOException;
import java.util.Properties;
-import junit.framework.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.cache.client.PoolFactory;
import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.cache.util.CacheWriterAdapter;
-import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
* This tests cases where we have both
* a connection pool and a bridge loader.
- *
*/
@Category(DistributedTest.class)
-public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
+public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
private static int bridgeServerPort;
- protected boolean useLocator;
+ private boolean useLocator;
- public ConnectionPoolAndLoaderDUnitTest() {
- super();
- }
-
@Override
public final void preTearDownCacheTestCase() {
- //TODO grid. This is a hack. The next dunit test to run after
- //this one is the ConnectionPoolAutoDUnit test. That ends up calling
- //getSystem() with no arguments and expects to get a system without
- //a locator. But getSystem() is broken in that it only compares the
- //passed in properties (an empty list) with the current properties.
disconnectAllFromDS();
}
@@ -74,10 +59,9 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
* load from loader.
*
* Anything that is loaded on the client is put on the server..
- *
*/
@Test
- public void testPoolAndLoader() {
+ public void testPoolAndLoader() throws Exception {
final String regionName = this.getName();
final Host host = Host.getHost(0);
VM server = host.getVM(0);
@@ -120,18 +104,18 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
Region region = getRootRegion(regionName);
region.put("a", "put-a");
region.put("b", "put-b");
- Assert.assertEquals("loaded-c", region.get("c"));
- Assert.assertEquals("loaded-d", region.get("d"));
+ assertEquals("loaded-c", region.get("c"));
+ assertEquals("loaded-d", region.get("d"));
}
});
server.invoke(new SerializableRunnable() {
public void run() {
Region region = getRootRegion(regionName);
- Assert.assertEquals("put-a", region.get("a"));
- Assert.assertEquals("put-b", region.get("b"));
- Assert.assertEquals("loaded-c", region.get("c"));
- Assert.assertEquals("loaded-d", region.get("d"));
+ assertEquals("put-a", region.get("a"));
+ assertEquals("put-b", region.get("b"));
+ assertEquals("loaded-c", region.get("c"));
+ assertEquals("loaded-d", region.get("d"));
region.put("e", "server-e");
}
});
@@ -139,11 +123,11 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
client.invoke(new SerializableRunnable() {
public void run() {
Region region = getRootRegion(regionName);
- Assert.assertEquals("put-a", region.get("a"));
- Assert.assertEquals("put-b", region.get("b"));
- Assert.assertEquals("loaded-c", region.get("c"));
- Assert.assertEquals("loaded-d", region.get("d"));
- Assert.assertEquals("server-e", region.get("e"));
+ assertEquals("put-a", region.get("a"));
+ assertEquals("put-b", region.get("b"));
+ assertEquals("loaded-c", region.get("c"));
+ assertEquals("loaded-d", region.get("d"));
+ assertEquals("server-e", region.get("e"));
}
});
}
@@ -157,7 +141,7 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
* put on server
*/
@Test
- public void testPoolAndWriter() {
+ public void testPoolAndWriter() throws Exception {
final String regionName = this.getName();
final Host host = Host.getHost(0);
VM server = host.getVM(0);
@@ -208,31 +192,31 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
region.put("a", "new-a");
fail("Should have gotten a cache writer exception");
} catch(CacheWriterException e) {
- Assert.assertEquals("beforeUpdate", e.getMessage());
+ assertEquals("beforeUpdate", e.getMessage());
}
try {
region.destroy("b");
fail("Should have gotten a cache writer exception");
} catch(CacheWriterException e) {
- Assert.assertEquals("beforeDestroy", e.getMessage());
+ assertEquals("beforeDestroy", e.getMessage());
}
try {
region.put("d", "d");
fail("Should have gotten a cache writer exception");
} catch(CacheWriterException e) {
- Assert.assertEquals("beforeCreate", e.getMessage());
+ assertEquals("beforeCreate", e.getMessage());
}
try {
region.clear();
fail("Should have gotten a cache writer exception");
} catch(CacheWriterException e) {
- Assert.assertEquals("beforeRegionClear", e.getMessage());
+ assertEquals("beforeRegionClear", e.getMessage());
}
try {
region.destroyRegion();
fail("Should have gotten a cache writer exception");
} catch(CacheWriterException e) {
- Assert.assertEquals("beforeRegionDestroy", e.getMessage());
+ assertEquals("beforeRegionDestroy", e.getMessage());
}
}
});
@@ -240,10 +224,10 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
server.invoke(new SerializableRunnable() {
public void run() {
Region region = getRootRegion(regionName);
- Assert.assertEquals("a", region.get("a"));
- Assert.assertEquals("b", region.get("b"));
- Assert.assertEquals(null, region.get("c"));
- Assert.assertEquals(null, region.get("d"));
+ assertEquals("a", region.get("a"));
+ assertEquals("b", region.get("b"));
+ assertEquals(null, region.get("c"));
+ assertEquals(null, region.get("d"));
}
});
}
@@ -259,7 +243,7 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
* 4 loader
*/
@Test
- public void testPoolLoadAndPeer() {
+ public void testPoolLoadAndPeer() throws Exception {
final String regionName = this.getName();
final Host host = Host.getHost(0);
VM server = host.getVM(0);
@@ -279,11 +263,7 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
return null;
}
});
-
-
-
-
-
+
SerializableCallable createClient1 = new SerializableCallable() {
public Object call() {
//Make sure we get a distributed system that has the locator
@@ -304,8 +284,7 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
}
};
client1.invoke(createClient1);
-
-
+
SerializableCallable createClient2 = new SerializableCallable() {
public Object call() {
//Make sure we get a distributed system that has the locator
@@ -326,8 +305,6 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
}
};
client2.invoke(createClient2);
-
-
//We need to test what happens when
//we do a load in client1 in each of these cases:
@@ -340,7 +317,6 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
// f X X client1
// g X client2 (loader does a netSearch)
// h client1 loader
-
//Setup scenarios
client1.invoke(new SerializableRunnable() {
@@ -356,9 +332,9 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
client2.invoke(new SerializableRunnable() {
public void run() {
Region region = getRootRegion(regionName);
- Assert.assertEquals("client1-c", region.get("c"));
+ assertEquals("client1-c", region.get("c"));
region.put("d", "client2-d");
- Assert.assertEquals("client1-f", region.get("f"));
+ assertEquals("client1-f", region.get("f"));
region.put("g", "client2-g");
}
});
@@ -377,48 +353,47 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
client1.invoke(new SerializableRunnable() {
public void run() {
Region region = getRootRegion(regionName);
- Assert.assertEquals("server-a", region.get("a"));
- Assert.assertEquals("client1-b", region.get("b"));
- Assert.assertEquals("client1-c", region.get("c"));
- Assert.assertEquals("client2-d", region.get("d"));
- Assert.assertEquals("client1-e", region.get("e"));
- Assert.assertEquals("client1-f", region.get("f"));
- Assert.assertEquals("client2-g", region.get("g"));
- Assert.assertEquals("loaded1-h", region.get("h"));
+ assertEquals("server-a", region.get("a"));
+ assertEquals("client1-b", region.get("b"));
+ assertEquals("client1-c", region.get("c"));
+ assertEquals("client2-d", region.get("d"));
+ assertEquals("client1-e", region.get("e"));
+ assertEquals("client1-f", region.get("f"));
+ assertEquals("client2-g", region.get("g"));
+ assertEquals("loaded1-h", region.get("h"));
}
});
server.invoke(new SerializableRunnable() {
public void run() {
Region region = getRootRegion(regionName);
- Assert.assertEquals("server-a", region.get("a"));
- Assert.assertEquals("client1-b", region.get("b"));
- Assert.assertEquals("client1-c", region.get("c"));
- Assert.assertEquals("client2-d", region.get("d"));
- Assert.assertEquals(null, region.get("e"));
- Assert.assertEquals(null, region.get("f"));
+ assertEquals("server-a", region.get("a"));
+ assertEquals("client1-b", region.get("b"));
+ assertEquals("client1-c", region.get("c"));
+ assertEquals("client2-d", region.get("d"));
+ assertEquals(null, region.get("e"));
+ assertEquals(null, region.get("f"));
//dsmith - This result seems somewhat suspect. client1 did a net load
//which found a value in client2, but it never propagated that result
//to the server. After talking with Darrel we decided to keep it this
//way for now.
- Assert.assertEquals(null, region.get("g"));
- Assert.assertEquals("loaded1-h", region.get("h"));
+ assertEquals(null, region.get("g"));
+ assertEquals("loaded1-h", region.get("h"));
}
});
}
- protected void startBridgeServer(int port, boolean notifyBySubscription)
- throws IOException {
-
- Cache cache = getCache();
- CacheServer bridge = cache.addCacheServer();
- bridge.setPort(port);
- bridge.setNotifyBySubscription(notifyBySubscription);
- bridge.start();
- bridgeServerPort = bridge.getPort();
-}
+ private void startBridgeServer(int port, boolean notifyBySubscription) throws IOException {
+ Cache cache = getCache();
+ CacheServer bridge = cache.addCacheServer();
+ bridge.setPort(port);
+ bridge.setNotifyBySubscription(notifyBySubscription);
+ bridge.start();
+ bridgeServerPort = bridge.getPort();
+ }
+ @Override
public Properties getDistributedSystemProperties() {
Properties p = new Properties();
if(!useLocator) {
@@ -428,45 +403,49 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
return p;
}
- public static class MyCacheWriter extends CacheWriterAdapter {
+ private static class MyCacheWriter extends CacheWriterAdapter {
+
protected boolean throwException = false;
+ @Override
public void beforeCreate(EntryEvent event) throws CacheWriterException {
- if(throwException) {
+ if (throwException) {
throw new CacheWriterException("beforeCreate");
}
}
+ @Override
public void beforeDestroy(EntryEvent event) throws CacheWriterException {
- if(throwException) {
+ if (throwException) {
throw new CacheWriterException("beforeDestroy");
}
}
+ @Override
public void beforeRegionClear(RegionEvent event)
throws CacheWriterException {
- if(throwException) {
+ if (throwException) {
throw new CacheWriterException("beforeRegionClear");
}
}
+ @Override
public void beforeRegionDestroy(RegionEvent event)
throws CacheWriterException {
- if(throwException) {
+ if (throwException) {
throw new CacheWriterException("beforeRegionDestroy");
}
}
+ @Override
public void beforeUpdate(EntryEvent event) throws CacheWriterException {
- if(throwException) {
+ if (throwException) {
throw new CacheWriterException("beforeUpdate");
}
}
-
-
}
- public static class MyCacheLoader implements CacheLoader {
+ private static class MyCacheLoader implements CacheLoader {
private String message;
@@ -474,6 +453,7 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
this.message = message;
}
+ @Override
public Object load(LoaderHelper helper) throws CacheLoaderException {
if(helper.getRegion().getAttributes().getScope().equals(Scope.DISTRIBUTED_ACK)) {
System.err.println("Doing a net search for " + helper.getKey());
@@ -488,10 +468,8 @@ public class ConnectionPoolAndLoaderDUnitTest extends JUnit4CacheTestCase {
return message + "-" + key;
}
+ @Override
public void close() {
}
}
-
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java
index 2f9be54..8f6ef81 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java
@@ -25,8 +25,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
@@ -40,7 +38,7 @@ import com.gemstone.gemfire.test.dunit.ThreadUtils;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
-public class PutAllGlobalLockJUnitTest {
+public class PutAllGlobalLockJUnitTest { // TODO: reformat
Region testRegion = null;
volatile boolean done = false;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/QueryTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/QueryTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/QueryTestUtils.java
index c50e3b5..934b121 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/QueryTestUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/QueryTestUtils.java
@@ -19,14 +19,9 @@ package com.gemstone.gemfire.cache.query;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
-import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
-
-import junit.framework.Assert;
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.cache.AttributesFactory;
@@ -39,19 +34,12 @@ import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.cache.RegionFactory;
import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.client.ClientCacheFactory;
-import com.gemstone.gemfire.cache.query.data.Numbers;
-import com.gemstone.gemfire.cache.query.data.Portfolio;
-import com.gemstone.gemfire.cache.query.types.CollectionType;
-import com.gemstone.gemfire.cache.query.types.ObjectType;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
/**
* Utility class for testing supported queries
- *
- *
*/
public class QueryTestUtils implements Serializable {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CloseCacheAuthorization.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CloseCacheAuthorization.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CloseCacheAuthorization.java
index 720168f..da26f4e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CloseCacheAuthorization.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CloseCacheAuthorization.java
@@ -18,8 +18,6 @@ package com.gemstone.gemfire.cache.query.dunit;
import java.security.Principal;
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheClosedException;
@@ -29,7 +27,11 @@ import com.gemstone.gemfire.distributed.DistributedMember;
import com.gemstone.gemfire.security.AccessControl;
import com.gemstone.gemfire.security.NotAuthorizedException;
-public class CloseCacheAuthorization extends TestCase implements AccessControl {
+/**
+ * Used by CqStateDUnitTest
+ */
+public class CloseCacheAuthorization implements AccessControl {
+
private DistributedMember remoteDistributedMember;
private Cache cache;
private LogWriter logger;
@@ -43,8 +45,7 @@ public class CloseCacheAuthorization extends TestCase implements AccessControl {
}
@Override
- public void init(Principal principal, DistributedMember remoteMember,
- Cache cache) throws NotAuthorizedException {
+ public void init(Principal principal, DistributedMember remoteMember, Cache cache) throws NotAuthorizedException {
this.remoteDistributedMember = remoteMember;
this.cache = cache;
this.logger = cache.getSecurityLogger();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryAuthorization.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryAuthorization.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryAuthorization.java
index c4b3240..fca163e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryAuthorization.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryAuthorization.java
@@ -16,9 +16,9 @@
*/
package com.gemstone.gemfire.cache.query.dunit;
-import java.security.Principal;
+import static org.junit.Assert.*;
-import junit.framework.TestCase;
+import java.security.Principal;
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.cache.Cache;
@@ -32,9 +32,12 @@ import com.gemstone.gemfire.security.NotAuthorizedException;
* Test authorization class for testing the accessibility of query bind
* parameters from QueryOperationContext
*
- *
+ * Used by test:
+ *
+ * <li/>QueryParamsAuthorizationDUnitTest (via reflection)
*/
-public class QueryAuthorization extends TestCase implements AccessControl {
+public class QueryAuthorization implements AccessControl {
+
private DistributedMember remoteDistributedMember;
private LogWriter logger;
@@ -48,8 +51,7 @@ public class QueryAuthorization extends TestCase implements AccessControl {
}
@Override
- public void init(Principal principal, DistributedMember remoteMember,
- Cache cache) throws NotAuthorizedException {
+ public void init(Principal principal, DistributedMember remoteMember, Cache cache) throws NotAuthorizedException {
this.remoteDistributedMember = remoteMember;
this.logger = cache.getSecurityLogger();
}
@@ -60,10 +62,8 @@ public class QueryAuthorization extends TestCase implements AccessControl {
if (context instanceof QueryOperationContext) {
Object[] params = ((QueryOperationContext) context).getQueryParams();
assertTrue(" Bind parameters should not be null", params != null);
- assertEquals(" 2 bind parameters should have been received.", 2,
- params.length);
+ assertEquals(" 2 bind parameters should have been received.", 2, params.length);
}
return 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/ConstantsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/ConstantsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/ConstantsJUnitTest.java
index d1ecff6..b437734 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/ConstantsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/ConstantsJUnitTest.java
@@ -22,12 +22,7 @@
*/
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.Query;
-import com.gemstone.gemfire.cache.query.QueryService;
-import com.gemstone.gemfire.cache.query.data.Portfolio;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import static org.junit.Assert.*;
import java.util.Collection;
@@ -36,19 +31,15 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.*;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.query.CacheUtils;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.data.Portfolio;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-/**
- *
- */
@Category(IntegrationTest.class)
public class ConstantsJUnitTest {
- public ConstantsJUnitTest() {
- }
-
@Before
public void setUp() throws java.lang.Exception {
CacheUtils.startCache();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/CountStarJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/CountStarJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/CountStarJUnitTest.java
index 7b28cae..942a36b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/CountStarJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/CountStarJUnitTest.java
@@ -19,6 +19,8 @@
*/
package com.gemstone.gemfire.cache.query.functional;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.HashMap;
@@ -27,10 +29,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,8 +46,6 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* This test runs {Select COUNT(*) from /regionName [where clause]} queries
* on different types of regions with and without multiple indexes.
- *
- *
*/
@Category(IntegrationTest.class)
public class CountStarJUnitTest {
@@ -58,9 +54,6 @@ public class CountStarJUnitTest {
private static String exampleRegionName = "employee";
private int numElem = 100;
- public CountStarJUnitTest() {
- }
-
@Before
public void setUp() throws Exception {
System.setProperty("gemfire.Query.VERBOSE", "true");
@@ -74,7 +67,6 @@ public class CountStarJUnitTest {
private static HashMap<String, Integer> countStarQueries = new HashMap<String, Integer>();
-
//EquiJoin Queries
private static String[] countStarQueriesWithEquiJoins = { "select COUNT(*) from /" + regionName + " p, /"+ exampleRegionName +" e where p.ID = e.ID AND p.ID > 0",
"select COUNT(*) from /" + regionName + " p, /"+ exampleRegionName +" e where p.ID = e.ID AND p.ID > 20 AND e.ID > 40",
@@ -109,11 +101,12 @@ public class CountStarJUnitTest {
}
//Queries without indexes.
+
/**
* Test on Local Region data
*/
@Test
- public void testCountStartQueriesOnLocalRegion(){
+ public void testCountStartQueriesOnLocalRegion() throws Exception {
Cache cache = CacheUtils.getCache();
createLocalRegion();
@@ -123,27 +116,23 @@ public class CountStarJUnitTest {
QueryService queryService = cache.getQueryService();
Query query1 = null;
Query query2 = null;
- try {
- for(String queryStr: countStarQueries.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- assertEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
-
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+
+ for(String queryStr: countStarQueries.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ assertEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
+
}
}
@@ -151,7 +140,7 @@ public class CountStarJUnitTest {
* Test on Replicated Region data
*/
@Test
- public void testCountStarQueriesOnReplicatedRegion(){
+ public void testCountStarQueriesOnReplicatedRegion() throws Exception {
Cache cache = CacheUtils.getCache();
createReplicatedRegion();
@@ -161,28 +150,24 @@ public class CountStarJUnitTest {
QueryService queryService = cache.getQueryService();
Query query1 = null;
Query query2 = null;
- try {
- for(String queryStr: countStarQueries.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- assertEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+
+ for(String queryStr: countStarQueries.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ assertEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
}
-
+
//Destroy current Region for other tests
cache.getRegion(regionName).destroyRegion();
}
@@ -191,7 +176,7 @@ public class CountStarJUnitTest {
* Test on Partitioned Region data
*/
@Test
- public void testCountStarQueriesOnPartitionedRegion(){
+ public void testCountStarQueriesOnPartitionedRegion() throws Exception {
Cache cache = CacheUtils.getCache();
createPartitionedRegion();
@@ -201,35 +186,31 @@ public class CountStarJUnitTest {
QueryService queryService = cache.getQueryService();
Query query1 = null;
Query query2 = null;
- try {
- for(String queryStr: countStarQueries.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+
+ for(String queryStr: countStarQueries.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
}
-
+
//Destroy current Region for other tests
cache.getRegion(regionName).destroyRegion();
}
//Test with indexes available on region
@Test
- public void testCountStartQueriesOnLocalRegionWithIndex(){
+ public void testCountStartQueriesOnLocalRegionWithIndex() throws Exception {
Cache cache = CacheUtils.getCache();
createLocalRegion();
@@ -239,14 +220,10 @@ public class CountStarJUnitTest {
QueryService queryService = cache.getQueryService();
//CReate Index on status and ID
- try {
- queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
- queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
- queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "pos.secId", "/"+regionName+" p, p.positions.values pos");
- } catch (Exception e1) {
- fail("Index Creation Failed with message: " + e1.getMessage());
- }
-
+ queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
+ queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
+ queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "pos.secId", "/"+regionName+" p, p.positions.values pos");
+
Region region = cache.getRegion(regionName);
//Verify Index Creation
assertNotNull(queryService.getIndex(region, "sampleIndex-1"));
@@ -256,34 +233,30 @@ public class CountStarJUnitTest {
//Run queries
Query query1 = null;
Query query2 = null;
- try {
- for(String queryStr: countStarQueries.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+
+ for(String queryStr: countStarQueries.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
}
-
+
//Destroy current Region for other tests
region.destroyRegion();
}
@Test
- public void testCountStarQueriesOnReplicatedRegionWithIndex(){
+ public void testCountStarQueriesOnReplicatedRegionWithIndex() throws Exception {
Cache cache = CacheUtils.getCache();
createReplicatedRegion();
@@ -292,52 +265,43 @@ public class CountStarJUnitTest {
QueryService queryService = cache.getQueryService();
//CReate Index on status and ID
- try {
- queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
- queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
- queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "pos.secId", "/"+regionName+" p, p.positions.values pos");
- } catch (Exception e1) {
- fail("Index Creation Failed with message: " + e1.getMessage());
- }
-
+ queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
+ queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
+ queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "pos.secId", "/"+regionName+" p, p.positions.values pos");
+
Region region = cache.getRegion(regionName);
//Verify Index Creation
assertNotNull(queryService.getIndex(region, "sampleIndex-1"));
assertNotNull(queryService.getIndex(region, "sampleIndex-2"));
assertEquals(3, queryService.getIndexes().size());
-
- //Run queries
+ //Run queries
Query query1 = null;
Query query2 = null;
- try {
- for(String queryStr: countStarQueries.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+
+ for(String queryStr: countStarQueries.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
}
-
+
//Destroy current Region for other tests
region.destroyRegion();
}
@Test
- public void testCountStarQueriesOnPartitionedRegionWithIndex(){
+ public void testCountStarQueriesOnPartitionedRegionWithIndex() throws Exception {
Cache cache = CacheUtils.getCache();
createPartitionedRegion();
@@ -347,15 +311,10 @@ public class CountStarJUnitTest {
QueryService queryService = cache.getQueryService();
//CReate Index on status and ID
- try {
- queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
- //queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
- //queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "pos.secId", "/"+regionName+" p, p.positions.values pos");
- } catch (Exception e1) {
- fail("Index Creation Failed with message: " + e1.getMessage());
- }
-
-
+ queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
+ //queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
+ //queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "pos.secId", "/"+regionName+" p, p.positions.values pos");
+
Region region = cache.getRegion(regionName);
//Verify Index Creation
//assertNotNull(queryService.getIndex(region, "sampleIndex-1"));
@@ -365,34 +324,30 @@ public class CountStarJUnitTest {
//Run queries
Query query1 = null;
Query query2 = null;
- try {
- for(String queryStr: countStarQueries.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+
+ for(String queryStr: countStarQueries.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
}
+
//Destroy current Region for other tests
region.destroyRegion();
}
@Test
- public void testEquiJoinCountStarQueries(){
-
+ public void testEquiJoinCountStarQueries() throws Exception {
Cache cache = CacheUtils.getCache();
createLocalRegion();
@@ -408,38 +363,29 @@ public class CountStarJUnitTest {
Query query2 = null;
// Without Indexes
- try {
- for(String queryStr: countStarQueriesWithEquiJoins){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+ for(String queryStr: countStarQueriesWithEquiJoins){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
}
-
+
//CReate Index on status and ID
- try {
- queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
- queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
- queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "e.ID", "/"+exampleRegionName+ " e");
- queryService.createIndex("sampleIndex-4", IndexType.FUNCTIONAL, "e.status", "/"+exampleRegionName+ " e");
- } catch (Exception e1) {
- fail("Index Creation Failed with message: " + e1.getMessage());
- }
-
+ queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
+ queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
+ queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "e.ID", "/"+exampleRegionName+ " e");
+ queryService.createIndex("sampleIndex-4", IndexType.FUNCTIONAL, "e.status", "/"+exampleRegionName+ " e");
+
Region region = cache.getRegion(regionName);
Region region2 = cache.getRegion(exampleRegionName);
//Verify Index Creation
@@ -450,35 +396,30 @@ public class CountStarJUnitTest {
assertEquals(4, queryService.getIndexes().size());
//With Indexes
- try {
- for(String queryStr: countStarQueriesWithEquiJoins){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query with indexes: " + queryStr , result2.size(), count);
-
- //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+ for(String queryStr: countStarQueriesWithEquiJoins){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query with indexes: " + queryStr , result2.size(), count);
+
+ //assertIndexDetailsEquals("Query: "+ queryStr, countStarQueries.get(queryStr).intValue(), count);
}
-
+
//Destroy current Region for other tests
region.destroyRegion();
region2.destroyRegion();
}
@Test
- public void testCountStarOnCollection() {
+ public void testCountStarOnCollection() throws Exception {
String collection = "$1";
HashMap<String, Integer> countStarQueriesWithParms = new HashMap<String, Integer>();
countStarQueriesWithParms.put("select COUNT(*) from " + collection , 100);
@@ -506,32 +447,26 @@ public class CountStarJUnitTest {
portfolios.add(new Portfolio(i, i));
}
// Without Indexes
- try {
- for(String queryStr: countStarQueriesWithParms.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute(new Object[]{portfolios});
- SelectResults result2 = (SelectResults)query2.execute(new Object[]{portfolios});
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- assertEquals("Query: "+ queryStr, countStarQueriesWithParms.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+ for(String queryStr: countStarQueriesWithParms.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute(new Object[]{portfolios});
+ SelectResults result2 = (SelectResults)query2.execute(new Object[]{portfolios});
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ assertEquals("Query: "+ queryStr, countStarQueriesWithParms.get(queryStr).intValue(), count);
}
}
@Test
- public void testCountStarWithDuplicateValues() {
-
+ public void testCountStarWithDuplicateValues() throws Exception {
Cache cache = CacheUtils.getCache();
createLocalRegion();
@@ -550,7 +485,6 @@ public class CountStarJUnitTest {
countStarDistinctQueries.put("select distinct COUNT(*) from /" + regionName + " where ID IN SET(1, 2, 3, 4, 5)", 5);
countStarDistinctQueries.put("select distinct COUNT(*) from /" + regionName + " where NOT (ID > 5)", 5);
-
QueryService queryService = cache.getQueryService();
//Run queries
Query query1 = null;
@@ -567,65 +501,52 @@ public class CountStarJUnitTest {
region.put(i+100, new Portfolio(i, i));
}
// Without Indexes
- try {
- for(String queryStr: countStarDistinctQueries.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- //assertIndexDetailsEquals("Query: "+ queryStr, countStarDistinctQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
- }
-
- //CReate Index on status and ID
- try {
- queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
- queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
- queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "pos.secId", "/"+regionName+" p, p.positions.values pos");
- } catch (Exception e1) {
- fail("Index Creation Failed with message: " + e1.getMessage());
+ for(String queryStr: countStarDistinctQueries.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ //assertIndexDetailsEquals("Query: "+ queryStr, countStarDistinctQueries.get(queryStr).intValue(), count);
}
-
+
+ //CReate Index on status and ID
+ queryService.createIndex("sampleIndex-1", IndexType.FUNCTIONAL, "p.ID", "/"+regionName+ " p");
+ queryService.createIndex("sampleIndex-2", IndexType.FUNCTIONAL, "p.status", "/"+regionName+ " p");
+ queryService.createIndex("sampleIndex-3", IndexType.FUNCTIONAL, "pos.secId", "/"+regionName+" p, p.positions.values pos");
+
//Verify Index Creation
assertNotNull(queryService.getIndex(region, "sampleIndex-1"));
assertNotNull(queryService.getIndex(region, "sampleIndex-2"));
assertEquals(3, queryService.getIndexes().size());
- // Without Indexes
- try {
- for(String queryStr: countStarDistinctQueries.keySet()){
- query1 = queryService.newQuery(queryStr);
- query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
-
- SelectResults result1 = (SelectResults)query1.execute();
- SelectResults result2 = (SelectResults)query2.execute();
- assertEquals(queryStr, 1, result1.size());
- assertTrue(result1.asList().get(0) instanceof Integer);
-
- int count = ((Integer)result1.asList().get(0)).intValue();
-
- //Also verify with size of result2 to count
- assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
-
- //assertIndexDetailsEquals("Query: "+ queryStr, countStarDistinctQueries.get(queryStr).intValue(), count);
- }
- } catch (Exception e){
- e.printStackTrace();
- fail("Query "+ query1+" Execution Failed!");
+ // Without Indexes
+ for(String queryStr: countStarDistinctQueries.keySet()){
+ query1 = queryService.newQuery(queryStr);
+ query2 = queryService.newQuery(queryStr.replace("COUNT(*)", "*"));
+
+ SelectResults result1 = (SelectResults)query1.execute();
+ SelectResults result2 = (SelectResults)query2.execute();
+ assertEquals(queryStr, 1, result1.size());
+ assertTrue(result1.asList().get(0) instanceof Integer);
+
+ int count = ((Integer)result1.asList().get(0)).intValue();
+
+ //Also verify with size of result2 to count
+ assertEquals("COUNT(*) query result is wrong for query: " + queryStr , result2.size(), count);
+
+ //assertIndexDetailsEquals("Query: "+ queryStr, countStarDistinctQueries.get(queryStr).intValue(), count);
}
}
+
private void createLocalRegion() {
Cache cache = CacheUtils.getCache();
AttributesFactory attributesFactory = new AttributesFactory();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/FunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/FunctionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/FunctionJUnitTest.java
index f2a1743..5c845ff 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/FunctionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/FunctionJUnitTest.java
@@ -22,6 +22,8 @@
*/
package com.gemstone.gemfire.cache.query.functional;
+import static org.junit.Assert.*;
+
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
@@ -32,10 +34,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.Region;
import com.gemstone.gemfire.cache.query.CacheUtils;
import com.gemstone.gemfire.cache.query.FunctionDomainException;
@@ -49,13 +47,9 @@ import com.gemstone.gemfire.cache.query.internal.ExecutionContext;
import com.gemstone.gemfire.cache.query.internal.parse.OQLLexerTokenTypes;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-/**
- *
- */
@Category(IntegrationTest.class)
public class FunctionJUnitTest {
-
@Before
public void setUp() throws java.lang.Exception {
CacheUtils.startCache();