Patch for TestRestartService.java

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch for TestRestartService.java

richard.hensley
I'm working with the CVS version of Tapestry 4.0, and could not get the
tests to pass. I've started patching the tests that are failing. I don't
know if this patch is right, but the test now passes. This patch should be
able to be applied using Eclipse, or any other patch capability.


Index: TestRestartService.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tapestry/framework/src/test/org/apache/tapestry/engi
ne/TestRestartService.java,v
retrieving revision 1.5
diff -u -r1.5 TestRestartService.java
--- TestRestartService.java 18 Apr 2005 17:07:51 -0000  1.5
+++ TestRestartService.java 12 May 2005 16:52:01 -0000
@@ -19,6 +19,7 @@
 import javax.servlet.http.HttpSession;
 
 import org.apache.commons.logging.Log;
+import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.engine.RestartService;
 import org.apache.tapestry.junit.TapestryTestCase;
 import org.apache.tapestry.services.AbsoluteURLBuilder;
@@ -41,16 +42,22 @@
 
         MockControl builderControl = newControl(AbsoluteURLBuilder.class);
         AbsoluteURLBuilder builder = (AbsoluteURLBuilder)
builderControl.getMock();
+        
+        MockControl cycleControl = newControl(IRequestCycle.class);
+        IRequestCycle cycle = (IRequestCycle) cycleControl.getMock();

 
         // Training
 
         request.getSession();
         requestControl.setReturnValue(null);
 
-        builder.constructURL("/app");
+        builder.constructURL("http://myserver/app");
         builderControl.setReturnValue("http://myserver/app");
 
         response.sendRedirect("http://myserver/app");
+        
+        cycle.getAbsoluteURL("/app");
+        cycleControl.setReturnValue("http://myserver/app");
 
         replayControls();
 
@@ -60,7 +67,7 @@
         s.setResponse(response);
         s.setServletPath("/app");
 
-        s.service(null);
+        s.service(cycle);
 
         verifyControls();
     }
@@ -77,6 +84,9 @@
 
         HttpSession session = (HttpSession) newMock(HttpSession.class);
 
+        MockControl cycleControl = newControl(IRequestCycle.class);
+        IRequestCycle cycle = (IRequestCycle) cycleControl.getMock();

+
         // Training
 
         request.getSession();
@@ -84,11 +94,14 @@
 
         session.invalidate();
 
-        builder.constructURL("/tap");
+        builder.constructURL("http://myserver/tap");
         builderControl.setReturnValue("http://myserver/tap");
 
         response.sendRedirect("http://myserver/tap");
 
+        cycle.getAbsoluteURL("/tap");
+        cycleControl.setReturnValue("http://myserver/tap");
+
         replayControls();
 
         RestartService s = new RestartService();
@@ -97,7 +110,7 @@
         s.setResponse(response);
         s.setServletPath("/tap");
 
-        s.service(null);
+        s.service(cycle);
 
         verifyControls();
     }
@@ -118,6 +131,9 @@
         Log log = (Log) newMock(Log.class);
 
         IllegalStateException ex = new IllegalStateException();
+        
+        MockControl cycleControl = newControl(IRequestCycle.class);
+        IRequestCycle cycle = (IRequestCycle) cycleControl.getMock();

 
         // Training
 
@@ -129,11 +145,14 @@
 
         log.warn("Exception thrown invalidating HttpSession.", ex);
 
-        builder.constructURL("/app");
+        builder.constructURL("http://myserver/app");
         builderControl.setReturnValue("http://myserver/app");
 
         response.sendRedirect("http://myserver/app");
 
+        cycle.getAbsoluteURL("/app");
+        cycleControl.setReturnValue("http://myserver/app");
+
         replayControls();
 
         RestartService s = new RestartService();
@@ -143,7 +162,7 @@
         s.setLog(log);
         s.setServletPath("/app");
 
-        s.service(null);
+        s.service(cycle);
 
         verifyControls();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Patch for TestRestartService.java

pferraro
This was my fault - the bug fix for TAPESTRY-322 inadvertantly caused a
NullPointerException in the RestartService test case (thanks to Richard
for pointing this out and fixing it).  I failed to catch this because by
console output from my test suite is being overwhelmed by a huge stack
trace (resulting from a StackOverflowError) in the TestMarkupWriter test
case.  Is anyone else experiencing the same thing?

Paul

Here's a snippet:

    [junit] Testcase:
testFlush(org.apache.tapestry.markup.TestMarkupWriter):   Caused an ERROR
    [junit] null
    [junit] java.lang.StackOverflowError
    [junit]     at org.objectweb.asm.ClassWriter.newString(Unknown Source)
    [junit]     at org.objectweb.asm.ClassWriter.newCst(Unknown Source)
    [junit]     at org.objectweb.asm.CodeWriter.visitLdcInsn(Unknown Source)
    [junit]     at net.sf.cglib.core.CodeEmitter.push(CodeEmitter.java:317)
    [junit]     at
