01: /*
02: (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved.
04: $Id: TestPropertyImpl.java,v 1.2 2008/01/02 12:04:41 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.rdf.model.test;
08:
09: import com.hp.hpl.jena.rdf.model.Property;
10: import com.hp.hpl.jena.rdf.model.impl.PropertyImpl;
11: import com.hp.hpl.jena.vocabulary.*;
12:
13: public class TestPropertyImpl extends ModelTestBase {
14: public TestPropertyImpl(String name) {
15: super (name);
16: }
17:
18: public void testOrdinalValues() {
19: testRDFOrdinalValue(1, "_1");
20: testRDFOrdinalValue(2, "_2");
21: testRDFOrdinalValue(3, "_3");
22: testRDFOrdinalValue(4, "_4");
23: testRDFOrdinalValue(5, "_5");
24: testRDFOrdinalValue(6, "_6");
25: testRDFOrdinalValue(7, "_7");
26: testRDFOrdinalValue(8, "_8");
27: testRDFOrdinalValue(9, "_9");
28: testRDFOrdinalValue(10, "_10");
29: testRDFOrdinalValue(100, "_100");
30: testRDFOrdinalValue(1234, "_1234");
31: testRDFOrdinalValue(67890, "_67890");
32: }
33:
34: public void testNonOrdinalRDFURIs() {
35: testRDFOrdinalValue(0, "x");
36: testRDFOrdinalValue(0, "x1");
37: testRDFOrdinalValue(0, "_x");
38: testRDFOrdinalValue(0, "x123");
39: testRDFOrdinalValue(0, "0xff");
40: testRDFOrdinalValue(0, "_xff");
41: }
42:
43: private void testRDFOrdinalValue(int i, String local) {
44: testOrdinalValue(i, RDF.getURI() + local);
45: }
46:
47: public void testNonRDFElementURIsHaveOrdinal0() {
48: testOrdinalValue(0, "foo:bar");
49: testOrdinalValue(0, "foo:bar1");
50: testOrdinalValue(0, "foo:bar2");
51: testOrdinalValue(0, RDFS.getURI() + "_17");
52: }
53:
54: private void testOrdinalValue(int i, String URI) {
55: String message = "property should have expected ordinal value for "
56: + URI;
57: assertEquals(message, i, createProperty(URI).getOrdinal());
58: }
59:
60: protected Property createProperty(String uri) {
61: return new PropertyImpl(uri);
62: }
63: }
64:
65: /*
66: * (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
67: * All rights reserved.
68: *
69: * Redistribution and use in source and binary forms, with or without
70: * modification, are permitted provided that the following conditions
71: * are met:
72: * 1. Redistributions of source code must retain the above copyright
73: * notice, this list of conditions and the following disclaimer.
74: * 2. Redistributions in binary form must reproduce the above copyright
75: * notice, this list of conditions and the following disclaimer in the
76: * documentation and/or other materials provided with the distribution.
77: * 3. The name of the author may not be used to endorse or promote products
78: * derived from this software without specific prior written permission.
79: *
80: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
81: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
82: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
83: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
84: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
85: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
86: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
87: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
89: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90: */
|