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

  • SEARCH
  • Home
  • 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 6793329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:05:16+00:00 2026-05-26T18:05:16+00:00

currently I am working on a spring based application. I do have some unit

  • 0

currently I am working on a spring based application. I do have some unit tests for many purposes of the application. The problem is, I’ve not found any solution to do a real integration test on my application.

Let me give you an example:

In my current tests I do setup a request for a specific controller and pass those components to my handler:

// setup request
request.setMethod("GET");
request.setRequestURI("/customer");
request.addHeader("Accept", "application/json");
request.addHeader("Authorization", "Basic xyz"); // base_64
handlerAdapter.handle(request, response, myController);

But this is not a real integration test, because what I am saying is, okay I do have a request, and myController should handle this request.

That’s a problem, because what I really want to test is the following:

I do have a request, and my application should handle this request. I do not want to specify the controller because in case of a running application and a request to “/customer” spring does dispatch which controller solves my request.
I really want to simulate that I am a browser or another client sending requests to my backend.

The reason I want to test this is, that otherwise some kind of tests passes although the tested functionality doesn’t work in the “real world”

I could give you this example to understand, in which way the tests differ from the production run:

Let’s assume I do have a file upload within a form with a parameter. My controller function is this one:

@RequestMapping(value="/{id}", method = RequestMethod.PUT, headers="content-type=multipart/form-data")
public ResponseEntity<String> createFromMyForm(@PathVariable("id") Long id, @RequestParam String myParameter, @RequestParam MultipartFile myFile) {
//...
}

Have a look at the RequestMethod.PUT, this is not working in an production build, because html standard for uploading files is POST.

In my unit test I am doing this:

// setup request
MockMultipartHttpServletRequest multipartRequest = new MockMultipartHttpServletRequest();
MockHttpServletResponse multipartResponse = new MockHttpServletResponse();

// Open file
final FileInputStream fis = new FileInputStream("img/test.png");
MockMultipartFile multipartFile = new MockMultipartFile(
            "myParameter", fis);

// generate multipart mock
multipartRequest.addFile(multipartFile);
multipartRequest.addParameter("json", "test");

// send request
handlerAdapter.handle(multipartRequest, multipartResponse, controller);

Problem: The test passes, while it should not. The reasons this test passes are several. First I am specifing the request. I do not say I have a request, but instead I have to say I have a MultipartRequest. This leads the dispatcher servlet to return true in an function called something like isMultipartRequest(). In the production run it returns false, because there are no multipart requests on PUT methods. Further I specify again the controller which should handle this request.

Maybe there are other examples, but what I want to say is, is there any way to test my application under real conditions including my html protocol and everything else?

I would really appreciate any kind of help!

Thanks in advance

  • 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-05-26T18:05:16+00:00Added an answer on May 26, 2026 at 6:05 pm

    Integration tests will test the integration between your code and your framework, but at some point you need to deploy the application and test it for real.

    Have a look at HtmlUnit. It’s a Junit-based framework for navigating and functionally testing web applications.

    Better yet, look at Selenium. This will actually drive a real browser and assert on the contents of the page. It’s more complex than HtmlUnit, but generally results in a more meaningful test, especially for javascript-heavy webapps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am working on a ajax-based web application that does some XHR. I
I'm currently working on a membership system for my web application, which is based
I am currently working on rails3 application that uses jQuery. I have a javascript
I have a web application running with Spring Webflow, Tiles and JSP. Currently all
Currently working in the deployment of an OFBiz based ERP, we've come to the
Currently working on a VBScript to automate some of the dirty PST ingestion work
Am currently working on an application that requires users to submit posts and comments
I`m currently working on a script, and I have the following situation. function somnicefunction()
I have a Spring Security (form based authentication) web app running CXF JAX-RS webservices
I'm currently working on an android application that uses a subclass of SimpleListAdapter to

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.