Package com.hp.jena.rules.ast.tests

Source Code of com.hp.jena.rules.ast.tests.TestPrefixMapping

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

package com.hp.jena.rules.ast.tests;

import static org.junit.Assert.*;

import org.junit.Test;

import com.hp.jena.rules.ast.PrefixMapping;

public class TestPrefixMapping
    {
    @Test public void testAbsentPrefixMapsToNull()
        {
        PrefixMapping pm = PrefixMapping.create().setPrefix( "my", "spoo:/flarn#" );
        assertEquals( null, pm.getURI( "your" ) );
        }
   
    @Test public void testMapsPrefixIfPresent()
        {
        PrefixMapping pm = PrefixMapping.create().setPrefix( "my", "spoo:/flarn#" );
        assertEquals( "spoo:/flarn#", pm.getURI( "my" ) );
        }
   
    @Test public void testOverridingMergesDifferentPrefixes()
        {
        PrefixMapping A = PrefixMapping.create().setPrefix( "a", "my:A#" );
        PrefixMapping B = PrefixMapping.create().setPrefix( "b", "my:B#" );
        PrefixMapping AB = A.overriddenBy( B );
        assertEquals( "my:A#", AB.getURI( "a" ) );
        assertEquals( "my:B#", AB.getURI( "b" ) );
        }
   
    @Test public void testOverridingPrefersLaterPrefix()
        {
        PrefixMapping A = PrefixMapping.create().setPrefix( "a", "my:A#" );
        PrefixMapping B = PrefixMapping.create().setPrefix( "a", "my:B#" );
        PrefixMapping AB = A.overriddenBy( B );
        assertEquals( "my:B#", AB.getURI( "a" ) );
        assertEquals( null, AB.getURI( "b" ) );
        }
    }
TOP

Related Classes of com.hp.jena.rules.ast.tests.TestPrefixMapping

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.