Search in sources :

Example 16 with ResourceProxy

use of org.apache.sling.ide.transport.ResourceProxy in project sling by apache.

the class ContentXmlHandlerTest method emptyMultivaluedProperties.

@Test
public void emptyMultivaluedProperties() throws Exception {
    ResourceProxy root = parseContentXmlFile("empty-multivalued-property.xml", "/");
    assertThat("properties[labels]", (String[]) root.getProperties().get("labels"), Matchers.arrayWithSize(0));
    assertThat("properties[values]", (Long[]) root.getProperties().get("values"), Matchers.arrayWithSize(0));
}
Also used : ResourceProxy(org.apache.sling.ide.transport.ResourceProxy) Test(org.junit.Test)

Example 17 with ResourceProxy

use of org.apache.sling.ide.transport.ResourceProxy in project sling by apache.

the class ContentXmlHandlerTest method escapedCommaInMultiValuedProperty.

@Test
public void escapedCommaInMultiValuedProperty() throws Exception {
    ResourceProxy root = parseContentXmlFile("escaped-comma-in-multi-valued-property.xml", "/");
    assertThat("properties[someProp]", (String[]) root.getProperties().get("someProp"), Matchers.is(new String[] { "first,first", "second" }));
}
Also used : ResourceProxy(org.apache.sling.ide.transport.ResourceProxy) Test(org.junit.Test)

Example 18 with ResourceProxy

use of org.apache.sling.ide.transport.ResourceProxy in project sling by apache.

the class DefaultBatcherTest method identicalAddOrUpdatesAreCompacted.

@Test
public void identicalAddOrUpdatesAreCompacted() {
    AddOrUpdateNodeCommand first = new AddOrUpdateNodeCommand(mockRepo, credentials, null, null, new ResourceProxy("/content"), null);
    AddOrUpdateNodeCommand second = new AddOrUpdateNodeCommand(mockRepo, credentials, null, null, new ResourceProxy("/content"), null);
    batcher.add(first);
    batcher.add(second);
    List<Command<?>> batched = batcher.get();
    assertThat(batched, hasSize(1));
    Command<?> command = batched.get(0);
    assertThat(command, instanceOf(AddOrUpdateNodeCommand.class));
    assertThat(command.getPath(), equalTo("/content"));
}
Also used : AddOrUpdateNodeCommand(org.apache.sling.ide.impl.vlt.AddOrUpdateNodeCommand) ReorderChildNodesCommand(org.apache.sling.ide.impl.vlt.ReorderChildNodesCommand) DeleteNodeCommand(org.apache.sling.ide.impl.vlt.DeleteNodeCommand) GetNodeContentCommand(org.apache.sling.ide.impl.vlt.GetNodeContentCommand) Command(org.apache.sling.ide.transport.Command) AddOrUpdateNodeCommand(org.apache.sling.ide.impl.vlt.AddOrUpdateNodeCommand) ResourceProxy(org.apache.sling.ide.transport.ResourceProxy) Test(org.junit.Test)

Example 19 with ResourceProxy

use of org.apache.sling.ide.transport.ResourceProxy in project sling by apache.

the class AddOrUpdateNodeCommandTest method nodeNotPresentButOutsideOfFilterIsNotRemoved.

@Test
public void nodeNotPresentButOutsideOfFilterIsNotRemoved() throws Exception {
    final CommandContext context = new CommandContext(new Filter() {

        @Override
        public FilterResult filter(String repositoryPath) {
            if (repositoryPath.equals("/content/not-included-child")) {
                return FilterResult.DENY;
            }
            return FilterResult.ALLOW;
        }
    });
    doWithTransientRepository(new CallableWithSession() {

        @Override
        public Void call() throws Exception {
            Node content = session().getRootNode().addNode("content", "nt:unstructured");
            content.addNode("included-child");
            content.addNode("not-included-child");
            session().save();
            ResourceProxy resource = newResource("/content", "nt:unstructured");
            resource.addChild(newResource("/content/included-child", "nt:unstructured"));
            AddOrUpdateNodeCommand cmd = new AddOrUpdateNodeCommand(repo(), credentials(), context, null, resource, logger);
            cmd.execute().get();
            session().refresh(false);
            content = session().getRootNode().getNode("content");
            content.getNode("included-child");
            content.getNode("not-included-child");
            return null;
        }
    });
}
Also used : CommandContext(org.apache.sling.ide.transport.CommandContext) Filter(org.apache.sling.ide.filter.Filter) Node(javax.jcr.Node) FilterResult(org.apache.sling.ide.filter.FilterResult) NodeTypeExistsException(javax.jcr.nodetype.NodeTypeExistsException) InvalidNodeTypeDefinitionException(javax.jcr.nodetype.InvalidNodeTypeDefinitionException) RepositoryException(javax.jcr.RepositoryException) ParseException(org.apache.jackrabbit.commons.cnd.ParseException) IOException(java.io.IOException) UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) ResourceProxy(org.apache.sling.ide.transport.ResourceProxy) Test(org.junit.Test)

Example 20 with ResourceProxy

use of org.apache.sling.ide.transport.ResourceProxy in project sling by apache.

the class ContentXmlHandlerTest method encodedChildContentXml.

@Test
public void encodedChildContentXml() throws ParserConfigurationException, SAXException, IOException {
    ResourceProxy root = parseContentXmlFile("encoded-child-content.xml", "/ROOT");
    assertThat("/ROOT contains /_jcr_content", root.getChildren(), hasChildPath("/ROOT/_jcr_content"));
}
Also used : ResourceProxy(org.apache.sling.ide.transport.ResourceProxy) Test(org.junit.Test)

Aggregations

ResourceProxy (org.apache.sling.ide.transport.ResourceProxy)42 Test (org.junit.Test)14 Node (javax.jcr.Node)8 NodeIterator (javax.jcr.NodeIterator)5 IPath (org.eclipse.core.runtime.IPath)5 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 HashMap (java.util.HashMap)4 FilterResult (org.apache.sling.ide.filter.FilterResult)4 IFile (org.eclipse.core.resources.IFile)4 IFolder (org.eclipse.core.resources.IFolder)4 Filter (org.apache.sling.ide.filter.Filter)3 RepositoryException (org.apache.sling.ide.transport.RepositoryException)3 JsonReader (com.google.gson.stream.JsonReader)2 JsonToken (com.google.gson.stream.JsonToken)2 File (java.io.File)2 InputStreamReader (java.io.InputStreamReader)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2