Announcement Announcement Module
Collapse
No announcement yet.
forwading requestDispatcher sing MockHttpServletRequest and MockHttpAServletResponse Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • forwading requestDispatcher sing MockHttpServletRequest and MockHttpAServletResponse

    Hi all,

    We're making us of the MockHttpServletRequest and MockHttpAServletResponse, BUT not in executing test cases (yes it's strange). Our web application is to be integrated with a message based service invocation layer and therefore we're not going to have hold to request/response objects.

    As any web app, we have filters, listeners etc... So what we're trying to do is creating new MockHttpServletRequest and MockHttpAServletResponse objects, populating with the necessary headers, parameters etc... and doing a forward to a url (/foo/bar which relative to our root) which is mapped to our controller. The forward is done using the RequestDispatcher (have tried getting it from the MockHttpAServletRequest as well as from the container provided ServletContext), however nothing happens. The forward logic in inside a TimerTask which gets invoked every x minutes.
    What i'm expecting (from the forward) is the application to be hit as any normal HTTP request and execute the filters, controllers etc...

    Has anyone tried something similar to this.

    Thanks.

  • #2
    Not sure what you are trying to do but for some reason it doesn't feel right... You shouldn't use test classes in production systems. If you want to do a httprequest then use an UrlConnection or something like the httpclient library from apache but messing around with test classes in production code isn't something you should do.

    Also if you are using message based systems I think Spring Integration (with a http inbound gateway of sorts) and not a web application. That also feels weird (but that is from my location ).

    Comment


    • #3
      Thanks for your reply Marten. I'll try to cut across your point regarding the usage of test classes for production. But do you have any idea why the requestdispacther forward on the mock request/response might not work?

      Thanks.

      Comment


      • #4
        Because, as the classname suggest, it is a mock. It has absolutly no ties to any real functionality... So it will never work.

        Comment

        Working...
        X