[
https://issues.apache.org/jira/browse/SLING-8053?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16665275#comment-16665275
]
ASF GitHub Bot commented on SLING-8053:
---------------------------------------
bosschaert closed pull request #7: SLING-8053 - Fix Text Extension
Serialization.
URL: https://github.com/apache/sling-org-apache-sling-feature-io/pull/7
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
b/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
index 19f6282..3533e68 100644
--- a/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
+++ b/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
@@ -222,7 +222,11 @@ protected void writeExtensions(final JsonGenerator
generator,
}
generator.write(key, struct);
} else if ( ext.getType() == ExtensionType.TEXT ) {
- generator.write(key, ext.getText());
+ generator.writeStartArray(key);
+ for(String line : ext.getText().split("\n")) {
+ generator.write(line);
+ }
+ generator.writeEnd();
} else {
generator.writeStartArray(key);
for(final Artifact artifact : ext.getArtifacts()) {
diff --git
a/src/test/java/org/apache/sling/feature/io/json/FeatureJSONWriterTest.java
b/src/test/java/org/apache/sling/feature/io/json/FeatureJSONWriterTest.java
index 314925a..2389334 100644
--- a/src/test/java/org/apache/sling/feature/io/json/FeatureJSONWriterTest.java
+++ b/src/test/java/org/apache/sling/feature/io/json/FeatureJSONWriterTest.java
@@ -17,10 +17,13 @@
package org.apache.sling.feature.io.json;
import org.apache.sling.feature.Feature;
+import org.junit.Assert;
import org.junit.Test;
-import java.io.StringReader;
-import java.io.StringWriter;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+import java.io.*;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
@@ -86,4 +89,18 @@
assertEquals(f.getInclude().getId(), rf.getInclude().getId());
}
+ @Test public void testRepoInitWrite() throws Exception {
+ final Feature f = U.readFeature("repoinit2");
+ try ( final StringWriter writer = new StringWriter() ) {
+ FeatureJSONWriter.write(writer, f);
+ final JsonObject refJson = Json.createReader(
+ new
InputStreamReader(U.class.getResourceAsStream("/features/repoinit2.json"))
+ ).readObject();
+ final JsonObject resultJson = Json.createReader(new
StringReader(writer.toString())).readObject();
+
+ JsonArray refJsonArray =
refJson.getJsonArray("repoinit:TEXT|false");
+ JsonArray resultJsonArray =
resultJson.getJsonArray("repoinit:TEXT|false");
+ Assert.assertEquals(refJsonArray, resultJsonArray);
+ }
+ }
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Fix Text Extension Serialization
> --------------------------------
>
> Key: SLING-8053
> URL: https://issues.apache.org/jira/browse/SLING-8053
> Project: Sling
> Issue Type: New Feature
> Components: Feature Model
> Affects Versions: Feature Model 0.1.2
> Reporter: David Bosschaert
> Assignee: David Bosschaert
> Priority: Major
> Fix For: Feature Model IO 0.1.4
>
>
> When the feature model is rewritten using the feature model writer API, a
> multi-line text extensions, such as a repo init description in the feature
> model is converted into one unreadable line.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)