[
https://issues.apache.org/jira/browse/SLING-5257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stefan Seifert reassigned SLING-5257:
-------------------------------------
Assignee: Stefan Seifert
> [TESTING][JCR MOCK] MockProperty getType generates
> java.lang.ArrayIndexOutOfBoundsException when the underlying array value is
> empty
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: SLING-5257
> URL: https://issues.apache.org/jira/browse/SLING-5257
> Project: Sling
> Issue Type: Bug
> Components: Testing
> Affects Versions: Testing JCR Mock 1.1.10
> Reporter: Guillaume Douillet
> Assignee: Stefan Seifert
>
> Hello,
> When the underlying property value is an empty array, calling
> {{MockProperty.getType}} generates an
> {{java.lang.ArrayIndexOutOfBoundsException}}.
> Here a small test case exhibiting this behavior (to put in
> {{org.apache.sling.testing.mock.jcr.MockPropertyTest}}) :
> {code}
> @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());
> }
> {code}
> A fix could be to return {{PropertyType.UNDEFINED}} when the underlying array
> value is empty :
> {code}
> @Override
> public int getType() throws RepositoryException {
> if (this.itemData.getValues().length>0)
> {
> return this.itemData.getValues()[0].getType();
> }
> else
> {
> return PropertyType.UNDEFINED;
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)