tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r547395 - in /tapestry/tapestry4/trunk/tapestry-framework/src: java/org/apache/tapestry/markup/ java/org/apache/tapestry/services/impl/ test/org/apache/tapestry/services/impl/
Date Thu, 14 Jun 2007 20:26:22 GMT
Author: jkuhnert
Date: Thu Jun 14 13:26:21 2007
New Revision: 547395

URL: http://svn.apache.org/viewvc?view=rev&rev=547395
Log:
Fixes TAPESTRY-1574.  Some exceptions - like StaleLinkException - were causing a new page
render in the response but the DojoAjaxResponseBuilder() wasn't taking in to account the fact
that its renderResponse() method might be called twice in one response.

Modified:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/markup/MarkupWriterImpl.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/markup/MarkupWriterImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/markup/MarkupWriterImpl.java?view=diff&rev=547395&r1=547394&r2=547395
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/markup/MarkupWriterImpl.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/markup/MarkupWriterImpl.java
Thu Jun 14 13:26:21 2007
@@ -14,17 +14,13 @@
 
 package org.apache.tapestry.markup;
 
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.util.Defense;
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.NestedMarkupWriter;
+
+import java.io.PrintWriter;
+import java.util.*;
 
 /**
  * Completely revised (for 4.0) implementation of {@link org.apache.tapestry.IMarkupWriter}.
No

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java?view=diff&rev=547395&r1=547394&r2=547395
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
Thu Jun 14 13:26:21 2007
@@ -181,7 +181,16 @@
 
         if (_responseStarted)
         {
+            // clear out any previous input
+            clearPartialWriters();
+            
             cycle.renderPage(this);
+
+            TapestryUtils.removePageRenderSupport(cycle);
+            endResponse();
+
+            _writer.close();
+            
             return;
         }
         
@@ -216,7 +225,7 @@
         cycle.renderPage(this);
         
         TapestryUtils.removePageRenderSupport(cycle);
-        
+
         endResponse();
         
         _writer.close();

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java?view=diff&rev=547395&r1=547394&r2=547395
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java
Thu Jun 14 13:26:21 2007
@@ -13,6 +13,7 @@
 // limitations under the License.
 package org.apache.tapestry.services.impl;
 
+import org.apache.hivemind.Location;
 import org.apache.tapestry.*;
 import org.apache.tapestry.asset.AssetFactory;
 import org.apache.tapestry.engine.IEngineService;
@@ -26,14 +27,15 @@
 import org.apache.tapestry.services.RequestLocaleManager;
 import org.apache.tapestry.services.ResponseBuilder;
 import org.apache.tapestry.services.ServiceConstants;
+import org.apache.tapestry.util.ContentType;
 import org.apache.tapestry.web.WebRequest;
 import org.apache.tapestry.web.WebResponse;
-import static org.easymock.EasyMock.checkOrder;
-import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.*;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 import java.io.CharArrayWriter;
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -42,7 +44,7 @@
 
 /**
  * Tests functionality of {@link DojoAjaxResponseBuilder}.
- * 
+ *
  * @author jkuhnert
  */
 @SuppressWarnings("cast")
@@ -51,7 +53,7 @@
 {
 
     private static CharArrayWriter _writer;
-    
+
     private PrintWriter newPrintWriter()
     {
         _writer = new CharArrayWriter();
@@ -71,152 +73,150 @@
 
         _writer.reset();
     }
-    
-    public void test_Null_Render() 
+
+    public void test_Null_Render()
     {
         IRender render = newMock(IRender.class);
         IRequestCycle cycle = newMock(IRequestCycle.class);
         IMarkupWriter writer = newWriter();
-        
+
         ResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, writer, null);
-        
+
         render.render(NullWriter.getSharedInstance(), cycle);
-        
+
         replay();
-        
+
         builder.render(writer, render, cycle);
-        
+
         verify();
-        
+
         assertSame(builder.getWriter(), writer);
     }
-    
+
     public void test_Normal_Render()
     {
         IRender render = newMock(IRender.class);
         IRequestCycle cycle = newMock(IRequestCycle.class);
         IMarkupWriter writer = newMock(IMarkupWriter.class);
-        
+
         ResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, writer, null);
-        
+
         render.render(NullWriter.getSharedInstance(), cycle);
