Search in sources :

Example 26 with ResultSetRewindable

use of org.apache.jena.query.ResultSetRewindable in project jena by apache.

the class TestResultSet method test_RS_4.

@Test
public void test_RS_4() {
    ResultSetRewindable rs1 = makeRewindable("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
    Model model = RDFOutput.encodeAsModel(rs1);
    rs1.reset();
    ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(RDFInput.fromRDF(model));
    boolean b = ResultSetCompare.equalsByTerm(rs1, rs2);
    if (!b) {
        rs1.reset();
        rs2.reset();
        ResultSetFormatter.out(rs1);
        ResultSetFormatter.out(rs2);
    }
    assertTrue(b);
}
Also used : Model(org.apache.jena.rdf.model.Model) ResultSetRewindable(org.apache.jena.query.ResultSetRewindable) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 27 with ResultSetRewindable

use of org.apache.jena.query.ResultSetRewindable in project jena by apache.

the class TestResultSet method test_RS_2.

@Test
public void test_RS_2() {
    ResultSetRewindable rs1 = makeRewindable("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
    ByteArrayOutputStream arr = new ByteArrayOutputStream();
    ResultSetFormatter.outputAsXML(arr, rs1);
    rs1.reset();
    ByteArrayInputStream ins = new ByteArrayInputStream(arr.toByteArray());
    ResultSet rs2 = ResultSetFactory.fromXML(ins);
    assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BuilderResultSet(org.apache.jena.sparql.sse.builders.BuilderResultSet) ResultSet(org.apache.jena.query.ResultSet) ResultSetRewindable(org.apache.jena.query.ResultSetRewindable) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 28 with ResultSetRewindable

use of org.apache.jena.query.ResultSetRewindable in project jena by apache.

the class TestResultSet method isotest.

private void isotest(String[] rs1$2, String[] rs2$2) {
    ResultSetRewindable rs1 = ResultSetFactory.makeRewindable(BuilderResultSet.build(SSE.parseItem(StrUtils.strjoinNL(rs1$))));
    ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(BuilderResultSet.build(SSE.parseItem(StrUtils.strjoinNL(rs2$))));
    assertTrue(ResultSetCompare.isomorphic(rs1, rs2));
    rs1.reset();
    rs2.reset();
    assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2));
    assertTrue(ResultSetCompare.equalsByValue(rs1, rs2));
}
Also used : ResultSetRewindable(org.apache.jena.query.ResultSetRewindable)

Example 29 with ResultSetRewindable

use of org.apache.jena.query.ResultSetRewindable in project jena by apache.

the class TestResultSet method test_RS_cmp_value_1.

// Value based 
@Test
public void test_RS_cmp_value_1() {
    ResultSetRewindable rs1 = makeRewindable("x", NodeFactoryExtra.parseNode("123"));
    ResultSetRewindable rs2 = makeRewindable("x", NodeFactoryExtra.parseNode("0123"));
    assertFalse(ResultSetCompare.equalsByTerm(rs1, rs2));
    assertTrue(ResultSetCompare.equalsByValue(rs1, rs2));
}
Also used : ResultSetRewindable(org.apache.jena.query.ResultSetRewindable) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 30 with ResultSetRewindable

use of org.apache.jena.query.ResultSetRewindable in project jena by apache.

the class TestResultSet method test_RS_3.

// RDF
@Test
public void test_RS_3() {
    ResultSetRewindable rs1 = new ResultSetMem();
    Model model = RDFOutput.encodeAsModel(rs1);
    rs1.reset();
    ResultSet rs2 = RDFInput.fromRDF(model);
    assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2));
}
Also used : Model(org.apache.jena.rdf.model.Model) BuilderResultSet(org.apache.jena.sparql.sse.builders.BuilderResultSet) ResultSet(org.apache.jena.query.ResultSet) ResultSetRewindable(org.apache.jena.query.ResultSetRewindable) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Aggregations

ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)32 Test (org.junit.Test)18 BaseTest (org.apache.jena.atlas.junit.BaseTest)17 ResultSet (org.apache.jena.query.ResultSet)11 BuilderResultSet (org.apache.jena.sparql.sse.builders.BuilderResultSet)11 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 QuerySolution (org.apache.jena.query.QuerySolution)5 Extractor (infoeval.main.WikiData.Extractor)3 RDFNode (org.apache.jena.rdf.model.RDFNode)3 Model (org.apache.jena.rdf.model.Model)2 SqlTablesFiller (infoeval.main.WikiData.SqlTablesFiller)1 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1 Item (org.apache.jena.sparql.sse.Item)1 Ignore (org.junit.Ignore)1