Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-8621

TestUtil.cleanup causes in WARNing due to SlingContext Rule

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Repoinit JCR 1.1.14
    • Component/s: Repoinit
    • Labels:
      None

      Description

      there are a bunch of tests with sling-jcr-repoinit that call TestUtil.cleanup in the after method essentially logging out the admin session created in the constructor of the TestUtil.

      however, the TestUtil is created from a SlingContext rule, which will take care of releasing the resource-resolver and associated session itself. therefore the call to TestUtil.cleanup will result in the following warning:

      [main] INFO org.apache.sling.jcr.repoinit.impl.NodetypesVisitor - Registering nodetypes from <RegisterNodetypesTest='uri:RegisterNodetypesTest:863a68ae-5725-45ec-9e29-fa2624d7911a'>
      [RegisterN...
      [main] WARN org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider - Unable to revert pending changes.
      javax.jcr.RepositoryException: This session has been closed.
      	at org.apache.jackrabbit.oak.jcr.session.SessionImpl.checkAlive(SessionImpl.java:142)
      	at org.apache.jackrabbit.oak.jcr.session.SessionImpl.refresh(SessionImpl.java:432)
      	at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.revert(JcrResourceProvider.java:478)
      	at org.apache.sling.resourceresolver.impl.providers.stateful.AuthenticatedResourceProvider.revert(AuthenticatedResourceProvider.java:205)
      	at org.apache.sling.resourceresolver.impl.helper.ResourceResolverControl.revert(ResourceResolverControl.java:412)
      	at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.revert(ResourceResolverImpl.java:1169)
      	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.tearDown(SlingContextImpl.java:190)
      	at org.apache.sling.testing.mock.sling.junit.SlingContext.access$200(SlingContext.java:40)
      	at org.apache.sling.testing.mock.sling.junit.SlingContext$1.after(SlingContext.java:134)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:50)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
      	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
      	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
      

      i run into this whilke working on SLING-8602, where i actually need the cleanup, because i can't make use of the SlingContext to obtain a session.... but for the existing tests, calling the cleanup should be avoided.

      affected tests are:

      • RegisterNamespacesTest
      • RegisterNodetypesTest
      • RegisterPrivilegeTest
      • ExecutionOrderTest
      • ManyServiceUsersTest

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rombert Robert Munteanu
                Reporter:
                angela Angela Schreiber
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: