use of org.glassfish.tests.paas.basetest.BaseTest in project Payara by payara.
the class BasicbookstoreDnsPaasTest method runTests.
private void runTests(GlassFish glassfish) throws Exception {
// 2. Deploy the PaaS application.
File basicArchive = new File(System.getProperty("basedir") + // TODO :: use mvn apis to
"/basic_paas_sample.war");
File bookArchive = new File(System.getProperty("basedir") + "/bookstore.war");
Assert.assertTrue(basicArchive.exists());
Assert.assertTrue(bookArchive.exists());
Deployer deployer = null;
String firstappName = null;
String secondappName = null;
BaseTest firstBaseTest = new BaseTest(glassfish);
BaseTest secondBaseTest = new BaseTest(glassfish);
try {
CreateDNSExternalService();
CreateLbSharedService(glassfish);
firstappName = firstBaseTest.deploy(basicArchive, "basic_paas_sample", null);
System.err.println("Deployed [" + firstappName + "]");
Assert.assertNotNull(firstappName);
CommandRunner commandRunner = glassfish.getCommandRunner();
CommandResult result = commandRunner.run("list-services");
System.out.println("\nlist-services command output [ " + result.getOutput() + "]");
// 3. Access the app to make sure PaaS app is correctly provisioned.
firstappName = firstappName.replaceAll("_", "-");
String HTTP_PORT = (System.getProperty("http.port") != null) ? System.getProperty("http.port") : "28080";
get("http://" + firstappName + ".hudson.com:" + HTTP_PORT + "/BasicPaaSServlet", "Request headers from the request:");
secondappName = secondBaseTest.deploy(bookArchive, "bookstore", null);
System.err.println("Deployed [" + secondappName + "]");
Assert.assertNotNull(secondappName);
secondappName = secondappName.replaceAll("_", "-");
get("http://" + secondappName + ".hudson.com:" + HTTP_PORT + "/BookStoreServlet", "Please wait while accessing the bookstore database.....");
get("http://" + secondappName + ".hudson.com:" + HTTP_PORT + "/BookStoreServlet?title=Advanced+guide+for+developing+PaaS+components&authors=Shalini+M&price=100%24", "Here are the list of books available in our store:");
get("http://" + secondappName + ".hudson.com:" + HTTP_PORT + "/BookStoreServlet", "Advanced guide for developing PaaS components");
get("http://" + firstappName + ".hudson.com:" + HTTP_PORT + "/BasicPaaSServlet", "Request headers from the request:");
if (secondappName != null) {
secondBaseTest.undeploy();
System.err.println("Undeployed [" + secondappName + "]");
}
get("http://" + firstappName + ".hudson.com:" + HTTP_PORT + "/BasicPaaSServlet", "Request headers from the request:");
// 4. Undeploy the PaaS application . TODO :: use cloud-undeploy??
} finally {
if (firstappName != null) {
firstappName = firstappName.replaceAll("-", "_");
firstBaseTest.undeploy();
System.err.println("Undeployed [" + firstappName + "]");
deleteSharedLbandDNSexternalSerivce();
try {
boolean undeployClean = false;
CommandResult commandResult = glassfish.getCommandRunner().run("list-services");
if (commandResult.getOutput().contains("Nothing to list.")) {
undeployClean = true;
}
Assert.assertTrue(undeployClean);
} catch (Exception e) {
System.err.println("Couldn't varify whether undeploy succeeded");
}
}
}
}
Aggregations