You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Guillaume Douillet (JIRA)" <ji...@apache.org> on 2015/11/03 16:03:27 UTC

[jira] [Created] (SLING-5250) [TESTING][JCR MOCK] MockProperty getValues does not comply with JCR 2.0 API

Guillaume Douillet created SLING-5250:
-----------------------------------------

             Summary: [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


Hello,

According to JCR 2.0 API, {{javax.jcr.Property.getValues()}} should throw ValueFormatException when the underlying property is single-values :
{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 to put in {{org.apache.sling.testing.mock.jcr.MockPropertyTest}} exhibiting this behavior :
{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)