Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:04:03+00:00 2026-06-17T05:04:03+00:00

Like the title says whenever I run my integration tests with the Jersey Test

  • 0

Like the title says whenever I run my integration tests with the Jersey Test Framework they pass when I do one test at a time. When I do a clean and build on my project it passes some tests but fails on two or three.

A message body reader for Java class com.foo.Result, and Java type class com.foo.Result, and MIME media type application/octet-stream was not found

com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.RenderedImageProvider */* ->
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
com.sun.jersey.core.impl.provider.entity.EntityHolderReader

My web service resource has a @Produces and @Consumes annotation on the methods and do not understand why it some pass and others fail when the code is basically the same.

A snippet of the web resource:

@Path("/data")
@RolesAllowed({"upload"})
@Component
@Scope("request")
public final class UploadData {

   @POST
   @Consumes("application/vnd.foo.data-v1.0.0+xml")
   @Produces("application/xml")
   public Response uploadData(final Data data) {
        // Processes the data and returns the response
        return getResponse(data, null);
   }
}

All my integration tests have something like this:

ClientResponse response = resource().path("123_10").entity(getData(), "application/vnd.foo.data-v1.0.0+xml").post(ClientResponse.class);
Result result = response.getEntity(Result.class); // Seems to fail on this line for some tests

Here is the main test class that my other test classes inherit from:

public abstract class AbstractRestTest {

    private static final String PACKAGE = UploadData.class.getPackage().getName();
    private static JerseyTest jerseyTest;
    private Data data;

    /**
     * Initializes the Jersey Test to use for testing.
     */
    @BeforeSuite
    public final void init() {
        jerseyTest = new JerseyTest(new WebAppDescriptor.Builder(PACKAGE)
                     .contextPath("rest").contextParam("contextConfigLocation",
                     "classpath:testApplicationContext.xml")
                     .servletClass(SpringServlet.class)
                     .contextListenerClass(ContextLoaderListener.class)
                     .requestListenerClass(RequestContextListener.class).build()) {
        };
    }

   /**
    * Gets the Jersey Test client.
    *
    * @return - the Jersey Test client.
    */
    public final Client client() {
        return jerseyTest.client();
    }

    /**
     * Gets the Jersey Test web resource.
     *
     * @return - the Jersey Test web resource.
     */
    public final WebResource resource() {
       return jerseyTest.resource().path("data");
    }

    /**
     * Sets up the necessary code to run the tests.
     *
     * @throws Exception if it cannot set up the test.
     */
    @BeforeTest
    public final void setUp() throws Exception {
        jerseyTest.setUp();
        data = new Data();
    }

    /**
     * Tears down the resources after the tests.
     *
     * @throws Exception if it cannot tear down the test.
     */
    @AfterTest
    public final void tearDown() throws Exception {
        jerseyTest.tearDown();
    }

    /**
     * Get the data.
     *
     * @return - the data.
     */
    public final Data getData() {
       return data;
    }

    /**
     * Set the data.
     *
     * @param theData - the data.
     */
     public final void setData(final Data theData) {
        this.data = theData;
     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:04:04+00:00Added an answer on June 17, 2026 at 5:04 am

    Solved it! Cannot have any code in the setup method in the AbstractRestTest. Once I removed it and only called the JerseyTest.setup() all my unit tests passed.

    /**
     * Sets up the necessary code to run the tests.
     *
     * @throws Exception if it cannot set up the test.
     */
    @BeforeTest
    public final void setUp() throws Exception {
        jerseyTest.setUp();
        data = new Data(); // Removed and set it in the tests I needed it to be in, this was the problem having this line before or after the jerseyTest.setup()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

as the title says, I would like to create a many-to-one relationship using Fluent
Like the title says, my code basically does this: set proxy, test proxy, do
Like the title says I am getting an error when I try to run
Like the title says, whenever I make any changes in the code I don't
Like the title says, if I use a gem in one app (install it,
Like the title says I need to have a final result where on one
Like the title says I'm having some trouble printing out symbol codes and their
Like the title says, I'm wondering if the use of WebClient is the proper
Like the title says, PHP is really confusing me on a simple if comparison
Like the title says, I'm trying to determine if data is a standard attribute

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.