----- Original Message -----
From: "Malcolm Alexander" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 26, 2001 3:04 PM
Subject: testStatusCode IOException during cactus unit tests


> With cactus 2.2, and following the steps in the samples howto, I get an
> IOException during the testStatusCode test (did "ant tests_all").
> Commenting out the testcase code for testStatusCode (in
> TestServletTestCase2.java) shows that all the other tests run fine.
>
> Did I miss something in the configuration?
>

Yes, probably, but it is a bit tricky ! :-) You may have missed the trailing
"/" in the URL ... See http://jakarta.apache.org/cactus/howto_config.html,
you'll see a note:
"Notice the trailing slash ("/") to Redirector URLs. This is because Cactus
uses the JDK HttpURLConnection class to connect to these URLs and if your
code on the server side returns an HTTP status code greater than 400,
HttpURLConnection will return an exception. It does not if the URL ends with
a forward slash ("/") ! "

-Vincent

> The build results are shown below.
>
> Thanks,
>
> ****************************
>
> Buildfile: build.xml
>
> init:
>      [echo] --------- Cactus Sample 1.2 ---------
>      [echo]
>      [echo] java.class.path = G:\jdk1.3.1_01\lib\tools.jar;F:
> \Development\Tools\jakarta-ant-1.4\lib\junit.jar;F:\Develop
> ment\Tools\jakarta-ant-1.4\lib\jaxp.jar;F:
> \Development\Tools\jakarta-ant-1.4\lib\jakarta-ant-1.4-optional.jar;F:
> \Develop
> ment\Tools\jakarta-ant-1.4\lib\crimson.jar;F:
> \Development\Tools\jakarta-ant-1.4\lib\ant.jar;
>      [echo]
>      [echo] java.home = G:\jdk1.3.1_01\jre
>      [echo] user.home = C:\WINNT\Profiles\alexander
>      [echo]
>      [echo] basedir = F:\Development\Tools\jakarta-cactus-23-1.2\sample
>      [echo]
>      [echo] cactus.jar = ../lib/cactus.jar
>      [echo] cactus.ant.jar = ../lib/cactus-ant.jar
>      [echo] servlet.jar = G:/Apache Tomcat 4.0/common/lib/servlet.jar
>      [echo] junit.jar = F:/Development/Tools/jakarta-ant-1.4/lib/junit.jar
>      [echo] httpclient.jar = ../lib/httpclient.jar
>
> prepare:
>      [copy] Copying 1 file to F:
> \Development\Tools\jakarta-cactus-23-1.2\sample\target\src
>
> prepare-compile:
>
> compile:
>     [javac] Compiling 1 source file to F:
> \Development\Tools\jakarta-cactus-23-1.2\sample\target\classes
>     [javac] Note: F:
>
\Development\Tools\jakarta-cactus-23-1.2\sample\target\src\org\apache\cactus
\sample\unit\TestServlet
> TestCase2.java uses or overrides a deprecated API.
>     [javac] Note: Recompile with -deprecation for details.
>
> prepare-testwar-log4j:
>
> prepare-testwar:
>
> testwar:
>       [war] Building war: F:
> \Development\Tools\jakarta-cactus-23-1.2\sample\target\test\test.war
>
> check_tests_resin_20:
>      [echo]
>      [echo] *********************************************************
>      [echo] WARNING : The 'resin.home.20' property has not been set.
>      [echo]           No test will be run on that servlet engine.
>      [echo] *********************************************************
>      [echo]
>
> prepare_tests_resin_20:
>
> tests_resin_20:
>
> check_tests_resin_13:
>      [echo]
>      [echo] *********************************************************
>      [echo] WARNING : The 'resin.home.13' property has not been set.
>      [echo]           No test will be run on that servlet engine.
>      [echo] *********************************************************
>      [echo]
>
> prepare_tests_resin_13:
>
> tests_resin_13:
>
> check_tests_tomcat_40:
>
> prepare_tests_tomcat_40:
>      [echo] tomcat.home.40 = G:/Apache Tomcat 4.0
>    [delete] Deleting: F:
>
\Development\Tools\jakarta-cactus-23-1.2\sample\target\test\tomcat40\conf\se
rver.xml
>    [delete] Deleting directory F:
>
\Development\Tools\jakarta-cactus-23-1.2\sample\target\test\tomcat40\webapps
\test
>      [copy] Copying 1 file to F:
> \Development\Tools\jakarta-cactus-23-1.2\sample\target\test\tomcat40\conf
>      [copy] Copying 1 file to F:
>
\Development\Tools\jakarta-cactus-23-1.2\sample\target\test\tomcat40\webapps
>
> tests_tomcat_40:
>
> start_tomcat_40:
>      [java] HttpConnector Opening server socket on all host IP addresses
>      [java] Starting service Tomcat-Standalone
>      [java] Apache Tomcat/4.0
>      [java] StandardHost[localhost]: Installing web application at context
> path /test from URL jar:file:F:\Development\T
> ools\jakarta-cactus-23-1.2\sample\target\test\tomcat40\webapps\test.war!/
>      [java] WebappLoader[/test]: Deploying class repositories to work
> directory G:\Apache Tomcat 4.0\work\localhost\test
>
>      [java] WebappLoader[/test]: Deploy JAR /WEB-INF/lib/cactus.jar to F:
> \Development\Tools\jakarta-cactus-23-1.2\sample
> \target\test\tomcat40\webapps\test\WEB-INF\lib\cactus.jar
>      [java] WebappLoader[/test]: Deploy JAR /WEB-INF/lib/httpclient.jar to
> F:\Development\Tools\jakarta-cactus-23-1.2\sa
> mple\target\test\tomcat40\webapps\test\WEB-INF\lib\httpclient.jar
>      [java] WebappLoader[/test]: Deploy JAR /WEB-INF/lib/junit.jar to F:
> \Development\Tools\jakarta-cactus-23-1.2\sample\
> target\test\tomcat40\webapps\test\WEB-INF\lib\junit.jar
>      [java] WebappLoader[/test]: Deploy JAR /WEB-INF/lib/log4j.jar to F:
> \Development\Tools\jakarta-cactus-23-1.2\sample\
> target\test\tomcat40\webapps\test\WEB-INF\lib\log4j.jar
>      [java] StandardManager[/test]: Seeding random number generator class
> java.security.SecureRandom
>      [java] StandardManager[/test]: Seeding of random number generator has
> been completed
>      [java] StandardWrapper[/test:default]: Loading container servlet
> default
>      [java] StandardWrapper[/test:invoker]: Loading container servlet
> invoker
>      [java] StandardWrapper[/test:jsp]: Using Jasper classloader for
> servlet jsp
>      [java] HttpConnector[8180] Starting background thread
>
> tests:
>     [junit] Running org.apache.cactus.TestAll
>      [java] StandardWrapper[/test:JspRedirector]: Using Jasper classloader
> for servlet JspRedirector
>     [junit] Tests run: 41, Failures: 0, Errors: 1, Time elapsed: 10.154
sec
>     [junit] Testsuite: org.apache.cactus.TestAll
>     [junit] Tests run: 41, Failures: 0, Errors: 1, Time elapsed: 10.154
sec
>     [junit]
>     [junit] Testcase: testLongProcess took 3.655 sec
>     [junit] Testcase: testLotsOfData took 2.003 sec
>     [junit] Testcase: testReadServletOutputStream took 0.11 sec
>     [junit] Testcase: testPostMethod took 0.04 sec
>     [junit] Testcase: testGetMethod took 0.03 sec
>     [junit] Testcase: testSetAttribute took 0.03 sec
>     [junit] Testcase: testSetRequestAttribute took 0.04 sec
>     [junit] Testcase: testSendParams took 0.03 sec
>     [junit] Testcase: testSendHeader took 0.05 sec
>     [junit] Testcase: testSendCookie took 0.07 sec
>     [junit] Testcase: testSendMultipleCookies took 0.03 sec
>     [junit] Testcase: testReceiveHeader took 0.031 sec
>     [junit] Testcase: testReceiveCookie took 0.1 sec
>     [junit] Testcase: testRequestDispatcher took 2.153 sec
>     [junit] Testcase: testServletConfig took 0.06 sec
>     [junit] Testcase: testAddHeaderParamOK took 0.09 sec
>     [junit] Testcase: testAddHeaderParamNotDefined took 0.04 sec
>     [junit] Testcase: testAddFooterParamOK took 0.03 sec
>     [junit] Testcase: testAddFooterParamNotDefined took 0.03 sec
>     [junit] Testcase: testDoFilterOK took 0.06 sec
>     [junit] Testcase: testDoStartTag took 0.691 sec
>     [junit] Testcase: testDoStartTagInclude took 0.04 sec
>     [junit] Testcase: testDoEndTagContinue took 0.03 sec
>     [junit] Testcase: testDoEndTagStop took 0.04 sec
>     [junit] Testcase: testReplacement took 0.06 sec
>     [junit] Testcase: testAssertionFailedError took 0.101 sec
>     [junit] Testcase: testExceptionNotSerializable took 0.03 sec
>     [junit] Testcase: testExceptionSerializable took 0.03 sec
>     [junit] Testcase: testNoAutomaticSessionCreation took 0.05 sec
>     [junit] Testcase: testMultiValueParameters took 0.02 sec
>     [junit] Testcase: testWriteOutputStream took 0.03 sec
>     [junit] Testcase: testSetConfigParameter took 0.03 sec
>     [junit] Testcase: testGetServletName took 0.03 sec
>     [junit] Testcase: testSendMultivaluedHeader took 0.02 sec
>     [junit] Testcase: testGetResponseAsStringMultiLines took 0.03 sec
>     [junit] Testcase: testGetResponseAsStringArrayMultiLines took 0.06 sec
>     [junit] Testcase: testCookieEncoding took 0.03 sec
>     [junit] Testcase: testGetRequestDispatcherFromRequest1 took 0.05 sec
>     [junit] Testcase: testGetRequestDispatcherFromRequest2 took 0.03 sec
>     [junit] Testcase: testGetLogs took 0.02 sec
>     [junit] Testcase: testStatusCode took 0.02 sec
>     [junit]     Caused an ERROR
>     [junit] Server returned HTTP response code: 401 for URL:
> http://localhost:8180/test/ServletRedirector/
>     [junit] java.io.IOException: Server returned HTTP response code: 401
> for URL: http://localhost:8180/test/ServletRedi
> rector/
>     [junit]     at
>
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
.java:564)
>     [junit]     at
>
org.apache.cactus.client.AutoReadHttpURLConnection.getInputStream(AutoReadHt
tpURLConnection.java:127)
>
>     [junit]     at
>
org.apache.cactus.client.AbstractHttpClient.doTest(AbstractHttpClient.java:1
36)
>     [junit]     at
>
org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.java:422)
>     [junit]     at
> org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:130)
>     [junit]     at
> org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:371)
>     [junit]     at
> junit.framework.TestResult$1.protect(TestResult.java:106)
>     [junit]     at
> junit.framework.TestResult.runProtected(TestResult.java:124)
>     [junit]     at junit.framework.TestResult.run(TestResult.java:109)
>     [junit]     at junit.framework.TestCase.run(TestCase.java:131)
>     [junit]     at junit.framework.TestSuite.runTest(TestSuite.java:173)
>     [junit]     at junit.framework.TestSuite.run(TestSuite.java:168)
>     [junit]     at junit.framework.TestSuite.runTest(TestSuite.java:173)
>     [junit]     at junit.framework.TestSuite.run(TestSuite.java:168)
>     [junit]     at
>
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRu
nner.java:231)
>     [junit]     at
>
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestR
unner.java:409)
>     [junit]
>
> stop_tomcat_40:
>      [java] Stopping service Tomcat-Standalone
>      [java] HttpConnector[8180] Stopping background thread
>      [java] StandardHost[localhost]: Removing web application at context
> path /test
> [runservertests] Server stopped !
>
> BUILD FAILED
>
> F:\Development\Tools\jakarta-cactus-23-1.2\sample\build\build.xml:376:
Test
> org.apache.cactus.TestAll failed
>
> Total time: 30 seconds
>
>
>
>
>

Reply via email to