public void testHasPropertyByInvalidRelativePath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); List<String> wrongPaths = new ArrayList<String>(); wrongPaths.add("../jcr:primaryType"); wrongPaths.add("../../jcr:primaryType"); wrongPaths.add("../testing/jcr:primaryType"); for (String path : wrongPaths) { assertFalse(auth.hasProperty(path)); } List<String> invalidPaths = new ArrayList<String>(); invalidPaths.add(".."); invalidPaths.add("."); invalidPaths.add(null); for (String invalidPath : invalidPaths) { try { assertFalse(auth.hasProperty(invalidPath)); } catch (Exception e) { // success } } }
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 testGetNotExistingProperty() throws RepositoryException, NotExecutableException { Authorizable auth = getTestUser(superuser); String hint = "Fullname"; String propName = hint; int i = 0; while (auth.hasProperty(propName)) { propName = hint + i; i++; } assertNull(auth.getProperty(propName)); assertFalse(auth.hasProperty(propName)); }
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); } } }
for (Iterator<String> it = auth.getPropertyNames(); it.hasNext();) { String name = it.next(); assertFalse("Fullname".equals(name)); String rp = "testing/" + name; assertFalse(auth.hasProperty(name)); assertNull(auth.getProperty(name)); String rp = "testing/" + name; assertFalse(auth.hasProperty(name)); assertNull(auth.getProperty(name));
assertFalse(auth.hasProperty(propName));
assertFalse(auth.hasProperty(propName));