jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: 500 error after accessing WebRequest object
Date Mon, 17 Dec 2001 09:36:22 GMT
Hi Ken,

I have just tried the following test and it works fine for me (with
Cactus 1.3 - I have not tried with Cactus 1.2) :

    public void beginSetContentTypeHeader(WebRequest request)
    {
        request.addHeader("Content-type", "text/xml");
    }

    public void testSetContentTypeHeader()
    {
        assertEquals("text/xml", request.getContentType());
    }

Now, if you are using Cactus 1.3 (still in CVS but you can use the
nightly builds), there is also a new API (which does the same as above)
: WebRequest.setContentType(String contentType)

Ex :

    public void beginTest(WebRequest theRequest)
    {
        theRequest.setContentType("text/xml");
    }

    public void testTest() throws Exception
    {
        assertEquals("text/xml", request.getContentType());
    }


-Vincent

> -----Original Message-----
> From: KenRussell@spektra.co.uk [mailto:KenRussell@spektra.co.uk]
> Sent: 17 December 2001 09:23
> To: Cactus Users List
> Subject: RE: 500 error after accessing WebRequest object
> 
> Thanks for the reply.
> It looks like the problem is a specific header type, as you suggest. I
> want to do some tests based on setting "content-type", but this throws
an
> error whenever I try to set it.
> Other arbitrary header settings seem to run OK, including the test you
> outline below  - no errors for this on my platform.
> I can force content-type OK on the non-cactus tests I have been
running,
> so it looks like I have a problem if I want to cactus-ise my tests. Is
> there a list of "vital" headers which you can't touch when using
cactus?
> Ken
> 
> 
> 
> 
> 
> 
> 
> "Vincent Massol" <vmassol@octo.com>
> 12/14/2001 08:52 PM
> Please respond to "Cactus Users List"
> 
> 
>         To:     "'Cactus Users List'" <cactus-user@jakarta.apache.org>
>         cc:
>         Subject:        RE: 500 error after accessing WebRequest
object
> 
> 
> Ken,
> 
> I don't know what's wrong with what you're doing - it seems fine to me
> (unless you're modifying a "vital" header which cause the server to
> throw a 500 exception).
> 
> There is one test in the Cactus test suite that does this : it is as
> follows :
> 
> public void beginSendHeader(WebRequest theRequest)
> {
>     theRequest.addHeader("testheader", "this is a header test");
> }
> 
> public void testSendHeader()
> {
>     assertEquals("this is a header test",
>        request.getHeader("testheader"));
> }
> 
> -Vincent
> 
> > -----Original Message-----
> > From: KenRussell@spektra.co.uk [mailto:KenRussell@spektra.co.uk]
> > Sent: 14 December 2001 18:29
> > To: cactus-user@jakarta.apache.org
> > Subject: 500 error after accessing WebRequest object
> >
> > Wondering if anyone can help me...
> > I set up a cactus test (testInit) which ran succesfully to
conclusion
> with
> > empty method bodies on beginInit, testInit endInit.
> > I then tried setting a header value in beginInit, using the
WebRequest
> > object. The header was set correctly (I checked this by reading the
> > headers back from the WebRequest object, immediately after setting)
> but
> > the test then threw the following error:
> >
> > test.uk.co.spektra.ofs.runtime.TestCactusOrigoHTTPInput constructor
> > .beginInit
> > E
> > Time: 0.862
> > There was 1 error:
> > 1) testInit(test.uk.co.spektra.ofs.runtime.TestCactusOrigoHTTPInput)
> > java.io.IOException: Server returned HTTP response code: 500 for
URL:
> > http://localhost:8080/ServletRedirector/
> >         at
> >
>
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnec
> ti
> > on.java:564)
> >         at
> >
>
org.apache.cactus.client.AutoReadHttpURLConnection.getInputStream(AutoRe
> ad
> > HttpURLConnection.java:127)
> >         at
> >
>
org.apache.cactus.client.AbstractHttpClient.doTest(AbstractHttpClient.ja
> va
> > :136)
> >         at
> >
>
org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.java:
> 42
> > 2)
> >         at
> > org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:130)
> >         at
> >
org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:371)
> >         at
> >
>
test.uk.co.spektra.ofs.runtime.LocalTestPackage.main(LocalTestPackage.ja
> va
> > :27)
> >
> > FAILURES!!!
> > Tests run: 1,  Failures: 0,  Errors: 1
> >
> > This error appears to get thrown when I start trying to access the
> > WebRequest method.
> > Having looked at the archives, I see references to 500 errors, but
not
> > exactly the same situation.
> > Any ideas?
> > Thanks
> > Ken
> >
> > --
> > To unsubscribe, e-mail:   <mailto:cactus-user-
> > unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: <mailto:cactus-user-
> > help@jakarta.apache.org>
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>
> 




--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message