@Override public void close() { ((ResultIterator<E>) delegate).close(); } }
@Test(expectedExceptions = NoSuchElementException.class) public void testEagerIteratorExCase() throws ParseException { loadTestingData(); CacheQuery<?> cacheQuery = createCacheQuery(cache, "blurb", "playing"); ResultIterator<?> found = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER)); try { assertTrue(found.hasNext()); found.next(); assertFalse(found.hasNext()); found.next(); } finally { found.close(); } }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testIteratorRemove() throws ParseException { loadTestingData(); queryParser = createQueryParser("blurb"); Query luceneQuery = queryParser.parse("Eats"); CacheQuery<?> cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery); ResultIterator<?> iterator = cacheQuery.iterator(); try { if (iterator.hasNext()) { iterator.next(); iterator.remove(); } } finally { iterator.close(); } StaticTestingErrorHandler.assertAllGood(cache); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testEagerIteratorRemove() throws ParseException { loadTestingData(); CacheQuery<?> cacheQuery = createCacheQuery(cache, "blurb", "playing"); ResultIterator<?> found = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER)); try { assertTrue(found.hasNext()); found.remove(); } finally { found.close(); } }
@Test(expectedExceptions = NoSuchElementException.class) public void testLazyIteratorWithNoElementsFound() throws ParseException { loadTestingData(); queryParser = createQueryParser("blurb"); Query luceneQuery = queryParser.parse("fish"); CacheQuery<?> cacheQuery = Search.getSearchManager(cache).<Person>getQuery(luceneQuery).firstResult(1); ResultIterator<?> found = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.LAZY)); try { found.next(); } finally { found.close(); } }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testIteratorRemove() { cacheQuery.maxResults(1); try (ResultIterator<Person> iterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER))) { assert iterator.hasNext(); iterator.remove(); } StaticTestingErrorHandler.assertAllGood(cacheAMachine1, cacheAMachine2); }
public void testEagerIterator() throws ParseException { loadTestingData(); CacheQuery<?> cacheQuery = createCacheQuery(cache, "blurb", "playing"); ResultIterator<?> found = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER)); try { assertTrue(found.hasNext()); found.next(); assertFalse(found.hasNext()); } finally { found.close(); } StaticTestingErrorHandler.assertAllGood(cache); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testIteratorWithNullFetchMode() throws ParseException { loadTestingData(); queryParser = createQueryParser("blurb"); Query luceneQuery = queryParser.parse("Eats"); CacheQuery<?> cacheQuery = Search.getSearchManager(cache).<Person>getQuery(luceneQuery).firstResult(1); ResultIterator<?> found = cacheQuery.iterator(new FetchOptions().fetchMode(null)); try { found.next(); } finally { found.close(); } }
public void testIteratorWithDefaultOptions() throws ParseException { loadTestingData(); queryParser = createQueryParser("blurb"); Query luceneQuery = queryParser.parse("playing"); CacheQuery<?> cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery); ResultIterator<?> found = cacheQuery.iterator(); try { assertTrue(found.hasNext()); found.next(); assertFalse(found.hasNext()); } finally { found.close(); } StaticTestingErrorHandler.assertAllGood(cache); }
@Override public void close() { delegate.close(); } }
@Override public List<E> list() throws SearchException { partitionHandlingSupport.checkCacheAvailable(); List<E> values = new ArrayList<>(); try (ResultIterator<E> iterator = iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER))) { while (iterator.hasNext()) { values.add(iterator.next()); } } return values; }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Unknown FetchMode null") public void testUnknownFetchModeIterator() throws ParseException { loadTestingData(); queryParser = createQueryParser("blurb"); Query luceneQuery = queryParser.parse("playing"); CacheQuery<?> cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery); ResultIterator<?> found = cacheQuery.iterator(new FetchOptions() { public FetchMode getFetchMode() { return null; } }); try { assertTrue(found.hasNext()); found.next(); assertFalse(found.hasNext()); } finally { found.close(); } }
@AfterMethod public void tearDown() { iterator.close(); keys = null; dummyResults = null; iterator = null; }
public void testNextAndHasNext() { for (int i = 0; i < keys.size(); i++) { Object expectedValue = resultAt(i); assert iterator.hasNext(); // should have next as long as we are less than the number of elements. assert expectedValue == iterator.next(); // tests next() } assert !iterator.hasNext(); // this should now NOT be true. }
public void testSearchManagerWithInstantiation() throws ParseException { loadTestingData(); queryParser = createQueryParser("blurb"); Query luceneQuery = queryParser.parse("playing"); CacheQuery<?> cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery); ResultIterator<?> found = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.valueOf("LAZY"))); try { assertTrue(found.hasNext()); found.next(); assertFalse(found.hasNext()); } finally { found.close(); } }
@AfterMethod(alwaysRun = false) public void tearDown() { iterator.close(); verify(extractor).close(); super.tearDown(); } }
@Test(expectedExceptions = NoSuchElementException.class) public void testIteratorNextOutOfBounds() { cacheQuery.maxResults(1); try (ResultIterator<Person> iterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER))) { assert iterator.hasNext(); iterator.next(); assert !iterator.hasNext(); iterator.next(); } StaticTestingErrorHandler.assertAllGood(cacheAMachine1, cacheAMachine2); }
public void testLazyIterator() throws ParseException { loadTestingData(); queryParser = createQueryParser("blurb"); Query luceneQuery = queryParser.parse("playing"); CacheQuery<?> cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery); ResultIterator<?> found = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.LAZY)); try { assertTrue(found.hasNext()); found.next(); assertFalse(found.hasNext()); } finally { found.close(); } StaticTestingErrorHandler.assertAllGood(cache); }