/** * Removes the test data from the quad store. * @throws CumulusStoreException If the test data could not be removed. */ @After public void clear() throws CumulusStoreException { _quadStore.removeData(asList(_data).iterator()); assertEmptyIterator(Arrays.toString(SELECT_ALL_QUADS_PATTERN), _quadStore.query(SELECT_ALL_QUADS_PATTERN)); }
@Test public void testQueryNumOfResults() throws Exception { for (Entry<Value[], Integer> query2count : queries2count.entrySet()) { Iterator<Statement> it = _tripleStore.query(query2count.getKey(), Integer.MAX_VALUE); assertNotNull(it); int numOfRes = TestUtils.numOfRes(it); assertTrue(Arrays.toString(query2count.getKey()) + " failed", numOfRes == query2count.getValue()); } } }
/** * Internal method used by several test to assert that a set of queries produces correct results. * * @param queries the set of queries to be checked. * @throws Exception never, otherwise the corresponding test will fail. */ private void assertQuery(final Value[][] queries) throws Exception { for (final Value[] query : queries) { final Iterator<Statement> iterator = _quadStore.query(query); assertNotNull(iterator); assertEquals("query: " + Arrays.toString(query), (int) _query2numOfRes.get(query), numOfRes(iterator)); } }
/** * Loads the test data into the quad store. * @throws CumulusStoreException If the test data could not be loaded. */ @Before public void load() throws CumulusStoreException { _quadStore.addData(asList(_data).iterator()); assertEquals(_data.length, numOfRes(_quadStore.query(SELECT_ALL_QUADS_PATTERN))); }
/** * If a pattern doesn't match any triple then no deletion happens. * * @throws Exception never, otherwise the tests fail. */ @Test public void testRemoveEmptyQuery() throws Exception { for (final Value[] pattern : _pattern_emtpy_query_result) { assertEquals("query: " + Arrays.toString(pattern), 0, numOfRes(_tripleStore.query(pattern))); _tripleStore.removeData(pattern); assertEquals(_howManyTriplesInDataset, numOfRes(_tripleStore.query(SELECT_ALL_TRIPLES_PATTERN))); } }
@Before public void loadTestData() throws Exception { _quadStore.bulkLoad(DATA_NQ, RDFFormat.NQUADS); assertEquals((int) _query2numOfRes.get(_null_queries[0]), numOfRes(_quadStore.query(_null_queries[0]))); }
/** * If a pattern doesn't match any triple then no deletion happens. * * @throws Exception never, otherwise the tests fail. */ @Test public void testRemoveEmptyQuery() throws Exception { for (final Value[] pattern : _pattern_emtpy_query_result) { assertEquals("query: " + Arrays.toString(pattern), 0, numOfRes(_tripleStore.query(pattern))); _tripleStore.removeData(pattern); assertEquals(_howManyTriplesInDataset, numOfRes(_tripleStore.query(SELECT_ALL_TRIPLES_PATTERN))); } }
/** * If a triple doesn't exist then no deletion happens. * * @throws Exception never, otherwise the tests fail. */ @Test public void testRemoveNotExistingData() throws Exception { for (final Value[] triple : _triple_not_existing) { assertEquals("triple: " + Arrays.toString(triple), 0, numOfRes(_tripleStore.query(triple))); _tripleStore.removeData(triple); assertEquals(_howManyTriplesInDataset, numOfRes(_tripleStore.query(SELECT_ALL_TRIPLES_PATTERN))); } }
/** * Cleans up the given store. * * @param crdf could be a triple or a quad store. * @throws CumulusStoreException in case the cleanup fails. */ public static void clean(final Store crdf) throws CumulusStoreException { final Value[] pattern = crdf instanceof TripleStore ? SELECT_ALL_TRIPLES_PATTERN : SELECT_ALL_QUADS_PATTERN; crdf.removeData(pattern); assertEquals("Store seems not empty after issuing a delete * command.", 0, numOfRes(crdf.query(pattern))); }
@Test public void testOSQueries() throws Exception { for (Value[] q : queriesOs) { for (int limit : limits) { Iterator<Statement> it = _tripleStore.query(q, limit); assertNotNull(it); int numOfRes = TestUtils.numOfRes(it); assertTrue(Arrays.toString(q) + " failed", numOfRes <= limit); assertTrue(Arrays.toString(q) + " failed. Number of result is " + numOfRes, numOfRes >= 1); } } }
/** * Tests if the normal indexes are cleared correctly. * * @throws Exception never, otherwise the tests fail. */ @Test public void testClear() throws Exception { _tripleStore.clear(); assertEmptyIterator("clear(): Triple indexes", _tripleStore.query(SELECT_ALL_TRIPLES_PATTERN)); } }
@Test public void testSPQueries() throws Exception { for (Value[] q : queriesSp) { for (int limit : limits) { Iterator<Statement> it = _tripleStore.query(q, limit); assertNotNull(it); int numOfRes = TestUtils.numOfRes(it); assertTrue(Arrays.toString(q) + " failed", numOfRes <= limit); assertTrue(Arrays.toString(q) + " failed", numOfRes >= 1); } } }
/** * Cleans up the given store. * * @param crdf could be a triple or a quad store. * @throws CumulusStoreException in case the cleanup fails. */ public static void clean(final Store crdf) throws CumulusStoreException { crdf.clear(); assertEquals("Store seems not empty after issuing a delete * command.", 0, numOfRes(crdf.query(crdf instanceof TripleStore ? SELECT_ALL_TRIPLES_PATTERN : SELECT_ALL_QUADS_PATTERN))); }
@Test public void testPOQueries() throws Exception { for (Value[] q : queriesPo) { for (int limit : limits) { Iterator<Statement> it = _tripleStore.query(q, limit); assertNotNull(it); int numOfRes = TestUtils.numOfRes(it); assertTrue(Arrays.toString(q) + " failed", numOfRes <= limit); assertTrue(Arrays.toString(q) + " failed", numOfRes >= 1); } } }
/** * Setup fixture before each test. * * @throws Exception never, otherwise the tests fail. */ @Before public void beforeTest() throws Exception { _tripleStore.bulkLoad(DATA_NT, RDFFormat.NTRIPLES); assertEquals(_howManyTriplesInDataset, numOfRes(_tripleStore.query(SELECT_ALL_TRIPLES_PATTERN))); }
/** * Tests if deleting with queries with zero results really deletes nothing. * @throws CumulusStoreException If the deletion fails. */ @Test // SC_OP index public void testDeleteInvalid() throws CumulusStoreException { final Value[] query = new Value[] { buildResource("d1"), null, null, buildResource("d1") }; _quadStore.removeData(query); assertEmptyIterator(Arrays.toString(query), _quadStore.query(query)); }
/** * Removes all data from the triple store. * * @throws Exception never, otherwise the tests fail. */ @Test public void testRemoveAll() throws Exception { clean(_tripleStore); assertEquals(0, numOfRes(_tripleStore.query(SELECT_ALL_TRIPLES_PATTERN))); }
/** * Setup fixture before each test. * * @throws Exception never, otherwise the tests fail. */ @Before public void beforeTest() throws Exception { _tripleStore.bulkLoad(DATA_NT, RDFFormat.NTRIPLES); assertEquals(_howManyTriplesInDataset, numOfRes(_tripleStore.query(SELECT_ALL_TRIPLES_PATTERN))); }
/** * Removes all data from the triple store. * * @throws Exception never, otherwise the tests fail. */ @Test public void testRemoveAll() throws Exception { clean(_tripleStore); assertEquals(0, numOfRes(_tripleStore.query(SELECT_ALL_TRIPLES_PATTERN))); }