This is an automated email from the ASF dual-hosted git repository.
apelluru pushed a commit to branch SLING-12063
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-bundleresource-impl.git
The following commit(s) were added to refs/heads/SLING-12063 by this push:
new 328d91c SLING-12063: migrate to jakarta.json
328d91c is described below
commit 328d91c4a21961dec43ec0f5124c42b3cf5ac920
Author: Ashok Pelluru <[email protected]>
AuthorDate: Wed Oct 4 01:32:14 2023 +0200
SLING-12063: migrate to jakarta.json
---
pom.xml | 34 ++++++++++++++++++----
.../sling/bundleresource/impl/BundleResource.java | 12 ++++----
.../impl/BundleResourceProviderTest.java | 22 +++++++-------
.../bundleresource/impl/BundleResourceTest.java | 17 ++++++-----
.../bundleresource/impl/NoBundleContextTest.java | 15 ++++++----
.../sling/bundleresource/impl/PathMappingTest.java | 10 ++++---
.../impl/url/ResourceURLStreamHandler.java | 8 ++---
7 files changed, 72 insertions(+), 46 deletions(-)
diff --git a/pom.xml b/pom.xml
index 888b1e1..ba7b1f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling-bundle-parent</artifactId>
- <version>41</version>
+ <version>52</version>
<relativePath />
</parent>
@@ -63,10 +63,18 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <version>2.0.2</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -89,15 +97,18 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.util.tracker</artifactId>
<version>1.5.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.bundle</artifactId>
+ <scope>provided</scope>
</dependency>
<!-- This is only used for some constants, no runtime dependency -->
@@ -110,21 +121,32 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!-- Testing -->
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>5.10.0</version>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.10.0</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
+ <artifactId>mockito-core</artifactId>
+ <version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-core</artifactId>
- <version>1.0.0</version>
+ <classifier>jakarta</classifier>
+ <version>1.2.14</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
b/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
index 2bb0cde..3978805 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
@@ -29,12 +29,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonNumber;
-import javax.json.JsonObject;
-import javax.json.JsonString;
-import javax.json.JsonValue;
+import jakarta.json.Json;
+import jakarta.json.JsonArray;
+import jakarta.json.JsonNumber;
+import jakarta.json.JsonObject;
+import jakarta.json.JsonString;
+import jakarta.json.JsonValue;
import org.apache.sling.api.resource.AbstractResource;
import org.apache.sling.api.resource.Resource;
diff --git
a/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceProviderTest.java
b/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceProviderTest.java
index aa51f21..9b8ee72 100644
---
a/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceProviderTest.java
+++
b/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceProviderTest.java
@@ -18,10 +18,7 @@
*/
package org.apache.sling.bundleresource.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -35,8 +32,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import javax.json.Json;
-import javax.json.stream.JsonGenerator;
+import jakarta.json.Json;
+import jakarta.json.stream.JsonGenerator;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
@@ -44,9 +41,9 @@ import
org.apache.sling.bundleresource.impl.url.ResourceURLStreamHandler;
import
org.apache.sling.bundleresource.impl.url.ResourceURLStreamHandlerFactory;
import org.apache.sling.spi.resource.provider.ResolveContext;
import org.apache.sling.spi.resource.provider.ResourceContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.osgi.framework.Bundle;
public class BundleResourceProviderTest {
@@ -106,12 +103,12 @@ public class BundleResourceProviderTest {
assertEquals(content, getContent(rsrc));
}
- @Before
+ @BeforeEach
public void setup() {
ResourceURLStreamHandlerFactory.init();
}
- @After
+ @AfterEach
public void finish() {
ResourceURLStreamHandler.reset();
}
@@ -164,7 +161,8 @@ public class BundleResourceProviderTest {
assertEquals("HELLOWORLD", getContent(rsrc));
}
- @Test public void testTreeWithoutDeepJSON() throws IOException {
+ @Test
+ public void testTreeWithoutDeepJSON() throws IOException {
testTreeWithoutDeepJSON("");
testTreeWithoutDeepJSON("/SLING-INF");
}
diff --git
a/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceTest.java
b/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceTest.java
index 892c1d3..8ea858f 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceTest.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceTest.java
@@ -18,8 +18,8 @@
*/
package org.apache.sling.bundleresource.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -34,9 +34,9 @@ import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.bundleresource.impl.url.ResourceURLStreamHandler;
import
org.apache.sling.bundleresource.impl.url.ResourceURLStreamHandlerFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.osgi.framework.Bundle;
public class BundleResourceTest {
@@ -51,12 +51,12 @@ public class BundleResourceTest {
return cache;
}
- @Before
+ @BeforeEach
public void setup() {
ResourceURLStreamHandlerFactory.init();
}
- @After
+ @AfterEach
public void finish() {
ResourceURLStreamHandler.reset();
}
@@ -75,7 +75,8 @@ public class BundleResourceTest {
when(cache.getEntry(path)).thenReturn(url);
}
- @Test public void testFileResource() throws MalformedURLException {
+ @Test
+ public void testFileResource() throws MalformedURLException {
final BundleResourceCache cache = getBundleResourceCache();
when(cache.getEntry("/libs/foo/test.json")).thenReturn(new
URL("file:/libs/foo/test.json"));
final BundleResource rsrc = new BundleResource(null, cache,
diff --git
a/src/test/java/org/apache/sling/bundleresource/impl/NoBundleContextTest.java
b/src/test/java/org/apache/sling/bundleresource/impl/NoBundleContextTest.java
index e7b0394..2148a85 100644
---
a/src/test/java/org/apache/sling/bundleresource/impl/NoBundleContextTest.java
+++
b/src/test/java/org/apache/sling/bundleresource/impl/NoBundleContextTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.sling.bundleresource.impl;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -28,7 +28,7 @@ import java.io.IOException;
import java.util.Dictionary;
import org.apache.sling.spi.resource.provider.ResourceProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
@@ -40,14 +40,17 @@ import org.osgi.framework.ServiceRegistration;
*/
public class NoBundleContextTest {
- @Test(expected = IllegalStateException.class)
+ @Test
public void verifyIllegalStateExceptionWhenNoBundleContextIsAvailable()
throws IOException {
final Bundle bundle = mock(Bundle.class);
when(bundle.getBundleContext()).thenReturn(null);
final PathMapping path = new PathMapping("/libs/foo", null, null);
final BundleResourceProvider provider = new BundleResourceProvider(new
BundleResourceCache(bundle), path);
- provider.registerService();
+ Exception exception = assertThrows(IllegalStateException.class, () -> {
+ provider.registerService();
+ });
+ assertTrue(exception.getMessage().contains("No BundleContext was
found"));
}
@SuppressWarnings("unchecked")
diff --git
a/src/test/java/org/apache/sling/bundleresource/impl/PathMappingTest.java
b/src/test/java/org/apache/sling/bundleresource/impl/PathMappingTest.java
index 6ed1703..60afb92 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/PathMappingTest.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/PathMappingTest.java
@@ -18,14 +18,16 @@
*/
package org.apache.sling.bundleresource.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class PathMappingTest {
- @Test public void testSimpleRoot() {
+ @Test
+ public void testSimpleRoot() {
final PathMapping[] paths = PathMapping.getRoots("/libs/foo");
assertEquals(1, paths.length);
assertNull(paths[0].getEntryRoot());
diff --git
a/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandler.java
b/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandler.java
index 2f804d6..0cb79ab 100644
---
a/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandler.java
+++
b/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandler.java
@@ -28,10 +28,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.json.Json;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonStructure;
+import jakarta.json.Json;
+import jakarta.json.JsonArrayBuilder;
+import jakarta.json.JsonObjectBuilder;
+import jakarta.json.JsonStructure;
import org.apache.sling.api.resource.ResourceUtil;