use of javax.jcr.Value in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testCreateValueDouble.
@Test
public void testCreateValueDouble() throws Exception {
Value v = syncCtx.createValue(Double.valueOf(1.1));
assertNotNull(v);
assertEquals(PropertyType.DOUBLE, v.getType());
assertEquals(1.1, v.getDouble(), 0);
v = syncCtx.createValue(Float.NaN);
assertNotNull(v);
assertEquals(PropertyType.DOUBLE, v.getType());
assertEquals(Float.NaN, v.getDouble(), 0);
}
use of javax.jcr.Value in project jackrabbit-oak by apache.
the class DefaultSyncHandlerTest method testRequiresSyncExpiredSyncProperty.
@Test
public void testRequiresSyncExpiredSyncProperty() throws Exception {
login(new SimpleCredentials(USER_ID, new char[0])).close();
root.refresh();
final Calendar nowCal = Calendar.getInstance();
nowCal.setTimeInMillis(nowCal.getTimeInMillis() - 1000);
Value nowValue = getValueFactory().createValue(nowCal);
Authorizable a = userManager.getAuthorizable(USER_ID);
a.setProperty(DefaultSyncContext.REP_LAST_SYNCED, nowValue);
root.commit();
SyncedIdentity id = syncHandler.findIdentity(userManager, USER_ID);
assertNotNull("known authorizable should exist", id);
assertTrue("synced id should require sync", syncHandler.requiresSync(id));
}
use of javax.jcr.Value in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncPropertiesMappingConstants.
@Test
public void testSyncPropertiesMappingConstants() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
sync(externalUser);
Authorizable a = userManager.getAuthorizable(externalUser.getId());
// create mapping that doesn't match to names in the external-properties
// -> previously synced properties must be removed
Map<String, String> mapping = new HashMap();
Map<String, ?> extProps = externalUser.getProperties();
for (String propName : extProps.keySet()) {
mapping.put(propName, "\"any\"");
}
syncCtx.syncProperties(externalUser, a, mapping);
Value anyValue = valueFactory.createValue("any");
for (String propName : extProps.keySet()) {
assertTrue(a.hasProperty(propName));
assertEquals(anyValue, a.getProperty(propName)[0]);
}
}
use of javax.jcr.Value in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncPropertiesEmptyMapExistingProps.
@Test
public void testSyncPropertiesEmptyMapExistingProps() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
Authorizable a = syncCtx.createUser(externalUser);
Value anyValue = valueFactory.createValue("any");
Map<String, ?> extProps = externalUser.getProperties();
for (String propName : extProps.keySet()) {
a.setProperty(propName, anyValue);
}
syncCtx.syncProperties(externalUser, a, ImmutableMap.<String, String>of());
for (String propName : extProps.keySet()) {
assertTrue(a.hasProperty(propName));
assertEquals(anyValue, a.getProperty(propName)[0]);
}
}
use of javax.jcr.Value in project jackrabbit by apache.
the class AbstractEntryTest method testCreateFromBase.
public void testCreateFromBase() throws RepositoryException, NotExecutableException {
Map<String, Value> testRestrictions = getTestRestrictions();
JackrabbitAccessControlEntry base = createEntry(testPrincipal, privilegesFromName(Privilege.JCR_READ), false, testRestrictions);
assertEquals(testPrincipal, base.getPrincipal());
assertTrue(Arrays.equals(privilegesFromName(Privilege.JCR_READ), base.getPrivileges()));
assertFalse(base.isAllow());
Map<String, Value> baseRestrictions = new HashMap<String, Value>();
for (String name : base.getRestrictionNames()) {
baseRestrictions.put(name, base.getRestriction(name));
}
assertEquals(testRestrictions, baseRestrictions);
JackrabbitAccessControlEntry entry = createEntryFromBase(base, privilegesFromName(Privilege.JCR_WRITE), true);
assertEquals(testPrincipal, entry.getPrincipal());
assertTrue(Arrays.equals(privilegesFromName(Privilege.JCR_WRITE), entry.getPrivileges()));
assertTrue(entry.isAllow());
Map<String, Value> entryRestrictions = new HashMap<String, Value>();
for (String name : entry.getRestrictionNames()) {
entryRestrictions.put(name, entry.getRestriction(name));
}
assertEquals(testRestrictions, entryRestrictions);
}
Aggregations