Search in sources :

Example 1 with MavenDependency

use of org.apache.sling.ide.test.impl.helpers.MavenDependency in project sling by apache.

the class BundleDeploymentTest method deployBundleOnServer.

private void deployBundleOnServer(boolean installBundleLocally) throws Exception {
    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");
            return null;
        }
    }, nullValue(Void.class));
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) InputStream(java.io.InputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) OsgiBundleManifest(org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) HttpException(org.apache.commons.httpclient.HttpException) Poller(org.apache.sling.ide.test.impl.helpers.Poller) MavenDependency(org.apache.sling.ide.test.impl.helpers.MavenDependency)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HttpException (org.apache.commons.httpclient.HttpException)1 MavenDependency (org.apache.sling.ide.test.impl.helpers.MavenDependency)1 OsgiBundleManifest (org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest)1 Poller (org.apache.sling.ide.test.impl.helpers.Poller)1 ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)1 RepositoryAccessor (org.apache.sling.ide.test.impl.helpers.RepositoryAccessor)1 ServerAdapter (org.apache.sling.ide.test.impl.helpers.ServerAdapter)1 IProject (org.eclipse.core.resources.IProject)1