Cactus
  1. Cactus
  2. CACTUS-256

ServletTestRunner should build test redirector URL from incoming request, not use CACTUS_CONTEXT_URL_PROPERTY unless instructed

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7.2, 1.8
    • Fix Version/s: None
    • Component/s: Framework
    • Labels:
      None

      Description

      The first time ServletTestRunner gets invoked, it builds the context URL for the actual test requests, and saves it in the system property "cactus.contextURL" (BaseConfiguration.CACTUS_CONTEXT_URL_PROPERTY). All subsequent requests then use that property value, ignoring the actual request URL. This is bad on several levels.

      First, because it's impolite to set system-wide properties in a shared execution environment.

      Second, and more important, because it prevents running tests in an environment that uses virtual homes and extracts information from the request URL. If you want to have particular behavior for requests to "foo.example.com", and have already run tests for "bar.example.com", you have to restart your container. Or spend a couple hours with a debugger and the Cactus source code, trying to figure out why your tests are failing (no, I'm not bitter ).

      And third (just throwing this in for good measure), because it breaks the JUnit premise that tests execute in isolation, and are not dependent on execution order.

      Personally, I can't see a reason for caching this value. It's not terribly expensive to create it anew for each run. For those people who do want to have their first test influence all subsequent tests, it could be a request parameter ("rememberThisHost=yes").

        Activity

        Hide
        Keith D Gregory added a comment -

        Work and Real Life(tm) has kept me from this, but look for something in the September/October timeframe.

        Show
        Keith D Gregory added a comment - Work and Real Life(tm) has kept me from this, but look for something in the September/October timeframe.
        Hide
        Petar Tahchiev added a comment -

        Hi Keith,

        First of all thanks for the suggestion, and sorry for my late response.

        I am not sure what was the initial reason for Cactus team to implement this cache mechanism. I guess that initially developers intended to use no more than one container, with no virtual homes. However your point is really reasonable and I would be glad to see a patch. I don't promise it will get accepted, but it's worth a try .

        Show
        Petar Tahchiev added a comment - Hi Keith, First of all thanks for the suggestion, and sorry for my late response. I am not sure what was the initial reason for Cactus team to implement this cache mechanism. I guess that initially developers intended to use no more than one container, with no virtual homes. However your point is really reasonable and I would be glad to see a patch. I don't promise it will get accepted, but it's worth a try .
        Hide
        Keith D Gregory added a comment -

        Incidentally, I would be happy to produce a patch, if the committers concur that this is poor behavior. Seems like it should be a simple matter of saving the desired URL in the config object.

        Show
        Keith D Gregory added a comment - Incidentally, I would be happy to produce a patch, if the committers concur that this is poor behavior. Seems like it should be a simple matter of saving the desired URL in the config object.

          People

          • Assignee:
            Unassigned
            Reporter:
            Keith D Gregory
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development