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 Robert Koberg <ro...@koberg.com> on 2002/04/20 01:02:50 UTC
new user - problems with latest nightly build
Hi,
It is taking me a while to get going with Cactus :( I am trying to get
the an example in _Java Tools for Extreme Programming_ (Writing Cactus
Tests starting on page 227).
I have been searching for answers in the archives, but have not found
anything similar. I have taken the properties posted by Vincent Massol
for log4j-1.2beta4.jar
(http://www.mail-archive.com/cactus-user%40jakarta.apache.org/msg01536.html).
I get the following error (test case is below - hitting the servlet
alone returns the expected result):
$ java com.livestoryboard.MapperServletTest
.E
Time: 0.047
There was 1 error:
1) testDoGet(com.livestoryboard.MapperServletTest)
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:42)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:28)
at
org.apache.cactus.AbstractTestCase.callBeginMethod(AbstractTestCase.j
ava:227)
at
org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.ja
va:433)
at
org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133)
at
org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:400)
at
com.livestoryboard.MapperServletTest.main(MapperServletTest.java:49)
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
// MapperServletTest.java
package com.livestoryboard;
import org.apache.cactus.*;
import junit.framework.*;
public class MapperServletTest extends ServletTestCase {
private MapperServlet servlet;
public MapperServletTest(String name) {
super(name);
}
public void beginDoGet(ServletTestRequest request) {
request.addParameter("foo", "manchu");
}
public void setUp() throws Exception {
this.config.setInitParameter("ALL_CAPS", "true");
servlet = new MapperServlet();
servlet.init(config);
}
public void testDoGet() throws Exception {
servlet.doGet(request, response);
String value = (String)session.getAttribute("foo");
assertEquals("request param not mapped into session", "manchu",
value);
}
public void tearDown() {}
//public void testUseAllCaps() {
//assertTrue("servlet set to use all cpas", servletUseAllCaps());
//}
public void endDoGet(WebResponse respons) {
String responseString = respons.getText();
System.out.println(responseString);
boolean paramInResponse = responseString.indexOf("FOO=MANCHU") > -1;
assertTrue("param not foound in response", paramInResponse);
}
public static TestSuite suite() {
TestSuite suite = new TestSuite(MapperServletTest.class);
return suite;
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: new user - problems with latest nightly build
Posted by Nicholas Lesiecki <ni...@eblox.com>.
Sorry Rob, you are correct, WebRequest is the appropriate class. I mistyped.
There isn't currently an erratum for that chapter, although I suppose I
could generate some. Your best bet for Cactus 1.3 is to use the samples that
come with the Cactus distribution.
Cheers,
nick
-----Original Message-----
From: Robert Koberg [mailto:rob@koberg.com]
Sent: Friday, April 19, 2002 7:04 PM
To: Cactus Users List
Subject: Re: new user - problems with latest nightly build
Hi - thanks,
Nicholas Lesiecki wrote:
>Robert,
>
>It looks like you are using the example from the book, which was designed
>with 1.1/1.2 in mind with Cactus 1.3 (the nightly build).
>
>The old begin signature was:
>public void beginDoGet(ServletTestRequest request) {
>
>the new one would be:
>public void beginDoGet(WebTestRequest request) {
>
I tried that but I could not find this class. I then tried WebRequest
and it compiled. But I am still getting errors.I don't suppose there is
errata somewhere (couldn't find it)?
thanks,
-Rob
>
>This would cause the java.lang.IllegalArgumentException: argument type
>mismatch that you are seeing.
>
>Try switching to the new signature and see if that works for you.
>
>Cheers,
>
>Nicholas Lesiecki
>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: new user - problems with latest nightly build
Posted by Robert Koberg <ro...@koberg.com>.
Hi - thanks,
Nicholas Lesiecki wrote:
>Robert,
>
>It looks like you are using the example from the book, which was designed
>with 1.1/1.2 in mind with Cactus 1.3 (the nightly build).
>
>The old begin signature was:
>public void beginDoGet(ServletTestRequest request) {
>
>the new one would be:
>public void beginDoGet(WebTestRequest request) {
>
I tried that but I could not find this class. I then tried WebRequest
and it compiled. But I am still getting errors.I don't suppose there is
errata somewhere (couldn't find it)?
thanks,
-Rob
>
>This would cause the java.lang.IllegalArgumentException: argument type
>mismatch that you are seeing.
>
>Try switching to the new signature and see if that works for you.
>
>Cheers,
>
>Nicholas Lesiecki
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: new user - problems with latest nightly build
Posted by Nicholas Lesiecki <ni...@eblox.com>.
Robert,
It looks like you are using the example from the book, which was designed
with 1.1/1.2 in mind with Cactus 1.3 (the nightly build).
The old begin signature was:
public void beginDoGet(ServletTestRequest request) {
the new one would be:
public void beginDoGet(WebTestRequest request) {
This would cause the java.lang.IllegalArgumentException: argument type
mismatch that you are seeing.
Try switching to the new signature and see if that works for you.
Cheers,
Nicholas Lesiecki
-----Original Message-----
From: Robert Koberg [mailto:rob@koberg.com]
Sent: Friday, April 19, 2002 4:03 PM
To: cactus-user@jakarta.apache.org
Subject: new user - problems with latest nightly build
Hi,
It is taking me a while to get going with Cactus :( I am trying to get
the an example in _Java Tools for Extreme Programming_ (Writing Cactus
Tests starting on page 227).
I have been searching for answers in the archives, but have not found
anything similar. I have taken the properties posted by Vincent Massol
for log4j-1.2beta4.jar
(http://www.mail-archive.com/cactus-user%40jakarta.apache.org/msg01536.html)
.
I get the following error (test case is below - hitting the servlet
alone returns the expected result):
$ java com.livestoryboard.MapperServletTest
.E
Time: 0.047
There was 1 error:
1) testDoGet(com.livestoryboard.MapperServletTest)
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:42)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:28)
at
org.apache.cactus.AbstractTestCase.callBeginMethod(AbstractTestCase.j
ava:227)
at
org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.ja
va:433)
at
org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133)
at
org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:400)
at
com.livestoryboard.MapperServletTest.main(MapperServletTest.java:49)
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
// MapperServletTest.java
package com.livestoryboard;
import org.apache.cactus.*;
import junit.framework.*;
public class MapperServletTest extends ServletTestCase {
private MapperServlet servlet;
public MapperServletTest(String name) {
super(name);
}
public void beginDoGet(ServletTestRequest request) {
request.addParameter("foo", "manchu");
}
public void setUp() throws Exception {
this.config.setInitParameter("ALL_CAPS", "true");
servlet = new MapperServlet();
servlet.init(config);
}
public void testDoGet() throws Exception {
servlet.doGet(request, response);
String value = (String)session.getAttribute("foo");
assertEquals("request param not mapped into session", "manchu",
value);
}
public void tearDown() {}
//public void testUseAllCaps() {
//assertTrue("servlet set to use all cpas", servletUseAllCaps());
//}
public void endDoGet(WebResponse respons) {
String responseString = respons.getText();
System.out.println(responseString);
boolean paramInResponse = responseString.indexOf("FOO=MANCHU") > -1;
assertTrue("param not foound in response", paramInResponse);
}
public static TestSuite suite() {
TestSuite suite = new TestSuite(MapperServletTest.class);
return suite;
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>