use of org.apache.jackrabbit.value.BooleanValue in project jackrabbit by apache.
the class EntryTest method testGetGlob.
public void testGetGlob() throws RepositoryException, NotExecutableException {
Privilege[] privs = privilegesFromName(Privilege.JCR_ALL);
JackrabbitAccessControlEntry pe = createEntry(testPrincipal, privs, true);
assertEquals(restrictions.get(glob), pe.getRestriction(glob));
assertEquals(PropertyType.STRING, pe.getRestriction(glob).getType());
Map<String, Value> restr = new HashMap<String, Value>();
restr.put(nodePath, restrictions.get(nodePath));
pe = createEntry(testPrincipal, privs, true, restr);
assertNull(pe.getRestriction(glob));
restr = new HashMap<String, Value>();
restr.put(nodePath, restrictions.get(nodePath));
restr.put(glob, new StringValue(""));
pe = createEntry(testPrincipal, privs, true, restr);
assertEquals("", pe.getRestriction(glob).getString());
restr = new HashMap<String, Value>();
restr.put(nodePath, restrictions.get(nodePath));
restr.put(glob, new BooleanValue(true));
assertEquals(PropertyType.STRING, pe.getRestriction(glob).getType());
}
use of org.apache.jackrabbit.value.BooleanValue in project jackrabbit by apache.
the class EntryTest method testTypeConversion.
public void testTypeConversion() throws RepositoryException, NotExecutableException {
// ACLTemplate impl tries to convert the property types if the don't
// match the required ones.
Privilege[] privs = privilegesFromName(Privilege.JCR_ALL);
Map<String, Value> restr = new HashMap<String, Value>();
restr.put(nodePath, new StringValue("/a/b/c/d"));
JackrabbitAccessControlEntry pe = createEntry(testPrincipal, privs, true, restr);
assertEquals("/a/b/c/d", pe.getRestriction(nodePath).getString());
assertEquals(PropertyType.PATH, pe.getRestriction(nodePath).getType());
restr = new HashMap<String, Value>();
restr.put(nodePath, restrictions.get(nodePath));
restr.put(glob, new BooleanValue(true));
pe = createEntry(testPrincipal, privs, true, restr);
assertEquals(true, pe.getRestriction(glob).getBoolean());
assertEquals(PropertyType.STRING, pe.getRestriction(glob).getType());
}
use of org.apache.jackrabbit.value.BooleanValue in project jackrabbit by apache.
the class EntryTest method testRestrictions.
public void testRestrictions() throws RepositoryException {
// test if restrictions with expanded name are properly resolved
Map<String, Value> restrictions = new HashMap<String, Value>();
restrictions.put(ACLTemplate.P_GLOB.toString(), superuser.getValueFactory().createValue("*/test"));
restrictions.put(ACLTemplate.P_NODE_PATH.toString(), superuser.getValueFactory().createValue("/a/b/c"));
Privilege[] privs = new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_ALL) };
ACLTemplate.Entry ace = (ACLTemplate.Entry) createEntry(testPrincipal, privs, true, restrictions);
Value v = ace.getRestriction(ACLTemplate.P_GLOB.toString());
Value v2 = ace.getRestriction(glob);
assertEquals(v, v2);
v = ace.getRestriction(ACLTemplate.P_NODE_PATH.toString());
v2 = ace.getRestriction(nodePath);
assertEquals(v, v2);
Map<String, Boolean> toMatch = new HashMap<String, Boolean>();
toMatch.put("/a/b/c", false);
toMatch.put("/a/b/ctest", false);
toMatch.put("/a/b/c/test", true);
toMatch.put("/a/b/c/something/test", true);
toMatch.put("/a/b/cde/test", true);
for (String str : toMatch.keySet()) {
assertEquals("Path to match : " + str, toMatch.get(str).booleanValue(), ace.matches(str));
}
}
Aggregations