Eric Norman created SLING-11813:
-----------------------------------

             Summary: Provide a MockNodeTypeManager mode that utilizes real 
node types
                 Key: SLING-11813
                 URL: https://issues.apache.org/jira/browse/SLING-11813
             Project: Sling
          Issue Type: Improvement
          Components: Testing
            Reporter: Eric Norman
            Assignee: Eric Norman
             Fix For: Testing JCR Mock 1.6.8


The old MockNodeTypeManager implementation was mostly stubs and getNodeType 
accepted all node types and return a partial mock.  Any test code that was 
exercising these mock node types would get an UnsupportedOperationException for 
many of the apis which makes testing those code paths difficult.

Expected:

Provide a MockNodeTypeManager mode that (optionally) reads and registers the 
node types from provided content in the compact node type definition format.  
Doing this call would also change the mode of the MockNodeTypeManager to 
consider only the registered node types.  Tests for code paths that interact 
with the node types can return more real details about the node type 
definitions.

For example, the setup for test could do something like below to load the 
nodetype definitions to use during the test run:
{code:java}
try (Reader reader = new 
InputStreamReader(getClass().getResourceAsStream("test_nodetypes.cnd"))) {
    MockJcr.loadNodeTypeDefs(this.session, reader);
}{code}
NOTE: for backward compatibility, if no loadNodeTypeDefs call happens for the 
session,  then it will remain using the default permissive MOCK_ALL mode as 
before.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to