net.sf.cglib.core.EmitUtils$6.processCase(EmitUtils.java:285)
    [junit]     at
net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:610)
    [junit]     at
net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:583)
    [junit]     at
net.sf.cglib.core.EmitUtils.string_switch_hash(EmitUtils.java:268)
    [junit]     at
net.sf.cglib.core.EmitUtils.string_switch(EmitUtils.java:170)
    [junit]     at
net.sf.cglib.core.EmitUtils.member_helper_type(EmitUtils.java:810)
    [junit]     at net.sf.cglib.core.EmitUtils.access$900(EmitUtils.java:24)
    [junit]     at
net.sf.cglib.core.EmitUtils$16.processCase(EmitUtils.java:812)
    [junit]     at
net.sf.cglib.core.EmitUtils$6.processCase(EmitUtils.java:293)
    [junit]     at
net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:610)
    [junit]     at
net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:583)
    [junit]     at
net.sf.cglib.core.EmitUtils.string_switch_hash(EmitUtils.java:268)
    [junit]     at
net.sf.cglib.core.EmitUtils.string_switch(EmitUtils.java:170)
    [junit]     at
net.sf.cglib.core.EmitUtils.member_helper_type(EmitUtils.java:810)
    [junit]     at net.sf.cglib.core.EmitUtils.access$900(EmitUtils.java:24)
    [junit]     at
net.sf.cglib.core.EmitUtils$16.processCase(EmitUtils.java:812)
    [junit]     at
net.sf.cglib.core.EmitUtils$6.processCase(EmitUtils.java:293)
    [junit]     at
net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:610)
    [junit]     at
net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:583)

... and so on, and so on...

Hensley, Richard wrote:

>I'm working with the CVS version of Tapestry 4.0, and could not get the
>tests to pass. I've started patching the tests that are failing. I don't
>know if this patch is right, but the test now passes. This patch should be
>able to be applied using Eclipse, or any other patch capability.
>
>
>Index: TestRestartService.java
>===================================================================
>RCS file:
>/home/cvspublic/jakarta-tapestry/framework/src/test/org/apache/tapestry/engi
>ne/TestRestartService.java,v
>retrieving revision 1.5
>diff -u -r1.5 TestRestartService.java
>--- TestRestartService.java 18 Apr 2005 17:07:51 -0000  1.5
>+++ TestRestartService.java 12 May 2005 16:52:01 -0000
>@@ -19,6 +19,7 @@
> import javax.servlet.http.HttpSession;
>
> import org.apache.commons.logging.Log;
>+import org.apache.tapestry.IRequestCycle;
> import org.apache.tapestry.engine.RestartService;
> import org.apache.tapestry.junit.TapestryTestCase;
> import org.apache.tapestry.services.AbsoluteURLBuilder;
>@@ -41,16 +42,22 @@
>
>         MockControl builderControl = newControl(AbsoluteURLBuilder.class);
>         AbsoluteURLBuilder builder = (AbsoluteURLBuilder)
>builderControl.getMock();
>+        
>+        MockControl cycleControl = newControl(IRequestCycle.class);
>+        IRequestCycle cycle = (IRequestCycle) cycleControl.getMock();
>
>
>         // Training
>
>         request.getSession();
>         requestControl.setReturnValue(null);
>
>-        builder.constructURL("/app");
>+        builder.constructURL("http://myserver/app");
>         builderControl.setReturnValue("http://myserver/app");
>
>         response.sendRedirect("http://myserver/app");
>+        
>+        cycle.getAbsoluteURL("/app");
>+        cycleControl.setReturnValue("http://myserver/app");
>
>         replayControls();
>
>@@ -60,7 +67,7 @@
>         s.setResponse(response);
>         s.setServletPath("/app");
>
>-        s.service(null);
>+        s.service(cycle);
>
>         verifyControls();
>     }
>@@ -77,6 +84,9 @@
>
>         HttpSession session = (HttpSession) newMock(HttpSession.class);
>
>+        MockControl cycleControl = newControl(IRequestCycle.class);
>+        IRequestCycle cycle = (IRequestCycle) cycleControl.getMock();
>
>+
>         // Training
>
>         request.getSession();
>@@ -84,11 +94,14 @@
>
>         session.invalidate();
>
>-        builder.constructURL("/tap");
>+        builder.constructURL("http://myserver/tap");
>         builderControl.setReturnValue("http://myserver/tap");
>
>         response.sendRedirect("http://myserver/tap");
>
>+        cycle.getAbsoluteURL("/tap");
>+        cycleControl.setReturnValue("http://myserver/tap");
>+
>         replayControls();
>
>         RestartService s = new RestartService();
>@@ -97,7 +110,7 @@
>         s.setResponse(response);
>         s.setServletPath("/tap");
>
>-        s.service(null);
>+        s.service(cycle);
>
>         verifyControls();
>     }
>@@ -118,6 +131,9 @@
>         Log log = (Log) newMock(Log.class);
>
>         IllegalStateException ex = new IllegalStateException();
>+        
>+        MockControl cycleControl = newControl(IRequestCycle.class);
>+        IRequestCycle cycle = (IRequestCycle) cycleControl.getMock();
>
>
>         // Training
>
>@@ -129,11 +145,14 @@
>
>         log.warn("Exception thrown invalidating HttpSession.", ex);
>
>-        builder.constructURL("/app");
>+        builder.constructURL("http://myserver/app");
>         builderControl.setReturnValue("http://myserver/app");
>
>         response.sendRedirect("http://myserver/app");
>
>+        cycle.getAbsoluteURL("/app");
>+        cycleControl.setReturnValue("http://myserver/app");
>+
>         replayControls();
>
>         RestartService s = new RestartService();
>@@ -143,7 +162,7 @@
>         s.setLog(log);
>         s.setServletPath("/app");
>
>-        s.service(null);
>+        s.service(cycle);
>
>         verifyControls();
>     }
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Patch for TestRestartService.java

