Package com.hp.hpl.jena.graph.compose

Examples of com.hp.hpl.jena.graph.compose.MultiUnion


    public void testGraphSize2() {
        Graph g0 = graphWith( "x p y" );
        Graph g1 = graphWith( "x p z; z p zz" );        // disjoint with g0
        Graph g2 = graphWith( "x p y; z p a" );         // intersects with g1
       
        Graph m01 = new MultiUnion( iterateOver( g0, g1 ) );
        Graph m10 = new MultiUnion( iterateOver( g1, g0 ) );
        Graph m12 = new MultiUnion( iterateOver( g1, g2 ) );
        Graph m21 = new MultiUnion( iterateOver( g2, g1 ) );
        Graph m02 = new MultiUnion( iterateOver( g0, g2 ) );
        Graph m20 = new MultiUnion( iterateOver( g2, g0 ) );
       
        Graph m00 = new MultiUnion( iterateOver( g0, g0 ) );
       
        int s0 = g0.size();
        int s1 = g1.size();
        int s2 = g2.size();
       
        assertEquals( "Size of union of g0 and g1 not correct", s0+s1, m01.size() );
        assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m10.size() );
       
        assertEquals( "Size of union of g1 and g2 not correct", s1+s2, m12.size() );
        assertEquals( "Size of union of g2 and g1 not correct", s1+s2, m21.size() );

        assertEquals( "Size of union of g0 and g2 not correct", s0+s2 - 1, m02.size() );
        assertEquals( "Size of union of g2 and g0 not correct", s0+s2 - 1, m20.size() );
       
        assertEquals( "Size of union of g0 with itself not correct", s0, m00.size() );
    }
View Full Code Here


       
        int s0 = g0.size();
        int s1 = g1.size();
        int s2 = g2.size();
       
        MultiUnion m0 = new MultiUnion( new Graph[] {g0} );
       
        assertEquals( "Size of union of g0 not correct", s0, m0.size() );
        m0.addGraph( g1 );
        assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m0.size() );
       
        m0.addGraph( g2 );
        assertEquals( "Size of union of g0, g1 and g2 not correct", s0+s1+s2 -1, m0.size() );
       
        m0.removeGraph( g1 );
        assertEquals( "Size of union of g0 and g2 not correct", s0+s2 -1, m0.size() );
       
        m0.removeGraph( g0 );
        assertEquals( "Size of union of g2 not correct", s2, m0.size() );
       
        // remove again
        m0.removeGraph( g0 );
        assertEquals( "Size of union of g2 not correct", s2, m0.size() );
       
        m0.removeGraph( g2 );
        assertEquals( "Size of empty union not correct", 0, m0.size() );
       
    }
View Full Code Here

    public void testAdd() {
        Graph g0 = graphWith( "x p y" );
        Graph g1 = graphWith( "x p z; z p zz" );        // disjoint with g0
        Graph g2 = graphWith( "x p y; z p a" );         // intersects with g1
       
        MultiUnion m = new MultiUnion( new Graph[] {g0, g1} );
       
        int s0 = g0.size();
        int s1 = g1.size();
        int s2 = g2.size();
        int m0 = m.size();

        // add a triple to the union
        m.add( triple( "a q b" ) );
       
        assertEquals( "m.size should have increased by one", m0 + 1, m.size() );
        assertEquals( "g0.size should have increased by one", s0 + 1, g0.size() );
        assertEquals( "g1 size should be constant", s1, g1.size() );
       
        // change the designated receiver and try again
        m.setBaseGraph( g1 );
       
        s0 = g0.size();
        s1 = g1.size();
        s2 = g2.size();
        m0 = m.size();
       
        m.add( triple( "a1 q b1" ));

        assertEquals( "m.size should have increased by one", m0 + 1, m.size() );
        assertEquals( "g0 size should be constant", s0, g0.size() );
        assertEquals( "g1.size should have increased by one", s1 + 1, g1.size() );
       
        // check that we can't make g2 the designated updater
        boolean expected = false;
        try {
            m.setBaseGraph( g2 );
        }
        catch (IllegalArgumentException e) {
            expected = true;
        }
        assertTrue( "Should not have been able to make g2 the updater", expected );
View Full Code Here

     * @param spec The model spec to interpret
     * @param base The base model, or null
     */
    private static Graph generateGraph( OntModelSpec spec, Graph base ) {
        // create a empty union graph
        MultiUnion u = new MultiUnion();
        u.addGraph( base );
        u.setBaseGraph( base );

        Reasoner r = spec.getReasoner();
        // if we have a reasoner in the spec, bind to the union graph and return
        return r == null ? (Graph) u : r.bind( u );
    }
View Full Code Here

   
    @Override
    public Graph getGraph()
        {
        Graph gBase = graphWith( "" ), g1 = graphWith( "" );
        return new MultiUnion( new Graph[] {gBase, g1} );
        }
View Full Code Here

        Graph gBase = graphWith( "" ), g1 = graphWith( "" );
        return new MultiUnion( new Graph[] {gBase, g1} );
        }

    public void testEmptyGraph() {
        Graph m = new MultiUnion();
        Graph g0 = graphWith( "x p y");
       
        assertEquals( "Empty model should have size zero", 0, m.size() );
        assertFalse( "Empty model should not contain another graph", m.dependsOn( g0 ) );
    }
