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/07 20:55:14 UTC
[59/62] [abbrv] incubator-geode git commit: Merge remote-tracking
branch 'origin/develop' into feature/GEODE-837
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd38e10f/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java
index 309f381,16ff4cf..f6ced21
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java
@@@ -16,43 -16,13 +16,25 @@@
*/
package com.gemstone.gemfire.cache.query.dunit;
- 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.File;
+import java.util.ArrayList;
+import java.util.Collection;
- import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
- import java.util.Set;
++
++import org.junit.Ignore;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.LogWriter;
- import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
- import com.gemstone.gemfire.cache.CacheException;
import com.gemstone.gemfire.cache.CacheExistsException;
import com.gemstone.gemfire.cache.CacheFactory;
- import com.gemstone.gemfire.cache.DataPolicy;
- import com.gemstone.gemfire.cache.EvictionAction;
- import com.gemstone.gemfire.cache.EvictionAttributes;
import com.gemstone.gemfire.cache.Region;
- import com.gemstone.gemfire.cache.RegionAttributes;
- import com.gemstone.gemfire.cache.Scope;
- import com.gemstone.gemfire.cache.client.ClientCacheFactory;
- import com.gemstone.gemfire.cache.query.CacheUtils;
import com.gemstone.gemfire.cache.query.Index;
- import com.gemstone.gemfire.cache.query.IndexExistsException;
- import com.gemstone.gemfire.cache.query.IndexNameConflictException;
- import com.gemstone.gemfire.cache.query.IndexType;
import com.gemstone.gemfire.cache.query.Query;
- import com.gemstone.gemfire.cache.query.QueryException;
import com.gemstone.gemfire.cache.query.QueryService;
import com.gemstone.gemfire.cache.query.SelectResults;
import com.gemstone.gemfire.cache.query.data.Portfolio;
@@@ -62,30 -32,23 +44,29 @@@ import com.gemstone.gemfire.cache.query
import com.gemstone.gemfire.cache.query.internal.index.IndexManager;
import com.gemstone.gemfire.cache.query.internal.index.PartitionedIndex;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
--import com.gemstone.gemfire.cache30.CacheTestCase;
- import com.gemstone.gemfire.cache30.CertifiableTestCacheListener;
- import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.internal.FileUtil;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.internal.cache.LocalRegion;
import com.gemstone.gemfire.internal.cache.PartitionedRegion;
-import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.ThreadUtils;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
++import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
++import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.util.test.TestUtil;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Properties;
-
-public class QueryIndexUsingXMLDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class QueryIndexUsingXMLDUnitTest extends JUnit4CacheTestCase {
static private final String WAIT_PROPERTY = "QueryIndexBuckets.maxWaitTime";
@@@ -138,11 -101,11 +119,6 @@@
private String persistentOverFlowRegName = "PersistentOverflowPortfolios";
-- /** Creates a new instance of QueryIndexUsingXMLDUnitTest */
- public QueryIndexUsingXMLDUnitTest() {
- super();
- public QueryIndexUsingXMLDUnitTest(String name) {
- super(name);
-- }
--
@Override
public final void postSetUp() throws Exception {
//Workaround for #52008
@@@ -280,7 -241,7 +256,6 @@@
vm1.invoke(close());
}
--
/**
* Creates partitioned index from an xml description.
*/
@@@ -330,6 -290,6 +305,7 @@@
vm0.invoke(close());
vm1.invoke(close());
}
++
/**
* Creates persistent partitioned index from an xml description.
*/
@@@ -363,7 -322,7 +339,7 @@@
vm0.invoke(prIndexCreationCheck(persistentRegName, "secIndex", 50));
vm1.invoke(prIndexCreationCheck(persistentRegName, "secIndex", 50));
-- //check hash index creation
++ //check hash index creation
vm0.invoke(prIndexCreationCheck(persistentRegNameWithHash, statusIndex, 50));
vm1.invoke(prIndexCreationCheck(persistentRegNameWithHash, statusIndex, 50));
vm0.invoke(prIndexCreationCheck(persistentRegNameWithHash, idIndex, 50));
@@@ -395,7 -354,7 +371,6 @@@
vm1.invoke(close());
}
--
/**
* Creates partitioned index from an xml description.
*/
@@@ -435,9 -393,8 +410,9 @@@
}
/**
-- * Creats partitioned index from an xml discription.
++ * Creates partitioned index from an xml description.
*/
+ @Test
public void testCreateAsyncIndexWhileDoingGII() throws Exception
{
@@@ -533,9 -489,9 +508,7 @@@
vm1.invoke(indexCreationCheck(repRegName, "secIndex"));
vm1.invoke(prIndexCreationCheck(persistentRegNameWithHash, "secIndex", 50));
vm1.invoke(indexCreationCheck(repRegNameWithHash, "secIndex"));
--
--
--
++
// Execute query and verify index usage
vm0.invoke(executeQueryAndCompareResult(name, true));
vm1.invoke(executeQueryAndCompareResult(name, true));
@@@ -599,7 -554,7 +572,9 @@@
* <p>
* DISABLED. This test is disabled due to a high rate of failure. See ticket #52167
*/
-- public void disabled_testCreateAsyncIndexWhileDoingGIIAndCompareQueryResults() throws Exception
++ @Ignore("TODO: test is disabled because of #52167")
++ @Test
++ public void testCreateAsyncIndexWhileDoingGIIAndCompareQueryResults() throws Exception
{
Host host = Host.getHost(0);
@@@ -669,8 -623,8 +644,7 @@@
vm0.invoke(close());
}
--
--
++
public CacheSerializableRunnable setTestHook()
{
SerializableRunnable sr = new CacheSerializableRunnable("TestHook") {
@@@ -687,13 -641,13 +661,6 @@@
}
}
};
-- /*
-- try {
-- ClassLoader.getSystemClassLoader().loadClass(IndexManager.class.getName());
-- } catch (Exception ex) {
-- fail("Failed to load IndexManager.class");
-- }
-- */
IndexManager.testHook = new IndexTestHook();
}
};
@@@ -711,6 -665,6 +678,7 @@@
};
return (CacheSerializableRunnable)sr;
}
++
public CacheSerializableRunnable createIndexThrougXML(final String vmid,
final String regionName, final String xmlFileName)
{
@@@ -963,8 -917,8 +931,7 @@@
}
return basicGetSystem();
}
--
--
++
private Cache getCache(InternalDistributedSystem system) {
Cache cache = basicGetCache();
if (cache == null) {
@@@ -987,13 -941,13 +954,16 @@@
}
public static class QueryObserverImpl extends QueryObserverAdapter {
++
boolean isIndexesUsed = false;
ArrayList indexesUsed = new ArrayList();
++ @Override
public void beforeIndexLookup(Index index, int oper, Object key) {
indexesUsed.add(index.getName());
}
++ @Override
public void afterIndexLookup(Collection results) {
if (results != null) {
isIndexesUsed = true;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd38e10f/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryParamsAuthorizationDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd38e10f/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
index 101e5d3,7774920..cf73b81
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
@@@ -54,29 -30,32 +54,31 @@@ import com.gemstone.gemfire.cache.query
import com.gemstone.gemfire.cache.query.types.ObjectType;
import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
-import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.internal.cache.tier.sockets.CacheClientNotifier;
import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
+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.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-import com.jayway.awaitility.Awaitility;
-import org.junit.experimental.categories.Category;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
+ import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
+
/**
* Tests remote (client/server) query execution.
*
- * @since 5.0.1
+ * @since GemFire 5.0.1
*/
-public class QueryUsingPoolDUnitTest extends CacheTestCase {
-
+@Category(DistributedTest.class)
+public class QueryUsingPoolDUnitTest extends JUnit4CacheTestCase {
+ private static final Logger logger = LogService.getLogger();
+
/**
* The port on which the bridge server was started in this VM
*/
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd38e10f/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/RemoteQueryDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/RemoteQueryDUnitTest.java
index 0d033b7,829f9ec..3866f40
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/RemoteQueryDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/RemoteQueryDUnitTest.java
@@@ -16,28 -16,11 +16,29 @@@
*/
package com.gemstone.gemfire.cache.query.dunit;
- import org.junit.experimental.categories.Category;
- import org.junit.Test;
-
++import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+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.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.Properties;
+
++import org.junit.Ignore;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++
+ import cacheRunner.Portfolio;
+ import cacheRunner.Position;
++
import com.gemstone.gemfire.DataSerializable;
import com.gemstone.gemfire.DataSerializer;
-import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
import com.gemstone.gemfire.cache.query.SelectResults;
@@@ -47,41 -30,38 +48,31 @@@ import com.gemstone.gemfire.cache.query
import com.gemstone.gemfire.cache.query.internal.ResultsBag;
import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
--import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.cache30.ClientServerTestCase;
- import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
++import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
++import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-import org.junit.experimental.categories.Category;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
- import cacheRunner.Portfolio;
- import cacheRunner.Position;
- import org.junit.experimental.categories.Category;
-
/**
* Tests remote (client/server) query execution.
*
- * @since 5.0.1
+ * @since GemFire 5.0.1
*/
-public class RemoteQueryDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class RemoteQueryDUnitTest extends JUnit4CacheTestCase {
/** The port on which the bridge server was started in this VM */
private static int bridgeServerPort;
- public RemoteQueryDUnitTest() {
- super();
- public RemoteQueryDUnitTest(String name) {
- super(name);
-- }
--
-- //////// Test Methods
--
@Override
public final void postSetUp() throws Exception {
disconnectAllFromDS();
@@@ -495,7 -472,7 +486,9 @@@
/**
* Tests remote complex query execution.
*/
-- public void __testRemoteComplexQueries() throws CacheException {
++ @Ignore("TODO: test is disabled")
++ @Test
++ public void testRemoteComplexQueries() throws CacheException {
final String name = this.getName();
final Host host = Host.getHost(0);
@@@ -1111,14 -1085,13 +1104,11 @@@
});
}
--
/**
* This the dunit test for the bug no : 36434
-- * @throws Exception
*/
--
- public void testBug36434() throws Exception
+ @Test
+ public void testBug36434() throws Exception
{
final String name = this.getName();
final Host host = Host.getHost(0);
@@@ -1212,18 -1185,17 +1202,13 @@@
stopBridgeServer(getCache());
}
});
--
--
--
}
/**
-- * This the dunit test for the bug no : 36969
-- * @throws Exception
-- */
--
- public void testBug36969() throws Exception
++ * This the dunit test for the bug no : 36969
++ */
+ @Test
+ public void testBug36969() throws Exception
{
final String name = this.getName();
final Host host = Host.getHost(0);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd38e10f/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
index d5ea32f,1ea2c3f..4a09351
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
@@@ -16,40 -16,9 +16,41 @@@
*/
package com.gemstone.gemfire.cache.query.dunit;
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.cache.client.*;
-import com.gemstone.gemfire.cache.query.*;
++import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.PartitionAttributesFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.PoolFactory;
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.client.ServerOperationException;
+import com.gemstone.gemfire.cache.query.FunctionDomainException;
+import com.gemstone.gemfire.cache.query.Index;
+import com.gemstone.gemfire.cache.query.IndexInvalidException;
+import com.gemstone.gemfire.cache.query.NameResolutionException;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryException;
+import com.gemstone.gemfire.cache.query.QueryExecutionLowMemoryException;
+import com.gemstone.gemfire.cache.query.QueryExecutionTimeoutException;
+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.TypeMismatchException;
import com.gemstone.gemfire.cache.query.data.Portfolio;
import com.gemstone.gemfire.cache.query.internal.DefaultQuery;
import com.gemstone.gemfire.cache.query.internal.QueryMonitor;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd38e10f/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/CountStarJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/CountStarJUnitTest.java
index 942a36b,f58d4bd..5272f2b
--- 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
@@@ -29,19 -29,10 +29,20 @@@ import org.junit.Before
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import static org.junit.Assert.*;
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.PartitionAttributesFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.query.CacheUtils;
+import com.gemstone.gemfire.cache.query.IndexType;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.data.Portfolio;
++import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* This test runs {Select COUNT(*) from /regionName [where clause]} queries
@@@ -54,9 -47,12 +55,9 @@@ 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");
+ System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "Query.VERBOSE", "true");
CacheUtils.startCache();
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd38e10f/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/IndexCreationJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/IndexCreationJUnitTest.java
index e9a14ca,792ef99..8f21a8b
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/IndexCreationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/IndexCreationJUnitTest.java
@@@ -26,37 -26,10 +26,38 @@@
*/
package com.gemstone.gemfire.cache.query.functional;
+ import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.cache.query.*;
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.EvictionAction;
+import com.gemstone.gemfire.cache.EvictionAttributes;
+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.IndexStatistics;
+import com.gemstone.gemfire.cache.query.IndexType;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryInvalidException;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.Utils;
import com.gemstone.gemfire.cache.query.data.ComparableWrapper;
import com.gemstone.gemfire.cache.query.data.Portfolio;
import com.gemstone.gemfire.cache.query.internal.DefaultQueryService;
@@@ -76,268 -48,325 +76,267 @@@ import com.gemstone.gemfire.distributed
import com.gemstone.gemfire.internal.FileUtil;
import com.gemstone.gemfire.internal.cache.LocalRegion;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import java.io.File;
-import java.util.*;
+@Category(IntegrationTest.class)
+public class IndexCreationJUnitTest {
- private ObjectType resType1 = null;
- private ObjectType resType2 = null;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
-import static org.junit.Assert.*;
++ private ObjectType resType1=null;
++ private ObjectType resType2= null;
- private int resSize1 = 0;
- private int resSize2 = 0;
-@Category(IntegrationTest.class)
-public class IndexCreationJUnitTest{
- ObjectType resType1=null;
- ObjectType resType2= null;
-
- int resSize1=0;
- int resSize2=0;
-
- Iterator itert1=null;
- Iterator itert2=null;
-
- Set set1=null;
- Set set2=null;
-
- String s1;
- String s2;
-
- @Before
++ private int resSize1=0;
++ private int resSize2=0;
+
- private Iterator itert1 = null;
- private Iterator itert2 = null;
++ private Iterator itert1=null;
++ private Iterator itert2=null;
+
- private Set set1 = null;
- private Set set2 = null;
++ private Set set1=null;
++ private Set set2=null;
+
+ private String s1;
+ private String s2;
+
+ @Before
public void setUp() throws java.lang.Exception {
- CacheUtils.startCache();
- 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));
- }
-
+ CacheUtils.startCache();
+ Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
+ for (int i = 0; i < 4; i++) {
+ region.put("" + i, new Portfolio(i));
}
-
- @After
+ }
+
+ @After
public void tearDown() throws java.lang.Exception {
- CacheUtils.closeCache();
- }
-
- @Test
+ CacheUtils.closeCache();
+ }
+
+ @Test
public void testIndexCreation() throws Exception {
- QueryService qs;
- qs = CacheUtils.getQueryService();
-
- Index i1 = qs.createIndex("statusIndex", IndexType.FUNCTIONAL,"status","/portfolios, positions");
- //TASK ICM1
- Index i2 = qs.createIndex("secIdIndex", IndexType.FUNCTIONAL,"b.secId","/portfolios pf, pf.positions.values b");
- //TASK ICM2
- Index i5= qs.createIndex("intFunctionIndex", IndexType.FUNCTIONAL,"intFunction(pf.getID)","/portfolios pf, pf.positions b");
- Index i6 = qs.createIndex("statusIndex6", IndexType.FUNCTIONAL,"a.status","/portfolios.values.toArray a, positions");
- Index i7 = qs.createIndex("statusIndex7", IndexType.FUNCTIONAL,"a.status","/portfolios.getValues().asList() a, positions");
- Index i8 = qs.createIndex("statusIndex8", IndexType.FUNCTIONAL,"a.status","/portfolios.values.asSet a, positions");
- //TASK ICM6
- Object indices[]={i1,i2,i5,i6,i7,i8}; //remove any commented Index
- // from Array
-
- for(int j=0;j<indices.length;j++){
- CacheUtils.log(((IndexProtocol)indices[j]).isValid());
- boolean r = ((IndexProtocol)indices[j]).isValid();
- assertTrue("Test: testIndexCreation FAILED", r);
- CacheUtils.log(((IndexProtocol)indices[j]).getName());
- CacheUtils.log("Test: testIndexCreation PASS");
- }
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+
+ Index i1 = qs.createIndex("statusIndex", IndexType.FUNCTIONAL, "status", "/portfolios, positions");
+ //TASK ICM1
+ Index i2 = qs.createIndex("secIdIndex", IndexType.FUNCTIONAL, "b.secId", "/portfolios pf, pf.positions.values b");
+ //TASK ICM2
+ Index i5 = qs.createIndex("intFunctionIndex", IndexType.FUNCTIONAL, "intFunction(pf.getID)", "/portfolios pf, pf.positions b");
+ Index i6 = qs.createIndex("statusIndex6", IndexType.FUNCTIONAL, "a.status", "/portfolios.values.toArray a, positions");
+ Index i7 = qs.createIndex("statusIndex7", IndexType.FUNCTIONAL, "a.status", "/portfolios.getValues().asList() a, positions");
+ Index i8 = qs.createIndex("statusIndex8", IndexType.FUNCTIONAL, "a.status", "/portfolios.values.asSet a, positions");
+ //TASK ICM6
+ Object indices[] = { i1, i2, i5, i6, i7, i8 }; //remove any commented Index
+ // from Array
+
+ for (int j = 0; j < indices.length; j++) {
+ CacheUtils.log(((IndexProtocol) indices[j]).isValid());
+ boolean r = ((IndexProtocol) indices[j]).isValid();
+ assertTrue("Test: testIndexCreation FAILED", r);
+ CacheUtils.log(((IndexProtocol) indices[j]).getName());
+ CacheUtils.log("Test: testIndexCreation PASS");
}
-
- @Test
+ }
+
+ @Test
public void testIndexCreationWithImports() throws Exception {
- // Task ID ICM 16
- QueryService qs;
- qs = CacheUtils.getQueryService();
-
- Index idx;
-
- try {
- idx = qs.createIndex("importsIndex", IndexType.FUNCTIONAL, "status",
- "/portfolios, (map<string,Position>)positions");
- fail("Should have thrown a QueryInvalidException"); // can't find type
- // Position
- } catch (QueryInvalidException e) {
- // pass
- }
-
- idx = qs.createIndex("importsIndex", IndexType.FUNCTIONAL, "status",
- "/portfolios, (map<string,Position>)positions",
- "import com.gemstone.gemfire.cache.\"query\".data.Position");
- qs.removeIndex(idx);
-
- idx = qs.createIndex("importsIndex2", IndexType.FUNCTIONAL, "status",
- "/portfolios, positions TYPE Position",
- "import com.gemstone.gemfire.cache.\"query\".data.Position");
+ // Task ID ICM 16
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+
+ Index idx;
+
+ try {
+ idx = qs.createIndex("importsIndex", IndexType.FUNCTIONAL, "status", "/portfolios, (map<string,Position>)positions");
+ fail("Should have thrown a QueryInvalidException"); // can't find type
+ // Position
+ } catch (QueryInvalidException e) {
+ // pass
}
-
- @Test
+
+ idx = qs.createIndex("importsIndex", IndexType.FUNCTIONAL, "status", "/portfolios, (map<string,Position>)positions", "import com.gemstone.gemfire.cache.\"query\".data.Position");
+ qs.removeIndex(idx);
+
+ idx = qs.createIndex("importsIndex2", IndexType.FUNCTIONAL, "status", "/portfolios, positions TYPE Position", "import com.gemstone.gemfire.cache.\"query\".data.Position");
+ }
+
+ @Test
public void testSimilarIndexCreation() throws Exception {
- // Task ID: ICM17
- QueryService qs;
- qs = CacheUtils.getQueryService();
-// boolean exceptionoccured = true;
- qs.createIndex("statusIndex", IndexType.FUNCTIONAL,"status","/portfolios, positions");
- qs.createIndex("secIdIndex", IndexType.FUNCTIONAL,"b.secId","/portfolios pf, pf.positions.values b");
- try {
- qs.createIndex("secIdIndexDuplicate", IndexType.FUNCTIONAL,"b.secId","/portfolios pf, pf.positions.values b");
- fail("testSimilarIndexCreation: Allowed duplicate index creation");
- } catch (Exception e) {
- // testSimilarIndexCreation: Exception if duplicate index is
- // created with diffrenet name but same from clause & expression
- }
-
- try {
- qs.createIndex("secIdIndexDuplicate", IndexType.FUNCTIONAL,"b1.secId","/portfolios pf1, pf1.positions.values b1");
- fail("testSimilarIndexCreation: Allowed duplicate index creation");
- } catch ( Exception e) {
- // testSimilarIndexCreation: Exception if duplicate index is
- // created with diffrenet name but same from clause & expression
- }
- //com.gemstone.gemfire.cache.query.IndexExistsException: Similar Index
- // Exists
- try {
- qs.createIndex("statusIndexDuplicate", IndexType.FUNCTIONAL,"b.status","/portfolios b, positions");
- fail("testSimilarIndexCreation: Allowed duplicate index creation");
- } catch ( Exception e) {
- // testSimilarIndexCreation: Exception if duplicate index is
- // created with diffrenet name but same from clause & expression
- }
+ // Task ID: ICM17
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ // boolean exceptionoccured = true;
+ qs.createIndex("statusIndex", IndexType.FUNCTIONAL, "status", "/portfolios, positions");
+ qs.createIndex("secIdIndex", IndexType.FUNCTIONAL, "b.secId", "/portfolios pf, pf.positions.values b");
+ try {
+ qs.createIndex("secIdIndexDuplicate", IndexType.FUNCTIONAL, "b.secId", "/portfolios pf, pf.positions.values b");
+ fail("testSimilarIndexCreation: Allowed duplicate index creation");
+ } catch (Exception e) {
+ // testSimilarIndexCreation: Exception if duplicate index is
+ // created with diffrenet name but same from clause & expression
}
-
- @Test
+
+ try {
+ qs.createIndex("secIdIndexDuplicate", IndexType.FUNCTIONAL, "b1.secId", "/portfolios pf1, pf1.positions.values b1");
+ fail("testSimilarIndexCreation: Allowed duplicate index creation");
+ } catch (Exception e) {
+ // testSimilarIndexCreation: Exception if duplicate index is
+ // created with diffrenet name but same from clause & expression
+ }
+ //com.gemstone.gemfire.cache.query.IndexExistsException: Similar Index
+ // Exists
+ try {
+ qs.createIndex("statusIndexDuplicate", IndexType.FUNCTIONAL, "b.status", "/portfolios b, positions");
+ fail("testSimilarIndexCreation: Allowed duplicate index creation");
+ } catch (Exception e) {
+ // testSimilarIndexCreation: Exception if duplicate index is
+ // created with diffrenet name but same from clause & expression
+ }
+ }
+
+ @Test
public void testInvalidImportsIndexCreation() throws Exception {
- // Task ID: Invalid Indexes: ICM15
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- qs.createIndex("typeIndex", IndexType.FUNCTIONAL,"\"type\"","/portfolios pf, pf.positions b","pf.position1");
- // projection attributes are not yet implemented
- // last parameter is the imports statement, so this is a syntax
- // error
- fail("Should have thrown an exception since imports are invalid");
- //TASK ICM7
- } catch (QueryInvalidException e){
- // pass
- }
+ // Task ID: Invalid Indexes: ICM15
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ try {
+ qs.createIndex("typeIndex", IndexType.FUNCTIONAL, "\"type\"", "/portfolios pf, pf.positions b", "pf.position1");
+ // projection attributes are not yet implemented
+ // last parameter is the imports statement, so this is a syntax
+ // error
+ fail("Should have thrown an exception since imports are invalid");
+ //TASK ICM7
+ } catch (QueryInvalidException e) {
+ // pass
}
- public void _BUGtestElementIndexCreation() throws Exception {
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- qs.createIndex("funcReturnSecIdIndex", IndexType.FUNCTIONAL,"pf.funcReturnSecId(element(select distinct pos from /portfolios pf, pf.positions.values as pos where pos.sharesOutstanding = 5000))","/portfolios pf, pf.positions b");
- //TASK ICM8: InvalidIndexCreation
- // Query q = qs.newQuery("(element(select distinct pos from
- // /portfolios pf, pf.positions.values as pos where
- // pos.sharesOutstanding = 5000))");
- // Object r=q.execute();
- // CacheUtils.log(Utils.printResult(r));
- } catch (Exception e){
- e.printStackTrace();
- fail("Test Case:testElementIndexCreation FAILED");
- }
+ }
+
+ @Ignore("TODO: disabled and has no assertions")
+ @Test
+ public void testElementIndexCreation() throws Exception {
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ qs.createIndex("funcReturnSecIdIndex", IndexType.FUNCTIONAL, "pf.funcReturnSecId(element(select distinct pos from /portfolios pf, pf.positions.values as pos where pos.sharesOutstanding = 5000))", "/portfolios pf, pf.positions b");
+ //TASK ICM8: InvalidIndexCreation
+ // Query q = qs.newQuery("(element(select distinct pos from
+ // /portfolios pf, pf.positions.values as pos where
+ // pos.sharesOutstanding = 5000))");
+ // Object r=q.execute();
+ // CacheUtils.log(Utils.printResult(r));
+ }
+
+ @Test
+ public void testIndexCreationOnNVLFunction() throws Exception {
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Query query = null;
+ qs.createIndex("NVLIndex1", IndexType.FUNCTIONAL, "nvl(pf.position2, pf.position1).secId", "/portfolios pf");
+
+ query = CacheUtils.getQueryService()
+ .newQuery("select distinct * from /portfolios pf where nvl(pf.position2, pf.position1).secId = 'SUN'");
+ QueryObserverImpl observer = new QueryObserverImpl();
+ QueryObserverHolder.setInstance(observer);
+ query.execute();
+
+ if (!observer.isIndexesUsed) {
+ fail("NO INDEX USED");
}
-
- @Test
- public void testIndexCreationOnNVLFunction() {
- QueryService qs;
- qs = CacheUtils.getQueryService();
- Query query = null;
-// Object result = null;
- try {
- qs.createIndex("NVLIndex1",IndexType.FUNCTIONAL, "nvl(pf.position2, pf.position1).secId", "/portfolios pf");
-
- query = CacheUtils.getQueryService().newQuery("select distinct * from /portfolios pf where nvl(pf.position2, pf.position1).secId = 'SUN'");
- QueryObserverImpl observer = new QueryObserverImpl();
- QueryObserverHolder.setInstance(observer);
- query.execute();
-
- if(!observer.isIndexesUsed){
- fail("NO INDEX USED");
- }
-
-
- query = CacheUtils.getQueryService().newQuery("select distinct nvl(pf.position2, 'inProjection') from /portfolios pf where nvl(pf.position2, pf.position1).secId = 'SUN'");
- observer = new QueryObserverImpl();
- QueryObserverHolder.setInstance(observer);
- query.execute();
-
- if(!observer.isIndexesUsed && observer.indexesUsed.size() != 1){
- fail("NO INDEX USED");
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail("Test Case:testElementIndexCreation FAILED");
- }
+
+
+ query = CacheUtils.getQueryService()
+ .newQuery("select distinct nvl(pf.position2, 'inProjection') from /portfolios pf where nvl(pf.position2, pf.position1).secId = 'SUN'");
+ observer = new QueryObserverImpl();
+ QueryObserverHolder.setInstance(observer);
+ query.execute();
+
+ if (!observer.isIndexesUsed && observer.indexesUsed.size() != 1) {
+ fail("NO INDEX USED");
}
-
- @Test
+ }
+
+ @Test
public void testIndexCreationWithImport() throws Exception {
- // Task ID: ICM16
- QueryService qs;
- qs = CacheUtils.getQueryService();
- Index i3 = qs.createIndex("typeIndex", IndexType.FUNCTIONAL,"\"type\"","/portfolios type Portfolio, positions b","IMPORT com.gemstone.gemfire.cache.\"query\".data.Portfolio");
- //TASK ICM3 Region 'IMPORT' not found:....[BUG : Verified Fixed ]
- try{
- // Index i4=(Index)qs.createIndex("boolFunctionIndex",
- // IndexType.FUNCTIONAL,"boolFunction(pf.status)","/portfolios pf,
- // pf.positions.values b");
- //TASK ICM5 com.gemstone.gemfire.cache.query.IndexInvalidException
-
- Object indices[]={i3}; //remove any commented Index from Array
-
- for(int j=0;j<indices.length;j++){
- CacheUtils.log(((IndexProtocol)indices[j]).isValid());
- boolean r = ((IndexProtocol)indices[j]).isValid();
- if(r==true){
- CacheUtils.log(((IndexProtocol)indices[j]).getName());
- CacheUtils.log("Test: testIndexCreation PASS");
- } else{
- fail("Test: testIndexCreation FAILED");
- }
- }
- } catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
- @Test
+ // Task ID: ICM16
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Index i3 = qs.createIndex("typeIndex", IndexType.FUNCTIONAL, "\"type\"", "/portfolios type Portfolio, positions b", "IMPORT com.gemstone.gemfire.cache.\"query\".data.Portfolio");
+ //TASK ICM3 Region 'IMPORT' not found:....[BUG : Verified Fixed ]
+ // Index i4=(Index)qs.createIndex("boolFunctionIndex",
+ // IndexType.FUNCTIONAL,"boolFunction(pf.status)","/portfolios pf,
+ // pf.positions.values b");
+ //TASK ICM5 com.gemstone.gemfire.cache.query.IndexInvalidException
+
+ Object indices[] = { i3 }; //remove any commented Index from Array
+
+ for (int j = 0; j < indices.length; j++) {
+ CacheUtils.log(((IndexProtocol) indices[j]).isValid());
+ boolean r = ((IndexProtocol) indices[j]).isValid();
+ if (r == true) {
+ CacheUtils.log(((IndexProtocol) indices[j]).getName());
+ CacheUtils.log("Test: testIndexCreation PASS");
+ } else {
+ fail("Test: testIndexCreation FAILED");
+ }
+ }
+ }
+
+ @Test
public void testComparisonBetnWithAndWithoutIndexCreationComparableObject() throws Exception {
- // Task ID IUM10
- SelectResults r[][]= new SelectResults[4][2];
- QueryService qs;
- qs = CacheUtils.getQueryService();
- String queries[] = {
- "select distinct * from /portfolios pf where pf.getCW(pf.ID) = $1",
- "select distinct * from /portfolios pf where pf.getCW(pf.ID) > $1",
- "select distinct * from /portfolios pf where pf.getCW(pf.ID) < $1",
- "select distinct * from /portfolios pf where pf.getCW(pf.ID) != $1"
- // TASK IUM 10
- };
- for (int i = 0; i < queries.length; i++) {
- Query q = null;
- try {
- q = CacheUtils.getQueryService().newQuery(queries[i]);
- Object params[] = new Object[1];
- params[0] = new ComparableWrapper(1);
- QueryObserverImpl observer = new QueryObserverImpl();
- QueryObserverHolder.setInstance(observer);
- r[i][0] = (SelectResults)q.execute(params);
-
- if(!observer.isIndexesUsed){
- CacheUtils.log("NO INDEX USED");
- }
- CacheUtils.log(Utils.printResult(r[i][0]));
- resType1 =(r[i][0]).getCollectionType().getElementType();
- resSize1 =((r[i][0]).size());
- CacheUtils.log("Result Type= "+resType1);
- CacheUtils.log("Result Size= "+resSize1);
- set1=((r[i][0]).asSet());
- // Iterator iter=set1.iterator();
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(q.getQueryString());
- }
- }
-
- // Create an Index on status and execute the same query again.
-
- qs = CacheUtils.getQueryService();
- qs.createIndex("cIndex", IndexType.FUNCTIONAL,"pf.getCW(pf.ID)","/portfolios pf");
-
- for (int i = 0; i < queries.length; i++) {
- Query q = null;
- try {
- q = CacheUtils.getQueryService().newQuery(queries[i]);
- Object params[] = new Object[1];
- params[0] = new ComparableWrapper(1);
- QueryObserverImpl observer2 = new QueryObserverImpl();
- QueryObserverHolder.setInstance(observer2);
- r[i][1] = (SelectResults)q.execute(params);
- if(observer2.isIndexesUsed){
- CacheUtils.log("YES INDEX IS USED!");
- } else {
- fail("FAILED: Index NOT Used");
- }
- CacheUtils.log(Utils.printResult(r[i][1]));
- resType2 =(r[i][1]).getCollectionType().getElementType();
- resSize2 =((r[i][1]).size());
- set2=((r[i][1]).asSet());
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(q.getQueryString());
- }
- }
- /*for(int j = 0; j <= 3 ; j++){
- if ((((SelectResults)r[j][0]).getCollectionType().getElementType()).equals(((SelectResults)r[j][1]).getCollectionType().getElementType())){
- CacheUtils.log("Both Search Results are of the same Type i.e.--> "+((SelectResults)r[j][0]).getCollectionType().getElementType());
- }else {
- fail("FAILED:Search result Type is different in both the cases");
- }
- if (((SelectResults)r[j][0]).size()==((SelectResults)r[j][1]).size() || ((SelectResults)r[j][1]).size()!= 0 ){
- CacheUtils.log("Both Search Results are non-zero and are of Same Size i.e. Size= "+((SelectResults)r[j][1]).size());
- }else {
- fail("FAILED:Search result Type is different in both the cases");
- }
- set2=(((SelectResults)r[j][1]).asSet());
- set1=(((SelectResults)r[j][0]).asSet());
- if (!set1.equals(set2)){
- fail();
- }
-
- }*/
- CacheUtils.compareResultsOfWithAndWithoutIndex(r, this);
- }
-
+ // Task ID IUM10
+ SelectResults r[][] = new SelectResults[4][2];
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ String queries[] = {
+ "select distinct * from /portfolios pf where pf.getCW(pf.ID) = $1",
+ "select distinct * from /portfolios pf where pf.getCW(pf.ID) > $1",
+ "select distinct * from /portfolios pf where pf.getCW(pf.ID) < $1",
+ "select distinct * from /portfolios pf where pf.getCW(pf.ID) != $1"
+ // TASK IUM 10
+ };
+ for (int i = 0; i < queries.length; i++) {
+ Query q = null;
+ q = CacheUtils.getQueryService().newQuery(queries[i]);
+ Object params[] = new Object[1];
+ params[0] = new ComparableWrapper(1);
+ QueryObserverImpl observer = new QueryObserverImpl();
+ QueryObserverHolder.setInstance(observer);
+ r[i][0] = (SelectResults) q.execute(params);
+
+ if (!observer.isIndexesUsed) {
+ CacheUtils.log("NO INDEX USED");
+ }
+ CacheUtils.log(Utils.printResult(r[i][0]));
+ resType1 = (r[i][0]).getCollectionType().getElementType();
+ resSize1 = ((r[i][0]).size());
+ CacheUtils.log("Result Type= " + resType1);
+ CacheUtils.log("Result Size= " + resSize1);
+ set1 = ((r[i][0]).asSet());
+ // Iterator iter=set1.iterator();
+ }
+
+ // Create an Index on status and execute the same query again.
+
+ qs = CacheUtils.getQueryService();
+ qs.createIndex("cIndex", IndexType.FUNCTIONAL, "pf.getCW(pf.ID)", "/portfolios pf");
+
+ for (int i = 0; i < queries.length; i++) {
+ Query q = null;
+ q = CacheUtils.getQueryService().newQuery(queries[i]);
+ Object params[] = new Object[1];
+ params[0] = new ComparableWrapper(1);
+ QueryObserverImpl observer2 = new QueryObserverImpl();
+ QueryObserverHolder.setInstance(observer2);
+ r[i][1] = (SelectResults) q.execute(params);
+ if (observer2.isIndexesUsed) {
+ CacheUtils.log("YES INDEX IS USED!");
+ } else {
+ fail("FAILED: Index NOT Used");
+ }
+ CacheUtils.log(Utils.printResult(r[i][1]));
+ resType2 = (r[i][1]).getCollectionType().getElementType();
+ resSize2 = ((r[i][1]).size());
+ set2 = ((r[i][1]).asSet());
+ }
+ CacheUtils.compareResultsOfWithAndWithoutIndex(r, this);
+ }
+
@Test
public void testIndexCreationWithIndexOperatorUsage() throws Exception {
// Task ID : ICM 18
@@@ -390,323 -431,386 +389,321 @@@
// Index i3 =
// qs.createIndex("Task6Index",IndexType.FUNCTIONAL,"pos.secId","/portfolios
// pf, pf.positions.values pos");
- }
- @Test
+ }
+
+ @Test
public void testIndexCreationOnKeys() throws Exception {
- // Task ID : ICM 9
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- Index i1 = qs.createIndex("kIndex", IndexType.FUNCTIONAL, "pf","/portfolios.keys pf");
- Index i2 = qs.createIndex("k1Index", IndexType.FUNCTIONAL, "key","/portfolios.entries");
- Index i3 = qs.createIndex("k2Index", IndexType.FUNCTIONAL, "pf","/portfolios.keys.toArray pf");
- //Index i4 = qs.createIndex("k3Index", IndexType.FUNCTIONAL,
- // "pf","/portfolios.keys().toArray() pf");
- Index i5 = qs.createIndex("k4Index", IndexType.FUNCTIONAL, "pf","/portfolios.getKeys.asList pf");
- // Index i5 = qs.createIndex("k5Index", IndexType.FUNCTIONAL,
- // "pf","/portfolios.getKeys.asList() pf");
- Index i6 = qs.createIndex("k5Index", IndexType.FUNCTIONAL, "pf","/portfolios.getKeys.asSet() pf");
- //Index i5 = qs.createIndex("k5Index", IndexType.FUNCTIONAL,
- // "pf","/portfolios.getKeys.asSet pf");
- CacheUtils.log(((CompactRangeIndex)i1).dump());
- CacheUtils.log(((CompactRangeIndex)i2).dump());
- CacheUtils.log(((CompactRangeIndex)i3).dump());
- CacheUtils.log(((CompactRangeIndex)i5).dump());
- CacheUtils.log(((CompactRangeIndex)i6).dump());
- }catch (Exception e){
- e.printStackTrace();
- }
- }
- @Test
+ // Task ID : ICM 9
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Index i1 = qs.createIndex("kIndex", IndexType.FUNCTIONAL, "pf", "/portfolios.keys pf");
+ Index i2 = qs.createIndex("k1Index", IndexType.FUNCTIONAL, "key", "/portfolios.entries");
+ Index i3 = qs.createIndex("k2Index", IndexType.FUNCTIONAL, "pf", "/portfolios.keys.toArray pf");
+ //Index i4 = qs.createIndex("k3Index", IndexType.FUNCTIONAL,
+ // "pf","/portfolios.keys().toArray() pf");
+ Index i5 = qs.createIndex("k4Index", IndexType.FUNCTIONAL, "pf", "/portfolios.getKeys.asList pf");
+ // Index i5 = qs.createIndex("k5Index", IndexType.FUNCTIONAL,
+ // "pf","/portfolios.getKeys.asList() pf");
+ Index i6 = qs.createIndex("k5Index", IndexType.FUNCTIONAL, "pf", "/portfolios.getKeys.asSet() pf");
+ //Index i5 = qs.createIndex("k5Index", IndexType.FUNCTIONAL,
+ // "pf","/portfolios.getKeys.asSet pf");
+ CacheUtils.log(((CompactRangeIndex) i1).dump());
+ CacheUtils.log(((CompactRangeIndex) i2).dump());
+ CacheUtils.log(((CompactRangeIndex) i3).dump());
+ CacheUtils.log(((CompactRangeIndex) i5).dump());
+ CacheUtils.log(((CompactRangeIndex) i6).dump());
+ }
+
+ @Test
public void testIndexCreationOnRegionEntry() throws Exception {
- // Task ID : ICM11
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- Index i1 = qs.createIndex("r1Index", IndexType.FUNCTIONAL, "secId","/portfolios.values['1'].positions.values");
- qs.createIndex("r12Index", IndexType.FUNCTIONAL, "secId","/portfolios['1'].positions.values");
- CacheUtils.log(((CompactRangeIndex)i1).dump());
- //CacheUtils.log(((RangeIndex)i2).dump());
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- }
-
+ // Task ID : ICM11
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Index i1 = qs.createIndex("r1Index", IndexType.FUNCTIONAL, "secId", "/portfolios.values['1'].positions.values");
+ qs.createIndex("r12Index", IndexType.FUNCTIONAL, "secId", "/portfolios['1'].positions.values");
+ CacheUtils.log(((CompactRangeIndex) i1).dump());
+ //CacheUtils.log(((RangeIndex)i2).dump());
+ }
+
+
+ /**
+ * Creation of index on a path derived from Region.Entry object obtained
+ * via entrySet , fails as that function was not supported in the
+ * QRegion & DummyQRegion
+ */
+ @Test
+ public void testBug36823() throws Exception {
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ qs.createIndex("entryIndex", IndexType.FUNCTIONAL, "value.getID()", "/portfolios.entrySet pf");
+ Region rgn = CacheUtils.getRegion("/portfolios");
+ rgn.put("4", new Portfolio(4));
+ rgn.put("5", new Portfolio(5));
+ Query qr = qs.newQuery("Select distinct * from /portfolios.entrySet pf where pf.value.getID() = 4");
+ SelectResults sr = (SelectResults) qr.execute();
+ assertEquals(sr.size(), 1);
+ }
+
-
+ /**
+ * Creation of index on key path derived from Region.Entry object obtained
+ * via keySet , fails as that function was not supported in the
+ * QRegion & DummyQRegion
+ */
+ @Test
+ public void testBug36590() throws Exception {
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+
+ qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "keys", "/portfolios.keySet keys");
+ Region rgn = CacheUtils.getRegion("/portfolios");
+ rgn.put("4", new Portfolio(4));
+ rgn.put("5", new Portfolio(5));
+ Query qr = qs.newQuery("Select distinct * from /portfolios.keySet keys where keys = '4'");
+ SelectResults sr = (SelectResults) qr.execute();
+ assertEquals(sr.size(), 1);
+ }
+
+ /**
- * The Index maiantenance has a bug as it does not re-evaluate the
++ * The Index maintenance has a bug as it does not re-evaluate the
+ * index maintenance collection in the IMQEvaluator when an entry
+ * gets modified & so the index resultset is messed up
+ */
+ @Test
+ public void testBug36591() throws Exception {
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Index i1 = qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "ks.hashCode", "/portfolios.keys ks");
+ Region rgn = CacheUtils.getRegion("/portfolios");
+ rgn.put("4", new Portfolio(4));
+ rgn.put("5", new Portfolio(5));
+ CacheUtils.log(((CompactRangeIndex) i1).dump());
+
+ Query qr = qs.newQuery("Select distinct * from /portfolios.keys keys where keys.hashCode >= $1");
+ SelectResults sr = (SelectResults) qr.execute(new Object[] { new Integer(-1) });
+ assertEquals(6, sr.size());
+ }
+
+ /**
+ * Creation of index on a path derived from Region.Entry object obtained
+ * via entrySet , fails as that function was not supported in the
+ * QRegion & DummyQRegion
+ */
+ @Test
+ public void testBug43519() throws Exception {
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Index index = qs.createIndex("shortIndex", IndexType.FUNCTIONAL, "p.shortID", "/portfolios p");
+ Region rgn = CacheUtils.getRegion("/portfolios");
+ for (int i = 1; i <= 10; i++) {
+ String key = "" + i;
+ Portfolio p = new Portfolio(i);
+ p.shortID = new Short(key);
+ // addToIndex
+ rgn.put(key, p);
+ // updateIndex
+ rgn.put(key, p);
+ if (i % 2 == 0) {
+ // destroy from index.
+ rgn.destroy(key);
+ }
}
-
-
-
- /**
- * Creation of index on a path derived from Region.Entry object obtained
- * via entrySet , fails as that function was not supported in the
- * QRegion & DummyQRegion
- */
- @Test
- public void testBug36823() {
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- qs.createIndex("entryIndex", IndexType.FUNCTIONAL, "value.getID()","/portfolios.entrySet pf");
- Region rgn = CacheUtils.getRegion("/portfolios");
- rgn.put("4",new Portfolio(4));
- rgn.put("5",new Portfolio(5));
- Query qr = qs.newQuery("Select distinct * from /portfolios.entrySet pf where pf.value.getID() = 4");
- SelectResults sr = (SelectResults)qr.execute();
- assertEquals(sr.size(),1);
- }catch(Exception e) {
- CacheUtils.getLogger().error(e);
- fail("Test failed because of exception. e="+e);
- }
+ Query qr = qs.newQuery("Select p.shortID from /portfolios p where p.shortID < 5");
+ SelectResults sr = (SelectResults) qr.execute();
+ assertEquals(sr.size(), 2);
+ }
+
+ /**
+ * Test the Index maiantenance as it may use the method keys() of QRegion
+ * instead of DummyQRegion while running an IndexMaintenanceQuery
+ */
+ @Test
+ public void testIMQFailureAsMethodKeysNAInDummyQRegion() throws Exception {
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Index i1 = qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "ks.hashCode", "/portfolios.keys() ks");
+ Region rgn = CacheUtils.getRegion("/portfolios");
+ rgn.put("4", new Portfolio(4));
+ rgn.put("5", new Portfolio(5));
+ CacheUtils.log(((CompactRangeIndex) i1).dump());
+
+ Query qr = qs.newQuery("Select distinct keys.hashCode from /portfolios.keys() keys where keys.hashCode >= $1");
+ SelectResults sr = (SelectResults) qr.execute(new Object[] { new Integer(-1) });
+ assertEquals(6, sr.size());
+ }
+
-
+ @Test
+ public void testIndexCreationWithFunctions() throws Exception {
+ // Task ID : ICM14
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Index i1 = qs.createIndex("SetSecIDIndex1", IndexType.FUNCTIONAL, "b.secId", "/portfolios.asSet pf, pf.positions.values b");
+ Index i2 = qs.createIndex("ListSecIDIndex2", IndexType.FUNCTIONAL, "b.secId", "/portfolios.asList pf, pf.positions.values b");
+ Index i3 = qs.createIndex("ArraySecIDIndex3", IndexType.FUNCTIONAL, "b.secId", "/portfolios.toArray pf, pf.positions.values b");
+ CacheUtils.log(((RangeIndex) i1).dump());
+ CacheUtils.log(((RangeIndex) i2).dump());
+ CacheUtils.log(((RangeIndex) i3).dump());
+ }
+
+ @Test
+ public void testInvalidIndexes() throws Exception {
+ //Task ID: ICM15
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ try {
+ Index i1 = qs.createIndex("r1Index", IndexType.FUNCTIONAL, "secId", "/portfolios.toArray[1].positions.values");
+ CacheUtils.log(((RangeIndex) i1).dump());
+ fail("Index creation should have failed");
+ } catch (Exception e) {
}
-
-
- /**
- * Creation of index on key path derived from Region.Entry object obtained
- * via keySet , fails as that function was not supported in the
- * QRegion & DummyQRegion
- */
- @Test
- public void testBug36590() {
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "keys","/portfolios.keySet keys");
- Region rgn = CacheUtils.getRegion("/portfolios");
- rgn.put("4",new Portfolio(4));
- rgn.put("5",new Portfolio(5));
- Query qr = qs.newQuery("Select distinct * from /portfolios.keySet keys where keys = '4'");
- SelectResults sr = (SelectResults)qr.execute();
- assertEquals(sr.size(),1);
- }catch(Exception e) {
- CacheUtils.getLogger().error(e);
- fail("Test failed because of exception. e="+e);
- }
+ try {
+ Index i2 = qs.createIndex("r12Index", IndexType.FUNCTIONAL, "secId", "/portfolios.asList[1].positions.values");
+ CacheUtils.log(((RangeIndex) i2).dump());
+ fail("Index creation should have failed");
+ } catch (Exception e) {
}
-
- /**
- * The Index maiantenance has a bug as it does not re-evaluate the
- * index maintenance collection in the IMQEvaluator when an entry
- * gets modified & so the index resultset is messed up
- */
- @Test
- public void testBug36591() {
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- Index i1 = qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "ks.hashCode","/portfolios.keys ks");
- Region rgn = CacheUtils.getRegion("/portfolios");
- rgn.put("4",new Portfolio(4));
- rgn.put("5",new Portfolio(5));
- CacheUtils.log(((CompactRangeIndex)i1).dump());
-
- Query qr = qs.newQuery("Select distinct * from /portfolios.keys keys where keys.hashCode >= $1");
- SelectResults sr = (SelectResults)qr.execute(new Object[]{new Integer(-1)});
- assertEquals(6,sr.size());
- }catch(Exception e) {
- CacheUtils.getLogger().error(e);
- fail("Test failed because of exception. e="+e);
- }
+ }
+
+ @Test
+ public void testIndexCreationWithFunctionsinFromClause() throws Exception {
+ // Task ID: ICM13
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ // BUG #32586 : FIXED
+ Index i1 = qs.createIndex("Index11", IndexType.FUNCTIONAL, "status", "/portfolios.values.toArray()");
+ Index i2 = qs.createIndex("Index12", IndexType.FUNCTIONAL, "ID", "/portfolios.values.asSet");
+ Index i3 = qs.createIndex("Index13", IndexType.FUNCTIONAL, "ID", "/portfolios.values.asList");
+
+ qs.createIndex("Index14", IndexType.FUNCTIONAL, "value.ID", "/portfolios.entries.toArray()");
+ qs.createIndex("Index15", IndexType.FUNCTIONAL, "value.ID", "/portfolios.entries.asSet");
+ qs.createIndex("Index16", IndexType.FUNCTIONAL, "value.ID", "/portfolios.entries.asList");
+
+ // BUG #32586 : FIXED
+ qs.createIndex("Index17", IndexType.FUNCTIONAL, "kIter", "/portfolios.keys.toArray() kIter");
+ qs.createIndex("Index18", IndexType.FUNCTIONAL, "kIter", "/portfolios.keys.asSet kIter");
+ qs.createIndex("Index19", IndexType.FUNCTIONAL, "kIter", "/portfolios.keys.asList kIter");
+
+ CacheUtils.log(((CompactRangeIndex) i1).dump());
+ CacheUtils.log(((CompactRangeIndex) i2).dump());
+ CacheUtils.log(((CompactRangeIndex) i3).dump());
+ }
+
+ @Test
+ public void testIndexObjectTypeWithRegionConstraint() throws Exception {
+ QueryService qs;
+ qs = CacheUtils.getQueryService();
+ Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL, "b.secId", "/portfolios pf, pf.positions.values b");
+ ObjectType type = ((IndexProtocol) i1).getResultSetType();
+ String fieldNames[] = { "index_iter1", "index_iter2" };
+ ObjectType fieldTypes[] = { new ObjectTypeImpl(Portfolio.class), new ObjectTypeImpl(Object.class) };
+ //ObjectType expectedType = new StructTypeImpl( fieldNames,fieldTypes);
+ ObjectType expectedType = new StructTypeImpl(fieldNames, fieldTypes);
+ if (!(type instanceof StructType && type.equals(expectedType))) {
+ fail("The ObjectType obtained from index is not of the expected type. Type obtained from index=" + type);
}
-
- /**
- * Creation of index on a path derived from Region.Entry object obtained
- * via entrySet , fails as that function was not supported in the
- * QRegion & DummyQRegion
- */
- @Test
- public void testBug43519() {
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- Index index = qs.createIndex("shortIndex", IndexType.FUNCTIONAL, "p.shortID","/portfolios p");
- Region rgn = CacheUtils.getRegion("/portfolios");
- for (int i=1; i <= 10; i++) {
- String key ="" + i;
- Portfolio p = new Portfolio(i);
- p.shortID = new Short(key);
- // addToIndex
- rgn.put(key, p);
- // updateIndex
- rgn.put(key, p);
- if (i %2 == 0) {
- // destroy from index.
- rgn.destroy(key);
- }
- }
- Query qr = qs.newQuery("Select p.shortID from /portfolios p where p.shortID < 5");
- SelectResults sr = (SelectResults)qr.execute();
- assertEquals(sr.size(),2);
- }catch(Exception e) {
- CacheUtils.getLogger().error(e);
- fail("Test failed because of exception. e="+e);
- }
+
+ Index i2 = qs.createIndex("Index2", IndexType.FUNCTIONAL, "pf.ID", "/portfolios.values pf");
+ type = ((IndexProtocol) i2).getResultSetType();
+
+ expectedType = new ObjectTypeImpl(Portfolio.class);
+ if (!type.equals(expectedType)) {
+ fail("The ObjectType obtained from index is not of the expected type. Type obtained from index=" + type);
}
- /**
- * Test the Index maiantenance as it may use the method keys() of QRegion
- * instead of DummyQRegion while running an IndexMaintenanceQuery
- */
- @Test
- public void testIMQFailureAsMethodKeysNAInDummyQRegion() {
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- Index i1 = qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "ks.hashCode","/portfolios.keys() ks");
- Region rgn = CacheUtils.getRegion("/portfolios");
- rgn.put("4",new Portfolio(4));
- rgn.put("5",new Portfolio(5));
- CacheUtils.log(((CompactRangeIndex)i1).dump());
-
- Query qr = qs.newQuery("Select distinct keys.hashCode from /portfolios.keys() keys where keys.hashCode >= $1");
- SelectResults sr = (SelectResults)qr.execute(new Object[]{new Integer(-1)});
- assertEquals(6,sr.size());
- }catch(Exception e) {
- CacheUtils.getLogger().error(e);
- fail("Test failed because of exception. e="+e);
- }
+ Index i3 = qs.createIndex("Index3", IndexType.FUNCTIONAL, "pos.secId", "/portfolios['0'].positions.values pos");
+ type = ((IndexProtocol) i3).getResultSetType();
+
+ expectedType = new ObjectTypeImpl(Object.class);
+ if (!type.equals(expectedType)) {
+ fail("The ObjectType obtained from index is not of the expected type. Type obtained from index=" + type);
}
-
-
- @Test
- public void testIndexCreationWithFunctions() throws Exception {
- // Task ID : ICM14
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- Index i1 = qs.createIndex("SetSecIDIndex1", IndexType.FUNCTIONAL,"b.secId","/portfolios.asSet pf, pf.positions.values b");
- Index i2 = qs.createIndex("ListSecIDIndex2", IndexType.FUNCTIONAL,"b.secId","/portfolios.asList pf, pf.positions.values b");
- Index i3 = qs.createIndex("ArraySecIDIndex3", IndexType.FUNCTIONAL,"b.secId","/portfolios.toArray pf, pf.positions.values b");
- CacheUtils.log(((RangeIndex)i1).dump());
- CacheUtils.log(((RangeIndex)i2).dump());
- CacheUtils.log(((RangeIndex)i3).dump());
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- }
- }
- @Test
- public void testInvalidIndexes() {
- //Task ID: ICM15
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- Index i1 = qs.createIndex("r1Index", IndexType.FUNCTIONAL, "secId","/portfolios.toArray[1].positions.values");
- CacheUtils.log(((RangeIndex)i1).dump());
- fail("Index creation should have failed");
- } catch (Exception e) {
- //e.printStackTrace();
- Assert.assertTrue(true);
- }
- try{
- Index i2 = qs.createIndex("r12Index", IndexType.FUNCTIONAL, "secId","/portfolios.asList[1].positions.values");
- CacheUtils.log(((RangeIndex)i2).dump());
- fail("Index creation should have failed");
- } catch (Exception e) {
- //e.printStackTrace();
- Assert.assertTrue(true);
- }
+
+ Index i4 = qs.createIndex("Index4", IndexType.PRIMARY_KEY, "ID", "/portfolios");
+ type = ((IndexProtocol) i4).getResultSetType();
+
+ expectedType = new ObjectTypeImpl(Portfolio.class);
+ if (!type.equals(expectedType)) {
+ fail("The ObjectType obtained from index is not of the expected type. Type obtained from index=" + type);
}
- @Test
- public void testIndexCreationWithFunctionsinFromClause() throws Exception {
- // Task ID: ICM13
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- // BUG #32586 : FIXED
- Index i1 = qs.createIndex("Index11", IndexType.FUNCTIONAL,"status","/portfolios.values.toArray()");
- Index i2 = qs.createIndex("Index12", IndexType.FUNCTIONAL,"ID","/portfolios.values.asSet");
- Index i3 = qs.createIndex("Index13", IndexType.FUNCTIONAL,"ID","/portfolios.values.asList");
-
- qs.createIndex("Index14", IndexType.FUNCTIONAL,"value.ID","/portfolios.entries.toArray()");
- qs.createIndex("Index15", IndexType.FUNCTIONAL,"value.ID","/portfolios.entries.asSet");
- qs.createIndex("Index16", IndexType.FUNCTIONAL,"value.ID","/portfolios.entries.asList");
-
- // BUG #32586 : FIXED
- qs.createIndex("Index17", IndexType.FUNCTIONAL,"kIter","/portfolios.keys.toArray() kIter");
- qs.createIndex("Index18", IndexType.FUNCTIONAL,"kIter","/portfolios.keys.asSet kIter");
- qs.createIndex("Index19", IndexType.FUNCTIONAL,"kIter","/portfolios.keys.asList kIter");
-
- CacheUtils.log(((CompactRangeIndex)i1).dump());
- CacheUtils.log(((CompactRangeIndex)i2).dump());
- CacheUtils.log(((CompactRangeIndex)i3).dump());
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- }
+ }
+
+ @Test
+ public void testIndexOnOverflowRegion() throws Exception {
+ String regionName = "portfolios_overflow";
+
+ // overflow region.
+ AttributesFactory attributesFactory = new AttributesFactory();
+ attributesFactory.setValueConstraint(Portfolio.class);
+ attributesFactory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));
+
+ Region region = CacheUtils.createRegion(regionName, attributesFactory.create(), true);
+
+ for (int i = 0; i < 4; i++) {
+ region.put(new Portfolio(i), new Portfolio(i));
}
-
- @Test
- public void testIndexObjectTypeWithRegionConstraint() {
- QueryService qs;
- qs = CacheUtils.getQueryService();
- try{
- Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL,"b.secId","/portfolios pf, pf.positions.values b");
- ObjectType type = ((IndexProtocol)i1).getResultSetType();
- String fieldNames [] = {"index_iter1","index_iter2"};
- ObjectType fieldTypes [] = { new ObjectTypeImpl(Portfolio.class),new ObjectTypeImpl(Object.class) };
- //ObjectType expectedType = new StructTypeImpl( fieldNames,fieldTypes);
- ObjectType expectedType = new StructTypeImpl( fieldNames,fieldTypes);
- if( !(type instanceof StructType && type.equals(expectedType)) ){
- fail("The ObjectType obtained from index is not of the expected type. Type obtained from index="+type);
- }
-
- Index i2 = qs.createIndex("Index2", IndexType.FUNCTIONAL,"pf.ID","/portfolios.values pf");
- type = ((IndexProtocol)i2).getResultSetType();
-
- expectedType = new ObjectTypeImpl( Portfolio.class);
- if( ! type.equals(expectedType) ){
- fail("The ObjectType obtained from index is not of the expected type. Type obtained from index="+type);
- }
-
- Index i3 = qs.createIndex("Index3", IndexType.FUNCTIONAL,"pos.secId","/portfolios['0'].positions.values pos");
- type = ((IndexProtocol)i3).getResultSetType();
-
- expectedType = new ObjectTypeImpl( Object.class);
- if( ! type.equals(expectedType) ){
- fail("The ObjectType obtained from index is not of the expected type. Type obtained from index="+type);
- }
-
- Index i4 = qs.createIndex("Index4", IndexType.PRIMARY_KEY,"ID","/portfolios");
- type = ((IndexProtocol)i4).getResultSetType();
-
- expectedType = new ObjectTypeImpl( Portfolio.class);
- if( ! type.equals(expectedType) ){
- fail("The ObjectType obtained from index is not of the expected type. Type obtained from index="+type);
- }
-
-
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- }
+
+ QueryService qs = CacheUtils.getQueryService();
+ // Currently supported with compact range-index.
+ Index i1 = qs.createIndex("idIndex", IndexType.FUNCTIONAL, "pf.ID", "/portfolios_overflow pf");
+ Index i2 = qs.createIndex("keyIdIndex", IndexType.FUNCTIONAL, "key.ID", "/portfolios_overflow.keys key");
+
+ // Not yet supported with range-index.
+ try {
+ Index i3 = qs.createIndex("idIndex2", IndexType.FUNCTIONAL, "pf.ID", "/portfolios_overflow pf, pf.positions pos");
+ fail("Range index not supported on overflow region.");
+ } catch (UnsupportedOperationException ex) {
+ // Expected.
}
-
- @Test
- public void testIndexOnOverflowRegion() throws Exception
- {
- String regionName = "portfolios_overflow";
-
- // overflow region.
- AttributesFactory attributesFactory = new AttributesFactory();
- attributesFactory.setValueConstraint(Portfolio.class);
- attributesFactory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(
- 1, EvictionAction.OVERFLOW_TO_DISK));
-
- Region region = CacheUtils.createRegion(regionName, attributesFactory.create(), true);
-
- for(int i=0;i<4;i++){
- region.put(new Portfolio(i), new Portfolio(i));
- }
-
- QueryService qs = CacheUtils.getQueryService();
- // Currently supported with compact range-index.
- Index i1 = qs.createIndex("idIndex", IndexType.FUNCTIONAL, "pf.ID", "/portfolios_overflow pf");
- Index i2 = qs.createIndex("keyIdIndex", IndexType.FUNCTIONAL, "key.ID", "/portfolios_overflow.keys key");
-
- // Not yet supported with range-index.
- try {
- Index i3 = qs.createIndex("idIndex2", IndexType.FUNCTIONAL, "pf.ID", "/portfolios_overflow pf, pf.positions pos");
- fail("Range index not supported on overflow region.");
- } catch (UnsupportedOperationException ex){
- // Expected.
- Assert.assertTrue(true);
- }
- // Execute query.
- String[] queryStr = new String[] {
- "Select * from /portfolios_overflow pf where pf.ID = 2",
- "Select * from /portfolios_overflow.keys key where key.ID = 2",
- "Select * from /portfolios_overflow pf where pf.ID > 1",
- "Select * from /portfolios_overflow pf where pf.ID < 2",
- };
-
- int[] resultSize = new int[] {
- 1,
- 1,
- 2,
- 2
- };
-
- for (int i=0; i < queryStr.length; i++){
- Query q = qs.newQuery(queryStr[i]);
- QueryObserverImpl observer = new QueryObserverImpl();
- QueryObserverHolder.setInstance(observer);
- SelectResults results = (SelectResults)q.execute();
- if(!observer.isIndexesUsed){
- fail("Index not used for query. " + queryStr[i]);
- }
- assertEquals(results.size(), resultSize[i]);
- }
-
- for(int i=0;i<10;i++){
- region.put(new Portfolio(i), new Portfolio(i));
+ // Execute query.
+ String[] queryStr = new String[] {
+ "Select * from /portfolios_overflow pf where pf.ID = 2",
+ "Select * from /portfolios_overflow.keys key where key.ID = 2",
+ "Select * from /portfolios_overflow pf where pf.ID > 1",
+ "Select * from /portfolios_overflow pf where pf.ID < 2",
+ };
+
+ int[] resultSize = new int[] {
+ 1, 1, 2, 2
+ };
+
+ for (int i = 0; i < queryStr.length; i++) {
+ Query q = qs.newQuery(queryStr[i]);
+ QueryObserverImpl observer = new QueryObserverImpl();
+ QueryObserverHolder.setInstance(observer);
+ SelectResults results = (SelectResults) q.execute();
+ if (!observer.isIndexesUsed) {
+ fail("Index not used for query. " + queryStr[i]);
}
-
- // Persistent overflow region.
-
+ assertEquals(results.size(), resultSize[i]);
+ }
+
+ for (int i = 0; i < 10; i++) {
+ region.put(new Portfolio(i), new Portfolio(i));
}
-
+
+ // Persistent overflow region.
+
+ }
+
@Test
- public void testMapKeyIndexCreation_1_NonCompactType() throws Exception
- {
+ public void testMapKeyIndexCreation_1_NonCompactType() throws Exception {
QueryService qs;
qs = CacheUtils.getQueryService();
- Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL, "pf.positions[*]",
- "/portfolios pf");
- assertEquals(i1.getCanonicalizedIndexedExpression(),"index_iter1.positions[*]");
- assertTrue(i1 instanceof CompactMapRangeIndex);
+ Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL, "pf.positions[*]", "/portfolios pf");
+ assertEquals(i1.getCanonicalizedIndexedExpression(), "index_iter1.positions[*]");
+ assertTrue(i1 instanceof CompactMapRangeIndex);
}
-
+
@Test
- public void testMapKeyIndexCreation_2_NonCompactType() throws Exception
- {
+ public void testMapKeyIndexCreation_2_NonCompactType() throws Exception {
QueryService qs;
qs = CacheUtils.getQueryService();
- Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL,
- "pf.positions['key1','key2','key3']", "/portfolios pf");
- assertEquals(i1.getCanonicalizedIndexedExpression(),
- "index_iter1.positions['key1','key2','key3']");
+ Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL, "pf.positions['key1','key2','key3']", "/portfolios pf");
+ assertEquals(i1.getCanonicalizedIndexedExpression(), "index_iter1.positions['key1','key2','key3']");
assertTrue(i1 instanceof CompactMapRangeIndex);
- CompactMapRangeIndex mri = (CompactMapRangeIndex)i1;
+ CompactMapRangeIndex mri = (CompactMapRangeIndex) i1;
Object mapKeys[] = mri.getMapKeysForTesting();
- assertEquals(mapKeys.length,3);
+ assertEquals(mapKeys.length, 3);
Set<String> keys = new HashSet<String>();
keys.add("key1");
keys.add("key2");
@@@ -725,11 -829,11 +722,9 @@@
patternsSet.remove(ptrn);
}
assertTrue(patternsSet.isEmpty());
- assertEquals(mri.getIndexedExpression(),"pf.positions['key1','key2','key3']");
-
+ assertEquals(mri.getIndexedExpression(), "pf.positions['key1','key2','key3']");
-
}
-
-
/**
* Test for bug 46872, make sure
* we recover the index correctly if the cache.xml
@@@ -740,14 -844,12 +735,12 @@@
InternalDistributedSystem.getAnyInstance().disconnect();
File file = new File("persistData0");
file.mkdir();
-
+
{
Properties props = new Properties();
- props.setProperty(DistributionConfig.NAME_NAME, "test");
- props.setProperty("mcast-port", "0");
- props.setProperty("cache-xml-file", IndexCreationJUnitTest.class.getResource("index-creation-with-eviction.xml")
- .toURI()
- .getPath());
+ props.setProperty(NAME, "test");
+ props.setProperty(MCAST_PORT, "0");
- props.setProperty(CACHE_XML_FILE, IndexCreationJUnitTest.class.getResource("index-creation-with-eviction.xml").toURI().getPath());
++ props.setProperty(CACHE_XML_FILE, getClass().getResource("index-creation-with-eviction.xml").toURI().getPath());
DistributedSystem ds = DistributedSystem.connect(props);
// Create the cache which causes the cache-xml-file to be parsed
@@@ -770,13 -871,12 +763,11 @@@
{
Properties props = new Properties();
- props.setProperty(DistributionConfig.NAME_NAME, "test");
- props.setProperty("mcast-port", "0");
+ props.setProperty(NAME, "test");
+ props.setProperty(MCAST_PORT, "0");
//Using a different cache.xml that changes some region properties
//That will force the disk code to copy the region entries.
- props.setProperty("cache-xml-file", IndexCreationJUnitTest.class.getResource("index-creation-without-eviction.xml")
- .toURI()
- .getPath());
- props.setProperty(CACHE_XML_FILE,
- IndexCreationJUnitTest.class.getResource("index-creation-without-eviction.xml").toURI().getPath());
++ props.setProperty(CACHE_XML_FILE, getClass().getResource("index-creation-without-eviction.xml").toURI().getPath());
DistributedSystem ds = DistributedSystem.connect(props);
Cache cache = CacheFactory.create(ds);
QueryService qs = cache.getQueryService();
@@@ -798,11 -897,10 +789,9 @@@
file.mkdir();
Properties props = new Properties();
- props.setProperty(DistributionConfig.NAME_NAME, "test");
- props.setProperty("mcast-port", "0");
- props.setProperty("cache-xml-file", IndexCreationJUnitTest.class.getResource("index-creation-without-eviction.xml")
- .toURI()
- .getPath());
+ props.setProperty(NAME, "test");
+ props.setProperty(MCAST_PORT, "0");
- props
- .setProperty(CACHE_XML_FILE, IndexCreationJUnitTest.class.getResource("index-creation-without-eviction.xml").toURI().getPath());
++ props.setProperty(CACHE_XML_FILE, getClass().getResource("index-creation-without-eviction.xml").toURI().getPath());
DistributedSystem ds = DistributedSystem.connect(props);
Cache cache = CacheFactory.create(ds);
Region localRegion = cache.getRegion("localRegion");
@@@ -828,11 -925,10 +817,9 @@@
file.mkdir();
Properties props = new Properties();
- props.setProperty(DistributionConfig.NAME_NAME, "test");
- props.setProperty("mcast-port", "0");
- props.setProperty("cache-xml-file", IndexCreationJUnitTest.class.getResource("index-creation-without-eviction.xml")
- .toURI()
- .getPath());
+ props.setProperty(NAME, "test");
+ props.setProperty(MCAST_PORT, "0");
- props
- .setProperty(CACHE_XML_FILE, IndexCreationJUnitTest.class.getResource("index-creation-without-eviction.xml").toURI().getPath());
++ props.setProperty(CACHE_XML_FILE, getClass().getResource("index-creation-without-eviction.xml").toURI().getPath());
DistributedSystem ds = DistributedSystem.connect(props);
Cache cache = CacheFactory.create(ds);
Region localDiskRegion = cache.getRegion("localDiskRegion");
@@@ -856,16 -951,14 +843,14 @@@
InternalDistributedSystem.getAnyInstance().disconnect();
File file = new File("persistData0");
file.mkdir();
-
+
{
Properties props = new Properties();
- props.setProperty(DistributionConfig.NAME_NAME, "test");
- props.setProperty("mcast-port", "0");
- props.setProperty("statistic-sampling-enabled", "true");
- props.setProperty("enable-time-statistics", "true");
- props.setProperty("cache-xml-file", IndexCreationJUnitTest.class.getResource("index-recovery-overflow.xml")
- .toURI()
- .getPath());
+ props.setProperty(NAME, "test");
+ props.setProperty(MCAST_PORT, "0");
+ props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
+ props.setProperty(ENABLE_TIME_STATISTICS, "true");
- props.setProperty(CACHE_XML_FILE, IndexCreationJUnitTest.class.getResource("index-recovery-overflow.xml").toURI().getPath());
++ props.setProperty(CACHE_XML_FILE, getClass().getResource("index-recovery-overflow.xml").toURI().getPath());
DistributedSystem ds = DistributedSystem.connect(props);
// Create the cache which causes the cache-xml-file to be parsed
@@@ -896,13 -988,11 +881,11 @@@
{
Properties props = new Properties();
- props.setProperty(DistributionConfig.NAME_NAME, "test");
- props.setProperty("mcast-port", "0");
- props.setProperty("statistic-sampling-enabled", "true");
- props.setProperty("enable-time-statistics", "true");
- props.setProperty("cache-xml-file", IndexCreationJUnitTest.class.getResource("index-recovery-overflow.xml")
- .toURI()
- .getPath());
+ props.setProperty(NAME, "test");
+ props.setProperty(MCAST_PORT, "0");
+ props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
+ props.setProperty(ENABLE_TIME_STATISTICS, "true");
- props.setProperty(CACHE_XML_FILE, IndexCreationJUnitTest.class.getResource("index-recovery-overflow.xml").toURI().getPath());
++ props.setProperty(CACHE_XML_FILE, getClass().getResource("index-recovery-overflow.xml").toURI().getPath());
DistributedSystem ds = DistributedSystem.connect(props);
Cache cache = CacheFactory.create(ds);
QueryService qs = cache.getQueryService();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd38e10f/geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NumericQueryJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/cache/query/functional/NumericQueryJUnitTest.java
index 1e47bc0,017816d..08c48b3
--- 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
@@@ -26,26 -39,12 +26,27 @@@ import java.util.Collection
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.PartitionAttributesFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.query.CacheUtils;
+import com.gemstone.gemfire.cache.query.Index;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.data.Numbers;
+import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
+import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
++import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-/**
- *
- *
- */
@Category(IntegrationTest.class)
public class NumericQueryJUnitTest {
@@@ -58,7 -58,7 +59,6 @@@
private static String GT = ">";
private static String GTE = ">=";
private static String LTE = "<=";
--
@Before
public void setUp() throws Exception {