Search in sources :

Example 11 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetBinaryProperty.

@Test
public void testGetBinaryProperty() {
    InputStream stream = mock(InputStream.class);
    Blob blob = mock(Blob.class);
    doReturn(stream).when(blob).getNewStream();
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.BINARY).when(property).getType();
    doReturn(blob).when(property).getValue(Type.BINARY);
    Tree tree = mock(Tree.class);
    doReturn(singletonList(property)).when(tree).getProperties();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public long getBinaryThreshold() {
            return Long.MAX_VALUE;
        }
    });
    Map<String, RemoteValue> properties = remoteTree.getProperties();
    assertTrue(properties.containsKey("name"));
    assertTrue(properties.get("name").isBinary());
    assertEquals(stream, properties.get("name").asBinary().get());
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) InputStream(java.io.InputStream) RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 12 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetChildrenWithNegativeCount.

@Test
public void testGetChildrenWithNegativeCount() {
    Tree foo = mock(Tree.class);
    doReturn("foo").when(foo).getName();
    Tree bar = mock(Tree.class);
    doReturn("bar").when(bar).getName();
    Tree tree = mock(Tree.class);
    doReturn(asList(foo, bar)).when(tree).getChildren();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public int getChildrenCount() {
            return -1;
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertTrue(children.containsKey("foo"));
    assertTrue(children.containsKey("bar"));
}
Also used : RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Test(org.junit.Test)

Example 13 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetChildrenWithCountTooBig.

@Test
public void testGetChildrenWithCountTooBig() {
    Tree foo = mock(Tree.class);
    doReturn("foo").when(foo).getName();
    Tree bar = mock(Tree.class);
    doReturn("bar").when(bar).getName();
    Tree tree = mock(Tree.class);
    doReturn(asList(foo, bar)).when(tree).getChildren();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public int getChildrenCount() {
            return 3;
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertTrue(children.containsKey("foo"));
    assertTrue(children.containsKey("bar"));
}
Also used : RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Test(org.junit.Test)

Example 14 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testFilterPropertyIn.

@Test
public void testFilterPropertyIn() {
    PropertyState fooProperty = mock(PropertyState.class);
    doReturn("foo").when(fooProperty).getName();
    doReturn(Type.BOOLEAN).when(fooProperty).getType();
    doReturn(true).when(fooProperty).getValue(Type.BOOLEAN);
    PropertyState barProperty = mock(PropertyState.class);
    doReturn("bar").when(barProperty).getName();
    doReturn(Type.BOOLEAN).when(barProperty).getType();
    doReturn(true).when(barProperty).getValue(Type.BOOLEAN);
    Tree tree = mock(Tree.class);
    doReturn(asList(fooProperty, barProperty)).when(tree).getProperties();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public Set<String> getPropertyFilters() {
            return newHashSet("foo");
        }
    });
    Map<String, RemoteValue> properties = remoteTree.getProperties();
    assertTrue(properties.containsKey("foo"));
    assertFalse(properties.containsKey("bar"));
}
Also used : Sets.newHashSet(com.google.common.collect.Sets.newHashSet) Set(java.util.Set) RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 15 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetChildrenWithZeroCount.

@Test
public void testGetChildrenWithZeroCount() {
    Tree foo = mock(Tree.class);
    doReturn("foo").when(foo).getName();
    Tree bar = mock(Tree.class);
    doReturn("bar").when(bar).getName();
    Tree tree = mock(Tree.class);
    doReturn(asList(foo, bar)).when(tree).getChildren();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public int getChildrenCount() {
            return 0;
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertFalse(children.containsKey("foo"));
    assertFalse(children.containsKey("bar"));
}
Also used : RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Test(org.junit.Test)

Aggregations

RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)19 Tree (org.apache.jackrabbit.oak.api.Tree)17 RemoteTreeFilters (org.apache.jackrabbit.oak.remote.RemoteTreeFilters)17 Test (org.junit.Test)17 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)5 Set (java.util.Set)5 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)4 InputStream (java.io.InputStream)2 Blob (org.apache.jackrabbit.oak.api.Blob)2 RemoteRevision (org.apache.jackrabbit.oak.remote.RemoteRevision)2 RemoteSession (org.apache.jackrabbit.oak.remote.RemoteSession)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 ServletOutputStream (javax.servlet.ServletOutputStream)1