View Full Code Here

        A MultiUnion graph should have a MultiUnionStatisticsHandler, and that
        handler should point right back to that graph.
    */
    public void testMultiUnionHasMultiUnionStatisticsHandler()
        {
        MultiUnion mu = new MultiUnion();
        GraphStatisticsHandler sh = mu.getStatisticsHandler();
        assertInstanceOf( MultiUnionStatisticsHandler.class, sh );
        assertSame( mu, ((MultiUnionStatisticsHandler) sh).getUnion() );
        }
View Full Code Here

    public void testGraphSize1() {
        Graph g0 = graphWith( "x p y" );
        Graph g1 = graphWith( "x p z; z p zz" );        // disjoint with g0
        Graph g2 = graphWith( "x p y; z p a" );         // intersects with g1
       
        Graph m01 = new MultiUnion( new Graph[] {g0, g1} );
        Graph m10 = new MultiUnion( new Graph[] {g1, g0} );
        Graph m12 = new MultiUnion( new Graph[] {g1, g2} );
        Graph m21 = new MultiUnion( new Graph[] {g2, g1} );
        Graph m02 = new MultiUnion( new Graph[] {g0, g2} );
        Graph m20 = new MultiUnion( new Graph[] {g2, g0} );
       
        Graph m00 = new MultiUnion( new Graph[] {g0, g0} );
       
        int s0 = g0.size();
        int s1 = g1.size();
        int s2 = g2.size();
       
        assertEquals( "Size of union of g0 and g1 not correct", s0+s1, m01.size() );
        assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m10.size() );
       
        assertEquals( "Size of union of g1 and g2 not correct", s1+s2, m12.size() );
        assertEquals( "Size of union of g2 and g1 not correct", s1+s2, m21.size() );

        assertEquals( "Size of union of g0 and g2 not correct", s0+s2 - 1, m02.size() );
        assertEquals( "Size of union of g2 and g0 not correct", s0+s2 - 1, m20.size() );
       
        assertEquals( "Size of union of g0 with itself not correct", s0, m00.size() );
    }
View Full Code Here

    public void testGraphSize2() {
        Graph g0 = graphWith( "x p y" );
        Graph g1 = graphWith( "x p z; z p zz" );        // disjoint with g0
        Graph g2 = graphWith( "x p y; z p a" );         // intersects with g1
       
        Graph m01 = new MultiUnion( iterateOver( g0, g1 ) );
        Graph m10 = new MultiUnion( iterateOver( g1, g0 ) );
        Graph m12 = new MultiUnion( iterateOver( g1, g2 ) );
        Graph m21 = new MultiUnion( iterateOver( g2, g1 ) );
        Graph m02 = new MultiUnion( iterateOver( g0, g2 ) );
        Graph m20 = new MultiUnion( iterateOver( g2, g0 ) );
       
        Graph m00 = new MultiUnion( iterateOver( g0, g0 ) );
       
        int s0 = g0.size();
        int s1 = g1.size();
        int s2 = g2.size();
       
        assertEquals( "Size of union of g0 and g1 not correct", s0+s1, m01.size() );
        assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m10.size() );
       
        assertEquals( "Size of union of g1 and g2 not correct", s1+s2, m12.size() );
        assertEquals( "Size of union of g2 and g1 not correct", s1+s2, m21.size() );

        assertEquals( "Size of union of g0 and g2 not correct", s0+s2 - 1, m02.size() );
        assertEquals( "Size of union of g2 and g0 not correct", s0+s2 - 1, m20.size() );
       
        assertEquals( "Size of union of g0 with itself not correct", s0, m00.size() );
    }
View Full Code Here

       
        int s0 = g0.size();
        int s1 = g1.size();
        int s2 = g2.size();
       
        MultiUnion m0 = new MultiUnion( new Graph[] {g0} );
       
        assertEquals( "Size of union of g0 not correct", s0, m0.size() );
        m0.addGraph( g1 );
        assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m0.size() );
       
        m0.addGraph( g2 );
        assertEquals( "Size of union of g0, g1 and g2 not correct", s0+s1+s2 -1, m0.size() );
       
        m0.removeGraph( g1 );
        assertEquals( "Size of union of g0 and g2 not correct", s0+s2 -1, m0.size() );
       
        m0.removeGraph( g0 );
        assertEquals( "Size of union of g2 not correct", s2, m0.size() );
       
        // remove again
        m0.removeGraph( g0 );
        assertEquals( "Size of union of g2 not correct", s2, m0.size() );
       
        m0.removeGraph( g2 );
        assertEquals( "Size of empty union not correct", 0, m0.size() );
       
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.graph.compose.MultiUnion

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.