01: /*
02: (c) Copyright 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved.
04: $Id: TestLiteralsInModel.java,v 1.5 2008/01/02 12:04:44 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.rdf.model.test;
08:
09: import java.util.Date;
10:
11: import com.hp.hpl.jena.rdf.model.*;
12:
13: public class TestLiteralsInModel extends ModelTestBase {
14: public TestLiteralsInModel(String name) {
15: super (name);
16: }
17:
18: protected final Model m = getModel();
19:
20: protected Model getModel() {
21: return ModelFactory.createDefaultModel();
22: }
23:
24: static final Resource X = resource("X");
25:
26: static final Property P = property("P");
27:
28: public void testAddWithFloatObject() {
29: m.addLiteral(X, P, 14.0f);
30: assertTrue(m.contains(X, P, m.createTypedLiteral(14.0f)));
31: assertTrue(m.containsLiteral(X, P, 14.0f));
32: }
33:
34: public void testAddWithDoubleObject() {
35: m.addLiteral(X, P, 14.0d);
36: assertTrue(m.contains(X, P, m.createTypedLiteral(14.0d)));
37: assertTrue(m.containsLiteral(X, P, 14.0d));
38: }
39:
40: public void testAddWithBooleanObject() {
41: m.addLiteral(X, P, true);
42: assertTrue(m.contains(X, P, m.createTypedLiteral(true)));
43: assertTrue(m.containsLiteral(X, P, true));
44: }
45:
46: public void testAddWithCharObject() {
47: m.addLiteral(X, P, 'x');
48: assertTrue(m.contains(X, P, m.createTypedLiteral('x')));
49: assertTrue(m.containsLiteral(X, P, 'x'));
50: }
51:
52: public void testAddWithLongObject() {
53: m.addLiteral(X, P, 99L);
54: assertTrue(m.contains(X, P, m.createTypedLiteral(99L)));
55: assertTrue(m.containsLiteral(X, P, 99L));
56: }
57:
58: public void testAddWithIntObject() {
59: m.addLiteral(X, P, 99);
60: assertTrue(m.contains(X, P, m.createTypedLiteral(99)));
61: assertTrue(m.containsLiteral(X, P, 99));
62: }
63:
64: public void testAddWithAnObject() {
65: Object z = new Date();
66: m.addLiteral(X, P, z);
67: assertTrue(m.contains(X, P, m.createTypedLiteral(z)));
68: assertTrue(m.containsLiteral(X, P, z));
69: }
70: }
71:
72: /*
73: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
74: * All rights reserved.
75: *
76: * Redistribution and use in source and binary forms, with or without
77: * modification, are permitted provided that the following conditions
78: * are met:
79: * 1. Redistributions of source code must retain the above copyright
80: * notice, this list of conditions and the following disclaimer.
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: * 3. The name of the author may not be used to endorse or promote products
85: * derived from this software without specific prior written permission.
86: *
87: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
88: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
89: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
90: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
91: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
92: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
93: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
94: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
95: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
96: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
97: */
|