-        
+
         replay();
-        
+
         builder.render(null, render, cycle);
-        
+
         verify();
-        
+
         assertSame(builder.getWriter(), writer);
     }
-    
-    public void test_Null_Contains() 
+
+    public void test_Null_Contains()
     {
         IRequestCycle cycle = newMock(IRequestCycle.class);
         IMarkupWriter writer = newWriter();
-        
+
         ResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, writer, null);
-        
+
         replay();
-        
+
         builder.isBodyScriptAllowed(null);
-        
+
         verify();
     }
-    
+
     public void test_Partial_Render()
     {
         IRender render = newMock(IRender.class);
-        
+
         IComponent comp1 = newMock(IComponent.class);
         IRequestCycle cycle = newMock(IRequestCycle.class);
         IMarkupWriter writer = newMock(IMarkupWriter.class);
         NestedMarkupWriter nested = newMock(NestedMarkupWriter.class);
-        
+
         Infrastructure infra = newMock(Infrastructure.class);
-        
+
         List parts = new ArrayList();
         parts.add("id1");
-        
+
         DojoAjaxResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, writer, parts);
-        
+
         render.render(NullWriter.getSharedInstance(), cycle);
-        
+
         expect(comp1.getClientId()).andReturn("id1").anyTimes();
-        
+
         expect(comp1.peekClientId()).andReturn("id1").anyTimes();
-        
+
         expect(cycle.getInfrastructure()).andReturn(infra);
-        
+
         expect(infra.getOutputEncoding()).andReturn("UTF-8");
-        
+
         writer.printRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
         writer.printRaw("<!DOCTYPE html "
-                + "PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
-                + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\" [\n"
-                + "<!ENTITY nbsp '&#160;'>\n"
-                + "]>\n");
+                        + "PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
+                        + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\" [\n"
+                        + "<!ENTITY nbsp '&#160;'>\n"
+                        + "]>\n");
         writer.printRaw("<ajax-response>");
-        
+
         expect(writer.getNestedWriter()).andReturn(nested);
-        
+
         nested.begin("response");
         nested.attribute("id", "id1");
         nested.attribute("type", ResponseBuilder.ELEMENT_TYPE);
-        
+
         comp1.render(nested, cycle);
-        
+
         replay();
-        
+
         builder.render(null, render, cycle);
-        
+
         assertTrue(builder.contains(comp1));
         assertTrue(IComponent.class.isInstance(comp1));
-        
+
         builder.render(null, comp1, cycle);
-        
+
         verify();
-        
+
         assertSame(builder.getWriter(), writer);
     }
-    
+
     public void test_Page_Render()
     {
         IPage page = newMock(IPage.class);
         checkOrder(page, false);
-        
+
         IRequestCycle cycle = newMock(IRequestCycle.class);
         RequestLocaleManager rlm = newMock(RequestLocaleManager.class);
-        
+
         MarkupWriterSource mrs = newMock(MarkupWriterSource.class);
         WebResponse resp = newMock(WebResponse.class);
         WebRequest req = newMock(WebRequest.class);
         AssetFactory assetFactory = newMock(AssetFactory.class);
         IEngineService pageService = newEngineService();
-        
+
         List errorPages = new ArrayList();
-        
+
         List parts = new ArrayList();
         parts.add("id1");
-        
-        DojoAjaxResponseBuilder builder = 
-            new DojoAjaxResponseBuilder(cycle, rlm, mrs, resp, req,
-                    errorPages, assetFactory, "", pageService);
-        
+
+        DojoAjaxResponseBuilder builder =
+                new DojoAjaxResponseBuilder(cycle, rlm, mrs, resp, req,
+                                            errorPages, assetFactory, "", pageService);
+
         expect(page.getPageName()).andReturn("RequestPage").anyTimes();
-        
         expect(cycle.getParameter(ServiceConstants.PAGE)).andReturn("RequestPage").anyTimes();
-        
         expect(page.peekClientId()).andReturn("pageId");
-        
+
         expect(cycle.renderStackIterator()).andReturn(Collections.EMPTY_LIST.iterator());
-        
+
         page.render(NullWriter.getSharedInstance(), cycle);
-        
+
         replay();
-        
+
         builder.render(null, page, cycle);
-        
+
         verify();
     }
 
