You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by re...@apache.org on 2025/02/27 07:46:00 UTC

(sling-org-apache-sling-resourceresolver) branch SLING-12683 updated: SLING-12683: close Mocks

This is an automated email from the ASF dual-hosted git repository.

reschke pushed a commit to branch SLING-12683
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git


The following commit(s) were added to refs/heads/SLING-12683 by this push:
     new bf24d6f  SLING-12683: close Mocks
bf24d6f is described below

commit bf24d6f1d3ec860210543a29947d3aecdb4a223d
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu Feb 27 08:45:51 2025 +0100

    SLING-12683: close Mocks
---
 .../sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java   | 7 +++++--
 .../apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java | 7 +++++--
 .../resourceresolver/impl/mapping/VanityPathMapEntriesTest.java    | 7 +++++--
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java
index cae4357..53e85c2 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java
@@ -84,11 +84,13 @@ public class AliasMapEntriesTest extends AbstractMappingMapEntriesTest {
     public AliasMapEntriesTest() {
     }
 
+    private AutoCloseable mockCloser;
+
     @Override
     @SuppressWarnings({ "unchecked" })
     @Before
     public void setup() throws Exception {
-        MockitoAnnotations.openMocks(this);
+        this.mockCloser = MockitoAnnotations.openMocks(this);
 
         when(bundle.getSymbolicName()).thenReturn("TESTBUNDLE");
         when(bundleContext.getBundle()).thenReturn(bundle);
@@ -127,8 +129,9 @@ public class AliasMapEntriesTest extends AbstractMappingMapEntriesTest {
 
     @Override
     @After
-    public void tearDown() {
+    public void tearDown() throws Exception {
         mapEntries.dispose();
+        mockCloser.close();
     }
 
     private static void addResource(MapEntries mapEntries, String path, AtomicBoolean bool) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
index 33d33e6..b72a201 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
@@ -80,11 +80,13 @@ public class MapEntriesTest extends AbstractMappingMapEntriesTest {
     public MapEntriesTest() {
     }
 
+    private AutoCloseable mockCloser;
+
     @Override
     @SuppressWarnings({ "unchecked" })
     @Before
     public void setup() throws Exception {
-        MockitoAnnotations.openMocks(this);
+        this.mockCloser = MockitoAnnotations.openMocks(this);
 
         when(bundle.getSymbolicName()).thenReturn("TESTBUNDLE");
         when(bundleContext.getBundle()).thenReturn(bundle);
@@ -115,8 +117,9 @@ public class MapEntriesTest extends AbstractMappingMapEntriesTest {
 
     @Override
     @After
-    public void tearDown() {
+    public void tearDown() throws Exception {
         mapEntries.dispose();
+        mockCloser.close();
     }
 
     @Test
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
index aeaca33..e03493b 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
@@ -118,11 +118,13 @@ public class VanityPathMapEntriesTest extends AbstractMappingMapEntriesTest {
         this.isVanityPathCacheInitInBackground = isVanityPathCacheInitInBackground;
     }
 
+    private AutoCloseable mockCloser;
+
     @Override
     @SuppressWarnings({ "unchecked" })
     @Before
     public void setup() throws Exception {
-        MockitoAnnotations.openMocks(this);
+        this.mockCloser = MockitoAnnotations.openMocks(this);
 
         final List<VanityPathConfig> configs = new ArrayList<>();
         configs.add(new VanityPathConfig("/libs/", false));
@@ -218,8 +220,9 @@ public class VanityPathMapEntriesTest extends AbstractMappingMapEntriesTest {
 
     @Override
     @After
-    public void tearDown() {
+    public void tearDown() throws Exception {
         mapEntries.dispose();
+        mockCloser.close();
     }
 
     @Test