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 2015/12/03 16:29:38 UTC
svn commit: r1717781 - in /sling/trunk/tooling/ide:
impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/serialization/
impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/serialization/
impl-vlt/src/org/apache/sling/ide/impl/vlt/serial...
Author: rombert
Date: Thu Dec 3 15:29:38 2015
New Revision: 1717781
URL: http://svn.apache.org/viewvc?rev=1717781&view=rev
Log:
SLING-5349 - Empty multi-valued properties are not correctly handled
Correctly handle empty multi-value properties in ContentXmlHandler
Added:
sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/serialization/empty-multivalued-property.xml
Modified:
sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandlerTest.java
sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandler.java
Modified: sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandlerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandlerTest.java?rev=1717781&r1=1717780&r2=1717781&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandlerTest.java (original)
+++ sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandlerTest.java Thu Dec 3 15:29:38 2015
@@ -195,6 +195,18 @@ public class ContentXmlHandlerTest {
assertThat("properties[someProp]", (String[]) root.getProperties().get("someProp"),
Matchers.is(new String[] { "first,first", "second" }));
}
+
+ @Test
+ public void emptyMultivaluedProperties() throws Exception {
+
+ ResourceProxy root = parseContentXmlFile("empty-multivalued-property.xml", "/");
+
+ assertThat("properties[labels]", (String[]) root.getProperties().get("labels"),
+ Matchers.arrayWithSize(0));
+ assertThat("properties[values]", (Long[]) root.getProperties().get("values"),
+ Matchers.arrayWithSize(0));
+
+ }
private static Matcher<Calendar> millis(long millis) {
Added: sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/serialization/empty-multivalued-property.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/serialization/empty-multivalued-property.xml?rev=1717781&view=auto
==============================================================================
--- sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/serialization/empty-multivalued-property.xml (added)
+++ sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/serialization/empty-multivalued-property.xml Thu Dec 3 15:29:38 2015
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or
+ more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information regarding
+ copyright ownership. The ASF licenses this file to you under the
+ Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain
+ a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed
+ under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions
+ and limitations under the License.
+-->
+<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
+ jcr:primaryType="nt:unstructured"
+ labels="[]"
+ values="{Long}[]"/>
Modified: sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandler.java?rev=1717781&r1=1717780&r2=1717781&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandler.java (original)
+++ sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/ContentXmlHandler.java Thu Dec 3 15:29:38 2015
@@ -263,6 +263,10 @@ public class ContentXmlHandler extends D
private static String[] splitValues(String rawValues) {
+ if ( rawValues.isEmpty() ) {
+ return new String[0];
+ }
+
List<String> values = new ArrayList<>();
String[] firstPass = rawValues.split(",");
for ( int i = 0 ; i < firstPass.length; i++) {