@@ -224,231 +224,299 @@
     {
         IPage page = newMock(IPage.class);
         checkOrder(page, false);
-        
+
         IRequestCycle cycle = newMock(IRequestCycle.class);
         IMarkupWriter writer = newMock(IMarkupWriter.class);
         NestedMarkupWriter nwriter = newNestedWriter();
-        
+
         ILink link = newMock(ILink.class);
-        
+
         RequestLocaleManager rlm = newMock(RequestLocaleManager.class);
         MarkupWriterSource mrs = newMock(MarkupWriterSource.class);
         WebResponse resp = newMock(WebResponse.class);
         WebRequest req = newMock(WebRequest.class);
         AssetFactory assetFactory = newMock(AssetFactory.class);
         IEngineService pageService = newEngineService();
-        
+
         List errorPages = new ArrayList();
-        
+
         List parts = new ArrayList();
         parts.add("id1");
-        
-        DojoAjaxResponseBuilder builder = 
-            new DojoAjaxResponseBuilder(cycle, rlm, mrs, resp, req,
-                    errorPages, assetFactory, "", pageService);
-        
+
+        DojoAjaxResponseBuilder builder =  new DojoAjaxResponseBuilder(cycle, rlm, mrs, resp,
req,
+                                                                       errorPages, assetFactory,
"", pageService);
+
         builder.setWriter(writer);
-        
+
         expect(page.getPageName()).andReturn("RequestPage").anyTimes();
-        
         expect(cycle.getParameter(ServiceConstants.PAGE)).andReturn("anotherPage").anyTimes();
-        
+
         expect(writer.getNestedWriter()).andReturn(nwriter);
         nwriter.begin("response");
         nwriter.attribute("type", ResponseBuilder.PAGE_TYPE);
-        
+
         expect(pageService.getLink(true, "RequestPage")).andReturn(link);
         expect(link.getAbsoluteURL()).andReturn("/new/url");
-        
+
         nwriter.attribute("url", "/new/url");
-        
+
         replay();
-        
+
         builder.render(null, page, cycle);
+
+        verify();
+    }
+
+    private static final String NEWLINE = System.getProperty("line.separator");
+
+    public void test_Render_Response_Already_Started()
+            throws IOException
+    {
+        IPage page = newMock(IPage.class);
+        checkOrder(page, false);
+        IRequestCycle cycle = newMock(IRequestCycle.class);
+        Infrastructure infra = newMock(Infrastructure.class);
+        IMarkupWriter writer = newBufferWriter();
+        NestedMarkupWriter nwriter = newNestedWriter();
+
+        ILink link = newMock(ILink.class);
+        Location l = newLocation();
         
+        RequestLocaleManager rlm = newMock(RequestLocaleManager.class);
+        MarkupWriterSource mrs = newMock(MarkupWriterSource.class);
+        WebResponse resp = newMock(WebResponse.class);
+        WebRequest req = newMock(WebRequest.class);
+        AssetFactory assetFactory = newMock(AssetFactory.class);
+        IEngineService pageService = newEngineService();
+
+        List errorPages = new ArrayList();
+
+        List parts = new ArrayList();
+        parts.add("id1");
+
+        DojoAjaxResponseBuilder builder =  new DojoAjaxResponseBuilder(cycle, rlm, mrs, resp,
req,
+                                                                       errorPages, assetFactory,
"", pageService);
+
+        PrintWriter pw = newPrintWriter();
+
+        rlm.persistLocale();
+        expect(cycle.getInfrastructure()).andReturn(infra).anyTimes();
+        expect(infra.getOutputEncoding()).andReturn(("UTF-8")).anyTimes();
+        expect(cycle.getParameters("updateParts")).andReturn((String[])parts.toArray(new
String[parts.size()]));
+        expect(resp.getPrintWriter(isA(ContentType.class))).andReturn(pw);
+        expect(mrs.newMarkupWriter(eq(pw), isA(ContentType.class))).andReturn(writer);
+
+        expect(cycle.getPage()).andReturn(page);
+        expect(page.getLocation()).andReturn(l);
+        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(null);
+        cycle.setAttribute(eq(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE), isA(PageRenderSupport.class));
+        
+        cycle.renderPage(builder);
+        // only done to simulate a caught internal stale link / other exception that would
cause a new renderPage() request 
+        expectLastCall().andThrow(new RedirectException("redir"));
+        
+        cycle.renderPage(builder);
+        cycle.removeAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE);
+
+        replay();
+
+        try {
+
+            builder.renderResponse(cycle);
+            unreachable();
+        } catch (RedirectException e)
+        {
+            IMarkupWriter fakeWriter = builder.getComponentWriter("fakeComp");
+            fakeWriter.beginEmpty("div");
+            fakeWriter.attribute("id", "fakeComp");
+            
+            builder.renderResponse(cycle);
+        }
+
         verify();
