01: /*
02: (c) Copyright 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved.
04: $Id: TestQuery.java,v 1.2 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.Triple;
12: import com.hp.hpl.jena.graph.query.Query;
13:
14: public class TestQuery extends QueryTestBase {
15:
16: public TestQuery(String name) {
17: super (name);
18: }
19:
20: public void testEmptyQueryPattern() {
21: assertEquals(new ArrayList(), new Query().getPattern());
22: }
23:
24: public void testIOneTriple() {
25: Query q = new Query();
26: Triple spo = triple("S P O");
27: q.addMatch(spo);
28: assertEquals(listOfOne(spo), q.getPattern());
29: }
30:
31: public void testSeveralTriples() {
32: Triple[] triples = tripleArray("a P b; c Q ?d; ?e R '17'");
33: List expected = new ArrayList();
34: Query q = new Query();
35: for (int i = 0; i < triples.length; i += 1) {
36: expected.add(triples[i]);
37: q.addMatch(triples[i]);
38: assertEquals(expected, q.getPattern());
39: }
40: }
41: }
42:
43: /*
44: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
45: * All rights reserved.
46: *
47: * Redistribution and use in source and binary forms, with or without
48: * modification, are permitted provided that the following conditions
49: * are met:
50: * 1. Redistributions of source code must retain the above copyright
51: * notice, this list of conditions and the following disclaimer.
52: * 2. Redistributions in binary form must reproduce the above copyright
53: * notice, this list of conditions and the following disclaimer in the
54: * documentation and/or other materials provided with the distribution.
55: * 3. The name of the author may not be used to endorse or promote products
56: * derived from this software without specific prior written permission.
57: *
58: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
62: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
67: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68: */
|