Skip to content

Commit f27e1e6

Browse files
committed
[SLING-12493] Progressive cleanup of test cases
* Updated sling-bundle-parent to version 48. * Upgraded test dependencies to the latest compatible versions. * Migrated unit tests to use Mockito 5.
1 parent e44af7a commit f27e1e6

3 files changed

Lines changed: 32 additions & 19 deletions

File tree

pom.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<parent>
2525
<groupId>org.apache.sling</groupId>
2626
<artifactId>sling-bundle-parent</artifactId>
27-
<version>41</version>
27+
<version>48</version>
2828
<relativePath />
2929
</parent>
3030

@@ -104,7 +104,7 @@
104104
<dependency>
105105
<groupId>org.apache.sling</groupId>
106106
<artifactId>org.apache.sling.commons.osgi</artifactId>
107-
<version>2.1.0</version>
107+
<version>2.4.0</version>
108108
<scope>provided</scope>
109109
</dependency>
110110
<dependency>
@@ -145,13 +145,13 @@
145145
<dependency>
146146
<groupId>org.apache.sling</groupId>
147147
<artifactId>org.apache.sling.jcr.resource</artifactId>
148-
<version>2.3.8</version>
148+
<version>3.3.2</version>
149149
<scope>test</scope>
150150
</dependency>
151151
<dependency>
152152
<groupId>org.apache.sling</groupId>
153153
<artifactId>org.apache.sling.commons.testing</artifactId>
154-
<version>2.1.0</version>
154+
<version>2.1.2</version>
155155
<scope>test</scope>
156156
<exclusions>
157157
<exclusion>
@@ -162,32 +162,32 @@
162162
</dependency>
163163
<dependency>
164164
<groupId>org.apache.sling</groupId>
165-
<artifactId>org.apache.sling.testing.osgi-mock</artifactId>
166-
<version>2.3.4</version>
165+
<artifactId>org.apache.sling.testing.osgi-mock.junit4</artifactId>
166+
<version>3.5.0</version>
167167
<scope>test</scope>
168168
</dependency>
169169
<dependency>
170170
<groupId>org.mockito</groupId>
171-
<artifactId>mockito-all</artifactId>
172-
<version>1.10.19</version>
171+
<artifactId>mockito-core</artifactId>
172+
<version>5.14.2</version>
173173
<scope>test</scope>
174174
</dependency>
175175
<dependency>
176176
<groupId>org.apache.jackrabbit</groupId>
177-
<artifactId>jackrabbit-api</artifactId>
178-
<version>2.19.2</version>
179-
<scope>test</scope>
177+
<artifactId>oak-jackrabbit-api</artifactId>
178+
<version>1.72.0</version>
179+
<scope>test</scope>
180180
</dependency>
181181
<dependency>
182182
<groupId>org.apache.jackrabbit</groupId>
183183
<artifactId>jackrabbit-jcr-commons</artifactId>
184-
<version>2.19.4</version>
184+
<version>2.19.6</version>
185185
<scope>test</scope>
186186
</dependency>
187187
<dependency>
188188
<groupId>org.apache.jackrabbit</groupId>
189189
<artifactId>jackrabbit-core</artifactId>
190-
<version>2.19.4</version>
190+
<version>2.19.6 </version>
191191
<scope>test</scope>
192192
</dependency>
193193
</dependencies>

src/test/java/org/apache/sling/scripting/javascript/internal/ScriptEngineHelper.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
import org.apache.sling.commons.testing.osgi.MockBundle;
3434
import org.apache.sling.commons.testing.osgi.MockComponentContext;
3535
import org.apache.sling.scripting.api.ScriptCache;
36-
import org.mockito.internal.util.reflection.Whitebox;
36+
import org.mockito.InjectMocks;
37+
import org.mockito.Mock;
38+
import org.mockito.MockitoAnnotations;
3739
import org.mozilla.javascript.Context;
3840
import org.mozilla.javascript.ScriptableObject;
3941
import org.mozilla.javascript.Wrapper;
@@ -43,19 +45,30 @@
4345

4446
/** Helpers to run javascript code fragments in tests */
4547
public class ScriptEngineHelper {
48+
4649
private static ScriptEngine engine;
47-
private static ScriptCache scriptCache = mock(ScriptCache.class);
50+
51+
@Mock
52+
private static ScriptCache scriptCache;
53+
54+
@Mock
55+
private static RhinoJavaScriptEngineFactoryConfiguration configuration;
56+
57+
@InjectMocks
58+
private RhinoJavaScriptEngineFactory factory;
59+
60+
public ScriptEngineHelper() {
61+
MockitoAnnotations.initMocks(this);
62+
}
4863

4964
public static class Data extends HashMap<String, Object> {
5065
}
5166

52-
private static ScriptEngine getEngine() {
67+
private ScriptEngine getEngine() {
5368
if (engine == null) {
5469
synchronized (ScriptEngineHelper.class) {
5570
final RhinoMockComponentContext componentContext = new RhinoMockComponentContext();
5671
final RhinoJavaScriptEngineFactoryConfiguration configuration = mock(RhinoJavaScriptEngineFactoryConfiguration.class);
57-
RhinoJavaScriptEngineFactory factory = new RhinoJavaScriptEngineFactory();
58-
Whitebox.setInternalState(factory, "scriptCache", scriptCache);
5972
factory.activate(componentContext, configuration);
6073
engine = factory.getScriptEngine();
6174
}

src/test/java/org/apache/sling/scripting/javascript/wrapper/ScriptableResourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.apache.sling.api.resource.ValueMap;
4545
import org.apache.sling.api.wrappers.ValueMapDecorator;
4646
import org.apache.sling.commons.testing.sling.MockResourceResolver;
47-
import org.apache.sling.jcr.resource.JcrResourceConstants;
47+
import org.apache.sling.jcr.resource.api.JcrResourceConstants;
4848
import org.apache.sling.scripting.javascript.RepositoryScriptingTestBase;
4949
import org.apache.sling.scripting.javascript.internal.ScriptEngineHelper;
5050
import org.jetbrains.annotations.NotNull;

0 commit comments

Comments
 (0)