You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by la...@masq.ca on 2002/04/11 22:08:06 UTC
I'm probably misunderstanding something here...
Hi,
I'm trying to run the attached servlet test, but when I do, I get an error
on the assertion of the content type as text/plain. If I use my Web browser
to access the URL, though, I get the correct type.
Here is the ant target that runs the test:
<target name="run_tests">
<echo message="Running tests"/>
<junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
<classpath>
<pathelement path="${build}"/>
<pathelement path="etc"/>
<pathelement location="${weblogic.lib}/weblogic.jar"/>
<fileset dir="lib">
<include name="**/*.jar"/>
<exclude name="**/log4j.jar"/>
</fileset>
</classpath>
<formatter type="plain" usefile="false"/>
<test name="ca.masq.prototype.laurent.cactus.CactusServletTest"/>
</junit>
</target>
And the error I get is:
run_tests:
[echo] Running tests
[junit] Running ca.masq.prototype.laurent.cactus.CactusServletTest
[java] [warning] Failed to configure logging system : Could not find file [/log_server.properties]
[java] log4j:ERROR No appenders could be found for category (org.apache.cactus.server.ServletTestRedirector).
[java] log4j:ERROR Please initialize the log4j system properly.
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.717 sec
[junit] Testsuite: ca.masq.prototype.laurent.cactus.CactusServletTest
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.717 sec
[junit]
[junit] Testcase: testHelloWorld took 0.706 sec
[junit] FAILED
[junit] Unexpected type expected:<text/plain> but was:<application/x-www-form-urlencoded>
[junit] junit.framework.AssertionFailedError: Unexpected type expected:<text/plain> but was:<application/x-www-form-urlencoded>
[junit] at ca.masq.prototype.laurent.cactus.CactusServletTest.endHelloWorld(Unknown Source)
[junit] at org.apache.cactus.AbstractTestCase.callEndMethod(AbstractTestCase.java:329)
[junit] at org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.java:460)
[junit] at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133)
[junit] at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:400)
[junit]
[junit] Testcase: testHelloWorld
Trying to override old definition of task runservertests
Where is my understanding incorrect?
Thanks,
L
--
Laurent Duperval <ma...@masq.ca>
"God hates me, that's what it is ..."
Re: I'm probably misunderstanding something here...
Posted by la...@masq.ca.
On 15 Apr, Vincent Massol wrote:
> No you're not ... ! :-) I've just read you test case and you have that
> line :
>
> assertEquals("Unexpected type", "text/plain",
> theResponse.getWebRequest().getContentType());
>
<snip>
> However, I believe that what you really want to do is assert the content
> type of the _HTTP Response_ and not the one from the HTTP request, right
> ? You would do that easily by issuing a :
>
> assertEquals("Unexpected type", "text/plain",
> theResponse.getConnection().getContentType());
>
Mumble, grumble, !*@^#!!*@^!)... I believe there's a term for this here...
Ah yes: "Asleep at the switch". I believe this has caused numerous accidents
in the past... :-)
Thanks,
L
--
Laurent Duperval <ma...@masq.ca>
"Si tu te cognes la tête contre un vase et que cela résonne, ne t'empresses
pas à conclure que c'est le vase qui est creux".
-Anonymous
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: I'm probably misunderstanding something here...
Posted by Vincent Massol <vm...@octo.com>.
> -----Original Message-----
> From: laurent.duperval@masq.ca [mailto:laurent.duperval@masq.ca]
> Sent: 15 April 2002 13:52
> To: cactus-user@jakarta.apache.org
> Subject: Re: I'm probably misunderstanding something here...
>
> On 11 Apr, To: Cactus Mailing List wrote:
> > Hi,
> >
> > I'm trying to run the attached servlet test, but when I do, I get an
> error
> > on the assertion of the content type as text/plain. If I use my Web
> browser
> > to access the URL, though, I get the correct type.
> > Here is the ant target that runs the test:
> >
>
> Ouch! Seems like I'm on my own on this one. :-(
No you're not ... ! :-) I've just read you test case and you have that
line :
assertEquals("Unexpected type", "text/plain",
theResponse.getWebRequest().getContentType());
which looks strange to me because you're comparing the content type of
the HTTP request that was sent in beginXXX() to "text/plain". By default
Cactus sends a content type of "application/x-www-form-urlencoded". If
you wanted to specify the content type you would have to issue a
WebRequest.setContentType("text/plain") in beginXXX().
However, I believe that what you really want to do is assert the content
type of the _HTTP Response_ and not the one from the HTTP request, right
? You would do that easily by issuing a :
assertEquals("Unexpected type", "text/plain",
theResponse.getConnection().getContentType());
Cheers,
-Vincent
>
> L
>
> --
> Laurent Duperval <ma...@masq.ca>
>
> "There's a bug born every minute, and two to replace him."
> P. T. Bugem
>
>
>
> --
> 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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: I'm probably misunderstanding something here...
Posted by la...@masq.ca.
On 11 Apr, To: Cactus Mailing List wrote:
> Hi,
>
> I'm trying to run the attached servlet test, but when I do, I get an error
> on the assertion of the content type as text/plain. If I use my Web browser
> to access the URL, though, I get the correct type.
> Here is the ant target that runs the test:
>
Ouch! Seems like I'm on my own on this one. :-(
L
--
Laurent Duperval <ma...@masq.ca>
"There's a bug born every minute, and two to replace him."
P. T. Bugem
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>