Package com.hp.hpl.jena.query

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


        Query query = QueryFactory.read(queryFile) ;
        Dataset ds = DatasetFactory.create(defaultGraphURIs, namedGraphURIs) ;
       
        // ---- First, get the expected results by executing in-memory or from a results file.
       
        ResultSetRewindable rs1 = null ;
        String expectedLabel = "" ;
        if ( results != null )
        {
            rs1 = ResultSetFactory.makeRewindable(results.getResultSet()) ;
            expectedLabel = "Results file" ;
        }
        else
        {
            QueryEngineFactory f = QueryEngineRef.getFactory() ;
            QueryExecution qExec1 = new QueryExecutionBase(query, ds, null, f) ;
            rs1 = ResultSetFactory.makeRewindable(qExec1.execSelect()) ;
            qExec1.close() ;
            expectedLabel = "Standard engine" ;
        }
       
        // ---- Second, execute in persistent graph

        Dataset ds2 = dataset ; //DatasetFactory.create(model) ;
        QueryExecution qExec2 = QueryExecutionFactory.create(query, ds2) ;
        ResultSet rs = qExec2.execSelect() ;
        ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(rs) ;
       
        // See if the same.
        boolean b = ResultSetCompare.equalsByValue(rs1, rs2) ;
        if ( !b )
        {
            rs1.reset() ;
            rs2.reset() ;
            System.out.println("------------------- "+this.getName());
            System.out.printf("**** Expected (%s)", expectedLabel) ;
            ResultSetFormatter.out(System.out, rs1) ;
            System.out.println("**** Got (TDB)") ;
            ResultSetFormatter.out(System.out, rs2) ;
View Full Code Here


    private static void equals(ResultSet rs1, ResultSet rs2)
    { same(rs1, rs2, true) ; }
   
    private static void same(ResultSet rs1, ResultSet rs2, boolean result)
    {
        ResultSetRewindable rsw1 = ResultSetFactory.makeRewindable(rs1) ;
        ResultSetRewindable rsw2 = ResultSetFactory.makeRewindable(rs2) ;
        boolean b = ResultSetCompare.equalsByValue(rsw1, rsw2) ;
        if ( b != result)
        {
            System.out.println("Different: ") ;
            rsw1.reset() ;
            rsw2.reset() ;
            ResultSetFormatter.out(rsw1) ;
            ResultSetFormatter.out(rsw2) ;
            System.out.println() ;
        }
       
View Full Code Here

        //return equivalent(convert(rs1), convert(rs2), new BNodeIso(NodeUtils.sameValue)) ;
       
        // Add the isomprohism test
        // Imperfect - need by-value and isomorphism - but this covers test suite needs.

        ResultSetRewindable rs1a = ResultSetFactory.makeRewindable(rs1) ;
        ResultSetRewindable rs2a = ResultSetFactory.makeRewindable(rs2) ;
       
        if ( equivalent(convert(rs1a), convert(rs2a), new BNodeIso(NodeUtils.sameValue)) )
            return true ;
        rs1a.reset() ;   
        rs2a.reset() ;
        return isomorphic(rs1, rs2) ;
    }
View Full Code Here

    public static boolean equalsByTerm(ResultSet rs1, ResultSet rs2) {
        if ( ! compareHeader(rs1, rs2) ) return false ;

        //return equivalent(convert(rs1), convert(rs2), new BNodeIso(NodeUtils.sameTerm)) ;
        ResultSetRewindable rs1a = ResultSetFactory.makeRewindable(rs1) ;
        ResultSetRewindable rs2a = ResultSetFactory.makeRewindable(rs2) ;
       
        if ( equivalent(convert(rs1a), convert(rs2a), new BNodeIso(NodeUtils.sameTerm)) )
            return true ;
        rs1a.reset() ;   
        rs2a.reset() ;
        return isomorphic(rs1, rs2) ;
    }
View Full Code Here

        {
            pw.println("==== No variables ====") ;
            //return ;
        }

        ResultSetRewindable resultSetRewindable = ResultSetFactory.makeRewindable(resultSet) ;
       
        int numCols = resultSetRewindable.getResultVars().size() ;
        int[] colWidths = colWidths(resultSetRewindable) ;

        String row[] = new String[numCols] ;
        int lineWidth = 0 ;
        for ( int col = 0 ; col < numCols ; col++ )
        {
            String rVar = resultSet.getResultVars().get(col) ;
            row[col] = rVar ;
            lineWidth += colWidths[col] ;
            if ( col > 0 )
                lineWidth += colSep.length() ;
        }
        if ( colStart != null )
            lineWidth += colStart.length() ;
        if ( colEnd != null )
            lineWidth += colEnd.length() ;

        for ( int i = 0 ; i < lineWidth ; i++ )
            pw.print('-') ;
        pw.println() ;
       
        printRow(pw, row, colWidths, colStart, colSep, colEnd) ;

        for ( int i = 0 ; i < lineWidth ; i++ )
            pw.print('=') ;
        pw.println() ;

        for ( ; resultSetRewindable.hasNext() ; )
        {
            QuerySolution rBind = resultSetRewindable.nextSolution() ;
            for ( int col = 0 ; col < numCols ; col++ )
            {
                String rVar = resultSet.getResultVars().get(col) ;
                row[col] = this.getVarValueAsString(rBind, rVar );
            }
View Full Code Here

    private static void equals(ResultSet rs1, ResultSet rs2)
    { same(rs1, rs2, true) ; }
   
    private static void same(ResultSet rs1, ResultSet rs2, boolean result)
    {
        ResultSetRewindable rsw1 = ResultSetFactory.makeRewindable(rs1) ;
        ResultSetRewindable rsw2 = ResultSetFactory.makeRewindable(rs2) ;
        boolean b = ResultSetCompare.equalsByValue(rsw1, rsw2) ;
        if ( b != result)
        {
            System.out.println("Different: ") ;
            rsw1.reset() ;
            rsw2.reset() ;
            ResultSetFormatter.out(rsw1) ;
            ResultSetFormatter.out(rsw2) ;
            System.out.println() ;
        }
       
View Full Code Here

    }
   
    // Test reading, writing and comparison
    @Test public void test_RS_1()
    {
        ResultSetRewindable rs1 = new ResultSetMem() ;
        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)) ;
    }
View Full Code Here

        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
   
    @Test public void test_RS_1_str()
    {
        ResultSetRewindable rs1 = new ResultSetMem() ;
        String x = ResultSetFormatter.asXMLString(rs1) ;
        rs1.reset() ;
        ResultSet rs2 = ResultSetFactory.fromXML(x) ;
        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
View Full Code Here

        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }

    @Test public void test_RS_2()
    {
        ResultSetRewindable rs1 = makeRewindable("x", com.hp.hpl.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)) ;
    }
View Full Code Here

        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
   
    @Test public void test_RS_2_str()
    {
        ResultSetRewindable rs1 = makeRewindable("x", com.hp.hpl.jena.graph.NodeFactory.createURI("tag:local")) ;
        String x = ResultSetFormatter.asXMLString(rs1) ;
        rs1.reset() ;
        ResultSet rs2 = ResultSetFactory.fromXML(x) ;
        assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ;
    }
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.