[ https://issues.apache.org/jira/browse/SLING-5250?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefan Seifert resolved SLING-5250. ----------------------------------- Resolution: Fixed Completed: At revision: 1712653 > [TESTING][JCR MOCK] MockProperty getValues does not comply with JCR 2.0 API > --------------------------------------------------------------------------- > > Key: SLING-5250 > URL: https://issues.apache.org/jira/browse/SLING-5250 > Project: Sling > Issue Type: Bug > Components: Testing > Affects Versions: Testing JCR Mock 1.1.10 > Reporter: Guillaume Douillet > Assignee: Stefan Seifert > > Hello, > According to JCR 2.0 API, {{javax.jcr.Property.getValues()}} should throw > {{ValueFormatException}} when the underlying property is single-valued : > {code} > /** > * Returns an array of all the values of this property. Used to access > * multi-value properties. The array returned is a copy of the stored > * values, so changes to it are not reflected in internal storage. > * > * @return a <code>Value</code> array. > * @throws ValueFormatException if the property is single-valued. > * @throws RepositoryException if another error occurs. > */ > public Value[] getValues() throws ValueFormatException, > RepositoryException; > {code} > However, {{org.apache.sling.testing.mock.jcr.MockProperty}} implements a > different behavior. {{ValueFormatException}} is not thrown but an array > containing a single value is returned instead. > Here a small test case exhibiting this behavior (to put in > {{org.apache.sling.testing.mock.jcr.MockPropertyTest}}) : > {code} > @Test(expected=ValueFormatException.class) > public void testSingleValueAsValueArray() throws RepositoryException { > this.node1.setProperty("prop1", > this.session.getValueFactory().createValue("value1")); > Property prop1 = this.node1.getProperty("prop1"); > assertFalse(prop1.isMultiple()); > assertEquals("value1", prop1.getValues()[0].getString()); > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)