KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > vocabulary > test > TestVocabRDF


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: TestVocabRDF.java,v 1.6 2005/02/21 12:22:20 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.vocabulary.test;
8
9 import com.hp.hpl.jena.rdf.model.test.ModelTestBase;
10 import com.hp.hpl.jena.vocabulary.*;
11 import junit.framework.*;
12
13 /**
14     @author kers
15 */

16 public class TestVocabRDF extends ModelTestBase
17     {
18     public TestVocabRDF(String JavaDoc name)
19         { super(name); }
20
21      public static TestSuite suite()
22         { return new TestSuite( TestVocabRDF.class ); }
23
24     /**
25         The correct namespace for RDF. It is *important* that this be a literal
26         string, not a reference to RDF.getURI(), because we're testing that the
27         RDF vocabulary is correct, so this here string is the gold standard.
28     */

29     static final String JavaDoc RDFns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
30
31     /**
32         Tests that the RDF vocabulary identifiers are what they're supposed to be.
33         TODO arrange that we detect if there are any other identifiers in the class.
34     */

35     public void testRDFVocabulary()
36         {
37         String JavaDoc ns = RDFns;
38         assertEquals( ns, RDF.getURI() );
39         assertEquals( ns + "Alt", RDF.Alt.getURI() );
40         assertEquals( ns + "Bag", RDF.Bag.getURI() );
41         assertEquals( ns + "Property", RDF.Property.getURI() );
42         assertEquals( ns + "Seq", RDF. Seq.getURI() );
43         assertEquals( ns + "Statement", RDF. Statement.getURI() );
44         assertEquals( ns + "List", RDF. List.getURI() );
45         assertEquals( ns + "nil", RDF. nil.getURI() );
46         assertEquals( ns + "type", RDF. type.getURI() );
47         assertEquals( ns + "rest", RDF. rest.getURI() );
48         assertEquals( ns + "first", RDF. first.getURI() );
49         assertEquals( ns + "subject", RDF. subject.getURI() );
50         assertEquals( ns + "predicate", RDF. predicate.getURI() );
51         assertEquals( ns + "object", RDF. object.getURI() );
52         assertEquals( ns + "value", RDF. value.getURI() );
53         }
54
55     /**
56         Test that the RDF.li() method generates the correct strings for a few
57         plausible test cases.
58     */

59     public void testLI()
60         {
61         String JavaDoc ns = RDFns;
62         assertEquals( ns + "_1", RDF.li(1).getURI() );
63         assertEquals( ns + "_1", RDF.li(1).getURI() );
64         assertEquals( ns + "_10", RDF.li(10).getURI() );
65         assertEquals( ns + "_11", RDF.li(11).getURI() );
66         assertEquals( ns + "_100", RDF.li(100).getURI() );
67         assertEquals( ns + "_123", RDF.li(123).getURI() );
68         assertEquals( ns + "_32768", RDF.li(32768).getURI() );
69         }
70
71     public void testNodes()
72         {
73         assertEquals( RDF.Alt.getNode(), RDF.Nodes.Alt );
74         assertEquals( RDF.Bag.getNode(), RDF.Nodes.Bag );
75         assertEquals( RDF.Property.getNode(), RDF.Nodes.Property );
76         assertEquals( RDF.Seq.getNode(), RDF.Nodes. Seq );
77         assertEquals( RDF.Statement.getNode(), RDF.Nodes. Statement );
78         assertEquals( RDF.List.getNode(), RDF.Nodes. List );
79         assertEquals( RDF.nil.getNode(), RDF.Nodes. nil );
80         assertEquals( RDF.type.getNode(), RDF.Nodes. type );
81         assertEquals( RDF.rest.getNode(), RDF.Nodes. rest );
82         assertEquals( RDF.first.getNode(), RDF.Nodes. first );
83         assertEquals( RDF.subject.getNode(), RDF.Nodes. subject );
84         assertEquals( RDF.predicate.getNode(), RDF.Nodes. predicate );
85         assertEquals( RDF.object.getNode(), RDF.Nodes. object );
86         assertEquals( RDF.value.getNode(), RDF.Nodes. value );
87         }
88     }
89
90
91 /*
92     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
93     All rights reserved.
94
95     Redistribution and use in source and binary forms, with or without
96     modification, are permitted provided that the following conditions
97     are met:
98
99     1. Redistributions of source code must retain the above copyright
100        notice, this list of conditions and the following disclaimer.
101
102     2. Redistributions in binary form must reproduce the above copyright
103        notice, this list of conditions and the following disclaimer in the
104        documentation and/or other materials provided with the distribution.
105
106     3. The name of the author may not be used to endorse or promote products
107        derived from this software without specific prior written permission.
108
109     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
110     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
111     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
112     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
113     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
114     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
115     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
116     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
117     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
118     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
119 */

120
Popular Tags