Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-6423

ModuleVersionHandlerTestCase: late node type registration may cause NoSuchNodeTypeException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Neutral Neutral
    • None
    • None
    • testing
    • None

      MVHTestCase features a method to register extra node types info.magnolia.module.ModuleVersionHandlerTestCase.getExtraNodeTypes() however the actual registration happens only when running info.magnolia.module.ModuleVersionHandlerTestCase.executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version) that is when the repo structure with nodes of a certain type typically has already been set. This may cause a javax.jcr.nodetype.NoSuchNodeTypeException. Consider the following case

      @Test
          public void something() throws Exception {
              // GIVEN
              websiteSession.getRootNode().addNode("foo", "mgnl:page");
              websiteSession.getRootNode().addNode("foo/bar", "mgnl:variants"); 
              // WHEN
              executeUpdatesAsIfTheCurrentlyInstalledVersionWas(null);
      //rest omitted
      }
      

      mgnl:variants is a personalization node type which is provided to the test via

       @Override
          protected String getExtraNodeTypes() {
              return "/mgnl-nodetypes/magnolia-personalization-nodetypes.xml";
          }
      

      The above test will fail with

      javax.jcr.nodetype.NoSuchNodeTypeException: {http://www.magnolia.info/jcr/mgnl}variants
      	at org.apache.jackrabbit.core.nodetype.NodeTypeRegistry.getEffectiveNodeType(NodeTypeRegistry.java:1037)
      	at org.apache.jackrabbit.core.nodetype.NodeTypeRegistry.getEffectiveNodeType(NodeTypeRegistry.java:472)
      	at org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl.getNodeType(NodeTypeManagerImpl.java:186)
      	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1255)
      ...
      

        Acceptance criteria

              Unassigned Unassigned
              fgrilli Federico Grilli
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD