01: /*
02: (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved - see end of file.
04: $Id: TestQueryReification.java,v 1.4 2008/01/02 12:08:56 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.graph.query.test;
08:
09: import java.util.*;
10:
11: import com.hp.hpl.jena.graph.*;
12: import com.hp.hpl.jena.graph.query.Query;
13: import com.hp.hpl.jena.vocabulary.RDF;
14:
15: import junit.framework.*;
16:
17: public class TestQueryReification extends QueryTestBase {
18: public TestQueryReification(String name) {
19: super (name);
20: }
21:
22: public static TestSuite suite() {
23: return new TestSuite(TestQueryReification.class);
24: }
25:
26: public Graph getGraph() {
27: return Factory.createDefaultGraph();
28: }
29:
30: public Graph getGraph(String triples) {
31: return graphAdd(getGraph(), triples);
32: }
33:
34: public void testS() {
35: Graph g = geGraphSPO();
36: Query q = new Query().addMatch(Query.X, RDF.Nodes.subject,
37: Query.S);
38: Iterator it = q.executeBindings(g,
39: new Node[] { Query.X, Query.S }).mapWith(select(1));
40: assertEquals(nodeSet("S"), iteratorToSet(it));
41: }
42:
43: public void testP() {
44: Graph g = geGraphSPO();
45: Query q = new Query().addMatch(Query.X, RDF.Nodes.predicate,
46: Query.P);
47: Iterator it = q.executeBindings(g,
48: new Node[] { Query.X, Query.P }).mapWith(select(1));
49: assertEquals(nodeSet("P"), iteratorToSet(it));
50: }
51:
52: public void testO() {
53: Graph g = geGraphSPO();
54: Query q = new Query().addMatch(Query.X, RDF.Nodes.object,
55: Query.O);
56: Iterator it = q.executeBindings(g,
57: new Node[] { Query.X, Query.O }).mapWith(select(1));
58: assertEquals(nodeSet("O"), iteratorToSet(it));
59: }
60:
61: protected Graph geGraphSPO() {
62: return getGraph("_x rdf:subject S; _x rdf:predicate P; _x rdf:object O; _x rdf:type rdf:Statement");
63: }
64:
65: }
66:
67: /*
68: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
69: * All rights reserved.
70: *
71: * Redistribution and use in source and binary forms, with or without
72: * modification, are permitted provided that the following conditions
73: * are met:
74: * 1. Redistributions of source code must retain the above copyright
75: * notice, this list of conditions and the following disclaimer.
76: * 2. Redistributions in binary form must reproduce the above copyright
77: * notice, this list of conditions and the following disclaimer in the
78: * documentation and/or other materials provided with the distribution.
79: * 3. The name of the author may not be used to endorse or promote products
80: * derived from this software without specific prior written permission.
81: *
82: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
83: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
84: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
85: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
86: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
87: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
88: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
89: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
91: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92: */
|