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 <mailto:[EMAIL PROTECTED]>
"God hates me, that's what it is ..."
/*
* CactusServletTest.java
* JUnit based test
*
* Created on April 10, 2002, 2:33 PM
*/
package ca.masq.prototype.laurent.cactus;
import org.apache.cactus.*;
import junit.framework.*;
/**
*
* @author laurent
*/
public class CactusServletTest extends ServletTestCase {
public CactusServletTest(java.lang.String testName) {
super(testName);
}
public static void main(java.lang.String[] args) {
junit.textui.TestRunner.run(suite());
}
public static Test suite() {
TestSuite suite = new TestSuite(CactusServletTest.class);
return suite;
}
// Add test methods here, they have to start with 'test' name.
// for example:
// public void testHello() {}
public void testHelloWorld() throws Exception {
CactusServlet servlet = new CactusServlet();
servlet.doGet(request, response);
}
public void endHelloWorld(WebResponse theResponse) {
String expected = "Hello world!";
assertEquals("Unexpected type", "text/plain", theResponse.getWebRequest().getContentType());
assertEquals("Text differs", expected, theResponse.getText());
}
public void testHelloDude() {
CactusServlet servlet = new CactusServlet();
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>