use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class ContentDeploymentTest method filedDeployedWithFullCoverageSiblingDoesNotCauseSpuriousDeletion.
@Test
public void filedDeployedWithFullCoverageSiblingDoesNotCauseSpuriousDeletion() throws Exception {
wstServer.waitForServerToStart();
// 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");
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.installModule(contentProject);
// create filter.xml
project.createVltFilterWithRoots("/test");
// create sling:Folder at /test/folder
project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/.content.xml"), getClass().getResourceAsStream("sling-folder-nodetype.xml"));
// create nt:file at /test/folder/hello.esp
project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/hello.esp"), new ByteArrayInputStream("// not really javascript".getBytes()));
// create sling:OsgiConfig at /test/folder/config.xml
project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/config.xml"), getClass().getResourceAsStream("com.example.some.Component.xml"));
// verify that config node is created
final RepositoryAccessor repo = new RepositoryAccessor(config);
Poller poller = new Poller();
assertThatNode(repo, poller, "/test/folder/config", hasPrimaryType("sling:OsgiConfig"));
// update file at /test/folder/hello.esp
project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/hello.esp"), new ByteArrayInputStream("// maybe javascript".getBytes()));
// wait until the file is updated
assertThatNode(repo, poller, "/test/folder/hello.esp", hasFileContent("// maybe javascript"));
// verify that the sling:OsgiConfig node is still present
assertThatNode(repo, poller, "/test/folder/config", hasPrimaryType("sling:OsgiConfig"));
}
use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class ContentDeploymentTest method deployFile.
@Test
public void deployFile() throws CoreException, InterruptedException, URIException, HttpException, IOException {
wstServer.waitForServerToStart();
// 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");
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.installModule(contentProject);
// create filter.xml
project.createVltFilterWithRoots("/test");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
// verify that file is created
final RepositoryAccessor repo = new RepositoryAccessor(config);
Poller poller = new Poller();
poller.pollUntil(new Callable<Void>() {
@Override
public Void call() throws HttpException, IOException {
repo.assertGetIsSuccessful("test/hello.txt", "hello, world");
return null;
}
}, nullValue(Void.class));
project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
// verify that file is updated
poller.pollUntil(new Callable<Void>() {
@Override
public Void call() throws HttpException, IOException {
repo.assertGetIsSuccessful("test/hello.txt", "goodbye, world");
return null;
}
}, nullValue(Void.class));
project.deleteMember(Path.fromPortableString("jcr_root/test/hello.txt"));
// verify that file is deleted
poller.pollUntil(new Callable<Void>() {
@Override
public Void call() throws HttpException, IOException {
repo.assertGetReturns404("test/hello.txt");
return null;
}
}, nullValue(Void.class));
}
use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class ContentDeploymentTest method fileDeployedBeforeAddingModuleToServerIsPublished.
@Test
public void fileDeployedBeforeAddingModuleToServerIsPublished() throws Throwable {
wstServer.waitForServerToStart();
// 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");
// create filter.xml
project.createVltFilterWithRoots("/test");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
// install bundle facet
project.installFacet("sling.content", "1.0");
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.installModule(contentProject);
// verify that file is created
final RepositoryAccessor repo = new RepositoryAccessor(config);
Poller poller = new Poller();
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/test/hello.txt");
}
}, hasFileContent("hello, world"));
}
Aggregations