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 2017/11/07 10:18:27 UTC
[sling-org-apache-sling-testing-jcr-mock] 03/07: SLING-5257
MockProperty getType generates java.lang.ArrayIndexOutOfBoundsException
when the underlying array value is empty
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.testing.jcr-mock-1.1.12
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-jcr-mock.git
commit 4b5d898ca545dee1ccd3d110a040218e901ce418
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Nov 4 21:10:21 2015 +0000
SLING-5257 MockProperty getType generates java.lang.ArrayIndexOutOfBoundsException when the underlying array value is empty
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/jcr-mock@1712652 13f79535-47bb-0310-9956-ffa450edef68
---
.../java/org/apache/sling/testing/mock/jcr/MockProperty.java | 8 +++++++-
.../java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java | 9 +++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
index cd8b7d0..3eaa9ce 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
@@ -25,6 +25,7 @@ import java.util.Calendar;
import javax.jcr.Binary;
import javax.jcr.Node;
import javax.jcr.Property;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
@@ -197,7 +198,12 @@ class MockProperty extends AbstractItem implements Property {
@Override
public int getType() throws RepositoryException {
- return this.itemData.getValues()[0].getType();
+ if (this.itemData.getValues().length > 0) {
+ return this.itemData.getValues()[0].getType();
+ }
+ else {
+ return PropertyType.UNDEFINED;
+ }
}
@Override
diff --git a/src/test/java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java b/src/test/java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java
index a8f30a4..14d59af 100644
--- a/src/test/java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java
@@ -30,6 +30,7 @@ import java.util.Calendar;
import javax.jcr.Node;
import javax.jcr.Property;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
@@ -237,4 +238,12 @@ public class MockPropertyTest {
assertArrayEquals(new long[] { 2 }, prop1.getLengths());
}
+ @Test
+ public void testEmptyArrayGetType() throws RepositoryException {
+ this.node1.setProperty("prop1", new Value[] {});
+ Property prop1 = this.node1.getProperty("prop1");
+ assertTrue(prop1.isMultiple());
+ assertEquals(PropertyType.UNDEFINED, prop1.getType());
+ }
+
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.