use of org.glassfish.internal.embedded.EmbeddedDeployer in project Payara by payara.
the class EmbeddedTest method testWeb.
@Test
public void testWeb() throws Exception {
System.out.println("Starting Web " + server);
ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
System.out.println("builder is " + b);
server.addContainer(b);
EmbeddedDeployer deployer = server.getDeployer();
System.out.println("Added Web");
String testClass = "org/glassfish/tests/embedded/webwar/EmbeddedTest.class";
URL source = this.getClass().getClassLoader().getResource(testClass);
String p = source.getPath().substring(0, source.getPath().length() - testClass.length()) + "../../../war/target/test-war.war";
System.out.println("Root is " + p);
DeployCommandParameters dp = new DeployCommandParameters(new File(p));
System.out.println("Deploying " + p);
String appName = null;
try {
appName = deployer.deploy(new File(p), dp);
System.out.println("Deployed " + appName);
Assert.assertTrue(appName != null);
try {
URL servlet = new URL("http://localhost:8080/test-war/");
URLConnection yc = servlet.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine = in.readLine();
if (inputLine != null)
System.out.println(inputLine);
Assert.assertEquals(inputLine.trim(), "filterMessage=213");
in.close();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
if (appName != null)
deployer.undeploy(appName, null);
}
Aggregations