Java Code Examples for org.wildfly.swarm.Swarm#deploy()

The following examples show how to use org.wildfly.swarm.Swarm#deploy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeploymentFailureTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeploymentFailure() throws Exception {
    Swarm swarm = new Swarm();
    swarm.start();
    JARArchive a = ShrinkWrap.create(JARArchive.class, "bad-deployment.jar");
    a.addModule("com.i.do.no.exist");
    try {
        swarm.deploy(a);
        fail("should have throw a DeploymentException");
    } catch (DeploymentException e) {
        // expected and correct
        assertThat(e.getArchive()).isSameAs(a);
        assertThat(e.getMessage()).contains("org.jboss.modules.ModuleNotFoundException: com.i.do.no.exist");
    } finally {
        swarm.stop();
    }
}
 
Example 2
Source File: Main.java    From thorntail with Apache License 2.0 6 votes vote down vote up
public static void main(String... args) throws Exception {
    swarm = new Swarm(args);
    swarm.start();
    Archive<?> deployment = swarm.createDefaultDeployment();
    if (deployment == null) {
        throw new Error("Couldn't create default deployment");
    }

    Node persistenceXml = deployment.get("WEB-INF/classes/META-INF/persistence.xml");

    if (persistenceXml == null) {
        throw new Error("persistence.xml is not found");
    }

    if (persistenceXml.getAsset() == null) {
        throw new Error("persistence.xml is not found");
    }

    swarm.deploy(deployment);
}
 
Example 3
Source File: DeploymentSuccessTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeploymentSuccess() throws Exception {
    Swarm swarm = new Swarm();
    swarm.start();
    JARArchive a = ShrinkWrap.create(JARArchive.class, "good-deployment.jar");
    a.add(EmptyAsset.INSTANCE, "nothing.xml");
    swarm.deploy(a);
    swarm.stop();
}
 
Example 4
Source File: Main.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public static void main(String... args) throws Exception {
    swarm = new Swarm(args);
    swarm.start();
    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class, "myapp.war");
    deployment.addClass(MyResource.class);
    deployment.setContextRoot("rest");
    deployment.addAllDependencies();
    swarm.deploy(deployment);
}