Search in sources :

Example 16 with Person

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

the class LocalCacheTest method prepareTestingData.

private void prepareTestingData() {
    person1 = new Person();
    person1.setName("Navin Surtani");
    person1.setAge(20);
    person1.setBlurb("Likes playing WoW");
    person1.setNonIndexedField("test1");
    person2 = new Person();
    person2.setName("Big Goat");
    person2.setAge(30);
    person2.setBlurb("Eats grass");
    person2.setNonIndexedField("test2");
    person3 = new Person();
    person3.setName("Mini Goat");
    person3.setAge(25);
    person3.setBlurb("Eats cheese");
    person3.setNonIndexedField("test3");
    anotherGrassEater = new AnotherGrassEater("Another grass-eater", "Eats grass");
    StaticTestingErrorHandler.assertAllGood(cache);
}
Also used : AnotherGrassEater(org.infinispan.query.test.AnotherGrassEater) Person(org.infinispan.query.test.Person)

Example 17 with Person

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

the class MultipleCachesTest method notIndexedCacheNormalUse.

@Test
public void notIndexedCacheNormalUse() {
    cacheManager.defineConfiguration("notIndexedB", cacheManager.getDefaultCacheConfiguration());
    final Cache<Object, Object> notIndexedCache = cacheManager.getCache("notIndexedB");
    notIndexedCache.put("1", new Person("A Person's Name", "A paragraph containing some text", 75));
    assert notIndexedCache.get("1") != null;
}
Also used : Person(org.infinispan.query.test.Person) SingleCacheManagerTest(org.infinispan.test.SingleCacheManagerTest) Test(org.testng.annotations.Test)

Example 18 with Person

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

the class ClusteredCacheTest method testPutForExternalRead.

public void testPutForExternalRead() throws Exception {
    prepareTestData();
    assertEquals(3, createSelectAllQuery(cache2).execute().list().size());
    person4 = new Person();
    person4.setName("New Goat");
    person4.setBlurb("Also eats grass");
    cache2.putForExternalRead("newGoat", person4);
    eventually(() -> cache2.get("newGoat") != null);
    Query<Person> query = createSelectAllQuery(cache2);
    eventually(() -> {
        List<Person> found = query.execute().list();
        return found.size() == 4 && found.contains(person4);
    });
    Person person5 = new Person();
    person5.setName("Abnormal Goat");
    person5.setBlurb("Plays with grass.");
    cache2.putForExternalRead("newGoat", person5);
    eventually(() -> {
        QueryResult<Person> result = query.execute();
        List<Person> found = result.list();
        return found.size() == 4 && result.hitCount().orElse(-1) == 4 && found.contains(person4) && !found.contains(person5);
    });
    StaticTestingErrorHandler.assertAllGood(cache1, cache2);
}
Also used : Person(org.infinispan.query.test.Person)

Example 19 with Person

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

the class ClusteredCacheTest method testPutMapAsync.

public void testPutMapAsync() throws Exception {
    prepareTestData();
    assert createSelectAllQuery(cache2).execute().list().size() == 3;
    person4 = new Person();
    person4.setName("New Goat");
    person4.setBlurb("Also eats grass");
    Map<String, Person> allWrites = new HashMap<>();
    allWrites.put(key1, person1);
    allWrites.put(key2, person2);
    allWrites.put(key3, person3);
    allWrites.put("newGoat", person4);
    Future<Void> futureTask = cache2.putAllAsync(allWrites);
    futureTask.get();
    assert futureTask.isDone();
    List<Person> found = createSelectAllQuery(cache2).execute().list();
    assertEquals(4, found.size());
    assert found.contains(person4);
    futureTask = cache1.putAllAsync(allWrites);
    futureTask.get();
    assert futureTask.isDone();
    found = createSelectAllQuery(cache2).execute().list();
    assertEquals(4, found.size());
    assert found.contains(person4);
    StaticTestingErrorHandler.assertAllGood(cache1, cache2);
}
Also used : HashMap(java.util.HashMap) Person(org.infinispan.query.test.Person)

Example 20 with Person

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

the class ClusteredQueryTest method testEagerOrdered.

public void testEagerOrdered() {
    Query<Person> cacheQuery = createSortedQuery();
    try (CloseableIterator<Person> iterator = cacheQuery.iterator()) {
        assertEquals(10, cacheQuery.execute().hitCount().orElse(-1));
        int previousAge = 0;
        while (iterator.hasNext()) {
            Person person = iterator.next();
            assertTrue(person.getAge() > previousAge);
            previousAge = person.getAge();
        }
    }
    StaticTestingErrorHandler.assertAllGood(cacheAMachine1, cacheAMachine2);
}
Also used : Person(org.infinispan.query.test.Person)

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