public void testSetPropertyByRelPath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); Value[] v = new Value[] {superuser.getValueFactory().createValue("Super User")}; List<String> relPaths = new ArrayList<String>(); relPaths.add("testing/Fullname"); relPaths.add("testing/Email"); relPaths.add("testing/testing/testing/Fullname"); relPaths.add("testing/testing/testing/Email"); for (String relPath : relPaths) { try { auth.setProperty(relPath, v); save(superuser); assertTrue(auth.hasProperty(relPath)); String propName = Text.getName(relPath); assertFalse(auth.hasProperty(propName)); } finally { // try to remove the property even if previous calls failed. auth.removeProperty(relPath); save(superuser); } } }
public void testRemoveNotExistingProperty() throws RepositoryException, NotExecutableException { Authorizable auth = getTestUser(superuser); String hint = "Fullname"; String propName = hint; int i = 0; while (auth.hasProperty(propName)) { propName = hint + i; i++; } assertFalse(auth.removeProperty(propName)); save(superuser); }
public void testGetPropertyNames() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); // TODO: retrieve propname and value from config String propName = "Fullname"; Value v = superuser.getValueFactory().createValue("Super User"); try { auth.setProperty(propName, v); save(superuser); } catch (RepositoryException e) { throw new NotExecutableException("Cannot test 'Authorizable.setProperty'."); } try { for (Iterator<String> it = auth.getPropertyNames(); it.hasNext();) { String name = it.next(); assertTrue(auth.hasProperty(name)); assertNotNull(auth.getProperty(name)); } } finally { // try to remove the property again even if previous calls failed. auth.removeProperty(propName); save(superuser); } }