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 2017/01/01 13:28:28 UTC
[1/3] jena git commit: Deprecate some methods of Capabilities
Repository: jena
Updated Branches:
refs/heads/master 47d216f52 -> 0becdc7e1
Deprecate some methods of Capabilities
addAllowed( everyTriple )
deleteAllowed( everyTriple )
iteratorRemoveAllowed()
canBeEmpty()
findContractSafe()
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/cd19f7bb
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/cd19f7bb
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/cd19f7bb
Branch: refs/heads/master
Commit: cd19f7bbba9ddc37205650a0e8a35925572191c2
Parents: ff92139
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 23 22:54:15 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Dec 24 17:26:18 2016 +0000
----------------------------------------------------------------------
.../org/apache/jena/graph/Capabilities.java | 29 ++-
.../jena/rdfxml/xmloutput/impl/Abbreviated.java | 13 -
.../apache/jena/shared/RandomOrderGraph.java | 16 +-
.../apache/jena/graph/GraphContractTest.java | 238 ++++++-------------
.../jena/graph/test/AbstractTestGraph.java | 22 +-
.../jena/graph/test/TestCapabilities.java | 6 -
.../jena/rdfxml/xmloutput/PrettyWriterTest.java | 61 -----
.../reasoner/rulesys/test/TestCapabilities.java | 72 ------
.../jena/reasoner/rulesys/test/TestPackage.java | 1 -
.../apache/jena/reasoner/test/TestInfGraph.java | 9 -
.../permissions/graph/SecuredCapabilities.java | 13 +-
.../jena/permissions/impl/SecuredItemImpl.java | 10 +-
.../model/SecuredModelDetailTest.java | 13 +-
.../src/test/resources/log4j.properties | 7 +-
14 files changed, 139 insertions(+), 371 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/main/java/org/apache/jena/graph/Capabilities.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/Capabilities.java b/jena-core/src/main/java/org/apache/jena/graph/Capabilities.java
index d9a52bb..d79d3a1 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/Capabilities.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/Capabilities.java
@@ -18,6 +18,8 @@
package org.apache.jena.graph;
+import org.apache.jena.mem.GraphMem;
+
/**
Interface for expressing capabilities.
*/
@@ -35,45 +37,56 @@ public interface Capabilities
boolean addAllowed();
/**
+ Answer true iff Graph::delete() can be used to remove at least some triples
+ from the graph.
+ */
+ boolean deleteAllowed();
+
+ /**
Answer true if Graph::add() can be used to add at least some triples to the
graph. If everyTriple is true, answer true iff *any* triple can be added (ie the
graph places no special restrictions on triples).
+ @deprecated To be removed
*/
+ @Deprecated
boolean addAllowed( boolean everyTriple );
/**
- Answer true iff Graph::delete() can be used to remove at least some triples
- from the graph.
- */
- boolean deleteAllowed();
-
- /**
Answer true if Graph::delete() can be used to remove at least some triples
from the graph. If everyTriple is true, any such triple may be removed.
+ @deprecated To be removed
*/
+ @Deprecated
boolean deleteAllowed( boolean everyTriple );
/**
Answer true iff the iterators returned from <b>find</b> support the .remove()
operation.
+ @deprecated To be removed
*/
+ @Deprecated
boolean iteratorRemoveAllowed();
/**
Answer true iff the graph can be completely empty.
+ @deprecated To be removed
*/
+ @Deprecated
boolean canBeEmpty();
/**
Answer true if the find() contract on the associated graph is "safe", ie,
can be used safely by the pretty-printer (we'll tighten up that definition).
+ @deprecated To be removed
*/
+ @Deprecated
boolean findContractSafe();
/**
Answer true iff this graph compares literals for equality by value
- rather than by lexical form (the memory-based graphs do;
- TDB model do mostly (because of canonicalization), SDB models don't).
+ in find() operations, rather just applying RDFTerm equality.
+ Only applies to {@link GraphMem}.
+ TDB models have this effect because of canonicalization for certain datatypes and ranges, SDB models don't.
*/
boolean handlesLiteralTyping();
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Abbreviated.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Abbreviated.java b/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Abbreviated.java
index 8a3de2f..a9aec24 100644
--- a/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Abbreviated.java
+++ b/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Abbreviated.java
@@ -19,7 +19,6 @@
package org.apache.jena.rdfxml.xmloutput.impl;
import java.io.PrintWriter;
-import java.io.Writer;
import org.apache.jena.rdf.model.Model ;
import org.apache.jena.rdf.model.RDFErrorHandler ;
@@ -114,18 +113,6 @@ public class Abbreviated extends BaseXMLWriter implements RDFErrorHandler {
}
@Override
- synchronized public void write(Model baseModel, Writer out, String base)
- {
- if (baseModel.getGraph().getCapabilities().findContractSafe() == false)
- {
- logger.warn( "Workaround for bugs 803804 and 858163: using RDF/XML (not RDF/XML-ABBREV) writer for unsafe graph " + baseModel.getGraph().getClass() );
- baseModel.write( out, "RDF/XML", base );
- }
- else
- super.write( baseModel, out, base );
- }
-
- @Override
protected void writeBody(
Model model,
PrintWriter pw,
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/main/java/org/apache/jena/shared/RandomOrderGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/shared/RandomOrderGraph.java b/jena-core/src/main/java/org/apache/jena/shared/RandomOrderGraph.java
index 4059b8f..b277916 100644
--- a/jena-core/src/main/java/org/apache/jena/shared/RandomOrderGraph.java
+++ b/jena-core/src/main/java/org/apache/jena/shared/RandomOrderGraph.java
@@ -81,26 +81,30 @@ public class RandomOrderGraph extends WrappedGraph {
return parentCapabilities.addAllowed();
}
- @Override
+ @Override
+ public boolean deleteAllowed() {
+ return parentCapabilities.deleteAllowed();
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
public boolean addAllowed(boolean everyTriple) {
return parentCapabilities.addAllowed(everyTriple);
}
- @Override
- public boolean deleteAllowed() {
- return parentCapabilities.deleteAllowed();
- }
-
+ @SuppressWarnings("deprecation")
@Override
public boolean deleteAllowed(boolean everyTriple) {
return parentCapabilities.deleteAllowed(everyTriple);
}
+ @SuppressWarnings("deprecation")
@Override
public boolean canBeEmpty() {
return parentCapabilities.canBeEmpty();
}
+ @SuppressWarnings("deprecation")
@Override
public boolean findContractSafe() {
return parentCapabilities.findContractSafe();
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index 6f02750..9dfaae8 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -832,25 +832,10 @@ public class GraphContractTest<T extends Graph> {
fail("addAllowed() threw Exception: " + e.toString());
}
try {
- c.addAllowed(true);
- } catch (Exception e) {
- fail("addAllowed( boolean ) threw Exception: " + e.toString());
- }
- try {
c.deleteAllowed();
} catch (Exception e) {
fail("deleteAllowed() threw Exception: " + e.toString());
}
- try {
- c.deleteAllowed(true);
- } catch (Exception e) {
- fail("deleteAllowed( boolean ) threw Exception: " + e.toString());
- }
- try {
- c.canBeEmpty();
- } catch (Exception e) {
- fail("canBeEmpty() threw Exception: " + e.toString());
- }
}
@ContractTest
@@ -1042,9 +1027,6 @@ public class GraphContractTest<T extends Graph> {
assertFalse(g.contains(NodeCreateUtils.createTriple(findCheck)));
} catch (UnsupportedOperationException e) {
it.close();
- assertFalse(
- "delete failed but capailities indicates it should work", g
- .getCapabilities().iteratorRemoveAllowed());
}
}
@@ -1103,59 +1085,6 @@ public class GraphContractTest<T extends Graph> {
it.close();
}
- // public void testStuff()
- // {
- // // testAGraph( "StoreMem", new GraphMem() );
- // // testAGraph( "StoreMemBySubject", new GraphMem() );
- // // String [] empty = new String [] {};
- // // Graph g = graphWith( "x R y; p S q; a T b" );
- // // /* */
- // // assertContainsAll( "simple graph", g, "x R y; p S q; a T b" );
- // // graphAdd( g,
- // "spindizzies lift cities; Diracs communicate instantaneously" );
- // // g.delete( triple( "x R y" ) );
- // // g.delete( triple( "a T b" ) );
- // // assertContainsAll( "modified simple graph", g,
- // "p S q; spindizzies lift cities; Diracs communicate instantaneously" );
- // // assertOmitsAll( "modified simple graph", g, "x R y; a T b" );
- // }
-
- // /**
- // Test that Graphs have transaction support methods, and that if they fail
- // on some g they fail because they do not support the operation.
- // */
- // @ContractTest
- // public void testHasTransactions()
- // {
- // Graph g = producer.newInstance();
- // TransactionHandler th = g.getTransactionHandler();
- // th.transactionsSupported();
- // try { th.begin(); } catch (UnsupportedOperationException x) {}
- // try { th.abort(); } catch (UnsupportedOperationException x) {}
- // try { th.begin(); th.commit(); } catch (UnsupportedOperationException x)
- // {}
- // /* */
- // Command cmd = new Command()
- // { @Override
- // public Object execute() { return null; } };
- // try { th.executeInTransaction( cmd ); }
- // catch (UnsupportedOperationException x) {}
- // }
- //
- // @ContractTest
- // public void testExecuteInTransactionCatchesThrowable()
- // {Graph g = producer.newInstance();
- // TransactionHandler th = g.getTransactionHandler();
- // if (th.transactionsSupported())
- // {
- // Command cmd = new Command()
- // { @Override
- // public Object execute() throws Error { throw new Error(); } };
- // try { th.executeInTransaction( cmd ); }
- // catch (JenaException x) {}
- // }
- // }
-
@ContractTest
public void testAddWithReificationPreamble() {
Graph g = producer.newInstance();
@@ -1183,29 +1112,27 @@ public class GraphContractTest<T extends Graph> {
@ContractTest
public void failingTestDoubleRemoveAll() {
- final Graph g = producer.newInstance();
- if (g.getCapabilities().iteratorRemoveAllowed()) {
- try {
- graphAddTxn(g, "c S d; e:ff GGG hhhh; _i J 27; Ell Em 'en'");
- Iterator<Triple> it = new TrackingTripleIterator(
- g.find(Triple.ANY)) {
- @Override
- public void remove() {
- super.remove(); // removes current
- g.delete(current); // no-op.
- }
- };
- while (it.hasNext()) {
- it.next();
- it.remove();
- }
- assertTrue(g.isEmpty());
- } catch (UnsupportedOperationException e) {
- fail("Error attempting to remove nodes " + e.getMessage());
- }
- }
+ final Graph g = producer.newInstance();
+ try {
+ graphAddTxn(g, "c S d; e:ff GGG hhhh; _i J 27; Ell Em 'en'");
+ Iterator<Triple> it = new TrackingTripleIterator(g.find(Triple.ANY)) {
+ @Override
+ public void remove() {
+ super.remove(); // removes current
+ g.delete(current); // no-op.
+ }
+ };
+ while (it.hasNext()) {
+ it.next();
+ it.remove();
+ }
+ assertTrue(g.isEmpty());
+ } catch (UnsupportedOperationException e) {
+ // No Iterator.remove
+ }
}
+
/**
* Test cases for RemoveSPO(); each entry is a triple (add, remove, result).
* <ul>
@@ -1374,26 +1301,24 @@ public class GraphContractTest<T extends Graph> {
*/
@ContractTest
public void testIterator_Remove() {
- Graph graph = graphWith(producer.newInstance(), "a R b; b S e");
- if (graph.getCapabilities().iteratorRemoveAllowed()) {
- try {
- graph.getEventManager().register(GL);
- txnBegin(graph);
-
- Triple toRemove = triple("a R b");
- ExtendedIterator<Triple> rtr = graph.find(toRemove);
- assertTrue("ensure a(t least) one triple", rtr.hasNext());
- rtr.next();
- rtr.remove();
- rtr.close();
- GL.assertHas("delete", graph, toRemove);
- } catch (UnsupportedOperationException e) {
- fail("Error attempting to remove nodes " + e.getMessage());
- }
+ Graph graph = graphWith(producer.newInstance(), "a R b; b S e");
+ try {
+ graph.getEventManager().register(GL);
+ txnBegin(graph);
- }
+ Triple toRemove = triple("a R b");
+ ExtendedIterator<Triple> rtr = graph.find(toRemove);
+ assertTrue("ensure a(t least) one triple", rtr.hasNext());
+ rtr.next();
+ rtr.remove();
+ rtr.close();
+ GL.assertHas("delete", graph, toRemove);
+ } catch (UnsupportedOperationException e) {
+ // No Iterator.remove
+ }
}
+
@ContractTest
public void testTransactionHandler_Commit() {
Graph g = producer.newInstance();
@@ -1563,16 +1488,14 @@ public class GraphContractTest<T extends Graph> {
@ContractTest
public void testSizeAfterRemove() {
- Graph g = graphWith(producer.newInstance(), "x p y");
- if (g.getCapabilities().iteratorRemoveAllowed()) {
- try {
- ExtendedIterator<Triple> it = g.find(triple("x ?? ??"));
- it.removeNext();
- assertEquals(0, g.size());
- } catch (UnsupportedOperationException e) {
- fail("Error attempting to remove nodes " + e.getMessage());
- }
- }
+ Graph g = graphWith(producer.newInstance(), "x p y");
+ try {
+ ExtendedIterator<Triple> it = g.find(triple("x ?? ??"));
+ it.removeNext();
+ assertEquals(0, g.size());
+ } catch (UnsupportedOperationException e) {
+ // No Iterator.remove
+ }
}
@ContractTest
@@ -1664,66 +1587,57 @@ public class GraphContractTest<T extends Graph> {
@ContractTest
public void testBrokenIndexes() {
- Graph g = graphWith(producer.newInstance(), "x R y; x S z");
- if (g.getCapabilities().iteratorRemoveAllowed()) {
- try {
- ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY,
- Node.ANY);
- it.removeNext();
- it.removeNext();
- assertFalse(g.find(node("x"), Node.ANY, Node.ANY).hasNext());
- assertFalse(g.find(Node.ANY, node("R"), Node.ANY).hasNext());
- assertFalse(g.find(Node.ANY, Node.ANY, node("y")).hasNext());
- } catch (UnsupportedOperationException e) {
- fail("Error attempting to remove nodes " + e.getMessage());
- }
- }
+ Graph g = graphWith(producer.newInstance(), "x R y; x S z");
+ try {
+ ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY,
+ Node.ANY);
+ it.removeNext();
+ it.removeNext();
+ assertFalse(g.find(node("x"), Node.ANY, Node.ANY).hasNext());
+ assertFalse(g.find(Node.ANY, node("R"), Node.ANY).hasNext());
+ assertFalse(g.find(Node.ANY, Node.ANY, node("y")).hasNext());
+ } catch (UnsupportedOperationException e) {
+ // No Iterator.remove
+ }
}
@ContractTest
public void testBrokenSubject() {
Graph g = graphWith(producer.newInstance(), "x brokenSubject y");
- if (g.getCapabilities().iteratorRemoveAllowed()) {
- try {
- ExtendedIterator<Triple> it = g.find(node("x"), Node.ANY,
- Node.ANY);
- it.removeNext();
- assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
- } catch (UnsupportedOperationException e) {
- fail("Error attempting to remove nodes " + e.getMessage());
- }
+ try {
+ ExtendedIterator<Triple> it = g.find(node("x"), Node.ANY, Node.ANY);
+ it.removeNext();
+ assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+ } catch (UnsupportedOperationException e) {
+ // No Iterator.remove
}
}
@ContractTest
public void testBrokenPredicate() {
Graph g = graphWith(producer.newInstance(), "x brokenPredicate y");
- if (g.getCapabilities().iteratorRemoveAllowed()) {
- try {
- ExtendedIterator<Triple> it = g.find(Node.ANY,
- node("brokenPredicate"), Node.ANY);
- it.removeNext();
- assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
- } catch (UnsupportedOperationException e) {
- fail("Error attempting to remove nodes " + e.getMessage());
- }
+ try {
+ ExtendedIterator<Triple> it = g.find(Node.ANY, node("brokenPredicate"), Node.ANY);
+ it.removeNext();
+ assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+ } catch (UnsupportedOperationException e) {
+ // No Iterator.remove
}
}
@ContractTest
public void testBrokenObject() {
- Graph g = graphWith(producer.newInstance(), "x brokenObject y");
- if (g.getCapabilities().iteratorRemoveAllowed()) {
- try {
- ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY,
- node("y"));
- it.removeNext();
- assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+ Graph g = graphWith(producer.newInstance(), "x brokenObject y");
+
+ try {
+ ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY, node("y"));
+ it.removeNext();
+ assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+
+ } catch (UnsupportedOperationException e) {
+ // No Iterator.remove
+ }
- } catch (UnsupportedOperationException e) {
- fail("Error attempting to remove nodes " + e.getMessage());
- }
- }
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/test/java/org/apache/jena/graph/test/AbstractTestGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/test/AbstractTestGraph.java b/jena-core/src/test/java/org/apache/jena/graph/test/AbstractTestGraph.java
index 3e3612e..912a257 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/test/AbstractTestGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/test/AbstractTestGraph.java
@@ -388,10 +388,9 @@ public abstract class AbstractTestGraph extends GraphTestBase
assertFalse( g.contains( NodeCreateUtils.createTriple( findCheck ) ) );
}
catch (UnsupportedOperationException e) {
+ // No iterator remove.
it.close();
- assertFalse( g.getCapabilities().iteratorRemoveAllowed() );
}
- it.close();
}
public void testHasCapabilities()
@@ -400,10 +399,7 @@ public abstract class AbstractTestGraph extends GraphTestBase
Capabilities c = g.getCapabilities();
boolean sa = c.sizeAccurate();
boolean aaSome = c.addAllowed();
- boolean aaAll = c.addAllowed( true );
boolean daSome = c.deleteAllowed();
- boolean daAll = c.deleteAllowed( true );
- boolean cbe = c.canBeEmpty();
}
public void testFind()
@@ -522,15 +518,17 @@ public abstract class AbstractTestGraph extends GraphTestBase
public void testEventDeleteByFind()
{
Graph g = getAndRegister( L );
- if (g.getCapabilities().iteratorRemoveAllowed())
- {
- Triple toRemove = triple( "remove this triple" );
- g.add( toRemove );
+ Triple toRemove = triple( "remove this triple" );
+ g.add( toRemove );
+ try {
ExtendedIterator<Triple> rtr = g.find( toRemove );
assertTrue( "ensure a(t least) one triple", rtr.hasNext() );
rtr.next(); rtr.remove(); rtr.close();
L.assertHas( new Object[] { "add", g, toRemove, "delete", g, toRemove} );
+ } catch (UnsupportedOperationException ex) {
+ // No iterator remove
}
+
}
public void testTwoListeners()
@@ -823,8 +821,8 @@ public abstract class AbstractTestGraph extends GraphTestBase
public void failingTestDoubleRemoveAll() {
final Graph g = getGraph();
- if (g.getCapabilities().iteratorRemoveAllowed() ) {
- graphAdd(g,"c S d; e:ff GGG hhhh; _i J 27; Ell Em 'en'" );
+ graphAdd(g,"c S d; e:ff GGG hhhh; _i J 27; Ell Em 'en'" );
+ try {
Iterator<Triple> it = new TrackingTripleIterator(g.find(Triple.ANY)){
@Override
public void remove() {
@@ -837,6 +835,8 @@ public abstract class AbstractTestGraph extends GraphTestBase
it.remove();
}
assertTrue( g.isEmpty() );
+ } catch (UnsupportedOperationException ex) {
+ // Iterator.remove not supported.
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/test/java/org/apache/jena/graph/test/TestCapabilities.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/test/TestCapabilities.java b/jena-core/src/test/java/org/apache/jena/graph/test/TestCapabilities.java
index 2e28ba9..4b8de34 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/test/TestCapabilities.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/test/TestCapabilities.java
@@ -90,13 +90,7 @@ public class TestCapabilities extends GraphTestBase
Capabilities c = new AllFalse();
boolean b = false;
b = c.addAllowed();
- b = c.addAllowed( true );
- b = c.canBeEmpty();
b = c.deleteAllowed();
- b = c.deleteAllowed( false );
b = c.sizeAccurate();
- b = c.iteratorRemoveAllowed();
- b = c.findContractSafe();
- b = c.handlesLiteralTyping();
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/PrettyWriterTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/PrettyWriterTest.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/PrettyWriterTest.java
index 97d890d..cbf194d 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/PrettyWriterTest.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/PrettyWriterTest.java
@@ -20,20 +20,12 @@
///////////////
package org.apache.jena.rdfxml.xmloutput;
-// Imports
-///////////////
-
-import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.OutputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.regex.Pattern;
-import org.apache.jena.ontology.OntModel ;
-import org.apache.jena.ontology.OntModelSpec ;
import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
import org.apache.jena.rdf.model.test.ModelTestBase ;
public class PrettyWriterTest extends ModelTestBase {
@@ -116,57 +108,4 @@ public class PrettyWriterTest extends ModelTestBase {
"file:testing/abbreviated/container.rdf",
"<rdf:li.*<rdf:li.*<rdf:li.*<rdf:li");
}
- public void test803804() {
- String sourceT =
- "<rdf:RDF "
- + " xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'"
- + " xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'"
- + " xmlns:owl=\"http://www.w3.org/2002/07/owl#\">"
- + " <owl:ObjectProperty rdf:about="
- + "'http://example.org/foo#p'>"
- + " </owl:ObjectProperty>"
- + "</rdf:RDF>";
-
- OntModel m =
- ModelFactory.createOntologyModel(
- OntModelSpec.OWL_MEM_RULE_INF,
- null);
- m.read(
- new ByteArrayInputStream(sourceT.getBytes()),
- "http://example.org/foo");
-
- Model m0 = ModelFactory.createModelForGraph(m.getGraph());
- /*
- Set copyOfm0 = new HashSet();
- Set blankNodes = new HashSet();
- Iterator it = m0.listStatements();
- while (it.hasNext()) {
- Statement st = (Statement)it.next();
- copyOfm0.add(st);
- Resource subj = st.getSubject();
- if (subj.isAnon())
- blankNodes.add(subj);
- }
-
- it = blankNodes.iterator();
- while (it.hasNext()) {
- Resource b = (Resource)it.next();
- Statement st = m0.createStatement(b,OWL.sameAs,b);
- // assertEquals(m0.contains(st),copyOfm0.contains(st));
- }
- */
- XMLOutputTestBase.blockLogger();
- try {
- m0.write(new OutputStream() {
- @Override
- public void write(int b) {
- }
- }, "RDF/XML-ABBREV");
-
- } finally {
- // This will need to change when the bug is finally fixed.
-
- assertTrue(XMLOutputTestBase.unblockLogger());
- }
- }
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestCapabilities.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestCapabilities.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestCapabilities.java
deleted file mode 100644
index 0deeab8..0000000
--- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestCapabilities.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.reasoner.rulesys.test;
-
-import junit.framework.TestCase ;
-import junit.framework.TestSuite ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.reasoner.InfGraph ;
-import org.apache.jena.reasoner.Reasoner ;
-import org.apache.jena.reasoner.ReasonerRegistry ;
-
-/**
- * Test harness for checking that graphs generated by the main
- * reasoners report the correct capabilities to things like the RDF writer.
- */
-
-public class TestCapabilities extends TestCase {
-
- /**
- * Boilerplate for junit
- */
- public TestCapabilities( String name ) {
- super( name );
- }
-
- /**
- * Boilerplate for junit.
- * This is its own test suite
- */
- public static TestSuite suite() {
- return new TestSuite( TestCapabilities.class );
- }
-
- /**
- * Test capability returns.
- */
- public void testCapabilityValues() {
- Object[][] testSpec = new Object[][] {
- {ReasonerRegistry.getOWLMicroReasoner(), Boolean.TRUE},
- {ReasonerRegistry.getOWLMiniReasoner(), Boolean.TRUE},
- {ReasonerRegistry.getOWLReasoner(), Boolean.FALSE},
-// {ReasonerRegistry.getDIGReasoner(), Boolean.FALSE},
- {ReasonerRegistry.getRDFSReasoner(), Boolean.TRUE},
- {ReasonerRegistry.getRDFSSimpleReasoner(), Boolean.TRUE},
- };
- Model data = ModelFactory.createDefaultModel();
- for ( Object[] test : testSpec )
- {
- Reasoner r = (Reasoner) test[0];
- Boolean safe = (Boolean) test[1];
- InfGraph ig = r.bind( data.getGraph() );
- assertEquals( r.toString(), safe.booleanValue(), ig.getCapabilities().findContractSafe() );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestPackage.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestPackage.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestPackage.java
index fe3518c..ad8e26a 100755
--- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestPackage.java
+++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestPackage.java
@@ -58,7 +58,6 @@ public class TestPackage extends TestSuite {
addTest( "OWLRuleUnitTests", OWLUnitTest.suite() );
addTest( "TestBugs", TestBugs.suite() );
addTest( "TestOWLMisc", TestOWLMisc.suite() );
- addTest( "TestCapabilities", TestCapabilities.suite() );
addTest( "TestComparatorBuiltins", TestComparatorBuiltins.suite() );
addTest( "FRuleEngineIFactoryTest", FRuleEngineIFactoryTest.suite() );
//addTest ("TestRuleLoader", TestRuleLoader.suite() );
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java
index 22eca40..7641331 100644
--- a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java
@@ -52,13 +52,4 @@ public class TestInfGraph extends AbstractTestGraph
InfGraph ig = getInfGraph();
assertSame( ig.getPrefixMapping(), ig.getRawGraph().getPrefixMapping() );
}
-
- /**
- Placeholder. Will need revision later.
- */
- public void testInfCapabilities()
- {
- // The default Ontology inference model is RDFS which is safe
- assertTrue( getInfGraph().getCapabilities().findContractSafe() );
- }
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredCapabilities.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredCapabilities.java b/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredCapabilities.java
index 67cf047..d9ca28f 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredCapabilities.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredCapabilities.java
@@ -69,7 +69,8 @@ public class SecuredCapabilities implements Capabilities
* @sec.graph Update
* @sec.triple Create (if everyTriple is true)
*/
- @Override
+ @SuppressWarnings("deprecation")
+ @Override
public boolean addAllowed( final boolean everyTriple )
{
Object principal = securityEvaluator.getPrincipal();
@@ -85,7 +86,8 @@ public class SecuredCapabilities implements Capabilities
return retval;
}
- @Override
+ @SuppressWarnings("deprecation")
+ @Override
public boolean canBeEmpty()
{
return capabilities.canBeEmpty();
@@ -105,6 +107,7 @@ public class SecuredCapabilities implements Capabilities
* @sec.graph Update
* @sec.triple Delete (if everyTriple is true)
*/
+ @SuppressWarnings("deprecation")
@Override
public boolean deleteAllowed( final boolean everyTriple )
{
@@ -121,7 +124,8 @@ public class SecuredCapabilities implements Capabilities
return retval;
}
- @Override
+ @SuppressWarnings("deprecation")
+ @Override
public boolean findContractSafe()
{
return capabilities.findContractSafe();
@@ -136,7 +140,8 @@ public class SecuredCapabilities implements Capabilities
/**
* @sec.graph Update
*/
- @Override
+ @SuppressWarnings("deprecation")
+ @Override
public boolean iteratorRemoveAllowed()
{
return securityEvaluator.evaluate(securityEvaluator.getPrincipal(), Action.Update, graphIRI)
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java b/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java
index 182d30e..fd9a03e 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java
@@ -52,7 +52,7 @@ public abstract class SecuredItemImpl implements SecuredItem {
// a key for the secured item.
private class CacheKey implements Comparable<CacheKey> {
private final Action action;
- private final Node modelNode;
+ private final Node mNode;
private final Triple from;
private final Triple to;
private Integer hashCode;
@@ -69,7 +69,7 @@ public abstract class SecuredItemImpl implements SecuredItem {
public CacheKey(final Action action, final Node modelNode,
final Triple to, final Triple from) {
this.action = action;
- this.modelNode = modelNode;
+ this.mNode = modelNode;
this.to = to;
this.from = from;
}
@@ -111,8 +111,8 @@ public abstract class SecuredItemImpl implements SecuredItem {
public int compareTo(final CacheKey other) {
int retval = this.action.compareTo(other.action);
if (retval == Expr.CMP_EQUAL) {
- retval = NodeUtils.compareRDFTerms(this.modelNode,
- other.modelNode);
+ retval = NodeUtils.compareRDFTerms(this.mNode,
+ other.mNode);
}
if (retval == Expr.CMP_EQUAL) {
retval = compare(this.to, other.to);
@@ -135,7 +135,7 @@ public abstract class SecuredItemImpl implements SecuredItem {
public int hashCode() {
if (hashCode == null) {
hashCode = new HashCodeBuilder().append(action)
- .append(modelNode).append(from).append(to).toHashCode();
+ .append(mNode).append(from).append(to).toHashCode();
}
return hashCode;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
index eef28b9..5840969 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
@@ -43,10 +43,8 @@ public class SecuredModelDetailTest {
private Model baseModel;
private SecuredModel securedModel;
private DetailEvaluator secEval;
- private Property pTo = ResourceFactory
- .createProperty("http://example.com/to");
- private Property pFrom = ResourceFactory
- .createProperty("http://example.com/from");
+ private static Property pTo = ResourceFactory.createProperty("http://example.com/to");
+ private static Property pFrom = ResourceFactory.createProperty("http://example.com/from");
@Before
public void setup() {
@@ -273,12 +271,7 @@ public class SecuredModelDetailTest {
private Principal principal;
private Model model;
- private RDFNode msgType = ResourceFactory
- .createResource("http://example.com/msg");
- private Property pTo = ResourceFactory
- .createProperty("http://example.com/to");
- private Property pFrom = ResourceFactory
- .createProperty("http://example.com/from");
+ private RDFNode msgType = ResourceFactory.createResource("http://example.com/msg");
/**
*
http://git-wip-us.apache.org/repos/asf/jena/blob/cd19f7bb/jena-permissions/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/resources/log4j.properties b/jena-permissions/src/test/resources/log4j.properties
index f3d6f5e..84ecb9f 100644
--- a/jena-permissions/src/test/resources/log4j.properties
+++ b/jena-permissions/src/test/resources/log4j.properties
@@ -1,3 +1,4 @@
+# Testing
log4j.rootLogger=INFO, stdlog
log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
@@ -10,6 +11,6 @@ log4j.logger.org.apache.jena.arq.info=INFO
log4j.logger.org.apache.jena.arq.exec=INFO
# Everything else in Jena
-log4j.logger.org.apache.jena=WARN
-log4j.logger.org.apache.jena=WARN
-log4j.logger.org.apache.jena.riot=INFO
+# Off for permissions testing
+log4j.logger.org.apache.jena=ERROR
+log4j.logger.org.apache.jena.riot=ERROR
[3/3] jena git commit: JENA-1270: Merge commit 'refs/pull/200/head'
of github.com:apache/jena
Posted by an...@apache.org.
JENA-1270: Merge commit 'refs/pull/200/head' of github.com:apache/jena
This closes #200.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0becdc7e
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0becdc7e
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0becdc7e
Branch: refs/heads/master
Commit: 0becdc7e18cb16b81d854d56cb3ad481ba125d0f
Parents: 47d216f f547cc2
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Jan 1 13:27:42 2017 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Jan 1 13:27:42 2017 +0000
----------------------------------------------------------------------
.../org/apache/jena/graph/Capabilities.java | 29 +-
.../jena/rdfxml/xmloutput/impl/Abbreviated.java | 13 -
.../apache/jena/shared/RandomOrderGraph.java | 16 +-
.../apache/jena/graph/GraphContractTest.java | 270 ++++++-------------
.../jena/graph/test/AbstractTestGraph.java | 22 +-
.../jena/graph/test/TestCapabilities.java | 6 -
.../jena/rdfxml/xmloutput/PrettyWriterTest.java | 61 -----
.../reasoner/rulesys/test/TestCapabilities.java | 72 -----
.../jena/reasoner/rulesys/test/TestPackage.java | 1 -
.../apache/jena/reasoner/test/TestInfGraph.java | 9 -
.../permissions/graph/SecuredCapabilities.java | 13 +-
.../jena/permissions/impl/SecuredItemImpl.java | 10 +-
.../model/SecuredModelDetailTest.java | 13 +-
.../src/test/resources/log4j.properties | 7 +-
14 files changed, 151 insertions(+), 391 deletions(-)
----------------------------------------------------------------------
[2/3] jena git commit: Remove '//if handlesLiteralTyping'
Posted by an...@apache.org.
Remove '//if handlesLiteralTyping'
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f547cc2d
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f547cc2d
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f547cc2d
Branch: refs/heads/master
Commit: f547cc2d62fd99cdd71e3c0fd5d07154dd2630b7
Parents: cd19f7b
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Jan 1 13:26:57 2017 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Jan 1 13:26:57 2017 +0000
----------------------------------------------------------------------
.../apache/jena/graph/GraphContractTest.java | 32 ++++++++------------
1 file changed, 12 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/f547cc2d/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index 9dfaae8..addad6c 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -788,32 +788,24 @@ public class GraphContractTest<T extends Graph> {
@ContractTest
public void testFind_Triple_MatchLanguagedLiteralCaseInsensitive() {
Graph m = graphWith(producer.newInstance(), "a p 'chat'en");
- //if (m.getCapabilities().handlesLiteralTyping()) {
- Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
- assertDiffer(chaten, chatEN);
- assertTrue(chaten.sameValueAs(chatEN));
- assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
- assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chaten))
- .toList().size());
- assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN))
- .toList().size());
- //}
+ Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+ assertDiffer(chaten, chatEN);
+ assertTrue(chaten.sameValueAs(chatEN));
+ assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+ assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chaten)).toList().size());
+ assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN)).toList().size());
}
@ContractTest
public void testFind_Triple_NoMatchAgainstUnlanguagesLiteral() {
Graph m = graphWith(producer.newInstance(),
"a p 'chat'en; a p 'chat'");
- //if (m.getCapabilities().handlesLiteralTyping()) {
- Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
- assertDiffer(chaten, chatEN);
- assertTrue(chaten.sameValueAs(chatEN));
- assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
- assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chaten))
- .toList().size());
- assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN))
- .toList().size());
- //}
+ Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+ assertDiffer(chaten, chatEN);
+ assertTrue(chaten.sameValueAs(chatEN));
+ assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+ assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chaten)).toList().size());
+ assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN)).toList().size());
}
@ContractTest