Search in sources :

Example 11 with Person

use of org.infinispan.query.test.Person in project infinispan by infinispan.

the class ClusteredQueryMultipleCachesTest method prepareTestData.

@Override
protected void prepareTestData() {
    super.prepareTestData();
    Person person5 = new Person();
    person5.setName("People In Another Cache");
    person5.setBlurb("Also eats grass");
    person5.setAge(5);
    cacheBMachine2.put("anotherNewOne", person5);
}
Also used : Person(org.infinispan.query.test.Person)

Example 12 with Person

use of org.infinispan.query.test.Person in project infinispan by infinispan.

the class ClusteredQueryTest method testNonIndexedBroadcastInfinispanQuery.

@Test
public void testNonIndexedBroadcastInfinispanQuery() {
    QueryFactory queryFactory = Search.getQueryFactory(cacheAMachine2);
    Query<Person> slowQuery = queryFactory.create("FROM " + Person.class.getName() + " WHERE nonIndexedField LIKE 'na%'");
    assertEquals(NUM_ENTRIES, slowQuery.execute().list().size());
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) Person(org.infinispan.query.test.Person) Test(org.testng.annotations.Test) MultipleCacheManagersTest(org.infinispan.test.MultipleCacheManagersTest)

Example 13 with Person

use of org.infinispan.query.test.Person in project infinispan by infinispan.

the class ClusteredQueryTest method testBroadcastSortedInfinispanQuery.

@Test
public void testBroadcastSortedInfinispanQuery() {
    QueryFactory queryFactory = Search.getQueryFactory(cacheAMachine1);
    Query<Person> sortedQuery = queryFactory.create("FROM " + Person.class.getName() + " p order by p.age desc");
    List<Person> results = sortedQuery.execute().list();
    assertEquals(NUM_ENTRIES, results.size());
    assertEquals(NUM_ENTRIES - 1, results.iterator().next().getAge());
    StaticTestingErrorHandler.assertAllGood(cacheAMachine1, cacheAMachine2);
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) Person(org.infinispan.query.test.Person) Test(org.testng.annotations.Test) MultipleCacheManagersTest(org.infinispan.test.MultipleCacheManagersTest)

Example 14 with Person

use of org.infinispan.query.test.Person in project infinispan by infinispan.

the class ClusteredQueryTest method testPagination.

public void testPagination() {
    Query<Person> cacheQuery = createSortedQuery();
    cacheQuery.startOffset(2);
    cacheQuery.maxResults(1);
    QueryResult<Person> results = cacheQuery.execute();
    List<Person> list = results.list();
    assertEquals(1, list.size());
    assertEquals(10, results.hitCount().orElse(-1));
    Person result = list.get(0);
    assertEquals(12, result.getAge());
    StaticTestingErrorHandler.assertAllGood(cacheAMachine1, cacheAMachine2);
}
Also used : Person(org.infinispan.query.test.Person)

Example 15 with Person

use of org.infinispan.query.test.Person in project infinispan by infinispan.

the class ContinuousQueryTest method testDisallowGroupingAndAggregation.

/**
 * Using grouping and aggregation with continuous query is not allowed.
 */
@Test(expectedExceptions = ParsingException.class, expectedExceptionsMessageRegExp = ".*ISPN028509:.*")
public void testDisallowGroupingAndAggregation() {
    QueryFactory qf = Search.getQueryFactory(cache());
    Query<Object[]> query = qf.create("SELECT MAX(age) FROM org.infinispan.query.test.Person WHERE age >= 20");
    ContinuousQuery<Integer, Person> cq = Search.getContinuousQuery(cache());
    cq.addContinuousQueryListener(query, new CallCountingCQResultListener<>());
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) Person(org.infinispan.query.test.Person) SingleCacheManagerTest(org.infinispan.test.SingleCacheManagerTest) Test(org.testng.annotations.Test)

Aggregations

Person (org.infinispan.query.test.Person)82 QueryFactory (org.infinispan.query.dsl.QueryFactory)21 Test (org.testng.annotations.Test)11 ObjectFilter (org.infinispan.objectfilter.ObjectFilter)6 SingleCacheManagerTest (org.infinispan.test.SingleCacheManagerTest)6 TransactionManager (javax.transaction.TransactionManager)5 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)5 MagicKey (org.infinispan.distribution.MagicKey)3 AnotherGrassEater (org.infinispan.query.test.AnotherGrassEater)3 ArrayList (java.util.ArrayList)2 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)2 NumberFormat (java.text.NumberFormat)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 RollbackException (javax.transaction.RollbackException)1 CacheException (org.infinispan.commons.CacheException)1 CacheEntry (org.infinispan.container.entries.CacheEntry)1