use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.
the class ContentImportTest method importFullCoverageNode.
@Test
public void importFullCoverageNode() 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");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/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.doWithSession(new SessionRunnable<Void>() {
@Override
public Void doWithSession(Session session) throws RepositoryException {
Node configNode = session.getRootNode().addNode("content/test-root/org.apache.sling.example.Component.config", "sling:OsgiConfig");
configNode.setProperty("enabled", Boolean.TRUE.toString());
session.save();
return null;
}
});
runImport(contentProject);
assertThat(contentProject, hasFile("jcr_root/content/test-root/org.apache.sling.example.Component.config.xml"));
}
use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.
the class ContentImportTest method importFromRepositoryWithNtUnstructuredNodeWithNoPropertiesCausesSpuriousLocalDeletion.
@Test
public void importFromRepositoryWithNtUnstructuredNodeWithNoPropertiesCausesSpuriousLocalDeletion() throws Exception {
RepositoryAccessor repo = new RepositoryAccessor(config);
repo.createNode("/content/test-root/en", "nt:folder");
// 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");
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();
repo.createNode("/content/test-root/folder", "sling:Folder");
repo.createNode("/content/test-root/folder/jcr:content", "nt:unstructured");
repo.createFile("/content/test-root/folder/jcr:content/some_file.txt", "dummy contents".getBytes());
repo.doWithSession(new SessionRunnable<Void>() {
@Override
public Void doWithSession(Session session) throws RepositoryException {
session.getRootNode().getNode("content/test-root/folder/jcr:content/some_file.txt/jcr:content").setProperty("jcr:mimeType", "x-vendor-reserved");
session.save();
return null;
}
});
// run initial import
runImport(contentProject);
assertThat(contentProject, hasFile("jcr_root/content/test-root/folder/_jcr_content/some_file.txt.dir/.content.xml"));
// run second import
runImport(contentProject);
assertThat(contentProject, hasFile("jcr_root/content/test-root/folder/_jcr_content/some_file.txt.dir/.content.xml"));
}
use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.
the class ContentImportTest method importFilesAndFoldersRespectsVltIgnoreNotUnderImportRoot.
@Test
public void importFilesAndFoldersRespectsVltIgnoreNotUnderImportRoot() 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/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
project.createOrUpdateFile(Path.fromPortableString("jcr_root/.vltignore"), new ByteArrayInputStream("content/test-root/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.RepositoryAccessor in project sling by apache.
the class ContentImportTest method importFilesWithExtraNodesUnderJcrContent.
@Test
public void importFilesWithExtraNodesUnderJcrContent() 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");
// create filter.xml
project.createVltFilterWithRoots("/content/test-root");
// create sling:Folder at /content/test-root
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), getClass().getResourceAsStream("sling-folder-nodetype.xml"));
wstServer.waitForServerToStart();
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.installModule(contentProject);
deh.clearUnexpectedEventsAfterSettling();
// create server-side content
RepositoryAccessor repo = new RepositoryAccessor(config);
repo.tryDeleteResource("/content/test-root");
repo.createNode("/content/test-root", "sling:Folder");
repo.createFile("/content/test-root/file.txt", "hello, world".getBytes());
repo.doWithSession(new SessionRunnable<Void>() {
@Override
public Void doWithSession(Session session) throws RepositoryException {
ValueFactory valueFactory = session.getValueFactory();
Node contentNode = session.getNode("/content/test-root/file.txt/jcr:content");
contentNode.addMixin("sling:chunks");
Node chunkNode = contentNode.addNode("firstChunk", "sling:chunk");
chunkNode.setProperty("sling:offset", valueFactory.createValue(0));
chunkNode.setProperty("jcr:data", valueFactory.createValue(valueFactory.createBinary(new ByteArrayInputStream("hello, world".getBytes()))));
session.save();
return null;
}
});
assertThat(repo.getNode("/content/test-root").getPrimaryNodeType().getName(), equalTo("sling:Folder"));
runImport(contentProject);
assertThat("File not properly imported", contentProject, hasFile("jcr_root/content/test-root/file.txt", "hello, world".getBytes()));
assertThat("File extra serialization dir not imported", contentProject, hasFolder("jcr_root/content/test-root/file.txt.dir"));
assertThat("File jcr:content data not serialized in .content.xml", contentProject, hasFile("jcr_root/content/test-root/file.txt.dir/.content.xml"));
assertThat("File jcr:content extra dir not serialized as _jcr_content", contentProject, hasFolder("jcr_root/content/test-root/file.txt.dir/_jcr_content"));
assertThat("First chunk dir not serialized", contentProject, hasFolder("jcr_root/content/test-root/file.txt.dir/_jcr_content/firstChunk"));
assertThat("First chunk properties not serialized", contentProject, hasFile("jcr_root/content/test-root/file.txt.dir/_jcr_content/firstChunk/.content.xml"));
assertThat("Sling folder serialization file was deleted after import", contentProject, hasFile("jcr_root/content/test-root/.content.xml"));
}
use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor 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()));
}
Aggregations