1 6 7 package com.hp.hpl.jena.graph.test; 8 9 import java.io.File ; 10 11 import com.hp.hpl.jena.graph.*; 12 import com.hp.hpl.jena.graph.impl.*; 13 import com.hp.hpl.jena.shared.*; 14 import com.hp.hpl.jena.util.FileUtils; 15 16 import junit.framework.*; 17 18 24 public class TestFileGraphMaker extends AbstractTestGraphMaker 25 { 26 public TestFileGraphMaker( String name ) 27 { super( name ); } 28 29 public static TestSuite suite() 30 { return new TestSuite( TestFileGraphMaker.class ); } 31 32 public GraphMaker getGraphMaker() 33 { String scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker" ).getPath(); 34 return new FileGraphMaker( scratch, ReificationStyle.Minimal, true ); } 35 36 public void testToFilename() 37 { assertEquals( "plain", FileGraphMaker.toFilename( "plain" ) ); 38 assertEquals( "with_Sslash", FileGraphMaker.toFilename( "with/slash" ) ); 39 assertEquals( "with_Ccolon", FileGraphMaker.toFilename( "with:colon" ) ); 40 assertEquals( "with_Uunderbar", FileGraphMaker.toFilename( "with_underbar" ) ); 41 assertEquals( "with_Stwo_Sslashes", FileGraphMaker.toFilename( "with/two/slashes" ) ); 42 assertEquals( "with_Sa_Cmixture_U...", FileGraphMaker.toFilename( "with/a:mixture_..." ) ); } 43 44 public void testToGraphname() 45 { assertEquals( "plain", FileGraphMaker.toGraphname( "plain" ) ); 46 assertEquals( "with/slash", FileGraphMaker.toGraphname( "with_Sslash" ) ); 47 assertEquals( "with:colon", FileGraphMaker.toGraphname( "with_Ccolon" ) ); 48 assertEquals( "with_underbar", FileGraphMaker.toGraphname( "with_Uunderbar" ) ); 49 assertEquals( "a/mixture_of:things", FileGraphMaker.toGraphname( "a_Smixture_Uof_Cthings" ) ); 50 assertEquals( "with/two/slashes", FileGraphMaker.toGraphname( "with_Stwo_Sslashes" ) ); } 51 52 public void testDetectsExistingFiles() 53 { 54 File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-already" ); 55 Graph content = graphWith( "something hasProperty someValue" ); 56 FileGraphMaker A = new FileGraphMaker( scratch.getPath() ); 57 FileGraphMaker B = new FileGraphMaker( scratch.getPath() ); 58 FileGraph gA = (FileGraph) A.createGraph( "already", true ); 59 gA.getBulkUpdateHandler().add( content ); 60 gA.close(); 61 FileGraph gB = (FileGraph) B.openGraph( "already", false ); 62 assertIsomorphic( content, gB ); 63 gB.close(); 64 gB.delete(); 65 gA.delete(); 66 } 67 } 68 69 70 99 | Popular Tags |