ServletMethodExecution in Arquillian assumes "test" context
jaikiran Sep 17, 2010 7:24 AMI've got a Arquillian (1.0.0.alpha-3) IN_CONTAINER test running against JBoss AS 6 (trunk) remote. The test is simple - it just deploys a WebArchive and does a lookup of a EJB that's deployed in the .war (AS6 supports EJB deployments in .war):
@RunWith(Arquillian.class)
@Run(RunModeType.IN_CONTAINER)
public class JNDIAccessTestCase
{
private static final String MODULE_NAME = "hello";
@Deployment
public static WebArchive createDeployment() throws Exception
{
return ShrinkWrap.create(WebArchive.class, MODULE_NAME + ".war").addPackage(JNDIAccessTestCase.class.getPackage());
}
@Test
public void testSimpleJNDIAccess() throws Exception
{
Context ctx = new InitialContext();
Echo bean = (Echo) ctx.lookup("blah");
String echo = bean.echo("msg");
}
}
As you can see, I just deploy the hello.war. While running this test, I keep running into the following exception and Arquillian fails to fire the testcase:
Caused by: java.lang.IllegalStateException: Error launching test org.jboss.bean.integration.test.jndi.JNDIAccessTestCase public void org.jboss.bean.integration.test.jndi.JNDIAccessTestCase.testSimpleJNDIAccess() throws java.lang.Exception at org.jboss.arquillian.protocol.servlet_3.ServletMethodExecutor.invoke(ServletMethodExecutor.java:61) at org.jboss.arquillian.impl.handler.ContainerTestExecuter.callback(ContainerTestExecuter.java:50) at org.jboss.arquillian.impl.handler.ContainerTestExecuter.callback(ContainerTestExecuter.java:40) at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63) ... 26 more Caused by: java.lang.IllegalStateException: Error launching test at http://localhost:8080/test/ArquillianServletRunner?outputMode=serializedObject&className=org.jboss.bean.integration.test.jndi.JNDIAccessTestCase&methodName=testSimpleJNDIAccess. Kept on getting 404s. at org.jboss.arquillian.protocol.servlet_3.ServletMethodExecutor.execute(ServletMethodExecutor.java:125) at org.jboss.arquillian.protocol.servlet_3.ServletMethodExecutor.invoke(ServletMethodExecutor.java:57) ... 29 more
So it appears that Arquillian deploys the hello.war (at hello context) and then tries to run the in-container test by using the hardcoded "test" context. This is what I see in org.jboss.arquillian.protocol.servlet_3.ServletMethodExecutor.invoke:
public TestResult invoke(TestMethodExecutor testMethodExecutor)
{
if(testMethodExecutor == null)
{
throw new IllegalArgumentException("TestMethodExecutor must be specified");
}
Class<?> testClass = testMethodExecutor.getInstance().getClass();
String url = baseURL.toExternalForm() + "test/ArquillianServletRunner" +
"?outputMode=serializedObject&className=" + testClass.getName() +
"&methodName=" + testMethodExecutor.getMethod().getName();
try
{
return execute(url);
}
catch (Exception e)
{
throw new IllegalStateException("Error launching test " + testClass.getName() + " " + testMethodExecutor.getMethod(), e);
}
}