KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > model > test > TestModelRead


1 /*
2   (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP, all rights reserved.
3   [See end of file]
4   $Id: TestModelRead.java,v 1.4 2005/02/21 12:15:14 andy_seaborne Exp $
5 */

6 package com.hp.hpl.jena.rdf.model.test;
7
8 import com.hp.hpl.jena.rdf.model.*;
9
10 import junit.framework.TestSuite;
11
12 /**
13      TestModelRead - test that the new model.read operation(s) exist.
14      @author kers
15  */

16 public class TestModelRead extends ModelTestBase
17     {
18     public TestModelRead( String JavaDoc name )
19         { super( name ); }
20     
21     public static TestSuite suite()
22         { return new TestSuite( TestModelRead.class ); }
23     
24     public void testReturnsSelf()
25         {
26         Model m = ModelFactory.createDefaultModel();
27         assertSame( m, m.read( "file:testing/modelReading/empty.n3", "base", "N3" ) );
28         assertTrue( m.isEmpty() );
29         }
30     
31     public void testLoadsSimpleModel()
32         {
33         Model expected = ModelFactory.createDefaultModel();
34         Model m = ModelFactory.createDefaultModel();
35         expected.read( "file:testing/modelReading/simple.n3", "N3" );
36         assertSame( m, m.read( "file:testing/modelReading/simple.n3", "base", "N3" ) );
37         assertIsoModels( expected, m );
38         }
39     
40     /*
41          Suppressed, since the other Model::read(String url) operations apparently
42          don't retry failing URLs as filenames. But the code text remains, so that
43          when-and-if, we have a basis.
44      */

45     public void testLoadsSimpleModelWithoutProtocol()
46         {
47 // Model expected = ModelFactory.createDefaultModel();
48
// Model m = ModelFactory.createDefaultModel();
49
// expected.read( "testing/modelReading/simple.n3", "RDF/XML" );
50
// assertSame( m, m.read( "testing/modelReading/simple.n3", "base", "N3" ) );
51
// assertIsoModels( expected, m );
52
}
53     
54     public void testSimpleLoadImplictBase()
55         {
56         Model mBasedImplicit = ModelFactory.createDefaultModel();
57         mBasedImplicit.read( "file:testing/modelReading/based.n3", "N3" );
58         assertIsoModels( modelWithStatements( "file:testing/modelReading/based.n3 jms:predicate jms:object" ), mBasedImplicit );
59         }
60     
61     public void testSimpleLoadExplicitBase()
62         {
63         Model mBasedExplicit = ModelFactory.createDefaultModel();
64         mBasedExplicit.read( "file:testing/modelReading/based.n3", "base:", "N3" );
65         assertIsoModels( modelWithStatements( "base: jms:predicate jms:object" ), mBasedExplicit );
66         }
67     
68     public void testDefaultLangXML()
69         {
70         Model m = ModelFactory.createDefaultModel();
71         m.read( "file:testing/modelReading/plain.rdf", null, null );
72         }
73     }
74
75
76 /*
77     (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP
78     All rights reserved.
79
80     Redistribution and use in source and binary forms, with or without
81     modification, are permitted provided that the following conditions
82     are met:
83
84     1. Redistributions of source code must retain the above copyright
85     notice, this list of conditions and the following disclaimer.
86
87     2. Redistributions in binary form must reproduce the above copyright
88     notice, this list of conditions and the following disclaimer in the
89     documentation and/or other materials provided with the distribution.
90
91     3. The name of the author may not be used to endorse or promote products
92     derived from this software without specific prior written permission.
93
94     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
95     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
96     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
97     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
98     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
99     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
100     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
101     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
102     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
103     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104 */
Popular Tags