+
+        assertBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.0 Transitional//EN\" " +
+                     "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\" [" + NEWLINE
+
+                     "<!ENTITY nbsp '&#160;'>" + NEWLINE +
+                     "]>" + NEWLINE +
+                     "<ajax-response></ajax-response>");
     }
-    
+
     public void test_Allowed_Scripts()
     {
         IRequestCycle cycle = newMock(IRequestCycle.class);
         IComponent comp = newMock(IComponent.class);
         IMarkupWriter writer = newWriter();
-        
+
         List parts = new ArrayList();
         parts.add("comp1");
-        
+
         ResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, writer, parts);
-        
+
         expect(comp.getClientId()).andReturn("comp");
 
         expect(cycle.renderStackIterator()).andReturn(Collections.EMPTY_LIST.iterator());
-        
+
         expect(comp.getClientId()).andReturn("comp1");
         expect(comp.getClientId()).andReturn("comp");
-        
+
         expect(cycle.renderStackIterator()).andReturn(Collections.EMPTY_LIST.iterator());
-        
+
         replay();
-        
+
         assertFalse(builder.isBodyScriptAllowed(comp));
         assertTrue(builder.isExternalScriptAllowed(comp));
         assertFalse(builder.isInitializationScriptAllowed(comp));
-        
+
         verify();
     }
-    
+
     public void test_Script_Contains_Stack()
     {
         IRequestCycle cycle = newMock(IRequestCycle.class);
         IComponent comp = newMock(IComponent.class);
         checkOrder(comp, false);
-        
+
         IMarkupWriter writer = newWriter();
-        
+
         List parts = new ArrayList();
         parts.add("comp1");
-        
+
         List stack = new ArrayList();
         stack.add(comp);
-        
+
         ResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, writer, parts);
-        
+
         expect(comp.getClientId()).andReturn("comp").anyTimes();
-        
+
         expect(cycle.renderStackIterator()).andReturn(stack.iterator()).anyTimes();
-        
+
         replay();
-        
+
         assertFalse(builder.isBodyScriptAllowed(comp));
         assertFalse(builder.isExternalScriptAllowed(comp));
         assertFalse(builder.isInitializationScriptAllowed(comp));
-        
+
         verify();
     }
-    
+
     public void test_Write_Body_Script()
     {
         MarkupFilter filter = new UTFMarkupFilter();
         PrintWriter writer = newPrintWriter();
         IRequestCycle cycle = newMock(IRequestCycle.class);
         Infrastructure inf = newMock(Infrastructure.class);
-        
+
         replay();
-        
+
         IMarkupWriter mw = new MarkupWriterImpl("text/html", writer, filter);
         DojoAjaxResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, mw, null);
-        
+
         String bscript = "var e=4;";
         String imageInit = "image initializations";
         String preload = "preloadedvarname";
-        
+
         verify();
-        
+
         expect(cycle.getInfrastructure()).andReturn(inf);
         expect(inf.getOutputEncoding()).andReturn("UTF-8");
-        
+
         replay();
-        
+
         builder.beginResponse();
-        
         builder.beginBodyScript(mw, cycle);
-        
         builder.writeImageInitializations(mw, imageInit, preload, cycle);
-        
         builder.writeBodyScript(mw, bscript, cycle);
-        
         builder.endBodyScript(mw, cycle);
-        
         builder.endResponse();
