Search in sources :

Example 1 with TestObject

use of org.apache.geode.cache.query.dunit.QueryUsingPoolDUnitTest.TestObject in project geode by apache.

the class OrderByPartitionedJUnitTest method testBug.

// Asif: This test to me does not make sense as the bind parameter should be a
// constant
@Test
public void testBug() throws Exception {
    // String queries[] =
    // {"SELECT DISTINCT * FROM /test WHERE id < $1 ORDER BY $2" };
    String[] queries = { "SELECT DISTINCT * FROM /test WHERE id < $1 ORDER BY id" };
    Object[][] r = new Object[queries.length][2];
    QueryService qs;
    qs = CacheUtils.getQueryService();
    Position.resetCounter();
    // Create Regions
    PartitionAttributesFactory paf = new PartitionAttributesFactory();
    AttributesFactory af = new AttributesFactory();
    // af.setPartitionAttributes(paf.create());
    Region r1 = CacheUtils.createRegion("test", af.create(), false);
    for (int i = 0; i < 100; i++) {
        r1.put("key-" + i, new TestObject(i, "ibm"));
    }
    // Execute Queries without Indexes
    for (int i = 0; i < queries.length; i++) {
        Query q = null;
        try {
            q = CacheUtils.getQueryService().newQuery(queries[i]);
            CacheUtils.getLogger().info("Executing query: " + queries[i]);
            // r[i][0] = q.execute(new Object[]{new Integer(101),"id"});
            r[i][0] = q.execute(new Object[] { new Integer(101) });
            assertEquals(100, ((SelectResults) r[i][0]).size());
        } catch (Exception e) {
            e.printStackTrace();
            fail(q.getQueryString());
        }
    }
}
Also used : Query(org.apache.geode.cache.query.Query) TestObject(org.apache.geode.cache.query.dunit.QueryUsingPoolDUnitTest.TestObject) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) IndexInvalidException(org.apache.geode.cache.query.IndexInvalidException) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) IndexExistsException(org.apache.geode.cache.query.IndexExistsException) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) QueryService(org.apache.geode.cache.query.QueryService) Region(org.apache.geode.cache.Region) TestObject(org.apache.geode.cache.query.dunit.QueryUsingPoolDUnitTest.TestObject) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

AttributesFactory (org.apache.geode.cache.AttributesFactory)1 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)1 Region (org.apache.geode.cache.Region)1 IndexExistsException (org.apache.geode.cache.query.IndexExistsException)1 IndexInvalidException (org.apache.geode.cache.query.IndexInvalidException)1 IndexNameConflictException (org.apache.geode.cache.query.IndexNameConflictException)1 Query (org.apache.geode.cache.query.Query)1 QueryService (org.apache.geode.cache.query.QueryService)1 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)1 TestObject (org.apache.geode.cache.query.dunit.QueryUsingPoolDUnitTest.TestObject)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1