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

ModuleVersionHandlerTestCase: late node type registration may cause NoSuchNodeTypeException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Accepted
    • Priority: Neutral
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: testing
    • Labels:
      None

      Description

      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)
      ...
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              fgrilli Federico Grilli
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: