0 Replies Latest reply on Sep 19, 2012 5:24 PM by Mark Noten

    Error testing custom exceptions with Arquillian in remote mode on JBoss EAP 6

    Mark Noten Newbie

      All,

       

      can you point me in the right direction how to write an Arquillian test case that expects the below RestServiceException to be thrown in case of an invalid request?

       

       

      @POST
       @Consumes(APPLICATION_JSON)
       @Produces(APPLICATION_JSON)
                public Response createSubscription(@Valid SubscribeRequest subscribeRequest) {
                          Newsletter newsletter = newsletterRepository.findById(subscribeRequest
                                              .getNewsletterId());
                          if (newsletter == null) {
                                    throw new RestServiceException(BAD_REQUEST);
                          }
      

       

       

      @ApplicationException(inherited = true, rollback = true)
      public class RestServiceException extends WebApplicationException {
      
       private static final long serialVersionUID = 1L;
      
                public RestServiceException() {
                }
      
                public RestServiceException(Response response) {
                          super(response);
                }
      
                public RestServiceException(int status) {
                          super(status);
                }
      
      

       

      The full stact trace is shown below. I want to avoid the IllegalStateException because the ServerResponse is not serializable when using Arquillian in remote mode (arq-jbossas-remote Maven profile). How can I test that I have a response indicating a bad request (HTTP status code 500)?

       

      Thanks for your help,

       

      Mark

       

      java.lang.IllegalStateException: Error launching test com.itfc.mailing.controller.subscribe.SubscriptionControllerTest public void com.itfc.mailing.controller.subscribe.SubscriptionControllerTest.testInvalidSubscriptionRequest()

                at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:126)

                at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)

                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:135)

                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

                at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57)

      ...

      Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.jboss.resteasy.core.ServerResponse

                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1332)

                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

                at org.jboss.arquillian.test.spi.ExceptionProxy.readExternal(ExceptionProxy.java:177)

                at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)

                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)

                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)

                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)

                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

                at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.execute(ServletMethodExecutor.java:218)

                at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.executeWithRetry(ServletMethodExecutor.java:144)

                at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:122)

                ... 75 more

      Caused by: java.io.NotSerializableException: org.jboss.resteasy.core.ServerResponse

                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)

                at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)

                at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)

                at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)

                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)

                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)

                at org.jboss.arquillian.test.spi.ExceptionProxy.writeExternal(ExceptionProxy.java:227)