3 Replies Latest reply on Oct 2, 2011 11:01 AM by Karel Piwko

    Arquillian Test Error

    elfuhrer Novice

      I am using Arquillian for bootstraping AS 7 and run my tests.

       

      I have lately upgraded to 1.0.0.CR5 and I am getting the following exception

       

      org.apache.http.client.HttpResponseException: Not Found

       

      This used to work fine on earlier version and the dependencies of httpclient are included.

       

      What is the cause of this?

        • 1. Re: Arquillian Test Error
          Aslak Knutsen Master

          Nothing that springs to mind..  could you provide a example?

          • 2. Re: Arquillian Test Error
            elfuhrer Novice

            My application has the following service

            @Stateless
            @Path("/auditor")
            public class AuditorManagerBean {
            
                @POST
                @GET
                @Produces(MediaType.TEXT_PLAIN)
                @Path("/version")
                public String getVersion() {
                    return "0.0.1";
                }
            }
            

             

            my test case is as follows:

             

            @RunWith(Arquillian.class)
            public class AuditorManagerTest {
                      @Inject
                      AuditorManagerBean auditorManagerBean;
            
            
                      @Inject
                      Logger log;
            
            
                      @Deployment
                      public static Archive<?> createTestArchive() {
                                return ShrinkWrap
                                                    .create(WebArchive.class, "asgiLabTestApplication.war")
                                                    .addClasses(AuditorManagerBean.class, ApplicationServices.class)
                                                    .addAsWebInfResource(EmptyAsset.INSTANCE, "seam-beans.xml")
                                                    .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                                                    .addAsLibraries(MavenArtifactResolver.resolve("org.jboss.seam.solder","seam-solder", "3.0.0.Final"))
                                                    .addAsLibraries(MavenArtifactResolver.resolve("org.apache.httpcomponents", "httpcore", "4.1.2"))
                                                    .addAsLibraries(MavenArtifactResolver.resolve("org.apache.httpcomponents", "httpclient", "4.1.2"))
                                                    .addAsLibraries(MavenArtifactResolver.resolve("commons-logging", "commons-logging", "1.1.1"));
                      }
            
            
              @Test
              public void auditorServiceVersionGetRequestTest() throws ClientProtocolException, IOException {
                  HttpClient httpClient = new DefaultHttpClient();
                  HttpGet httpGet = new HttpGet("http://localhost:8080/osgiLab/services/auditor/version");
                  ResponseHandler<String> responseHandler = new BasicResponseHandler();
                  String responseBody = httpClient.execute(httpGet, responseHandler);
                  Assert.assertEquals(responseBody, "0.0.1");
                  httpClient.getConnectionManager().shutdown();
               }
            }
            
            

             

            I see JBoss AS being bootstrapped in my test and now I get a failure using the surefire report the relevant part of the error is the following:

             

            Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.118 sec <<< FAILURE!
            auditorServiceVersionGetRequestTest(org.webpatterns.labs.osgi.test.AuditorManagerTest)  Time elapsed: 0.302 sec  <<< ERROR!
            org.apache.http.client.HttpResponseException: Not Found
                      at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
                      at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:55)
                      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:945)
                      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:919)
                      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:910)
                      at org.webpatterns.labs.osgi.test.AuditorManagerTest.auditorServiceVersionGetRequestTest(AuditorManagerTest.java:61)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
                      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
                      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
                      at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:246)
                      at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
                      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
                      at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
                      at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
                      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
                      at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:82)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                      at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:68)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                      at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:54)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
                      at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)
                      at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:239)
                      at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:202)
                      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:290)
                      at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:45)
                      at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:216)
                      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
                      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
                      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
                      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
                      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
                      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
                      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
                      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
                      at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:161)
                      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:290)
                      at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:45)
                      at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:175)
                      at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
                      at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:123)
                      at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
                      at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
                      at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)
                      at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128)
                      at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107)
                      at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:203)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)
                      at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)
                      at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
                      at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
                      at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
                      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
                      at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
                      at org.jboss.as.jmx.tcl.TcclMBeanServer.invoke(TcclMBeanServer.java:214)
                      at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1427)
                      at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
                      at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1265)
                      at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1360)
                      at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:788)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
                      at sun.rmi.transport.Transport$1.run(Transport.java:159)
                      at java.security.AccessController.doPrivileged(Native Method)
                      at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
                      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
                      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
                      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                      at java.lang.Thread.run(Thread.java:680)
            

             

             

            This used to work perfectly with JBoss AS 7.0.0.Final

            • 3. Re: Arquillian Test Error
              Karel Piwko Master

              Hi elfuhrer,

               

              I think this is a typo. You named your was as "asgiLabTestApplication.war" which means it would be deployed under http://localhost:8080/asgiLabTestApplication.

               

              However, in the test you're asking for "http://localhost:8080/osgiLab/services/auditor/version", and you're getting HTTP 404 not found, which is AFAIK correct.

               

              If you're using Servlet 3.0 protocol with AS 7, you can get the URL of deployed application via @ArquillianResource URL url. This should help you avoid typos like this.