jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@pivolis.com>
Subject RE: Simple test for my login JSP
Date Sat, 29 Mar 2003 22:07:55 GMT
Hi Melissa,

It seems you have found a bug. I've fixed it in the Cactus CVS. That
said, this bug is only hiding another error. The faulty Cactus code is:

      else
      {
          // Display the first 100 characters of the invalid data as it
can
          // be very big ...
          throw new ParsingException("Not a valid response. First 100 "
              + "characters of the reponse: ["
              + theData.substring(0, 100) + "]");
      }

It should show max(100, theData.length()) characters.

Thanks
-Vincent

> -----Original Message-----
> From: White, Melissa [mailto:mwhite@triactive.com]
> Sent: 15 March 2003 00:24
> To: 'Cactus Users List'
> Subject: RE: Simple test for my login JSP
> 
> Trying that attachment again ...
> 
> 
> 
> -----Original Message-----
> From: White, Melissa [mailto:mwhite@triactive.com]
> Sent: Friday, March 14, 2003 5:17 PM
> To: 'Cactus Users List'
> Subject: RE: Simple test for my login JSP
> 
> 
> Hmmm... that results in even more problems. Here is the XML output
from
> ServletTestRunner. I've also attached my cactus.log file.
> 
> <?xml version="1.0" encoding="UTF-8" ?><testsuites><testsuite
> name="com.triactive.webapps.mgr.LoginWebTest" tests="2" failures="0"
> errors="2" time="1.063"><testcase name="testGetJsessionid"
> time="0.875"><error message="String index out of range: 100"
>
type="java.lang.StringIndexOutOfBoundsException">java.lang.StringIndexOu
tO
> fB
> oundsException: String index out of range: 100
> 	at java.lang.String.substring(String.java:1517)
> 	at
>
org.apache.cactus.client.WebTestResultParser.readRootElement(WebTestResu
lt
> Pa
> rser.java;org/apache/cactus/util/log/LogAspect.aj(1k):149)
> 	at
>
org.apache.cactus.client.WebTestResultParser.dispatch56_parse(WebTestRes
ul
> tP
> arser.java;org/apache/cactus/util/log/LogAspect.aj(1k):101)
> 	at
>
org.apache.cactus.client.WebTestResultParser.around56_parse(WebTestResul
tP
> ar
> ser.java;org/apache/cactus/util/log/LogAspect.aj(1k):1222)
> 	at
>
org.apache.cactus.client.WebTestResultParser.parse(WebTestResultParser.j
av
> a;
> org/apache/cactus/util/log/LogAspect.aj(1k):96)
> 	at
>
org.apache.cactus.client.connector.http.DefaultHttpClient.callGetResult(
De
> fa
> ultHttpClient.java;org/apache/cactus/util/log/LogAspect.aj(1k):247)
> 	at
>
org.apache.cactus.client.connector.http.DefaultHttpClient.dispatch48_doT
es
> t(
>
DefaultHttpClient.java;org/apache/cactus/util/log/LogAspect.aj(1k):126)
> 	at
>
org.apache.cactus.client.connector.http.DefaultHttpClient.around48_doTes
t(
> De
> faultHttpClient.java;org/apache/cactus/util/log/LogAspect.aj(1k):1222)
> 	at
>
org.apache.cactus.client.connector.http.DefaultHttpClient.doTest(Default
Ht
> tp
> Client.java;org/apache/cactus/util/log/LogAspect.aj(1k):115)
> 	at
>
org.apache.cactus.AbstractWebServerTestCase.runWebTest(AbstractWebServer
Te
> st
> Case.java:261)
> 	at
>
org.apache.cactus.AbstractWebServerTestCase.runGenericTest(AbstractWebSe
rv
> er
> TestCase.java:203)
> 	at
>
org.apache.cactus.AbstractWebServerTestCase.runTest(AbstractWebServerTes
tC
> as
> e.java:277)
> 	at
>
org.apache.cactus.AbstractClientTestCase.runBare(AbstractClientTestCase.
ja
> va
> :286)
> 	at
>
org.apache.cactus.server.runner.ServletTestRunner.run(ServletTestRunner.
ja
> va
> ;org/apache/cactus/util/log/LogAspect.aj(1k):313)
> 	at
>
org.apache.cactus.server.runner.ServletTestRunner.dispatch75_doGet(Servl
et
> Te
> stRunner.java;org/apache/cactus/util/log/LogAspect.aj(1k):209)
> 	at
>
org.apache.cactus.server.runner.ServletTestRunner.around75_doGet(Servlet
Te
> st
> Runner.java;org/apache/cactus/util/log/LogAspect.aj(1k):1151)
> 	at
>
org.apache.cactus.server.runner.ServletTestRunner.doGet(ServletTestRunne
r.
> ja
> va;org/apache/cactus/util/log/LogAspect.aj(1k):185)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
> 	at
>
allaire.jrun.session.JRunSessionService.service(../session/JRunSessionSe
rv
> ic
> e.java:1082)
> 	at
> allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1270)
> 	at
>
allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunReques
tD
> is
> patcher.java:89)
> 	at
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
> 	at
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
> 	at
>
allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
> 	at
allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:115)
> 	at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
> 	at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
> </error></testcase><testcase name="testLogin" time="0.032"><error
> message="null"
> type="java.lang.NullPointerException">java.lang.NullPointerException
> 	at
>
org.apache.cactus.client.connector.http.AbstractConnectionHelper.dispatc
h3
> 2_
>
getCookieString(AbstractConnectionHelper.java;org/apache/cactus/util/log
/L
> og
> Aspect.aj(1k):186)
> 	at
>
org.apache.cactus.client.connector.http.AbstractConnectionHelper.around3
2_
> ge
>
tCookieString(AbstractConnectionHelper.java;org/apache/cactus/util/log/L
og
> As
> pect.aj(1k):1222)
> 	at
>
org.apache.cactus.client.connector.http.AbstractConnectionHelper.getCook
ie
> St
>
ring(AbstractConnectionHelper.java;org/apache/cactus/util/log/LogAspect.
aj
> (1
> k):167)
> 	at
>
org.apache.cactus.client.connector.http.HttpClientConnectionHelper.dispa
tc
> h4
>
9_connect(HttpClientConnectionHelper.java;org/apache/cactus/util/log/Log
As
> pe
> ct.aj(1k):151)
> 	at
>
org.apache.cactus.client.connector.http.HttpClientConnectionHelper.aroun
d4
> 9_
>
connect(HttpClientConnectionHelper.java;org/apache/cactus/util/log/LogAs
pe
> ct
> .aj(1k):1222)
> 	at
>
org.apache.cactus.client.connector.http.HttpClientConnectionHelper.conne
ct
> (H
>
ttpClientConnectionHelper.java;org/apache/cactus/util/log/LogAspect.aj(1
k)
> :1
> 07)
> 	at
>
org.apache.cactus.client.connector.http.DefaultHttpClient.callRunTest(De
fa
> ul
> tHttpClient.java;org/apache/cactus/util/log/LogAspect.aj(1k):196)
> 	at
>
org.apache.cactus.client.connector.http.DefaultHttpClient.dispatch48_doT
es
> t(
>
DefaultHttpClient.java;org/apache/cactus/util/log/LogAspect.aj(1k):119)
> 	at
>
org.apache.cactus.client.connector.http.DefaultHttpClient.around48_doTes
t(
> De
> faultHttpClient.java;org/apache/cactus/util/log/LogAspect.aj(1k):1222)
> 	at
>
org.apache.cactus.client.connector.http.DefaultHttpClient.doTest(Default
Ht
> tp
> Client.java;org/apache/cactus/util/log/LogAspect.aj(1k):115)
> 	at
>
org.apache.cactus.AbstractWebServerTestCase.runWebTest(AbstractWebServer
Te
> st
> Case.java:261)
> 	at
>
org.apache.cactus.AbstractWebServerTestCase.runGenericTest(AbstractWebSe
rv
> er
> TestCase.java:203)
> 	at
>
org.apache.cactus.AbstractWebServerTestCase.runTest(AbstractWebServerTes
tC
> as
> e.java:277)
> 	at
>
org.apache.cactus.AbstractClientTestCase.runBare(AbstractClientTestCase.
ja
> va
> :286)
> 	at
>
org.apache.cactus.server.runner.ServletTestRunner.run(ServletTestRunner.
ja
> va
> ;org/apache/cactus/util/log/LogAspect.aj(1k):313)
> 	at
>
org.apache.cactus.server.runner.ServletTestRunner.dispatch75_doGet(Servl
et
> Te
> stRunner.java;org/apache/cactus/util/log/LogAspect.aj(1k):209)
> 	at
>
org.apache.cactus.server.runner.ServletTestRunner.around75_doGet(Servlet
Te
> st
> Runner.java;org/apache/cactus/util/log/LogAspect.aj(1k):1151)
> 	at
>
org.apache.cactus.server.runner.ServletTestRunner.doGet(ServletTestRunne
r.
> ja
> va;org/apache/cactus/util/log/LogAspect.aj(1k):185)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
> 	at
>
allaire.jrun.session.JRunSessionService.service(../session/JRunSessionSe
rv
> ic
> e.java:1082)
> 	at
> allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1270)
> 	at
>
allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunReques
tD
> is
> patcher.java:89)
> 	at
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
> 	at
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
> 	at
>
allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
> 	at
allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:115)
> 	at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
> 	at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
> </error></testcase></testsuite></testsuites>
> 
> 
> 
> -----Original Message-----
> From: Jason Arndt [mailto:jarndt196@yahoo.com]
> Sent: Friday, March 14, 2003 4:55 PM
> To: Cactus Users List
> Subject: Re: Simple test for my login JSP
> 
> 
> Have you LoginWebTest extend JspTestCase instead of
> ServletTestCase.
> 
> --- "White, Melissa" <mwhite@triactive.com> wrote:
> > I am trying to use Cactus to unit test our JSPs, but
> > am having difficulty
> > getting a simple test to work. I have a test case
> > defined as follows:
> >
> > public class LoginWebTest extends ServletTestCase
> > {
> >   private static Cookie jsessionid = null;
> >
> >   public LoginWebTest(String name)
> >   {
> >     super(name);
> >   }
> >
> >   public static void main(String[] args)
> >   {
> >     junit.textui.TestRunner.run(suite());
> >   }
> >
> >   public static Test suite()
> >   {
> >     final TestSuite suite = new TestSuite();
> >     suite.addTest(new
> > LoginWebTest("testGetJsessionid"));
> >     suite.addTest(new LoginWebTest("testLogin"));
> >     return suite;
> >   }
> >   public void beginGetJsessionid(WebRequest
> > webRequest)
> >   {
> >     webRequest.setURL("localhost:8101", "",
> > "/portal/login.jsp", null,
> > null);
> >   }
> >
> >   public void testGetJsessionid() {}
> >
> >   public void endGetJsessionid(WebResponse
> > webResponse)
> >   {
> >     Cookie c =
> > webResponse.getCookieIgnoreCase("jsessionid");
> >     assertNotNull(c);
> >     this.jsessionid = c;
> >   }
> >
> >   public void beginLogin(WebRequest webRequest)
> >   {
> >     webRequest.setURL("localhost:8101", "",
> > "/portal/doLogin.jsp", null,
> > null);
> >     webRequest.addParameter("company", "mwhite");
> >     webRequest.addParameter("username", "admin");
> >     webRequest.addParameter("password", "adminpwd");
> >   }
> >
> >   public void testLogin()
> >   {
> >     assertEquals("mwhite",
> > request.getParameter("company"));
> >     SpecialistValue sv =
> >
> (SpecialistValue)session.getAttribute(SpecialistKeys.CURRENT);
> >     assertNotNull("SpecialistValue not found in
> > session", sv);
> >   }
> > }
> >
> > The assertNotNull in testLogin fails, but it is not
> > clear to me that
> > doLogin.jsp is ever being reached. If it is, there
> > should be some output in
> > my JRun log, but there is none. After doLogin.jsp is
> > executed, I should be
> > able to retrieve the SpecialistValue object from the
> > session. Am I missing
> > something?
> >
> > I'm using JRun 3.1.  Any help would be greatly
> > appreciated.
> >
> > -- Melissa
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > cactus-user-help@jakarta.apache.org
> >
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - establish your business online
> http://webhosting.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> 
> 



Mime
View raw message