6

I have this interface:

 @Path("inbox")
public interface InboxQueryResourceTest {

    @POST
    @Path("{membershipExternalId}/query")
    @Consumes(MediaType.APPLICATION_XML)
    @Produces("multipart/mixed")
    public MultipartOutput query(@PathParam("membershipExternalId") final String membershipExternalId,
                             @QueryParam("page") @DefaultValue("0") final int page,
                             @QueryParam("pageSize") @DefaultValue("10") final int pageSize,
                             @QueryParam("sortProperty") final List<String> sortPropertyList,
                             @QueryParam("sortReversed") final List<Boolean> sortReversed,
                             @QueryParam("sortType") final List<String> sortTypeString,
                             final InstanceQuery instanceQuery) throws IOException;
}

I have implemented the method to return a MultipartOutput. I am posting an xml query from Fiddler and i receive the result without any problem.

BUT i have done an integration test for the same interface, i send the same objects and i put the response like:

final MultipartOutput multiPartOutput = getClient().query(getUserRestAuth(), 0, 25, null, null, null, instanceQuery);

But here, so from integration tests, i receive a strange error:

Unable to find a MessageBodyReader of content-type multipart/mixed;boundary="74c5b6b4-e820-452d-abea-4c56ffb514bb" and type class org.jboss.resteasy.plugins.providers.multipart.MultipartOutput

Anyone has any ideea why only in integration tests i receive this error?

PS: Some of you will say that i do not send application/xml as ContentType but multipart, which of course is false because the objects are annotated with the required @XmlRootElement etc, otherways neither the POST from Fiddler would work.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Cristian Boariu
  • 9,603
  • 14
  • 91
  • 162

3 Answers3

1

You can try this:

ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
providerFactory.registerProvider(org.jboss.resteasy.plugins.providers.multipart.MimeMultipartProvider.class);
Nikita Koksharov
  • 10,283
  • 1
  • 62
  • 71
0

Are including in classpath the corresponding resteasy addon for multipart encoding? (esteasy-multipart-provider).

Pablo Lalloni
  • 2,615
  • 19
  • 20
  • In client classpath as well? I believe the error is because the client resteasy proxy does not have a MessageBodyReader registered that can handle multipart/mixed. If you are using resteasy 1.2 or superior then it's enough to include in client's classpath the previous mentioned jar, in case of a resteasy version <1.2 then you have to do as Chandru writes in client's code. For your integration tests are you using two separate VMs or you run client and server in the same? – Pablo Lalloni Mar 25 '10 at 02:07
-1

Try adding this method to your test class. This would register the default built-in providers which are already registered on your server.

@BeforeClass
public static void registerProviders() {
    ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
    RegisterBuiltin.register(providerFactory);
}
Chandra Sekar
  • 10,683
  • 3
  • 39
  • 54