@Test public void testGetStatements() throws Exception { testCon.add(bob, name, nameBob); assertTrue("Repository should contain statement", testCon.hasStatement(bob, name, nameBob, false)); RepositoryResult<Statement> result = testCon.getStatements(null, name, null, false); try { assertNotNull("Iterator should not be null", result); assertTrue("Iterator should not be empty", result.hasNext()); while (result.hasNext()) { Statement st = result.next(); assertNull("Statement should not be in a context ", st.getContext()); assertTrue("Statement predicate should be equal to name ", st.getPredicate().equals(name)); } } finally { result.close(); } List<Statement> list = Iterations.addAll(testCon.getStatements(null, name, null, false), new ArrayList<Statement>()); assertNotNull("List should not be null", list); assertFalse("List should not be empty", list.isEmpty()); }
assertNotNull("List should not be null", list); assertFalse("List should not be empty", list.isEmpty());
@Test public void testGetStatementsMalformedTypedLiteral() throws Exception { Literal invalidIntegerLiteral = vf.createLiteral("the number four", XMLSchema.INTEGER); try { URI pred = vf.createURI(URN_PRED); testCon.add(bob, pred, invalidIntegerLiteral); RepositoryResult<Statement> statements = testCon.getStatements(bob, pred, null, true); assertNotNull(statements); assertTrue(statements.hasNext()); Statement st = statements.next(); assertTrue(st.getObject() instanceof Literal); assertTrue(st.getObject().equals(invalidIntegerLiteral)); } catch (RepositoryException e) { // shouldn't happen fail(e.getMessage()); } }
@Test public void testGetStatementsMalformedLanguageLiteral() throws Exception { Literal invalidLanguageLiteral = vf.createLiteral("the number four", "en_us"); try { URI pred = vf.createURI(URN_PRED); testCon.add(bob, pred, invalidLanguageLiteral); RepositoryResult<Statement> statements = testCon.getStatements(bob, pred, null, true); assertNotNull(statements); assertTrue(statements.hasNext()); Statement st = statements.next(); assertTrue(st.getObject() instanceof Literal); assertTrue(st.getObject().equals(invalidLanguageLiteral)); } catch (RepositoryException e) { e.printStackTrace(); // shouldn't happen fail(e.getMessage()); } }
@Test public void testGetStatements() throws Exception { testCon.add(bob, name, nameBob); assertTrue("Repository should contain statement", testCon.hasStatement(bob, name, nameBob, false)); RepositoryResult<Statement> result = testCon.getStatements(null, name, null, false); try { assertNotNull("Iterator should not be null", result); assertTrue("Iterator should not be empty", result.hasNext()); while (result.hasNext()) { Statement st = result.next(); assertNull("Statement should not be in a context ", st.getContext()); assertTrue("Statement predicate should be equal to name ", st.getPredicate().equals(name)); } } finally { result.close(); } List<Statement> list = Iterations.addAll(testCon.getStatements(null, name, null, false), new ArrayList<Statement>()); assertNotNull("List should not be null", list); assertFalse("List should not be empty", list.isEmpty()); }
assertNotNull("List should not be null", list); assertFalse("List should not be empty", list.isEmpty());
@Test public void testGetStatementsMalformedTypedLiteral() throws Exception { Literal invalidIntegerLiteral = vf.createLiteral("the number four", XMLSchema.INTEGER); try { URI pred = vf.createURI(URN_PRED); testCon.add(bob, pred, invalidIntegerLiteral); RepositoryResult<Statement> statements = testCon.getStatements(bob, pred, null, true); assertNotNull(statements); assertTrue(statements.hasNext()); Statement st = statements.next(); assertTrue(st.getObject() instanceof Literal); assertTrue(st.getObject().equals(invalidIntegerLiteral)); } catch (RepositoryException e) { // shouldn't happen fail(e.getMessage()); } }
@Test public void testGetStatementsMalformedLanguageLiteral() throws Exception { Literal invalidLanguageLiteral = vf.createLiteral("the number four", "en_us"); try { URI pred = vf.createURI(URN_PRED); testCon.add(bob, pred, invalidLanguageLiteral); RepositoryResult<Statement> statements = testCon.getStatements(bob, pred, null, true); assertNotNull(statements); assertTrue(statements.hasNext()); Statement st = statements.next(); assertTrue(st.getObject() instanceof Literal); assertTrue(st.getObject().equals(invalidLanguageLiteral)); } catch (RepositoryException e) { e.printStackTrace(); // shouldn't happen fail(e.getMessage()); } }