/*
(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" ) );
}
}