if (getRequestCount() == -1)
{
container = DefaultServletContainerFactory.getInstance().getServletContainer();
if (container == null)
{
return new FailureResponse(Failure.createAssertionFailure("No servlet container present"));
}
// Register and save the deployed web apps
registry = new WebAppRegistry();
container.addWebAppListener(registry);
keys = new HashSet<String>(registry.getKeys());
// Deploy the web app with init param of gatein.wci.native.DisableRegistration set to true
return new DeployResponse("test-native-skip-app.war");
}
else if (getRequestCount() == 0)
{
//make sure the test-native-skip-app.war is actually skipped
if (registry.getWebApp("/test-native-skip-app") != null)
{
return new FailureResponse(Failure.createAssertionFailure("The test-native-skip-app.war should not be seen by the native implemetentation."));
}
// Compute the difference with the previous deployed web apps
Set diff = new HashSet<String>(registry.getKeys());
diff.removeAll(keys);
// It should be 0, since the test-native-skip-app.war should not get registered by the native implementation
if (diff.size() != 0)
{
return new FailureResponse(Failure.createAssertionFailure("The size of the new web application deployed should be 0, it is " + diff.size() + " instead." +
"The previous set was " + keys + " and the new set is " + registry.getKeys()));
}
return new DeployResponse("test-native-skip-with-gateinservlet-app.war");
}
else if (getRequestCount() == 1)
{
// Compute the difference with the previous deployed web apps
Set diff = new HashSet<String>(registry.getKeys());
diff.removeAll(keys);
// It should be 1
if (diff.size() != 1)
{
return new FailureResponse(Failure.createAssertionFailure("The size of the new web application deployed should be 1, it is " + diff.size() + " instead." +
"The previous set was " + keys + " and the new set is " + registry.getKeys()));
}
WebApp webapp = registry.getWebApp("/test-native-skip-with-gateinservlet-app");
//make sure the test-native-skip-with-gateinservlet-app.war is picked up
if (webapp== null)
{
return new FailureResponse(Failure.createAssertionFailure("The test-native-skip-with-gateinservler-app.war should be seen."));
}
if (!webapp.getContextPath().equals("/test-native-skip-with-gateinservlet-app"))
{
return new FailureResponse(Failure.createAssertionFailure("The web app context is not equals to the expected value but has the value " + webapp.getContextPath()));
}
return new InvokeGetResponse("/test-spi-server");
}
else
{
return new FailureResponse(new Failure("Test not expected to reach RequestCount of " + getRequestCount(), FailureType.ERROR));
}
}