Search in sources :

Example 16 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class UserImporterPasswordTreeTest method testInvalidPropName.

@Test
public void testInvalidPropName() throws Exception {
    PropInfo propInfo = createPropInfo(null, "value");
    PropertyDefinition propDef = when(mock(PropertyDefinition.class).getName()).thenReturn(null).getMock();
    assertFalse(importer.handlePropInfo(pwTree, propInfo, propDef));
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) Test(org.junit.Test)

Example 17 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class UserImporterPasswordTreeTest method testLastModifiedWithRequiredType.

@Test
public void testLastModifiedWithRequiredType() throws Exception {
    PropInfo propInfo = createPropInfo(REP_PASSWORD_LAST_MODIFIED, "23000");
    PropertyDefinition propDef = when(mock(PropertyDefinition.class).getRequiredType()).thenReturn(PropertyType.LONG).getMock();
    when(propDef.isMultiple()).thenReturn(true);
    assertTrue(importer.handlePropInfo(pwTree, propInfo, propDef));
    PropertyState ps = pwTree.getProperty(REP_PASSWORD_LAST_MODIFIED);
    assertNotNull(ps);
    assertSame(Type.LONGS, ps.getType());
    assertEquals(1, ps.count());
    assertEquals(23000, ps.getValue(Type.LONG, 0).longValue());
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 18 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class UserImporterPasswordTreeTest method testAnyPropNameUndefinedRequiredType.

@Test
public void testAnyPropNameUndefinedRequiredType() throws Exception {
    PropInfo propInfo = createPropInfo("any", "value");
    PropertyDefinition propDef = when(mock(PropertyDefinition.class).getRequiredType()).thenReturn(PropertyType.UNDEFINED).getMock();
    when(propDef.isMultiple()).thenReturn(true);
    assertTrue(importer.handlePropInfo(pwTree, propInfo, propDef));
    PropertyState ps = pwTree.getProperty("any");
    assertNotNull(ps);
    assertSame(Type.STRINGS, ps.getType());
    assertTrue(ps.isArray());
    assertEquals("value", ps.getValue(Type.STRING, 0));
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 19 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class UserImporterPasswordTreeTest method testAnyPropNameWithRequiredType.

@Test
public void testAnyPropNameWithRequiredType() throws Exception {
    PropInfo propInfo = createPropInfo("any", "true");
    PropertyDefinition propDef = when(mock(PropertyDefinition.class).getRequiredType()).thenReturn(PropertyType.BOOLEAN).getMock();
    when(propDef.isMultiple()).thenReturn(false);
    assertTrue(importer.handlePropInfo(pwTree, propInfo, propDef));
    PropertyState ps = pwTree.getProperty("any");
    assertNotNull(ps);
    assertSame(Type.BOOLEAN, ps.getType());
    assertTrue(ps.getValue(Type.BOOLEAN));
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 20 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class UserImporterPasswordTreeTest method testLastModifiedUndefinedRequiredType.

@Test
public void testLastModifiedUndefinedRequiredType() throws Exception {
    PropInfo propInfo = createPropInfo(REP_PASSWORD_LAST_MODIFIED, "23000");
    PropertyDefinition propDef = when(mock(PropertyDefinition.class).getRequiredType()).thenReturn(PropertyType.UNDEFINED).getMock();
    when(propDef.isMultiple()).thenReturn(false);
    assertTrue(importer.handlePropInfo(pwTree, propInfo, propDef));
    PropertyState ps = pwTree.getProperty(REP_PASSWORD_LAST_MODIFIED);
    assertNotNull(ps);
    assertSame(Type.LONG, ps.getType());
    assertEquals(23000, ps.getValue(Type.LONG).longValue());
    assertFalse(ps.isArray());
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Aggregations

PropInfo (org.apache.jackrabbit.oak.spi.xml.PropInfo)37 Test (org.junit.Test)26 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)15 Tree (org.apache.jackrabbit.oak.api.Tree)14 MockUtility.mockTree (org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.MockUtility.mockTree)8 TextValue (org.apache.jackrabbit.oak.spi.xml.TextValue)8 ArrayList (java.util.ArrayList)5 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)5 RepositoryException (javax.jcr.RepositoryException)4 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 SAXException (org.xml.sax.SAXException)4 User (org.apache.jackrabbit.api.security.user.User)3 NodeInfo (org.apache.jackrabbit.oak.spi.xml.NodeInfo)3 ImmutableList (com.google.common.collect.ImmutableList)2 IOException (java.io.IOException)2 List (java.util.List)2 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Reader (java.io.Reader)1 Map (java.util.Map)1