Uploaded image for project: 'Cactus'
  1. Cactus
  2. CACTUS-256

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


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


      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").




            • Assignee:
              kdgregory Keith D Gregory
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: