SLING-7815: Add workaround for TransientRepository bug
Looks like TransientRepository can shut itself down prematurely during sudo testing, so keep a dummy session open as a workaround.
diff --git a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderSessionHandlingTest.java b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderSessionHandlingTest.java
index 952333c..ba06259 100644
--- a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderSessionHandlingTest.java
+++ b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderSessionHandlingTest.java
@@ -107,6 +107,11 @@
// Session we're using when loginStyle == SESSION, null otherwise.
private Session explicitSession;
+ // TransientRepository has a bug that makes it ignore sessions created
+ // by calling Session.impersonate(). To prevent the repo from closing
+ // prematurely, have this dummy session open during the whole lifetime
+ // of the test.
+ private Session footInDoor;
private JcrResourceProvider jcrResourceProvider;
private JcrProviderState jcrProviderState;
@@ -196,6 +201,9 @@
@Before
public void setUp() throws Exception {
final SlingRepository repo = new SlingRepositoryWithDummyServiceUsers(RepositoryProvider.instance().getRepository());
+
+ footInDoor = repo.loginAdministrative(null);
+
Map<String, Object> authInfo = new HashMap<>();
switch (loginStyle) {
case USER:
@@ -246,6 +254,8 @@
if (explicitSession != null) {
explicitSession.logout();
}
+
+ footInDoor.logout();
}
@Test