Search in sources :

Example 66 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class GarbageCollectorTest method testTransientObjects.

public void testTransientObjects() throws Exception {
    Node root = testRootNode;
    Session session = root.getSession();
    deleteMyNodes();
    Credentials cred = getHelper().getSuperuserCredentials();
    Session s2 = getHelper().getRepository().login(cred);
    root = s2.getRootNode();
    Node node2 = root.addNode("node3");
    Node n = node2.addNode("nodeWithBlob");
    ValueFactory vf = session.getValueFactory();
    n.setProperty("test", vf.createBinary(new RandomInputStream(10, 1000)));
    runGC(session, false);
    s2.save();
    InputStream in = n.getProperty("test").getBinary().getStream();
    InputStream in2 = new RandomInputStream(10, 1000);
    verifyInputStream(in, in2);
    deleteMyNodes();
    s2.logout();
}
Also used : InputStream(java.io.InputStream) Node(javax.jcr.Node) ValueFactory(javax.jcr.ValueFactory) Credentials(javax.jcr.Credentials) Session(javax.jcr.Session)

Example 67 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class PathTest method testCreatePathValue.

public void testCreatePathValue() throws RepositoryException {
    ValueFactory vf = superuser.getValueFactory();
    Value pathValue = vf.createValue("[" + identifier + "]", PropertyType.PATH);
    assertEquals(PropertyType.PATH, pathValue.getType());
    assertEquals("[" + identifier + "]", pathValue.getString());
    assertFalse(pathValue.equals(vf.createValue(testRootNode.getPath(), PropertyType.PATH)));
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory)

Example 68 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class PathTest method testCreateMultiplePathValue.

public void testCreateMultiplePathValue() throws RepositoryException {
    ValueFactory vf = superuser.getValueFactory();
    Value vID1 = vf.createValue("[" + identifier + "]", PropertyType.PATH);
    Value v = vf.createValue(testRootNode.getPath(), PropertyType.PATH);
    Value vID2 = vf.createValue("[" + identifier + "]", PropertyType.PATH);
    Value v2 = vf.createValue(testRootNode.getPath(), PropertyType.PATH);
    assertEquals(vID1, vID2);
    assertEquals(v, v2);
    assertFalse(v.equals(vID1));
    assertFalse(v.equals(vID2));
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory)

Example 69 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class PathTest method testIdentifierBasedPropertyValue.

public void testIdentifierBasedPropertyValue() throws RepositoryException {
    ValueFactory vf = superuser.getValueFactory();
    Value pathValue = vf.createValue("[" + identifier + "]", PropertyType.PATH);
    Property p = testRootNode.setProperty(propertyName1, pathValue);
    assertEquals(PropertyType.PATH, p.getType());
    assertEquals(pathValue.getString(), p.getValue().getString());
    assertEquals(pathValue, p.getValue());
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory) Property(javax.jcr.Property)

Example 70 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class PathTest method testExtendedNameBasedPathValue.

public void testExtendedNameBasedPathValue() throws RepositoryException {
    ValueFactory vf = superuser.getValueFactory();
    Value pathValue = vf.createValue(Workspace.PATH_VERSION_STORAGE_NODE, PropertyType.PATH);
    Property p = testRootNode.setProperty(propertyName1, pathValue);
    assertEquals("/jcr:system/jcr:versionStorage", p.getString());
    String path = Workspace.PATH_VERSION_STORAGE_NODE + "/a/b/c/jcr:frozenNode";
    pathValue = vf.createValue(path, PropertyType.PATH);
    p = testRootNode.setProperty(propertyName1, pathValue);
    assertEquals("/jcr:system/jcr:versionStorage/a/b/c/jcr:frozenNode", p.getString());
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory) Property(javax.jcr.Property)

Aggregations

ValueFactory (javax.jcr.ValueFactory)105 Value (javax.jcr.Value)51 Node (javax.jcr.Node)50 Session (javax.jcr.Session)40 Test (org.junit.Test)17 RepositoryException (javax.jcr.RepositoryException)16 InputStream (java.io.InputStream)13 AccessControlManager (javax.jcr.security.AccessControlManager)13 HashMap (java.util.HashMap)12 Privilege (javax.jcr.security.Privilege)12 Property (javax.jcr.Property)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Query (javax.jcr.query.Query)8 Calendar (java.util.Calendar)7 QueryManager (javax.jcr.query.QueryManager)7 RowIterator (javax.jcr.query.RowIterator)7 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)7 NodeIterator (javax.jcr.NodeIterator)6 JackrabbitNode (org.apache.jackrabbit.api.JackrabbitNode)6 IOException (java.io.IOException)5