Package com.hp.jena.net.deploy.functions.test

Source Code of com.hp.jena.net.deploy.functions.test.TestNetGraphReasoner

/* 
  (c) Copyright 2009 Hewlett-Packard Development Company, LP
  [See end of file]
  $Id$
*/
package com.hp.jena.net.deploy.functions.test;

import java.io.StringReader;

import org.junit.*;


import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.reasoner.*;
import com.hp.jena.ymris.deploy.reasoner.DirectReasoner;
import com.hp.jena.ymris.grammar.*;
import com.hp.jena.ymris.yast.YAST;

import static com.hp.hpl.jena.graph.test.GraphTestBase.*;

public class TestNetGraphReasoner
    {
    @Test public void testMe() throws ParseException
        {
        testNetInference( "", "RULE { ?x <eh:/p> ?y } => { ?x a <eh:/p-domain> }", "" );
        testNetInference( "a q b", "RULE { ?x <eh:/p> ?y } => { ?x a <eh:/p-domain> }", "a q b" );
        testNetInference( "a p b", "RULE { ?x <eh:/p> ?y } => { ?x a <eh:/p-domain> }", "a p b; a rdf:type p-domain" );
        testNetInference( "a p b; c q d", "RULE { ?x <eh:/p> ?y } => { ?x a <eh:/p-domain> }", "a p b; c q d; a rdf:type p-domain" );
        testNetInference( "a p b; b p c", "RULE { ?x <eh:/p> ?y. ?y <eh:/p> ?z } => { ?x <eh:/p> ?z }", "a p b; b p c; a p c" );
        }

    private void testNetInference( String baseTriples, String rules, String desiredTriples ) throws ParseException
        {
        Ymris y = new Ymris( new StringReader( rules ) );
        YAST yast = y.ymris();
        Reasoner r = new DirectReasoner( yast.ruleSets().get( 0 ) );
        Graph base = graphWith( baseTriples );
        InfGraph ig = r.bind( base );
        assertIsomorphic( graphWith( desiredTriples ), ig );
        }
    }


/*
    (c) Copyright 2009 Hewlett-Packard Development Company, LP
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:

    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.

    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.

    3. The name of the author may not be used to endorse or promote products
       derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ 
TOP

Related Classes of com.hp.jena.net.deploy.functions.test.TestNetGraphReasoner

TOP
Copyright © 2018 www.massapi.com. 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.