wstServer.waitForServerToStart();
// create faceted project
IProject bundleProject = projectRule.getProject();
ProjectAdapter project = new ProjectAdapter(bundleProject);
project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
// configure java project with dependencies
MavenDependency slingApiDep = new MavenDependency().groupId("org.apache.sling")
.artifactId("org.apache.sling.api").version("2.2.0");
MavenDependency servletApiDep = new MavenDependency().groupId("javax.servlet").artifactId("servlet-api")
.version("2.4");
project.configureAsJavaProject(slingApiDep, servletApiDep);
// create DS component class
InputStream simpleServlet = getClass().getResourceAsStream("SimpleServlet.java.v1.txt");
project.createOrUpdateFile(Path.fromPortableString("src/example/SimpleServlet.java"), simpleServlet);
// create DS component descriptor
InputStream servletDescriptor = getClass().getResourceAsStream("SimpleServlet.xml");
project.createOrUpdateFile(Path.fromPortableString("src/OSGI-INF/SimpleServlet.xml"), servletDescriptor);
// create manifest
OsgiBundleManifest manifest = OsgiBundleManifest.symbolicName("test.bundle001").version("1.0.0.SNAPSHOT")
.name("Test bundle").serviceComponent("OSGI-INF/SimpleServlet.xml")
.importPackage("javax.servlet,org.apache.sling.api,org.apache.sling.api.servlets");
project.createOsgiBundleManifest(manifest);
// install bundle facet
project.installFacet("sling.bundle", "1.0");
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.setAttribute(ISlingLaunchpadServer.PROP_INSTALL_LOCALLY, installBundleLocally);
server.installModule(bundleProject);
final RepositoryAccessor repo = new RepositoryAccessor(config);
Poller poller = new Poller();
poller.pollUntil(new Callable<Void>() {
@Override
public Void call() throws HttpException, IOException {
repo.assertGetIsSuccessful("simple-servlet", "Version 1");
return null;
}
}, nullValue(Void.class));
// update DS component class
InputStream simpleServlet2 = getClass().getResourceAsStream("SimpleServlet.java.v2.txt");
project.createOrUpdateFile(Path.fromPortableString("src/example/SimpleServlet.java"), simpleServlet2);
poller.pollUntil(new Callable<Void>() {
@Override
public Void call() throws HttpException, IOException {
repo.assertGetIsSuccessful("simple-servlet", "Version 2");