jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kimberly Nico <...@vizdom.com>
Subject Problem with adding cookies
Date Wed, 01 Jun 2005 21:03:55 GMT
I have had a problem when setting in beginXXX(), there are no cookies
in testXXX().  I have replicated the problem by making small changes
in the TestCookie unit test in samples/servlet.

Cactus version: jakarta-cactus-13-1.6.1

Adding a line setting the URL including a non-null, non-zero-length context:

    public void beginCookieEncoding(WebRequest theRequest)
    {
        theRequest.setURL("localhost", "/Webtop", null, null, null);
        // Note: the pipe ('&') character is a special character regarding
        // URL encoding
        theRequest.addCookie("testcookie", "user&pwd");
    }

made the test fail.  

Modifying it to set the cookie path to "/" (but not to "/Webtop"):

    public void beginCookieEncoding(WebRequest theRequest)
    {
        theRequest.setURL("localhost", "/Webtop", null, null, null);
        org.apache.cactus.Cookie cookie = new org.apache.cactus.Cookie(
            "localhost", "testcookie", "user&pwd");
        cookie.setPath("/");
        theRequest.addCookie(cookie);
    }

makes the test pass again.

It is my understanding that the path should be automatically be set to
the URL in the request it is in, or at least that it should
automatically be sent in the HttpServletRequest once we have put it
into the WebRequest.  Further, it seems to me that if I set the path
to the context ("/Webtop" in this case), it should also be sent in the
request.

Is this a bug, or user error?

Here is the run of all of the unit tests, where I have added the line that
breaks it.  I am also attaching test_client.log and test_server.log for
the case that breaks.

[kim@alcott servlet]$ ant
Buildfile: build.xml
 
init:
 
clean:
 
compile.java:
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/classes/java
    [javac] Compiling 7 source files to 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/classes/java
 
war:
      [war] Building war: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/cactus-sample-servlet.war
 
compile.cactus:
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/classes/cactus
    [javac] Compiling 32 source files to 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/classes/cactus
    [javac] Note: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/src/test-cactus/org/apache/cactus/sample/servlet/TestSampleServlet.java

uses or overrides a deprecated API.
    [javac] Note: Recompile with -deprecation for details.
 
test.prepare.logging:
     [copy] Copying 1 file to 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target
    [touch] Creating 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/logging_server.properties
 
test.prepare:
[cactifywar] Analyzing war: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/cactus-sample-servlet.war
[cactifywar] Building war: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/cactus-sample-servlet-cactified.war
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports/jboss3x
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports/orion1x
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports/orion2x
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports/resin2x
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports/resin3x
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports/tomcat4x
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports/tomcat5x
    [mkdir] Created dir: 
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/target/test-reports/weblogic7x
 
test:
   [cactus] 
-----------------------------------------------------------------
   [cactus] Running tests against Tomcat 5.0.18
   [cactus] 
-----------------------------------------------------------------
   [cactus] Deleting 66 files from /tmp/cactus/tomcat5x
   [cactus] Deleted 25 directories from /tmp/cactus/tomcat5x
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestBasicAuthentication
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.332 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestClientServerSynchronization
   [cactus] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 3.269 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.unit.TestCookie
   [cactus] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.259 sec
 
   [cactus] Testcase: 
testCookieEncoding(org.apache.cactus.sample.servlet.unit.TestCookie):     
FAILED
   [cactus] No cookies in request
   [cactus] junit.framework.AssertionFailedError: No cookies in request
   [cactus]     at 
org.apache.cactus.sample.servlet.unit.TestCookie.testCookieEncoding(Unknown 
Source)
   [cactus]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
   [cactus]     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   [cactus]     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   [cactus]     at 
org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
   [cactus]     at 
org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
   [cactus]     at 
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
   [cactus]     at 
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:124)
   [cactus]     at 
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
   [cactus]     at 
org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
   [cactus]     at 
org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:124)
   [cactus]     at 
org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
   [cactus]     at 
org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
   [cactus]     at 
org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:124)
   [cactus]     at 
org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
   [cactus]     at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
   [cactus]     at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
   [cactus]     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
   [cactus]     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
   [cactus]     at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
   [cactus]     at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
   [cactus]     at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
   [cactus]     at 
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
   [cactus]     at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
   [cactus]     at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
   [cactus]     at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:509)
   [cactus]     at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
   [cactus]     at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
   [cactus]     at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
   [cactus]     at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
   [cactus]     at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
   [cactus]     at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
   [cactus]     at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
   [cactus]     at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
   [cactus]     at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
   [cactus]     at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
   [cactus]     at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
   [cactus]     at 
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
   [cactus]     at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
   [cactus]     at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
   [cactus]     at 
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
   [cactus]     at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
   [cactus]     at java.lang.Thread.run(Thread.java:534)
 
 
   [cactus] Test org.apache.cactus.sample.servlet.unit.TestCookie FAILED
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestFilterHttpHeaders
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.216 sec
 
   [cactus] ------------- Standard Error -----------------
   [cactus] Rhino classes (js.jar) not found - Javascript disabled
   [cactus] ------------- ---------------- ---------------
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestGlobalBeginEnd
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.203 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.unit.TestHttpHeaders
   [cactus] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.274 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestHttpParameters
   [cactus] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.291 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.unit.TestHttpRequest
   [cactus] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.299 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestHttpRequestSpecific
   [cactus] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.226 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestHttpResponse
   [cactus] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 0.572 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.unit.TestHttpSession
   [cactus] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.637 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestHttpUnitIntegration
   [cactus] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.482 sec
 
   [cactus] ------------- Standard Error -----------------
   [cactus] Rhino classes (js.jar) not found - Javascript disabled
   [cactus] ------------- ---------------- ---------------
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestJUnitTestCaseWrapper
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.513 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.unit.TestJspOut
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.505 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestJspPageContext
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.194 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestJspTagLifecycle   [cactus] 
Tests run: 24, Failures: 0, Errors: 0, Time elapsed: 1.101 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestRequestDispatcher
   [cactus] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.947 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestServerSideExceptions
   [cactus] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.289 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestServletConfig
   [cactus] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.323 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestServletContext
   [cactus] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.23 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestServletRedirectorOverride
   [cactus] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.259 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.unit.TestSetURL
   [cactus] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 0.433 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestSetURLSpecific
   [cactus] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.269 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestSetUpTearDown
   [cactus] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.233 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.unit.TestTearDownException
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.188 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.TestSampleBodyTag
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.197 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.TestSampleFilter
   [cactus] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.316 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.TestSampleServlet
   [cactus] Tests run: 13, Failures: 0, Errors: 0, Time elapsed: 0.617 sec
 
   [cactus] Testsuite: 
org.apache.cactus.sample.servlet.TestSampleServletConfig
   [cactus] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.193 sec
 
   [cactus] Testsuite: org.apache.cactus.sample.servlet.TestSampleTag
   [cactus] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.335 sec
 
[junitreport] Transform time: 282ms
[junitreport] Transform time: 83ms
[junitreport] Transform time: 68ms
[junitreport] Transform time: 82ms
[junitreport] Transform time: 54ms
[junitreport] Transform time: 1514ms
[junitreport] Transform time: 56ms
 
BUILD FAILED
/usr/local/jakarta-cactus-13-1.6.1/samples/servlet/build.xml:454: At 
least one test failed!
 
Total time: 44 seconds
[kim@alcott servlet]$


Mime
View raw message