001: /*
002: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: $Id: TestVocabRDF.java,v 1.10 2008/01/02 12:08:10 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.vocabulary.test;
008:
009: import com.hp.hpl.jena.rdf.model.test.ModelTestBase;
010: import com.hp.hpl.jena.vocabulary.*;
011: import junit.framework.*;
012:
013: /**
014: @author kers
015: */
016: public class TestVocabRDF extends ModelTestBase {
017: public TestVocabRDF(String name) {
018: super (name);
019: }
020:
021: public static TestSuite suite() {
022: return new TestSuite(TestVocabRDF.class);
023: }
024:
025: /**
026: The correct namespace for RDF. It is *important* that this be a literal
027: string, not a reference to RDF.getURI(), because we're testing that the
028: RDF vocabulary is correct, so this here string is the gold standard.
029: */
030: static final String RDFns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
031:
032: /**
033: Tests that the RDF vocabulary identifiers are what they're supposed to be.
034: TODO arrange that we detect if there are any other identifiers in the class.
035: */
036: public void testRDFVocabulary() {
037: String ns = RDFns;
038: assertEquals(ns, RDF.getURI());
039: assertEquals(ns + "Alt", RDF.Alt.getURI());
040: assertEquals(ns + "Bag", RDF.Bag.getURI());
041: assertEquals(ns + "Property", RDF.Property.getURI());
042: assertEquals(ns + "Seq", RDF.Seq.getURI());
043: assertEquals(ns + "Statement", RDF.Statement.getURI());
044: assertEquals(ns + "List", RDF.List.getURI());
045: assertEquals(ns + "nil", RDF.nil.getURI());
046: assertEquals(ns + "type", RDF.type.getURI());
047: assertEquals(ns + "rest", RDF.rest.getURI());
048: assertEquals(ns + "first", RDF.first.getURI());
049: assertEquals(ns + "subject", RDF.subject.getURI());
050: assertEquals(ns + "predicate", RDF.predicate.getURI());
051: assertEquals(ns + "object", RDF.object.getURI());
052: assertEquals(ns + "value", RDF.value.getURI());
053: }
054:
055: /**
056: Test that the RDF.li() method generates the correct strings for a few
057: plausible test cases.
058: */
059: public void testLI() {
060: String ns = RDFns;
061: assertEquals(ns + "_1", RDF.li(1).getURI());
062: assertEquals(ns + "_1", RDF.li(1).getURI());
063: assertEquals(ns + "_10", RDF.li(10).getURI());
064: assertEquals(ns + "_11", RDF.li(11).getURI());
065: assertEquals(ns + "_100", RDF.li(100).getURI());
066: assertEquals(ns + "_123", RDF.li(123).getURI());
067: assertEquals(ns + "_32768", RDF.li(32768).getURI());
068: }
069:
070: public void testNodes() {
071: assertEquals(RDF.Alt.asNode(), RDF.Nodes.Alt);
072: assertEquals(RDF.Bag.asNode(), RDF.Nodes.Bag);
073: assertEquals(RDF.Property.asNode(), RDF.Nodes.Property);
074: assertEquals(RDF.Seq.asNode(), RDF.Nodes.Seq);
075: assertEquals(RDF.Statement.asNode(), RDF.Nodes.Statement);
076: assertEquals(RDF.List.asNode(), RDF.Nodes.List);
077: assertEquals(RDF.nil.asNode(), RDF.Nodes.nil);
078: assertEquals(RDF.type.asNode(), RDF.Nodes.type);
079: assertEquals(RDF.rest.asNode(), RDF.Nodes.rest);
080: assertEquals(RDF.first.asNode(), RDF.Nodes.first);
081: assertEquals(RDF.subject.asNode(), RDF.Nodes.subject);
082: assertEquals(RDF.predicate.asNode(), RDF.Nodes.predicate);
083: assertEquals(RDF.object.asNode(), RDF.Nodes.object);
084: assertEquals(RDF.value.asNode(), RDF.Nodes.value);
085: }
086: }
087:
088: /*
089: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
090: All rights reserved.
091:
092: Redistribution and use in source and binary forms, with or without
093: modification, are permitted provided that the following conditions
094: are met:
095:
096: 1. Redistributions of source code must retain the above copyright
097: notice, this list of conditions and the following disclaimer.
098:
099: 2. Redistributions in binary form must reproduce the above copyright
100: notice, this list of conditions and the following disclaimer in the
101: documentation and/or other materials provided with the distribution.
102:
103: 3. The name of the author may not be used to endorse or promote products
104: derived from this software without specific prior written permission.
105:
106: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
107: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
108: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
109: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
110: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
111: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
112: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
113: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
114: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
115: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
116: */
|