use of javax.jcr.Property in project jackrabbit by apache.
the class TokenProviderTest method testTokenNode.
public void testTokenNode() throws Exception {
Map<String, String> privateAttributes = new HashMap<String, String>();
privateAttributes.put(".token_exp", "value");
privateAttributes.put(".tokenTest", "value");
privateAttributes.put(".token_something", "value");
Map<String, String> publicAttributes = new HashMap<String, String>();
publicAttributes.put("any", "value");
publicAttributes.put("another", "value");
Map<String, String> attributes = new HashMap<String, String>();
attributes.putAll(publicAttributes);
attributes.putAll(privateAttributes);
SimpleCredentials sc = new SimpleCredentials(userId, userId.toCharArray());
for (String s : attributes.keySet()) {
sc.setAttribute(s, attributes.get(s));
}
TokenInfo info = tokenProvider.createToken(testuser, sc);
Node tokenNode = getTokenNode(info);
Property prop = tokenNode.getProperty("rep:token.key");
assertNotNull(prop);
assertEquals(PropertyType.STRING, prop.getType());
assertTrue(prop.getDefinition().isProtected());
prop = tokenNode.getProperty("rep:token.exp");
assertNotNull(prop);
assertEquals(PropertyType.DATE, prop.getType());
assertTrue(prop.getDefinition().isProtected());
for (String key : privateAttributes.keySet()) {
assertEquals(privateAttributes.get(key), tokenNode.getProperty(key).getString());
}
for (String key : publicAttributes.keySet()) {
assertEquals(publicAttributes.get(key), tokenNode.getProperty(key).getString());
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class CopyFrozenUuidTest method testCopyFrozenUuidProperty.
public void testCopyFrozenUuidProperty() throws Exception {
Node firstNode = testRootNode.addNode(nodeName1);
firstNode.setPrimaryType(JcrConstants.NT_UNSTRUCTURED);
firstNode.addMixin(JcrConstants.MIX_VERSIONABLE);
firstNode.getSession().save();
// create version for the node
Version firstNodeVersion = firstNode.checkin();
firstNode.checkout();
Node secondNode = testRootNode.addNode(nodeName2);
secondNode.setPrimaryType(JcrConstants.NT_UNSTRUCTURED);
secondNode.addMixin(JcrConstants.MIX_VERSIONABLE);
Property firstNodeVersionFrozenUuid = firstNodeVersion.getFrozenNode().getProperty(JcrConstants.JCR_FROZENUUID);
secondNode.setProperty(JcrConstants.JCR_FROZENUUID, firstNodeVersionFrozenUuid.getValue());
secondNode.getSession().save();
// create version of the second node
Version secondNodeVersion = secondNode.checkin();
secondNode.checkout();
// frozenUuid from the second node version node should not be the same as the one from the first node version
Property secondBodeVersionFrozenUuid = secondNodeVersion.getFrozenNode().getProperty(JcrConstants.JCR_FROZENUUID);
assertFalse(JcrConstants.JCR_FROZENUUID + " should not be the same for two different versions of different nodes! ", secondBodeVersionFrozenUuid.getValue().equals(firstNodeVersionFrozenUuid.getValue()));
}
use of javax.jcr.Property in project jackrabbit by apache.
the class RemoveOrphanVersionHistoryTest method testEmptyNonOrphanVersionHistory.
/**
* Test that an emptied version history that is still being referenced
* from another workspace does not get removed.
*
* @throws RepositoryException if an error occurs.
*/
public void testEmptyNonOrphanVersionHistory() throws RepositoryException {
Session session = testRootNode.getSession();
// Create versionable test node
Node node = testRootNode.addNode(nodeName1);
node.addMixin(mixVersionable);
session.save();
VersionHistory history = node.getVersionHistory();
String uuid = history.getUUID();
// Create version 1.0
Version v10 = node.checkin();
// Remove the test node
node.checkout();
node.remove();
session.save();
Session otherSession = getHelper().getReadWriteSession(workspaceName);
try {
// create a reference to the version history in another workspace
Node otherRoot = otherSession.getRootNode();
Property reference = otherRoot.setProperty("RemoveOrphanVersionTest", uuid, PropertyType.REFERENCE);
otherSession.save();
// Now remove the contents of the version history
history.removeVersion(v10.getName());
// Check that the version history still exists!
try {
session.getNodeByUUID(uuid);
} catch (ItemNotFoundException e) {
fail("Referenced empty version history must note be removed");
}
// Cleanup
reference.remove();
otherSession.save();
} finally {
otherSession.logout();
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class GetWeakReferencesTest method testSingleValueWithName.
public void testSingleValueWithName() throws RepositoryException {
Value weakRef = vf.createValue(target, true);
referring.setProperty(propertyName1, weakRef);
superuser.save();
PropertyIterator it = target.getWeakReferences(propertyName1);
assertTrue("no weak references returned", it.hasNext());
Property p = it.nextProperty();
assertEquals("wrong weak reference property", referring.getProperty(propertyName1).getPath(), p.getPath());
assertFalse("no more weak references expected", it.hasNext());
}
use of javax.jcr.Property in project jackrabbit by apache.
the class GetWeakReferencesTest method testMultiValuesWithName.
public void testMultiValuesWithName() throws RepositoryException {
Value weakRef = vf.createValue(target, true);
Value[] refs = new Value[] { weakRef, weakRef };
referring.setProperty(propertyName1, refs);
superuser.save();
PropertyIterator it = target.getWeakReferences(propertyName1);
assertTrue("no weak references returned", it.hasNext());
Property p = it.nextProperty();
assertEquals("wrong weak reference property", referring.getProperty(propertyName1).getPath(), p.getPath());
assertFalse("no more weak references expected", it.hasNext());
}
Aggregations