-        
-        assertOutput("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"
[\n" + 
-                "<!ENTITY nbsp \'&#160;\'>\n" + 
-                "]>\n" + 
-                "<ajax-response><response id=\"bodyscript\" type=\"script\"><script>\n"
+ 
-                "//<![CDATA[\n" + 
-                "\n" + 
-                "preloadedvarname = [];\n" + 
-                "if (document.images) {\n" + 
-                "image initializations}\n" + 
-                "var e=4;\n" + 
-                "//]]>\n" + 
-                "</script></response></ajax-response>");
-        
+
+        assertOutput("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"
[\n" +
+                     "<!ENTITY nbsp \'&#160;\'>\n" +
+                     "]>\n" +
+                     "<ajax-response><response id=\"bodyscript\" type=\"script\"><script>\n"
+
+                     "//<![CDATA[\n" +
+                     "\n" +
+                     "preloadedvarname = [];\n" +
+                     "if (document.images) {\n" +
+                     "image initializations}\n" +
+                     "var e=4;\n" +
+                     "//]]>\n" +
+                     "</script></response></ajax-response>");
+
         verify();
     }
-    
+
     public void test_Write_External_Scripts()
     {
         MarkupFilter filter = new UTFMarkupFilter();
         PrintWriter writer = newPrintWriter();
         IRequestCycle cycle = newMock(IRequestCycle.class);
         Infrastructure inf = newMock(Infrastructure.class);
-        
+
         replay();
-        
+
         IMarkupWriter mw = new MarkupWriterImpl("text/html", writer, filter);
         DojoAjaxResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, mw, null);
-        
+
         String script1 = "http://noname/js/package.js";
         String script2 = "http://noname/js/package2.js";
-        
+
         verify();
-        
+
         expect(cycle.getInfrastructure()).andReturn(inf);
         expect(inf.getOutputEncoding()).andReturn("UTF-8");
-        
+
         replay();
-        
+
         builder.beginResponse();
         builder.writeExternalScript(mw, script1, cycle);
         builder.writeExternalScript(mw, script2, cycle);
         builder.endResponse();
-        
-        assertOutput("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"
[\n" + 
-                "<!ENTITY nbsp \'&#160;\'>\n" + 
-                "]>\n" + 
-                "<ajax-response><response id=\"includescript\" type=\"script\">"

-                + "<include url=\"http://noname/js/package.js\" />"
-                + "<include url=\"http://noname/js/package2.js\" /></response></ajax-response>");
-        
+
+        assertOutput("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"
[\n" +
+                     "<!ENTITY nbsp \'&#160;\'>\n" +
+                     "]>\n" +
+                     "<ajax-response><response id=\"includescript\" type=\"script\">"
+                     + "<include url=\"http://noname/js/package.js\" />"
+                     + "<include url=\"http://noname/js/package2.js\" /></response></ajax-response>");
+
         verify();
     }
-    
+
     public void test_Write_Initialization_Script()
     {
         IRequestCycle cycle = newMock(IRequestCycle.class);
         MarkupFilter filter = new UTFMarkupFilter();
         PrintWriter writer = newPrintWriter();
         Infrastructure inf = newMock(Infrastructure.class);
-        
+
         replay();
-        
+
         IMarkupWriter mw = new MarkupWriterImpl("text/html", writer, filter);
         DojoAjaxResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, mw, null);
-        
+
         String script = "doThisInInit();";
-        
+
         verify();
-        
+
         expect(cycle.getInfrastructure()).andReturn(inf);
         expect(inf.getOutputEncoding()).andReturn("UTF-8");
-        
+
         replay();
-        
+
         builder.beginResponse();
         builder.writeInitializationScript(mw, script);
         builder.endResponse();
-        
-        assertOutput("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"
[\n" + 
-                "<!ENTITY nbsp \'&#160;\'>\n" + 
-                "]>\n" + 
-                "<ajax-response><response id=\"initializationscript\" type=\"script\"><script>\n"
+ 
-                "//<![CDATA[\n" + 
-                "doThisInInit();\n" + 
-                "//]]>\n" + 
-                "</script></response></ajax-response>");
-        
+
+        assertOutput("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"
[\n" +
+                     "<!ENTITY nbsp \'&#160;\'>\n" +
+                     "]>\n" +
+                     "<ajax-response><response id=\"initializationscript\" type=\"script\"><script>\n"
+
+                     "//<![CDATA[\n" +
+                     "doThisInInit();\n" +
+                     "//]]>\n" +
+                     "</script></response></ajax-response>");
+
         verify();
     }
 }



Mime
View raw message