use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class ContentImportTest method importFilesAndFolders.
@Test
public void importFilesAndFolders() throws Exception {
// create faceted project
IProject contentProject = projectRule.getProject();
ProjectAdapter project = new ProjectAdapter(contentProject);
project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
// install bundle facet
project.installFacet("sling.content", "1.0");
wstServer.waitForServerToStart();
project.createVltFilterWithRoots("/content/test-root/en");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.installModule(contentProject);
deh.clearUnexpectedEventsAfterSettling();
// create server-side content
RepositoryAccessor repo = new RepositoryAccessor(config);
repo.createNode("/content/test-root/en", "nt:folder");
repo.createNode("/content/test-root/en/files", "nt:folder");
repo.createFile("/content/test-root/en/files/first.txt", "first file".getBytes());
runImport(contentProject);
assertThat(contentProject, hasFolder("jcr_root/content/test-root/en/files"));
assertThat(contentProject, hasFile("jcr_root/content/test-root/en/files/first.txt", "first file".getBytes()));
}
use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class ContentResourceTesterTest method slingContentProjectUnrelatedResourcesAreNotExportable.
@Test
public void slingContentProjectUnrelatedResourcesAreNotExportable() throws CoreException, InterruptedException {
// create faceted project
IProject contentProject = projectRule.getProject();
ProjectAdapter project = new ProjectAdapter(contentProject);
project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
// install bundle facet
project.installFacet("sling.content", "1.0");
project.createOrUpdateFile(Path.fromPortableString("res/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
assertThat("Dir not under content sync dir can not be exported", new ContentResourceTester().test(contentProject.findMember("res"), "canBeExported", null, null), equalTo(false));
assertThat("File not under content sync dir can not be exported", new ContentResourceTester().test(contentProject.findMember("res/hello.txt"), "canBeExported", null, null), equalTo(false));
}
use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class ContentImportTest method importFilesAndFoldersRespectsVltIgnore.
@Test
public void importFilesAndFoldersRespectsVltIgnore() throws Exception {
// create faceted project
IProject contentProject = projectRule.getProject();
ProjectAdapter project = new ProjectAdapter(contentProject);
project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
// install bundle facet
project.installFacet("sling.content", "1.0");
wstServer.waitForServerToStart();
project.createVltFilterWithRoots("/content/test-root/en");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.vltignore"), new ByteArrayInputStream("en\n".getBytes()));
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.installModule(contentProject);
deh.clearUnexpectedEventsAfterSettling();
// create server-side content
RepositoryAccessor repo = new RepositoryAccessor(config);
repo.createNode("/content/test-root/en", "nt:folder");
repo.createNode("/content/test-root/en/files", "nt:folder");
repo.createFile("/content/test-root/en/files/first.txt", "first file".getBytes());
runImport(contentProject);
assertThat(contentProject.findMember("jcr_root/content/test-root/en"), nullValue());
}
use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class JcrContentContentProviderTest method prepareProject.
@Before
public void prepareProject() throws Exception {
contentProject = projectRule.getProject();
project = new ProjectAdapter(contentProject);
project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
// install content facet
project.installFacet("sling.content", "1.0");
}
use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class JcrPartialCoverageAggregatesDeploymentTest method deployNodeWithChildrenAndOrderableNodeTypes.
@Test
public void deployNodeWithChildrenAndOrderableNodeTypes() throws Exception {
wstServer.waitForServerToStart();
// create faceted project
IProject contentProject = projectRule.getProject();
ProjectAdapter project = new ProjectAdapter(contentProject);
project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
// install content facet
project.installFacet("sling.content", "1.0");
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.installModule(contentProject);
// create filter.xml
project.createVltFilterWithRoots("/content");
// create a sling:Folder at /content/test-root
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), getClass().getResourceAsStream("sling-folder-nodetype.xml"));
// create a nt:unstructured at /content/test-root/nested
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/nested/.content.xml"), getClass().getResourceAsStream("nt-unstructured-nodetype.xml"));
// create a nt:unstructured at /content/test-root/nested/nested
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/nested/nested/.content.xml"), getClass().getResourceAsStream("nt-unstructured-nodetype.xml"));
Matcher<Node> postConditions = allOf(hasPath("/content/test-root/nested"), hasPrimaryType("nt:unstructured"), hasChildrenCount(1));
final RepositoryAccessor repo = new RepositoryAccessor(config);
Poller poller = new Poller();
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/content/test-root/nested");
}
}, postConditions);
// update jcr:title for /content/test-root
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/nested/.content.xml"), getClass().getResourceAsStream("nt-unstructured-nodetype-with-title.xml"));
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/content/test-root/nested");
}
}, allOf(hasPath("/content/test-root/nested"), hasChildrenCount(1), hasPropertyValue("jcr:title", "Some Folder")));
}
Aggregations