001: /*
002: (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: All rights reserved - see end of file.
004: $Id: TestQueryNodeFactory.java,v 1.7 2008/01/02 12:08:56 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.graph.query.test;
008:
009: import junit.framework.TestSuite;
010:
011: import com.hp.hpl.jena.graph.*;
012: import com.hp.hpl.jena.graph.query.*;
013: import com.hp.hpl.jena.graph.test.NodeCreateUtils;
014:
015: public class TestQueryNodeFactory extends QueryTestBase {
016: public TestQueryNodeFactory(String name) {
017: super (name);
018: }
019:
020: public static TestSuite suite() {
021: return new TestSuite(TestQueryNodeFactory.class);
022: }
023:
024: QueryNodeFactory qnf = QueryNode.factory;
025:
026: public void testFixed() {
027: Node f = NodeCreateUtils.create("constant");
028: QueryNode F = qnf.createFixed(f);
029: assertInstanceOf(QueryNode.Fixed.class, F);
030: assertSame(f, F.node);
031: }
032:
033: public void testAny() {
034: QueryNode A = qnf.createAny();
035: assertInstanceOf(QueryNode.Any.class, A);
036: assertSame(Node.ANY, A.node);
037: }
038:
039: public void testBind() {
040: Node b = NodeCreateUtils.create("?x");
041: QueryNode B = qnf.createBind(b, 1);
042: assertInstanceOf(QueryNode.Bind.class, B);
043: assertSame(b, B.node);
044: }
045:
046: public void testJustBound() {
047: Node j = NodeCreateUtils.create("?y");
048: QueryNode J = qnf.createJustBound(j, 1);
049: assertInstanceOf(QueryNode.JustBound.class, J);
050: assertSame(j, J.node);
051: }
052:
053: public void testBound() {
054: Node u = NodeCreateUtils.create("?z");
055: QueryNode U = qnf.createBound(u, 2);
056: assertInstanceOf(QueryNode.Bound.class, U);
057: assertSame(u, U.node);
058: }
059:
060: public void testTriple() {
061: QueryNode S = qnf.createBound(node("?x"), 0);
062: QueryNode P = qnf.createFixed(node("P"));
063: QueryNode O = qnf.createBind(node("?y"), 1);
064: QueryTriple t = qnf.createTriple(S, P, O);
065: assertSame(t.S, S);
066: assertSame(t.P, P);
067: assertSame(t.O, O);
068: }
069:
070: public void testArray() {
071: QueryTriple[] a = qnf.createArray(42);
072: assertEquals(42, a.length);
073: }
074:
075: }
076:
077: /*
078: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
079: * All rights reserved.
080: *
081: * Redistribution and use in source and binary forms, with or without
082: * modification, are permitted provided that the following conditions
083: * are met:
084: * 1. Redistributions of source code must retain the above copyright
085: * notice, this list of conditions and the following disclaimer.
086: * 2. Redistributions in binary form must reproduce the above copyright
087: * notice, this list of conditions and the following disclaimer in the
088: * documentation and/or other materials provided with the distribution.
089: * 3. The name of the author may not be used to endorse or promote products
090: * derived from this software without specific prior written permission.
091: *
092: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
093: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
094: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
095: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
096: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
097: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
098: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
099: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
100: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
101: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102: */
|