You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2018/04/27 10:01:34 UTC

[sling-org-apache-sling-feature-modelconverter] 16/40: Add roundtrip testing prov model -> feature -> prov model

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

davidb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-modelconverter.git

commit 6fe1aff24f453dd390fe1d7014042c4f906b71a3
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Thu Mar 22 10:39:03 2018 +0000

    Add roundtrip testing prov model -> feature -> prov model
---
 .../modelconverter/impl/ModelConverterTest.java    | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/sling/feature/modelconverter/impl/ModelConverterTest.java b/src/test/java/org/apache/sling/feature/modelconverter/impl/ModelConverterTest.java
index 8a03fa1..194d95c 100644
--- a/src/test/java/org/apache/sling/feature/modelconverter/impl/ModelConverterTest.java
+++ b/src/test/java/org/apache/sling/feature/modelconverter/impl/ModelConverterTest.java
@@ -81,7 +81,7 @@ public class ModelConverterTest {
     }
 
     @Test
-    public void testBoot() throws Exception {
+    public void testBootToProvModel() throws Exception {
         testConvertToProvisioningModel("/boot.json", "/boot.txt");
     }
 
@@ -91,7 +91,12 @@ public class ModelConverterTest {
     }
 
     @Test
-    public void testOak() throws Exception {
+    public void testBootRoundTrip() throws Exception {
+        testConvertFromProvModelRoundTrip("/boot.txt");
+    }
+
+    @Test
+    public void testOakProvModel() throws Exception {
         testConvertToProvisioningModel("/oak.json", "/oak.txt");
     }
 
@@ -100,6 +105,25 @@ public class ModelConverterTest {
         testConvertToFeature("/oak.txt", "/oak.json");
     }
 
+    @Test
+    public void testOakRoundTrip() throws Exception {
+        testConvertFromProvModelRoundTrip("/oak.txt");
+    }
+
+    public void testConvertFromProvModelRoundTrip(String orgProvModel) throws Exception {
+        File inFile = new File(getClass().getResource(orgProvModel).toURI());
+        File outJSONFile = new File(tempDir.toFile(), orgProvModel + ".json.generated");
+        File outProvFile = new File(tempDir.toFile(), orgProvModel + ".txt.generated");
+
+        ProvisioningToFeature.convert(inFile, outJSONFile.getAbsolutePath());
+        FeatureToProvisioning.convert(outJSONFile, outProvFile.getAbsolutePath(),
+                artifactManager);
+
+        Model expected = readProvisioningModel(inFile);
+        Model actual = readProvisioningModel(outProvFile);
+        assertModelsEqual(expected, actual);
+    }
+
     public void testConvertToFeature(String originalProvModel, String expectedJSON) throws Exception {
         File inFile = new File(getClass().getResource(originalProvModel).toURI());
         File outFile = new File(tempDir.toFile(), expectedJSON + ".generated");

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.