1 6 7 package com.hp.hpl.jena.rdf.model.test; 8 9 import com.hp.hpl.jena.rdf.model.*; 10 11 import junit.framework.*; 12 13 18 public class TestResourceImpl extends ModelTestBase 19 { 20 public TestResourceImpl( String name ) 21 { super(name); } 22 23 public static TestSuite suite() 24 { return new TestSuite( TestResourceImpl.class ); } 25 26 29 public void testCannotAsNonLiteral() 30 { Model m = ModelFactory.createDefaultModel(); 31 resource( m, "plumPie" ).as( Resource.class ); } 32 33 36 public void testAsLiteral() 37 { Model m = ModelFactory.createDefaultModel(); 38 try 39 { literal( m, "17" ).as( Resource.class ); 40 fail( "literals cannot be resources"); } 41 catch (ResourceRequiredException e) 42 { pass(); }} 43 44 public void testNameSpace() 45 { 46 assertEquals( "eh:x", resource( "eh:xyz" ).getNameSpace() ); 47 assertEquals( "http://d/", resource( "http://d/stuff" ).getNameSpace() ); 48 assertEquals( "ftp://dd.com/12345", resource( "ftp://dd.com/12345" ).getNameSpace() ); 49 assertEquals( "http://domain/spoo#", resource( "http://domain/spoo#anchor" ).getNameSpace() ); 50 assertEquals( "ftp://abd/def#ghi#", resource( "ftp://abd/def#ghi#e11-2" ).getNameSpace() ); 51 } 52 53 public void testLocalName() 54 { 55 assertEquals( "yz", resource( "eh:xyz" ).getLocalName() ); 56 } 57 58 public void testHasURI() 59 { 60 assertTrue( resource( "eh:xyz" ).hasURI( "eh:xyz" ) ); 61 assertFalse( resource( "eh:xyz" ).hasURI( "eh:1yz" ) ); 62 assertFalse( ResourceFactory.createResource().hasURI( "42" ) ); 63 } 64 65 } 66 67 68 | Popular Tags |