Search in sources :

Example 6 with CacheSerializableRunnable

use of org.apache.geode.cache30.CacheSerializableRunnable in project geode by apache.

the class CompiledInDUnitTest method whenMultipleTypeBindParameterIsUsedWithInQueryAndMapIndexIsPresentInPartitionRegionReturnCorrectResults.

@Test
public void whenMultipleTypeBindParameterIsUsedWithInQueryAndMapIndexIsPresentInPartitionRegionReturnCorrectResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = numberOfEntries / 2;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1,$2,$3)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createPartitionRegion(false);
            createIndex("myIndex", "ts.getMapField[*]", regName + " ts");
            createEntries(numberOfEntries, regionName);
        }
    });
    Object[] bindArguments = new Object[] { 2, DayEnum.MONDAY, "Tuesday" };
    vm1.invoke(executeQueryOnPartitionRegion(numExpectedResults, queryString, bindArguments));
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 7 with CacheSerializableRunnable

use of org.apache.geode.cache30.CacheSerializableRunnable in project geode by apache.

the class CompiledInDUnitTest method whenASingleEnumBindParameterIsUsedWithInQueryInPartitionRegionReturnCorrectResults.

@Test
public void whenASingleEnumBindParameterIsUsedWithInQueryInPartitionRegionReturnCorrectResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = numberOfEntries / 2;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createPartitionRegion(false);
            createEntries(numberOfEntries, regionName);
        }
    });
    Object[] bindArguments = new Object[] { DayEnum.MONDAY };
    vm1.invoke(executeQueryOnPartitionRegion(numExpectedResults, queryString, bindArguments));
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 8 with CacheSerializableRunnable

use of org.apache.geode.cache30.CacheSerializableRunnable in project geode by apache.

the class CompiledInDUnitTest method whenUsingAccessorASingleEnumBindParameterIsUsedWithInQueryInPartitionRegionReturnCorrectResults.

@Test
public void whenUsingAccessorASingleEnumBindParameterIsUsedWithInQueryInPartitionRegionReturnCorrectResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = numberOfEntries / 2;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createPartitionRegion(false);
            createEntries(numberOfEntries, regionName);
        }
    });
    Object[] bindArguments = new Object[] { DayEnum.MONDAY };
    vm1.invoke(executeQueryWithAccessor(numExpectedResults, queryString, bindArguments));
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 9 with CacheSerializableRunnable

use of org.apache.geode.cache30.CacheSerializableRunnable in project geode by apache.

the class CompiledInDUnitTest method whenANDConditionWithInSetFiltersOutAllFieldsReturnNoResults.

@Test
public void whenANDConditionWithInSetFiltersOutAllFieldsReturnNoResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = 0;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1, $2) AND getMapField['1'] in SET($3)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createReplicateRegion();
            createIndex("myIndex", "ts.getMapField[*]", regName + " ts");
            createEntries(numberOfEntries, regionName);
        }
    });
    Object[] bindArguments = new Object[] { DayEnum.MONDAY, DayEnum.TUESDAY, DayEnum.WEDNESDAY };
    vm1.invoke(executeQueryWithIndexOnReplicateRegion(numExpectedResults, queryString, bindArguments, "myIndex", "ts.getMapField[*]", regName + " ts"));
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 10 with CacheSerializableRunnable

use of org.apache.geode.cache30.CacheSerializableRunnable in project geode by apache.

the class CompiledInDUnitTest method whenANDConditionWithInSetMatchesReturnResults.

@Test
public void whenANDConditionWithInSetMatchesReturnResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = 5;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1, $2) AND getMapField['2'] in SET($3)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createReplicateRegion();
            createIndex("myIndex", "ts.getMapField[*]", regName + " ts");
            HashMap entries = new HashMap();
            IntStream.range(0, 10).forEach(i -> {
                MapTestObject object = new MapTestObject(i);
                object.getMapField().put("2", DayEnum.WEDNESDAY);
                entries.put("key" + i, object);
            });
            createEntries(regionName, entries.entrySet().iterator());
        }
    });
    Object[] bindArguments = new Object[] { DayEnum.MONDAY, DayEnum.TUESDAY, DayEnum.WEDNESDAY };
    vm1.invoke(executeQueryWithIndexOnReplicateRegion(numExpectedResults, queryString, bindArguments, "myIndex", "ts.getMapField[*]", regName + " ts"));
}
Also used : IntStream(java.util.stream.IntStream) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Query(org.apache.geode.cache.query.Query) Day(org.apache.geode.cache.query.data.PortfolioPdx.Day) AttributesFactory(org.apache.geode.cache.AttributesFactory) HashMap(java.util.HashMap) Host(org.apache.geode.test.dunit.Host) VM(org.apache.geode.test.dunit.VM) DistributedRegionFunctionExecutionDUnitTest.region(org.apache.geode.internal.cache.execute.DistributedRegionFunctionExecutionDUnitTest.region) Cache(org.apache.geode.cache.Cache) LogWriterUtils(org.apache.geode.test.dunit.LogWriterUtils) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) Region(org.apache.geode.cache.Region) Map(java.util.Map) After(org.junit.After) CacheServer(org.apache.geode.cache.server.CacheServer) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Before(org.junit.Before) Scope(org.apache.geode.cache.Scope) Iterator(java.util.Iterator) IOException(java.io.IOException) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) QueryService(org.apache.geode.cache.query.QueryService) CacheException(org.apache.geode.cache.CacheException) Serializable(java.io.Serializable) DataPolicy(org.apache.geode.cache.DataPolicy) SelectResults(org.apache.geode.cache.query.SelectResults) JUnit4CacheTestCase(org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Assert(org.junit.Assert) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) HashMap(java.util.HashMap) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)595 CacheException (org.apache.geode.cache.CacheException)415 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)369 Test (org.junit.Test)369 Region (org.apache.geode.cache.Region)307 VM (org.apache.geode.test.dunit.VM)279 Host (org.apache.geode.test.dunit.Host)274 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)179 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)165 AttributesFactory (org.apache.geode.cache.AttributesFactory)145 IOException (java.io.IOException)135 Cache (org.apache.geode.cache.Cache)124 QueryService (org.apache.geode.cache.query.QueryService)118 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)107 LocalRegion (org.apache.geode.internal.cache.LocalRegion)106 SelectResults (org.apache.geode.cache.query.SelectResults)85 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)75 ClientServerTest (org.apache.geode.test.junit.categories.ClientServerTest)71 IgnoredException (org.apache.geode.test.dunit.IgnoredException)65 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)61