dpr-2
I also get the same error.


----- Original Message -----
From: "Paul Ferraro" <[hidden email]>
To: "Tapestry development" <[hidden email]>
Sent: Thursday, May 12, 2005 10:55 PM
Subject: Re: Patch for TestRestartService.java


> This was my fault - the bug fix for TAPESTRY-322 inadvertantly caused a
> NullPointerException in the RestartService test case (thanks to Richard
> for pointing this out and fixing it).  I failed to catch this because by
> console output from my test suite is being overwhelmed by a huge stack
> trace (resulting from a StackOverflowError) in the TestMarkupWriter test
> case.  Is anyone else experiencing the same thing?
>
> Paul
>
> Here's a snippet:
>
>     [junit] Testcase:
> testFlush(org.apache.tapestry.markup.TestMarkupWriter):   Caused an ERROR
>     [junit] null
>     [junit] java.lang.StackOverflowError
>     [junit]     at org.objectweb.asm.ClassWriter.newString(Unknown Source)
>     [junit]     at org.objectweb.asm.ClassWriter.newCst(Unknown Source)
>     [junit]     at org.objectweb.asm.CodeWriter.visitLdcInsn(Unknown
Source)
>     [junit]     at
net.sf.cglib.core.CodeEmitter.push(CodeEmitter.java:317)

>     [junit]     at
> net.sf.cglib.core.EmitUtils$6.processCase(EmitUtils.java:285)
>     [junit]     at
> net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:610)
>     [junit]     at
> net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:583)
>     [junit]     at
> net.sf.cglib.core.EmitUtils.string_switch_hash(EmitUtils.java:268)
>     [junit]     at
> net.sf.cglib.core.EmitUtils.string_switch(EmitUtils.java:170)
>     [junit]     at
> net.sf.cglib.core.EmitUtils.member_helper_type(EmitUtils.java:810)
>     [junit]     at
net.sf.cglib.core.EmitUtils.access$900(EmitUtils.java:24)

>     [junit]     at
> net.sf.cglib.core.EmitUtils$16.processCase(EmitUtils.java:812)
>     [junit]     at
> net.sf.cglib.core.EmitUtils$6.processCase(EmitUtils.java:293)
>     [junit]     at
> net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:610)
>     [junit]     at
> net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:583)
>     [junit]     at
> net.sf.cglib.core.EmitUtils.string_switch_hash(EmitUtils.java:268)
>     [junit]     at
> net.sf.cglib.core.EmitUtils.string_switch(EmitUtils.java:170)
>     [junit]     at
> net.sf.cglib.core.EmitUtils.member_helper_type(EmitUtils.java:810)
>     [junit]     at
net.sf.cglib.core.EmitUtils.access$900(EmitUtils.java:24)

>     [junit]     at
> net.sf.cglib.core.EmitUtils$16.processCase(EmitUtils.java:812)
>     [junit]     at
> net.sf.cglib.core.EmitUtils$6.processCase(EmitUtils.java:293)
>     [junit]     at
> net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:610)
>     [junit]     at
> net.sf.cglib.core.CodeEmitter.process_switch(CodeEmitter.java:583)
>
> ... and so on, and so on...


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]