KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > test > TestFileGraphMaker


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: TestFileGraphMaker.java,v 1.12 2005/03/10 14:57:29 chris-dollin Exp $
5 */

6
7 package com.hp.hpl.jena.graph.test;
8
9 import java.io.File JavaDoc;
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 /**
19     Test a FileGraphMaker; use the abstract tests, plus specialised ones for the name
20     conversion routines.
21
22     @author hedgehog
23 */

24 public class TestFileGraphMaker extends AbstractTestGraphMaker
25     {
26     public TestFileGraphMaker( String JavaDoc name )
27         { super( name ); }
28
29     public static TestSuite suite()
30         { return new TestSuite( TestFileGraphMaker.class ); }
31
32     public GraphMaker getGraphMaker()
33         { String JavaDoc 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 JavaDoc 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 /*
71     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
72     All rights reserved.
73
74     Redistribution and use in source and binary forms, with or without
75     modification, are permitted provided that the following conditions
76     are met:
77
78     1. Redistributions of source code must retain the above copyright
79        notice, this list of conditions and the following disclaimer.
80
81     2. Redistributions in binary form must reproduce the above copyright
82        notice, this list of conditions and the following disclaimer in the
83        documentation and/or other materials provided with the distribution.
84
85     3. The name of the author may not be used to endorse or promote products
86        derived from this software without specific prior written permission.
87
88     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
89     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
90     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
91     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
92     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
93     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
94     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
95     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
96     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
97     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
98 */

99
Popular Tags