Package com.hp.hpl.jena.query

Examples of com.hp.hpl.jena.query.ResultSetRewindable


    // RDF
   
    @Test public void test_RS_3()
    {
        ResultSetRewindable rs1 = new ResultSetMem() ;
        Model model = ResultSetFormatter.toModel(rs1) ;
        rs1.reset() ;
        ResultSet rs2 = ResultSetFactory.fromRDF(model) ;
        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
View Full Code Here


        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
   
    @Test public void test_RS_4()
    {
        ResultSetRewindable rs1 = makeRewindable("x", com.hp.hpl.jena.graph.NodeFactory.createURI("tag:local")) ;
        Model model = ResultSetFormatter.toModel(rs1) ;
        rs1.reset() ;
        ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(ResultSetFactory.fromRDF(model)) ;
        boolean b = ResultSetCompare.equalsByTerm(rs1, rs2) ;
        if ( ! b )
        {
            rs1.reset() ;
            rs2.reset() ;
            ResultSetFormatter.out(rs1) ;
            ResultSetFormatter.out(rs2) ;
        }
       
        assertTrue(b) ;
View Full Code Here

   
    // JSON
   
    @Test public void test_RS_5()
    {
        ResultSetRewindable rs1 = new ResultSetMem() ;
        ByteArrayOutputStream arr = new ByteArrayOutputStream() ;
        ResultSetFormatter.outputAsJSON(arr, rs1) ;
        rs1.reset() ;
        ByteArrayInputStream ins = new ByteArrayInputStream(arr.toByteArray()) ;
        ResultSet rs2 = ResultSetFactory.fromJSON(ins) ;
        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
View Full Code Here

        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
   
    @Test public void test_RS_6()
    {
        ResultSetRewindable rs1 = make2Rewindable("x", com.hp.hpl.jena.graph.NodeFactory.createURI("tag:local")) ;
        ByteArrayOutputStream arr = new ByteArrayOutputStream() ;
        ResultSetFormatter.outputAsJSON(arr, rs1) ;
        rs1.reset() ;
        ByteArrayInputStream ins = new ByteArrayInputStream(arr.toByteArray()) ;
        ResultSet rs2 = ResultSetFactory.fromJSON(ins) ;    // Test using the DAWG examples
        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
View Full Code Here

      ResultSetUtils.union(rs1, rs2) ;
    }

    private void test_RS_fmt(ResultSet rs, ResultsFormat fmt, boolean ordered)
    {
        ResultSetRewindable rs1 = ResultSetFactory.makeRewindable(rs) ;
        ByteArrayOutputStream arr = new ByteArrayOutputStream() ;
        ResultSetFormatter.output(arr, rs1, fmt) ;
        byte bytes[] = arr.toByteArray() ;
        rs1.reset() ;
        ByteArrayInputStream ins = new ByteArrayInputStream(bytes) ;
        ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(ResultSetFactory.load(ins, fmt)) ;

        // Ordered? Unordered?
        boolean b = ResultSetCompare.equalsByTerm(rs1, rs2) ;
        if ( ordered )
        {
            rs1.reset() ;
            rs2.reset() ;
            b = b & ResultSetCompare.equalsByTerm(rs1, rs2) ;
        }
       
        if ( !b )
        {
            System.out.println(new String(bytes)) ;
            rs1.reset() ;
            rs2.reset() ;
            ResultSetFormatter.out(rs1) ;
            ResultSetFormatter.out(rs2) ;
        }

        assertTrue(b) ;
View Full Code Here

        assertTrue(b) ;
    }
    // Test comparison
    @Test public void test_RS_cmp_1()
    {
        ResultSetRewindable rs1 = new ResultSetMem() ;
        ResultSetRewindable rs2 = new ResultSetMem() ;
        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
        rs1.reset() ;
        rs2.reset() ;
        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
View Full Code Here

    }

    @Test public void test_RS_cmp_5()
    {
        // Same variable, different values
        ResultSetRewindable rs1 = makeRewindable("x", com.hp.hpl.jena.graph.NodeFactory.createURI("tag:local:1")) ;
        ResultSetRewindable rs2 = makeRewindable("x", com.hp.hpl.jena.graph.NodeFactory.createURI("tag:local:2")) ;
        assertFalse(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
        rs1.reset() ;
        rs2.reset() ;
        assertFalse(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
View Full Code Here

    }

    @Test public void test_RS_cmp_6()
    {
        // Different variable, same values
        ResultSetRewindable rs1 = makeRewindable("x", com.hp.hpl.jena.graph.NodeFactory.createURI("tag:local")) ;
        ResultSetRewindable rs2 = makeRewindable("y", com.hp.hpl.jena.graph.NodeFactory.createURI("tag:local")) ;
        assertFalse(ResultSetCompare.equalsByTermAndOrder(rs1, rs2)) ;
        rs1.reset() ;
        rs2.reset() ;
        assertFalse(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
View Full Code Here

    }
   
    // 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)) ;
    }
View Full Code Here

   
    @Test
    public void test_RS_peeking_7() {
        // Peeking may fail if someone moves backwards in the result set
        // If we hadn't moved pass the first item this should be safe
        ResultSetRewindable inner = makeRewindable("x", NodeFactory.createURI("tag:local"));
        ResultSetPeekable rs = ResultSetFactory.makePeekable(inner);
        assertTrue(rs.hasNext());
        assertNotNull(rs.peek());
       
        // Reset the inner result set independently
        inner.reset();
       
        // Since we moved the underlying result set backwards but we hadn't gone anywhere
        // we should still be able to safely access the underlying results
        assertTrue(rs.hasNext());
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.query.ResultSetRewindable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.