Package com.hp.jena.net.deploy.local

Source Code of com.hp.jena.net.deploy.local.TestUnlessInPremises$MyHowTo

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

package com.hp.jena.net.deploy.local;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.graph.test.GraphTestBase;
import com.hp.jena.ymris.deploy.functions.LightFunctions;
import com.hp.jena.ymris.deploy.local.BindingSink;

public class TestUnlessInPremises
    {
    protected static class MyHowTo extends LightFunctions
        {
        protected final Graph given;
       
        public MyHowTo( Graph given )
            { this.given = given; }
       
        @Override public Graph getGraph()
            { return given; }
        };
       
    @Test public void testPlainUnless()
        {
        LogBindings sink = new LogBindings();
        Graph given = GraphTestBase.graphWith( "b Q c" );
        String rules = "RULE { ?a <eh:/P> ?b UNLESS ?b <eh:/Q> ?c } => { ?a a <eh:/UnQed-b> }";
        BindingSink in = Utils.rulesToDeployment( sink, rules, new MyHowTo( given ) );
    //
        in.consume( GraphTestBase.nodeArray( "X a P b" ) );
        in.consume( GraphTestBase.nodeArray( "X b Q c" ) );
        in.consume( GraphTestBase.nodeArray( "X x P y" ) );
        assertEquals( Utils.bindings( "x rdf:type UnQed-b" ), sink.bindings );
        }
       
    @Test public void testUnlessWithFilter()
        {
        LogBindings sink = new LogBindings();
        Graph given = GraphTestBase.graphWith( "b Q 1; y Q 2" );
        String rules = "RULE { ?a <eh:/P> ?b UNLESS GIVEN { ?b <eh:/Q> ?c FILTER ?c = 1 } } => { ?a a <eh:/UnQed-b> }";
        BindingSink in = Utils.rulesToDeployment( sink, rules, new MyHowTo( given ) );
    //
        in.consume( GraphTestBase.nodeArray( "X a P b" ) );
        in.consume( GraphTestBase.nodeArray( "X x P y" ) );
        assertEquals( Utils.bindings( "x rdf:type UnQed-b" ), sink.bindings );
        }
    }

/*
    (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.local.TestUnlessInPremises$MyHowTo

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.