1 6 package com.hp.hpl.jena.rdf.model.test; 7 8 import java.io.*; 9 10 import com.hp.hpl.jena.rdf.model.*; 11 import com.hp.hpl.jena.util.* ; 12 13 import junit.framework.TestSuite; 14 15 18 public class TestModelSpecMore extends ModelTestBase 19 { 20 21 public TestModelSpecMore( String name ) 22 { super( name ); } 23 24 public static TestSuite suite() 25 { return new TestSuite( TestModelSpecMore.class ); } 26 27 public void testLoadWorks() throws Exception 28 { 29 String url = makeModel( "a bb c" ); 30 Model wanted = FileManager.get().loadModel( url ); 31 Model spec = modelWithStatements( "_root rdf:type jms:PlainModelSpec; _root jms:maker jms:MemMaker; _root jms:loadWith " + url ); 32 ModelSpec ms = ModelFactory.createSpec( spec ); 33 Model m = ModelFactory.createModel( ms ); 34 assertIsoModels( wanted, m ); 35 } 36 37 public void testLoadMultiWorks() throws Exception 38 { 39 String url1 = makeModel( "dogs may bark" ), url2 = makeModel( "pigs might fly" ); 40 Model wanted = FileManager.get().loadModel(url1) ; 41 FileManager.get().readModel(wanted,url2) ; 42 Model spec = modelWithStatements( "_root rdf:type jms:PlainModelSpec; _root jms:maker jms:MemMaker" ); 43 modelAdd( spec, "_root jms:loadWith " + url1 ); 44 modelAdd( spec, "_root jms:loadWith " + url2 ); 45 ModelSpec ms = ModelFactory.createSpec( spec ); 46 Model m = ModelFactory.createModel( ms ); 47 assertIsoModels( wanted, m ); 48 } 49 50 protected String makeModel( String statements ) throws FileNotFoundException, IOException 51 { 52 String name = FileUtils.tempFileName( "test-load-with-", ".rdf" ).getAbsolutePath(); 53 Model m = modelWithStatements( statements ); 54 FileOutputStream fos = new FileOutputStream( name ); 55 m.write( fos, FileUtils.guessLang( name ) ); 56 fos.close(); 57 return "file:" + name; 58 } 59 60 public void testOpenModel() 61 { 62 Model s = modelWithStatements( "_root jms:maker jms:MemMaker" ); 63 assertTrue( ModelFactory.createSpec( s ).openModel( "nosuch" ) instanceof Model ); 64 } 65 } 66 67 96 | Popular Tags |