s.close();
}
}
public void testResults() throws Exception {
Solutions s = getTestData("sparql-results");
assertNotNull(s);
try {
assertTrue(s instanceof ProtocolResult);
assertTrue(((ProtocolResult)s).getMetadata().isEmpty());
String var = "a";
assertEquals(Arrays.asList(var), s.getVariables());
// Check cursor methods.
TestCursor.assertCursor(s, BEFORE_FIRST);
// Check results.
assertTrue(s.next());
TestCursor.assertCursor(s, FIRST);
assertEquals(URI.create("http://example.org/a"), s.getURI(var));
assertTrue(s.next());
TestCursor.assertCursor(s, NONE);
assertEquals(new BlankNodeImpl("node0"), s.getBinding(var));
assertTrue(s.next());
TestCursor.assertCursor(s, NONE);
assertEquals(new PlainLiteralImpl("xyz"), s.getBinding(var));
assertTrue(s.next());
TestCursor.assertCursor(s, NONE);
assertEquals(new TypedLiteralImpl("100", XsdTypes.INT), s.getBinding(var));
assertEquals(100, s.getInt(var));
assertTrue(s.next());
TestCursor.assertCursor(s, LAST);
assertEquals(new PlainLiteralImpl("chat", "fr"), s.getBinding(var));
// Check end of results.
assertFalse(s.next());
TestCursor.assertCursor(s, AFTER_LAST);
} finally {
s.close();
}
}