@Test public void testGetPropertyNamesByInvalidRelPath() throws NotExecutableException, RepositoryException { List<String> invalidPaths = new ArrayList<String>(); invalidPaths.add(""); invalidPaths.add("/"); invalidPaths.add("../"); invalidPaths.add("../../"); invalidPaths.add("../testing"); invalidPaths.add("/testing"); invalidPaths.add(null); for (String invalidRelPath : invalidPaths) { try { user.getPropertyNames(invalidRelPath); fail("Calling Authorizable#getPropertyNames with " + invalidRelPath + " must fail."); } catch (RepositoryException e) { // success } } }
for (Iterator<String> it = user.getPropertyNames(); it.hasNext() && !found;) { found = propName.equals(it.next()); for (Iterator<String> it = user.getPropertyNames("."); it.hasNext() && !found;) { found = propName.equals(it.next());
@Test public void testGetPropertyNames() throws NotExecutableException, RepositoryException { String propName = "Fullname"; Value v = superuser.getValueFactory().createValue("Super User"); try { user.setProperty(propName, v); superuser.save(); } catch (RepositoryException e) { throw new NotExecutableException("Cannot test 'Authorizable.setProperty'."); } try { for (Iterator<String> it = user.getPropertyNames(); it.hasNext();) { String name = it.next(); assertTrue(user.hasProperty(name)); assertNotNull(user.getProperty(name)); } } finally { // try to remove the property again even if previous calls failed. user.removeProperty(propName); superuser.save(); } }
for (Iterator<String> it = user.getPropertyNames(); it.hasNext();) { String name = it.next(); assertFalse("Fullname".equals(name)); for (Iterator<String> it = user.getPropertyNames("testing"); it.hasNext();) { String name = it.next(); String rp = "testing/" + name; assertNotNull(user.getProperty(rp)); for (Iterator<String> it = user.getPropertyNames("./testing"); it.hasNext();) { String name = it.next(); String rp = "testing/" + name;
for (Iterator<String> it = user.getPropertyNames(); it.hasNext() && !found;) { found = propName.equals(it.next()); for (Iterator<String> it = user.getPropertyNames("."); it.hasNext() && !found;) { found = propName.equals(it.next());