You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2024/11/08 10:36:17 UTC
(sling-org-apache-sling-feature-cpconverter) 01/01: SLING-12475 - Remove test-only usage of GSON
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch issue/SLING-12475
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git
commit 30507b2fac98267e0fe439e64c2dee7460fbd29b
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Nov 8 11:35:46 2024 +0100
SLING-12475 - Remove test-only usage of GSON
Use jakarta.json instead.
---
.../handlers/BundleEntryHandleSlingInitialContentTest.java | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandleSlingInitialContentTest.java b/src/test/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandleSlingInitialContentTest.java
index 3af8484..9810c1d 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandleSlingInitialContentTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandleSlingInitialContentTest.java
@@ -35,7 +35,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
-import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
@@ -74,9 +73,8 @@ import org.osgi.framework.Constants;
import org.osgi.framework.Version;
import org.xml.sax.SAXException;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
+import jakarta.json.Json;
+import jakarta.json.JsonObject;
@RunWith(MockitoJUnitRunner.class)
public class BundleEntryHandleSlingInitialContentTest extends AbstractBundleEntryHandlerTest {
@@ -208,7 +206,6 @@ public class BundleEntryHandleSlingInitialContentTest extends AbstractBundleEntr
converter.deployPackages();
- Type typeOfHashMap = new TypeToken<Map<String, String>>() { }.getType();
// verify generated package
try (VaultPackage vaultPackage = new PackageManagerImpl().open(new File(targetFolder, "mysite.core-apps-1.0.0-SNAPSHOT-cp2fm-converted.zip"));
Archive archive = vaultPackage.getArchive()) {
@@ -223,10 +220,8 @@ public class BundleEntryHandleSlingInitialContentTest extends AbstractBundleEntr
Reader actualJsonFileContents = new InputStreamReader(archive.getInputSource(jsonFileEntry).getByteStream(), UTF_8);
Reader expectedJsonFileContents = new InputStreamReader(getClass().getResourceAsStream("i18n-jsonfile-xml-descriptor-test/en.json"), UTF_8);
- Gson GSON = new GsonBuilder().create();
-
- Map<String,String> actualJson = GSON.fromJson(actualJsonFileContents, typeOfHashMap);
- Map<String,String> expectedJson = GSON.fromJson(expectedJsonFileContents, typeOfHashMap);
+ JsonObject actualJson = Json.createReader(actualJsonFileContents).readObject();
+ JsonObject expectedJson = Json.createReader(expectedJsonFileContents).readObject();
assertEquals(expectedJson, actualJson);
//compare XML