protected Node createVariable(String s, int line, int column) { s = s.substring(1) ; // Drop the marker return NodeFactory.createVariable(s) ; }
protected Node createVariable(String s, int line, int column) { s = s.substring(1) ; // Drop the marker return NodeFactory.createVariable(s) ; }
@Override public Node allocate() { return NodeFactory.createVariable("v"+(counter++)) ; } @Override
@Override public Node allocate() { return NodeFactory.createVariable("v"+(counter++)) ; } @Override
@Test public void test_variable1() { Node x = NodeFactory.createVariable("x"); Node y = NodeFactory.createVariable("x"); int res = NodeUtils.compareRDFTerms(x, y); assertTrue("Variable nodes should sort by variable names", Expr.CMP_EQUAL == res); }
@Before public void setup() { triples = new Triple[] { new Triple(NodeFactory.createVariable("foo"), RDF.type.asNode(), NodeFactory.createURI("http://example.com/class")), new Triple(NodeFactory.createVariable("foo"), NodeFactory.createBlankNode(), NodeFactory.createVariable("bar")), new Triple(NodeFactory.createVariable("bar"), NodeFactory.createBlankNode(), NodeFactory.createVariable("baz")), }; }
public void testVariables() { assertFalse( "variable nodes aren't blank", NodeFactory.createVariable( N ).isBlank() ); assertFalse( "variable nodes aren't literal", NodeFactory.createVariable( N ).isLiteral() ); assertFalse( "variable nodes aren't URIs", NodeFactory.createVariable( N ).isURI() ); assertTrue( "variable nodes are variable", NodeFactory.createVariable( N ).isVariable() ); assertEquals( "variable nodes keep their name", N, NodeFactory.createVariable( N ).getName() ); assertEquals( "variable nodes keep their name", N + "x", NodeFactory.createVariable( N + "x" ).getName() ); }
public void testVariables() { assertFalse( "variable nodes aren't blank", NodeFactory.createVariable( N ).isBlank() ); assertFalse( "variable nodes aren't literal", NodeFactory.createVariable( N ).isLiteral() ); assertFalse( "variable nodes aren't URIs", NodeFactory.createVariable( N ).isURI() ); assertTrue( "variable nodes are variable", NodeFactory.createVariable( N ).isVariable() ); assertEquals( "variable nodes keep their name", N, NodeFactory.createVariable( N ).getName() ); assertEquals( "variable nodes keep their name", N + "x", NodeFactory.createVariable( N + "x" ).getName() ); }
@Test public void test_variable2() { Node x = NodeFactory.createVariable("x"); Node y = NodeFactory.createVariable("y"); int res = NodeUtils.compareRDFTerms(x, y); assertTrue("Variable nodes should sort by variable names", Expr.CMP_LESS == res); res = NodeUtils.compareRDFTerms(y, x); assertTrue("Variable nodes should sort by variable names", Expr.CMP_GREATER == res); }
@Test public void serialize_node_06() throws Exception { Node v = NodeFactory.createVariable("Foo"); Node v1 = roundTrip(v); // This will be a "Var". assertEquals(v, v1); }
public void testNodeVariableConstructor() { assertEquals( NodeFactory.createVariable( "hello" ), new Node_Variable( "hello" ) ); assertEquals( NodeFactory.createVariable( "world" ), new Node_Variable( "world" ) ); assertDiffer( NodeFactory.createVariable( "hello" ), new Node_Variable( "world" ) ); assertEquals( "myName", new Node_Variable( "myName" ).getName() ); }
public void testNodeVariableConstructor() { assertEquals( NodeFactory.createVariable( "hello" ), new Node_Variable( "hello" ) ); assertEquals( NodeFactory.createVariable( "world" ), new Node_Variable( "world" ) ); assertDiffer( NodeFactory.createVariable( "hello" ), new Node_Variable( "world" ) ); assertEquals( "myName", new Node_Variable( "myName" ).getName() ); }
@Test public void variableNode() { assertEquals("?tt", FmtUtils.stringForNode(NodeFactory.createVariable("tt"))) ; }
public void testEquals() { assertDiffer( "different variables", NodeFactory.createVariable( "xx" ), NodeFactory.createVariable( "yy" ) ); assertEquals( "same vars", NodeFactory.createVariable( "aa" ), NodeFactory.createVariable( "aa" ) ); assertEquals( "same URI", NodeFactory.createURI( U ), NodeFactory.createURI( U ) ); assertEquals( "same anon", NodeFactory.createBlankNode( A ), NodeFactory.createBlankNode( A ) ); assertEquals( "same literal", NodeFactory.createLiteral( L ), NodeFactory.createLiteral( L ) ); assertFalse( "distinct URIs", NodeFactory.createURI( U ) == NodeFactory.createURI( U ) ); assertFalse( "distinct hyphens", NodeFactory.createBlankNode( A ) == NodeFactory.createBlankNode( A ) ); assertFalse( "distinct literals", NodeFactory.createLiteral( L ) == NodeFactory.createLiteral( L ) ); assertFalse( "distinct vars", NodeFactory.createVariable( "aa" ) == NodeFactory.createVariable( "aa" ) ); }
public void testEquals() { assertDiffer( "different variables", NodeFactory.createVariable( "xx" ), NodeFactory.createVariable( "yy" ) ); assertEquals( "same vars", NodeFactory.createVariable( "aa" ), NodeFactory.createVariable( "aa" ) ); assertEquals( "same URI", NodeFactory.createURI( U ), NodeFactory.createURI( U ) ); assertEquals( "same anon", NodeFactory.createBlankNode( A ), NodeFactory.createBlankNode( A ) ); assertEquals( "same literal", NodeFactory.createLiteral( L ), NodeFactory.createLiteral( L ) ); assertFalse( "distinct URIs", NodeFactory.createURI( U ) == NodeFactory.createURI( U ) ); assertFalse( "distinct hyphens", NodeFactory.createBlankNode( A ) == NodeFactory.createBlankNode( A ) ); assertFalse( "distinct literals", NodeFactory.createLiteral( L ) == NodeFactory.createLiteral( L ) ); assertFalse( "distinct vars", NodeFactory.createVariable( "aa" ) == NodeFactory.createVariable( "aa" ) ); }
@Test public void test_variable4() { Node x = NodeFactory.createVariable("x"); Node y = NodeFactory.createURI("http://uri"); int res = NodeUtils.compareRDFTerms(x, y); assertTrue("Variable nodes should be less than URI nodes", Expr.CMP_LESS == res); res = NodeUtils.compareRDFTerms(y, x); assertTrue("Variable nodes should be less than URI nodes", Expr.CMP_GREATER == res); }
@Test public void test_variable5() { Node x = NodeFactory.createVariable("x"); Node y = NodeFactory.createLiteral("test"); int res = NodeUtils.compareRDFTerms(x, y); assertTrue("Variable nodes should be less than literal nodes", Expr.CMP_LESS == res); res = NodeUtils.compareRDFTerms(y, x); assertTrue("Variable nodes should be less than literal nodes", Expr.CMP_GREATER == res); } }
@Test public void test_variable3() { Node x = NodeFactory.createVariable("x"); Node y = NodeFactory.createBlankNode(); int res = NodeUtils.compareRDFTerms(x, y); assertTrue("Variable nodes should be less than blank nodes", Expr.CMP_LESS == res); res = NodeUtils.compareRDFTerms(y, x); assertTrue("Variable nodes should be less than blank nodes", Expr.CMP_GREATER == res); }
/** test that the label of a Node can be retrieved from that Node in a way appropriate to that Node. */ public void testLabels() { BlankNodeId id = BlankNodeId.create(); assertEquals( "get URI value", U, NodeFactory.createURI( U ).getURI() ); assertEquals( "get blank value", id, NodeFactory.createBlankNode( id ).getBlankNodeId() ); assertEquals( "get literal value", L, NodeFactory.createLiteral( L ).getLiteral() ); assertEquals( "get variable name", N, NodeFactory.createVariable( N ).getName() ); }
/** test that the label of a Node can be retrieved from that Node in a way appropriate to that Node. */ public void testLabels() { BlankNodeId id = BlankNodeId.create(); assertEquals( "get URI value", U, NodeFactory.createURI( U ).getURI() ); assertEquals( "get blank value", id, NodeFactory.createBlankNode( id ).getBlankNodeId() ); assertEquals( "get literal value", L, NodeFactory.createLiteral( L ).getLiteral() ); assertEquals( "get variable name", N, NodeFactory.createVariable( N ).getName() ); }