You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/03/17 18:33:50 UTC
svn commit: r1457493 - in /jena/trunk/jena-core/src:
main/java/com/hp/hpl/jena/graph/Node.java
test/java/com/hp/hpl/jena/graph/test/TestNode.java
test/java/com/hp/hpl/jena/graph/test/TestTriple.java
Author: andy
Date: Sun Mar 17 17:33:49 2013
New Revision: 1457493
URL: http://svn.apache.org/r1457493
Log:
Remove Node.cache(boolean) and Node.isCaching().
They were deprecated and already had the implementation removed.
Modified:
jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java?rev=1457493&r1=1457492&r2=1457493&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java Sun Mar 17 17:33:49 2013
@@ -286,18 +286,6 @@ public abstract class Node {
{ this.label = label; }
/**
- provided only for testing purposes. _cache(false)_ switches off caching and
- clears the cache. _cache(true)_ switches caching [back] on. This allows
- structural equality to be tested.
- */
- @Deprecated
- public static void cache( boolean wantCache ) {}
-
- @Deprecated
- public static boolean isCaching() { return false ;}
-
-
- /**
We object strongly to null labels: for example, they make .equals flaky.
*/
public static Node create( NodeMaker maker, Object label )
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java?rev=1457493&r1=1457492&r2=1457493&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java Sun Mar 17 17:33:49 2013
@@ -39,8 +39,6 @@ import com.hp.hpl.jena.vocabulary.VCARD
Exercise nodes. Make sure that the different node types do not overlap
and that the test predicates work properly on the different node kinds.
*/
-@SuppressWarnings("deprecation")
-// Node.useCache is deprecated.
public class TestNode extends GraphTestBase
{
public TestNode( String name )
@@ -117,42 +115,36 @@ public class TestNode extends GraphTestB
associated strings test equal.
*/
private Object [][] eqTestCases()
- {
- try
+ {
+ AnonId id = AnonId.create();
+ LiteralLabel L2 = LiteralLabelFactory.create( id.toString(), "", false );
+
+ LiteralLabel LLang1 = LiteralLabelFactory.create( "xyz", "en", null) ;
+ LiteralLabel LLang2 = LiteralLabelFactory.create( "xyz", "EN", null) ;
+
+ String U2 = id.toString();
+ String N2 = id.toString();
+ return new Object [][]
{
- Node.cache( false );
- AnonId id = AnonId.create();
- LiteralLabel L2 = LiteralLabelFactory.create( id.toString(), "", false );
-
- LiteralLabel LLang1 = LiteralLabelFactory.create( "xyz", "en", null) ;
- LiteralLabel LLang2 = LiteralLabelFactory.create( "xyz", "EN", null) ;
-
- String U2 = id.toString();
- String N2 = id.toString();
- return new Object [][]
- {
- { Node.ANY, "0" },
- { Node.createAnon( id ), "1" },
- { Node.createAnon(), "2" },
- { Node.createAnon( id ), "1" },
- { Node.createLiteral( L ), "3" },
-
- { Node.createLiteral( L2 ), "4" },
- { Node.createLiteral( L ), "3" },
- { Node.createURI( U ), "5" },
- { Node.createURI( U2 ), "6" },
- { Node.createURI( U ), "5" },
- { Node.createVariable( N ), "7" },
- { Node.createVariable( N2 ), "8" },
- { Node.createVariable( N ), "7" } ,
-
- { Node.createLiteral( LLang1 ), "9" },
- { Node.createLiteral( LLang2 ), "10" },
- };
- }
- finally
- { Node.cache( true ); }
- }
+ { Node.ANY, "0" },
+ { Node.createAnon( id ), "1" },
+ { Node.createAnon(), "2" },
+ { Node.createAnon( id ), "1" },
+ { Node.createLiteral( L ), "3" },
+
+ { Node.createLiteral( L2 ), "4" },
+ { Node.createLiteral( L ), "3" },
+ { Node.createURI( U ), "5" },
+ { Node.createURI( U2 ), "6" },
+ { Node.createURI( U ), "5" },
+ { Node.createVariable( N ), "7" },
+ { Node.createVariable( N2 ), "8" },
+ { Node.createVariable( N ), "7" } ,
+
+ { Node.createLiteral( LLang1 ), "9" },
+ { Node.createLiteral( LLang2 ), "10" },
+ };
+ }
public void testNodeEquals()
{
@@ -186,24 +178,18 @@ public class TestNode extends GraphTestB
}
public void testEquals()
- {
- try
- {
- Node.cache( false );
- assertDiffer( "different variables", Node.createVariable( "xx" ), Node.createVariable( "yy" ) );
- assertEquals( "same vars", Node.createVariable( "aa" ), Node.createVariable( "aa" ) );
- assertEquals( "same URI", Node.createURI( U ), Node.createURI( U ) );
- assertEquals( "same anon", Node.createAnon( A ), Node.createAnon( A ) );
- assertEquals( "same literal", Node.createLiteral( L ), Node.createLiteral( L ) );
- assertFalse( "distinct URIs", Node.createURI( U ) == Node.createURI( U ) );
- assertFalse( "distinct hyphens", Node.createAnon( A ) == Node.createAnon( A ) );
- assertFalse( "distinct literals", Node.createLiteral( L ) == Node.createLiteral( L ) );
- assertFalse( "distinct vars", Node.createVariable( "aa" ) == Node.createVariable( "aa" ) );
- }
- finally
- { Node.cache( true ); }
- }
-
+ {
+ assertDiffer( "different variables", Node.createVariable( "xx" ), Node.createVariable( "yy" ) );
+ assertEquals( "same vars", Node.createVariable( "aa" ), Node.createVariable( "aa" ) );
+ assertEquals( "same URI", Node.createURI( U ), Node.createURI( U ) );
+ assertEquals( "same anon", Node.createAnon( A ), Node.createAnon( A ) );
+ assertEquals( "same literal", Node.createLiteral( L ), Node.createLiteral( L ) );
+ assertFalse( "distinct URIs", Node.createURI( U ) == Node.createURI( U ) );
+ assertFalse( "distinct hyphens", Node.createAnon( A ) == Node.createAnon( A ) );
+ assertFalse( "distinct literals", Node.createLiteral( L ) == Node.createLiteral( L ) );
+ assertFalse( "distinct vars", Node.createVariable( "aa" ) == Node.createVariable( "aa" ) );
+ }
+
/**
test that the label of a Node can be retrieved from that Node in
a way appropriate to that Node.
@@ -275,18 +261,6 @@ public class TestNode extends GraphTestB
assertDiffer( Node_Variable.variable( "aaa" ), Node_Variable.variable( "yyy" ) );
}
- public void testCache()
- {
- if ( Node.isCaching() )
- {
- assertEquals( Node_Variable.variable( "xxx" ), Node_Variable.variable( "xxx" ) );
- assertTrue( "remembers URI", Node.createURI( U ) == Node.createURI( U ) );
- assertTrue( "remembers literal", Node.createLiteral( L ) == Node.createLiteral( L ) );
- assertTrue( "remembers hyphens", Node.createAnon( A ) == Node.createAnon( A ) );
- assertTrue( "remembers variables", Node.createVariable( N ) == Node.createVariable( N ) );
- assertFalse( "is not confused", Node.createVariable( N ) == Node.createURI( N ) );
- }
- }
/**
Test that the create method does sensible things on null and ""
*/
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java?rev=1457493&r1=1457492&r2=1457493&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java Sun Mar 17 17:33:49 2013
@@ -18,16 +18,15 @@
package com.hp.hpl.jena.graph.test;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.impl.LiteralLabel;
-import com.hp.hpl.jena.graph.impl.LiteralLabelFactory;
-import com.hp.hpl.jena.rdf.model.AnonId;
-import com.hp.hpl.jena.shared.*;
+import junit.framework.TestSuite ;
-import junit.framework.*;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.Triple ;
+import com.hp.hpl.jena.graph.impl.LiteralLabel ;
+import com.hp.hpl.jena.graph.impl.LiteralLabelFactory ;
+import com.hp.hpl.jena.rdf.model.AnonId ;
+import com.hp.hpl.jena.shared.PrefixMapping ;
-@SuppressWarnings("deprecation")
-//Node.useCache is deprecated.
public class TestTriple extends GraphTestBase
{
@@ -42,79 +41,72 @@ public class TestTriple extends GraphTes
private static final LiteralLabel L = LiteralLabelFactory.create( "ashes are burning", "en", false );
public void testTripleEquals() {
- try {
- Node.cache(false);
-
- // create some nodes to test
- AnonId id = AnonId.create();
- LiteralLabel L2 = LiteralLabelFactory.create(id.toString(), "", false);
- String U2 = id.toString();
- String N2 = id.toString();
-
- Node[] nodes = new Node[] {
- Node.ANY,
- Node.createAnon(id), Node.createAnon(),
- Node.createLiteral(L), Node.createLiteral(L2),
- Node.createURI(U), Node.createURI(U2),
- Node.createVariable(N), Node.createVariable(N2)
- };
-
- Triple[] triples =
- new Triple [nodes.length * nodes.length * nodes.length];
- for (int i=0; i<nodes.length; i++) {
- for (int j=0; j<nodes.length; j++) {
- for (int k=0; k<nodes.length; k++) {
- triples[i*nodes.length*nodes.length +
- j*nodes.length +
- k] = new Triple(nodes[i], nodes[j], nodes[k]);
- }
+ // create some nodes to test
+ AnonId id = AnonId.create();
+ LiteralLabel L2 = LiteralLabelFactory.create(id.toString(), "", false);
+ String U2 = id.toString();
+ String N2 = id.toString();
+
+ Node[] nodes = new Node[] {
+ Node.ANY,
+ Node.createAnon(id), Node.createAnon(),
+ Node.createLiteral(L), Node.createLiteral(L2),
+ Node.createURI(U), Node.createURI(U2),
+ Node.createVariable(N), Node.createVariable(N2)
+ };
+
+ Triple[] triples =
+ new Triple [nodes.length * nodes.length * nodes.length];
+ for (int i=0; i<nodes.length; i++) {
+ for (int j=0; j<nodes.length; j++) {
+ for (int k=0; k<nodes.length; k++) {
+ triples[i*nodes.length*nodes.length +
+ j*nodes.length +
+ k] = new Triple(nodes[i], nodes[j], nodes[k]);
}
}
-
- // set up the expected results matrix
- // a expected[i][j] is true if triples[i] equals triples[j]
- // triples are expected to be equals if there components are equal
- boolean[][] expected = new boolean[triples.length][triples.length];
- for (int i1=0; i1<nodes.length; i1++) {
- for (int j1=0; j1<nodes.length; j1++) {
- for (int k1=0; k1<nodes.length; k1++) {
- for (int i2=0; i2<nodes.length; i2++) {
- for (int j2=0; j2<nodes.length; j2++) {
- for (int k2=0; k2<nodes.length; k2++) {
- expected[i1*nodes.length*nodes.length +
- j1*nodes.length +
- k1]
- [i2*nodes.length*nodes.length +
- j2*nodes.length +
- k2] =
- nodes[i1].equals(nodes[i2]) &&
- nodes[j1].equals(nodes[j2]) &&
- nodes[k1].equals(nodes[k2]);
- }
+ }
+
+ // set up the expected results matrix
+ // a expected[i][j] is true if triples[i] equals triples[j]
+ // triples are expected to be equals if there components are equal
+ boolean[][] expected = new boolean[triples.length][triples.length];
+ for (int i1=0; i1<nodes.length; i1++) {
+ for (int j1=0; j1<nodes.length; j1++) {
+ for (int k1=0; k1<nodes.length; k1++) {
+ for (int i2=0; i2<nodes.length; i2++) {
+ for (int j2=0; j2<nodes.length; j2++) {
+ for (int k2=0; k2<nodes.length; k2++) {
+ expected[i1*nodes.length*nodes.length +
+ j1*nodes.length +
+ k1]
+ [i2*nodes.length*nodes.length +
+ j2*nodes.length +
+ k2] =
+ nodes[i1].equals(nodes[i2]) &&
+ nodes[j1].equals(nodes[j2]) &&
+ nodes[k1].equals(nodes[k2]);
}
}
}
}
}
+ }
- assertEquals("triple, null", triples[0].equals(null), false);
- assertDiffer("triple, string", triples[0], "string");
-
- // now compare each triple with each other triple
- for (int i=0; i<triples.length; i++) {
- for (int j=0; j<triples.length; j++) {
- if (expected[i][j]) {
- assertEquals("triples " + i + ", " + j ,
- triples[i], triples[j]);
- } else {
- assertDiffer("triples" + i + ", " + j,
- triples[i], triples[j]);
- }
+ assertEquals("triple, null", triples[0].equals(null), false);
+ assertDiffer("triple, string", triples[0], "string");
+
+ // now compare each triple with each other triple
+ for (int i=0; i<triples.length; i++) {
+ for (int j=0; j<triples.length; j++) {
+ if (expected[i][j]) {
+ assertEquals("triples " + i + ", " + j ,
+ triples[i], triples[j]);
+ } else {
+ assertDiffer("triples" + i + ", " + j,
+ triples[i], triples[j]);
}
}
-
- } finally {
- Node.cache(true);
}
}