This is a message stack for Graph SPI Contract testing. It covers only the Jena 2 Graph Contract. This an attempt to document the current Graph contract. Any correction should specify the bullet point number.
1. add() -- technically from GraphAdd 1. when a triple is added to a graph all registered listeners must receive an (add graph triple) message 2. subsequent graph.contains( triple ) must return true. 3. If add is performed within a transaction the listeners are not notified until after the commit. 4. If graph is read only (Capabilities.addAllowed() returns false) must throw AddDeniedException 2. clear() 1. If the graph can be empty (Capabilities.canBeEmpty()) there should be no triples returned from find( Triple.ANY ) 2. If the graph can not be empty there should only be the elements that were present when the graph was created. 3. if delete is not allowed (Capabilities.canDelete() is false) clear() must throw DeleteDeniedException 3. close() 1. after close isClosed() should return true 2. calling close on closed graph should not throw an exception. 3. calling any Graph method other than close() on a closed graph should throw a ClosedException 4. contains() 1. returns true if the graph contains the specified triple. 1. Node.ANY will match any node in the position. 2. if the graph supports transactions and a transaction is in progress the graph will only not show any triples that only exist within the transaction. 5. delete() 1. if delete is not allowed (Capabilities.canDelete() is false) delete() must throw DeleteDeniedException 2. when a triple is deleted from a graph all registered listeners must receive an (delete graph triple) message 3. subsequent graph.contains( triple ) must return false. 4. If add is performed within a transaction the listeners are not notified until after the commit. 6. dependsOn() 1. true if this graph's content depends on the other graph. May be pessimistic (ie return true if it's not sure). Typically true when a graph is a composition of other graphs, eg union. 7. find() 1. returns an iterator of triples that match the specified triple. 8. getBulkUpdateHandler() -- deprecated / removed -- no tests 9. getCapabilities() 1. must not return null. 2. capabilities must match other results. 1. if not addAllowed() , add must throw exception 2. if not deleteAllowed(), 1. delete must throw exception 2. clear must throw exception 3. if iteratorRemoveAllowed(), iterator from find must allow remove() 4. if canBeEmpty() 1. initial construction must be empty() 2. clear() must be empty. 3. must pass Capabilities contract tests. 10. getEventManager() 1. May not return null 2. Listeners registered with event manager must be notified of changes. 3. EventManager must pass GraphEventManager contract test. 11. getPrefixMapping() 1. May not be null 2. changes to the prefixes managed by the PrefixMapping returned getPrefixMapping() must be reflected in all other PrefixMapping classes from the same graph. 3. Changes made to a prefix mapping within a transaction are visible outside of the transaction and are not rolled back by the transaction. 4. PrefixMapping must pass the PrefixMapping contract test 12. getStatisticsHandler() 1. may be null 2. if not null must pass the GraphStatisticsHandler contract test. 3. all GraphStatisticsHandlers returned must pass handler.equals( handler2 ) 13. getTransactionHandler() 1. may not be null 2. must pass the TransactionHandler contract test. 14. isClosed() 1. must return false when the graph is created. 2. must return true after the close() has been called. 15. isEmpty() 1. must return true when graph is created if Capabilities.canBeEmpty() is true 2. must not return true after triples are added 3. must return true after all triples are deleted if Capabilities.canBeEmpty() is true. 4. must return true after clear() if Capabilities.canBeEmpty() is true. 16. isIsomorphicWith() -- from ( http://www.w3.org/TR/2014/REC-rdf11-concepts-20140225/#section-graph-equality): Two RDF graphs G and G' are isomorphic (that is, they have an identical form) if there is a bijection M between the sets of nodes of the two graphs, such that: 1. M maps blank nodes to blank nodes. 2. M(lit)=lit for all RDF literals lit which are nodes of G. 3. M(iri)=iri for all IRIs iri which are nodes of G. 4. The triple ( s, p, o ) is in G if and only if the triple ( M(s), p, M(o) ) is in G' 17. remove() 1. when a triple is removed from a graph all registered listeners must receive an (remove graph triple) message 2. subsequent graph.contains( triple ) must return false, unless the triple was is in the newly constructed graph and Capabilities.canBeEmpty() is false. 3. If removed is performed within a transaction the listeners are not notified until after the commit. 4. If delete is denied (Capabilities.deleteAllowed() returns false) must throw DeleteDeniedException 18. size() 1. if Capabilities.sizeAccurate() is true 1. if transactions are supported (TransactionHandler.transactionsSupported() is true) 1. the size from within the transaction must function 1. adding a triple must increment the size of the graph. 2. removing a triple must decrement the size of the graph. 2. the size from outside the transaction must not change 2. if transactions are not in supported (TransactionHandler.transactionsSupported() is false) 1. adding a triple must increment the size of the graph. 2. removing a triple must decrement the size of the graph. 2. if Capabilities.sizeAccurate() is false 1. if transactions are supported (TransactionHandler.transactionsSupported() is true) 1. the size from within the transaction must function 1. adding a triple may increment the size of the graph. 2. adding a triple may not decrement the size of the graph. 3. removing a triple may decrement the size of the graph. 4. removing a triple may not increment the size of the graph. 2. the size from outside the transaction must not change 1. adding a triple may not decrement the size of the graph. 2. removing a triple may not increment the size of the graph. 2. if transactions are not in supported (TransactionHandler.transactionsSupported() is false) 1. adding a triple may increment the size of the graph. 2. adding a triple may not decrement the size of the graph. 3. removing a triple may decrement the size of the graph. 4. removing a triple may not increment the size of the graph. Please comment as appropriate. Claude -- I like: Like Like - The likeliest place on the web <http://like-like.xenei.com> LinkedIn: http://www.linkedin.com/in/claudewarren