You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2019/01/24 14:45:49 UTC

[myfaces] 01/04: MYFACES-4265: fixing a race condition issue, before proceeding with the next tests.

This is an automated email from the ASF dual-hosted git repository.

werpu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git

commit 6c2f66f64bb0469d0a14fc0538781b174eb69ede
Author: Werner Punz <we...@gmail.com>
AuthorDate: Thu Jan 24 12:09:00 2019 +0100

    MYFACES-4265: fixing a race condition issue, before proceeding with the
    next tests.
---
 integration-tests/ajax/readme.txt                  |   2 +-
 .../ajax/test1Protocol/ResponseMockup.java         | 497 ++++++++++-----------
 .../ajax/test1Protocol/ViewData.java               |  29 ++
 .../responses/TableResponseMockups.java            | 189 ++++++++
 .../ajax/src/main/webapp/WEB-INF/web.xml           |   4 +
 .../ajax/src/main/webapp/scripts/testhelpers.js    |  16 +-
 .../integrationtests/ajax/IntegrationTest.java     |  14 +-
 7 files changed, 469 insertions(+), 282 deletions(-)

diff --git a/integration-tests/ajax/readme.txt b/integration-tests/ajax/readme.txt
index 2dd9116..7929208 100644
--- a/integration-tests/ajax/readme.txt
+++ b/integration-tests/ajax/readme.txt
@@ -1,3 +1,3 @@
 run integration test manually  mvn clean integration-test -Ptomcat-embedded-9
 run jetty: mvn clean package jetty:run-exploded
-JDK baseline JAVA8
+cd JDK baseline JAVA8
diff --git a/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/ResponseMockup.java b/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/ResponseMockup.java
index d39ef01..d19356c 100644
--- a/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/ResponseMockup.java
+++ b/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/ResponseMockup.java
@@ -19,6 +19,7 @@
 package org.apache.myfaces.core.integrationtests.ajax.test1Protocol;
 
 import org.apache.myfaces.core.integrationtests.ajax.test1Protocol.jsfxmlnodes.*;
+import org.apache.myfaces.core.integrationtests.ajax.test1Protocol.responses.TableResponseMockups;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -26,20 +27,46 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 
-class ViewData {
-
-    public int cnt = 0;
-    public int elemCnt = 0;
-    public int red = 0;
-}
 
 
 /**
- * @author werpu
+ * A generic jsf simulating response servlet.
+ * The reason for this is twofold. Parts of this code
+ * and some tests were written even before the jsf.js implementation existed in myfaces.
+ * The other reason is, we can test conditions which are not yet exposed in the jsf impl
+ * but allowed by protocol (insert before and after or delete for instance)
+ *
+ * In the end some tests will use this servlet some tests will fall back into jsf
+ * with our javascript codebase as implementation
  */
 public class ResponseMockup extends HttpServlet {
 
     public static final String VIEW_DATA = "_viewData_";
+    public static final String RESET_STATE = "reset_counters";
+    public static final String EVAL_1 = "eval1";
+    public static final String UPDATEINSERT_1 = "updateinsert1";
+    public static final String UPDATEINSERT_2 = "updateinsert2";
+    public static final String DELETE_1 = "delete1";
+    public static final String VIEWSTATE = "viewstate";
+    public static final String ATTRIBUTES = "attributes";
+    public static final String ERRORS_TAG = "errors";
+    public static final String ILLEGAL_RESPONSE = "illegalResponse";
+    public static final String VIEW_BODY_REPLACE = "body";
+    public static final String VIEW_BODY_REPLACE_2 = "body2";
+    public static final String VIEW_ROOT_REPLACEMENT_1 = "body3";
+    public static final String ILLEGAL_RESPONSE_2 = "illegalResponse";
+    public static final String EXECUTE_NONE = "executenone";
+
+    public static final String TABLE_REPLACE_HEAD = "table_replace_head";
+    public static final String TABLE_REPLACE_BODY = "table_replace_body";
+    public static final String TABLE_INSERT_ROW_HEAD = "table_insert_row_head";
+    public static final String TABLE_INSERT_ROW_BODY = "table_insert_row_body";
+    public static final String TABLE_INSERT_COLUMN_HEAD = "table_insert_column_head";
+    public static final String TABLE_INSERT_COLUMN_BODY = "table_insert_column_body";
+    public static final String TABLE_INSERT_FOOTER = "table_insert_footer";
+    public static final String TABLE_INSERT_BODY = "table_insert_body";
+
+
     private static String DEFAULT_RESPONSE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
             "<partial-response><changes><update id=\"out1\"><![CDATA[<span id=\"out1\">2</span>]]></update><update id" +
             "=\"javax.faces.ViewState\"><![CDATA[j_id1:j_id3]]></update></changes></partial-response>";
@@ -85,131 +112,36 @@ public class ResponseMockup extends HttpServlet {
         try {
 
             if (op == null || op.isEmpty()) {
-                out.println(DEFAULT_RESPONSE);
-            } else if (op.trim().equalsIgnoreCase("reset_counters")) {
-                resetViewData(request, origin);
-                out.println(EMPTY_RESPONSE);
-                System.out.println("reset");
-            } else if (op.trim().toLowerCase().equals("eval1")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Eval(changes, "document.getElementById('evalarea1').innerHTML = 'eval test succeeded';"));
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("updateinsert1")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Update(changes, "changesArea", "<div id='changesArea'>update succeeded " + (viewData.cnt++) + "</div><script type='text/javascript'>document.getElementById('evalarea2').innerHTML='embedded script at update succeed';</script>"));
-                changes.addChild(new Insert(changes, "inserted1", "<div id='insertbefore'>insert before succeeded should display before test1</div><script type='text/javascript'>document.getElementById('evalarea3').innerHTML='embedded script at insert succeed';</script>", "changesArea", null));
-                changes.addChild(new Insert(changes, "inserted2", "<div  id='insertafter'>insert after succeeded should display after test1</div>", null, "changesArea"));
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("updateinsert2")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Update(changes, "changesArea", "<div id='changesArea'>update succeeded 1</div><script type='text/javascript'>document.getElementById('evalarea2').innerHTML='embedded script at update succeed';</script>"));
-                changes.addChild(new Insert2(changes, "inserted1", "<div id='insertbefore'>insert2 before succeeded " +
-                        "should display before test1</div><script type='text/javascript'>document.getElementById('evalarea3').innerHTML='embedded script at insert succeed';</script>", "changesArea", null));
-                changes.addChild(new Insert2(changes, "inserted2", "<div  id='insertafter'>insert2 after succeeded " +
-                        "should display after test1</div>", null, "changesArea"));
-                root.addElement(changes);
-                out.println(root.toString());
-
-            } else if (op.trim().toLowerCase().equals("delete1")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Delete(changes, "deleteable"));
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("viewstate")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Update(changes, "javax.faces.ViewState", "hello world"));
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("attributes")) {
-                Changes changes = new Changes(root);
-                Attributes attr = new Attributes(changes, "attributeChange");
-                attr.addAttribute(new Attribute("style", "color:rgb(" + ((viewData.red += 10) % 255) + ",100,100);"));
-                attr.addAttribute(new Attribute("style", "border:1px solid black"));
-                attr.addAttribute(new Attribute("onclick", "document.getElementById('evalarea4').innerHTML = 'attributes onclick succeeded';"));
-
-                changes.addChild(attr);
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("errors")) {
-                root.addElement(new ErrorResponse(root, "Error1", "Error1 Text"));
-                root.addElement(new ErrorResponse(root, "Error2", "Error2 Text"));
-
-                out.println(root.toString());
-            } else if (op.trim().equals("illegalResponse")) {
-                out.println(">>>> xxxx >YYYY-!->>>");
-            } else if (op.trim().toLowerCase().equals("body")) {
+                defaultResponse(out);
+            } else if (op.trim().equalsIgnoreCase(RESET_STATE)) {
+                resetInternalState(request, origin, out);
+            } else if (op.trim().toLowerCase().equals(EVAL_1)) {
+                embeddedJavascript1(out, root);
+            } else if (op.trim().toLowerCase().equals(UPDATEINSERT_1)) {
+                updateInsert1(viewData, out, root);
+            } else if (op.trim().toLowerCase().equals(UPDATEINSERT_2)) {
+                updateInsert2(out, root);
+
+            } else if (op.trim().toLowerCase().equals(DELETE_1)) {
+                delete1(out, root);
+            } else if (op.trim().toLowerCase().equals(VIEWSTATE)) {
+                viewstateHandling(out, root);
+            } else if (op.trim().toLowerCase().equals(ATTRIBUTES)) {
+                attributeHandling(viewData, out, root);
+            } else if (op.trim().toLowerCase().equals(ERRORS_TAG)) {
+                errors(out, root);
+            } else if (op.trim().equals(ILLEGAL_RESPONSE)) {
+                illegalResponse(out);
+            } else if (op.trim().toLowerCase().equals(VIEW_BODY_REPLACE)) {
                 //we omit our xml builder for now
-                StringBuilder replacement = new StringBuilder();
-
-                replacement.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">" +
-                        "<head>");
-                replacement.append("    <title></title>");
-                replacement.append("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
-                replacement.append("    <script type=\"text/javascript\" src=\"./myfaces/_impl/core/_Runtime.js\"></script>");
-
-                replacement.append("    <script type=\"text/javascript\" src=\"./myfaces/_impl/_util/_Lang.js\"></script>");
-                replacement.append("</head>" +
-                        "<body class=\"tundra\">  <div id=\"myfaces.logging\">\n" +
-                        "    </div>" +
-                        "    <div id = \"centerDiv\">\n" +
-                        "        <h1>Selenium Test for body change done</h1>\n" +
-                        "        <div id = \"testResults\">\n" +
-                        "            <h3>Body replacement test  successful</h3>" +
-                        "<div id='scriptreceiver'></div>\n" +
-                        "        " +
-                        "   <script type='text/javascript'>var b = true && true; document.getElementById" +
-                        "('scriptreceiver').innerHTML=" +
-                        "'hello from embedded script & in the body'; " +
-                        "</script>            </div>" +
-                        "    </div>" +
-                        "</body>" +
-                        "</html>");
+                viewBodyWithFullHTMLResponse(out, root);
+            } else if (op.trim().toLowerCase().equals(VIEW_BODY_REPLACE_2)) {
+                viewBodyWithOnlyBodyData(viewData, out, root);
 
-                Changes changes = new Changes(root);
-                root.addElement(changes);
-                changes.addChild(new Update(changes, "javax.faces.ViewBody", replacement.toString()));
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("body2")) {
-                //we omit our xml builder for now
-                StringBuilder replacement = new StringBuilder();
-
-                replacement.append("<body class=\"tundra\"> " +
-                        "    <div id=\"myfaces.logging\"><div id = \"centerDiv\">\n" +
-                        "        <h1>Selenium Test for body change done</h1>\n");
-                for (int cnt = 0; cnt < 300; viewData.cnt++) {
-                    replacement.append("        <div id = \"testResults" + cnt + "\" ></div>\n");
-                }
-                replacement.append("            <h3>Body replacement test successful</h3>\n" +
-                        //             "   <script type='text/javascript'>alert('hello from embedded script in replacement body');</script>            </div>" +
-                        "    </div>" +
-                        "</body>");
-
-                Changes changes = new Changes(root);
-                root.addElement(changes);
-                changes.addChild(new Update(changes, "javax.faces.ViewBody", replacement.toString()));
-                out.println(root.toString());
-
-            } else if (op.trim().toLowerCase().equals("body3")) {
-
-                File fIn = new File("/Users/werpu/development/workspace/TestRI20/TestRI20/src/main/webapp/34beta.html.html");
-                FileReader fRead = new FileReader(fIn);
-                BufferedReader reader = new BufferedReader(fRead);
-                String line = null;
-                StringBuilder replacement = new StringBuilder();
-                do {
-                    line = reader.readLine();
-                    if (line != null) {
-                        replacement.append(line);
-                        replacement.append("\n");
-                    }
-                } while (line != null);
-                Changes changes = new Changes(root);
-                root.addElement(changes);
-                changes.addChild(new Update(changes, "javax.faces.ViewRoot", replacement.toString()));
-                out.println(root.toString());
+            } else if (op.trim().toLowerCase().equals(VIEW_ROOT_REPLACEMENT_1)) {
+                viewRootReplacement1(out, root);
 
+                //TODO check if still used?
             } else if (op.trim().toLowerCase().equals("serversideresponsewriter")) {
                 DeferredScriptMockup scriptMockup = new DeferredScriptMockup();
                 Changes changes = new Changes(root);
@@ -217,150 +149,183 @@ public class ResponseMockup extends HttpServlet {
                 root.addElement(changes);
                 out.println(root.toString());
                 // table tests
-            } else if (op.trim().toLowerCase().equals("illegalResponse")) {
-                out.println("blablabl this is an illegal reponse, you should see an error");
-            } else if (op.trim().toLowerCase().equals("table_replace_head")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Update(changes, "head1", "<thead id=\"head1\">" +
-                        "<tr id=\"head_row1\">" +
-                        "<td id=\"head_col1\"><div id=\"col1_head\">column1 in line1 replaced</div></td>" +
-                        "<td id=\"head_col2\">colum2 in line1 replaced<script " +
-                        "type=\"text/javascript\">document.getElementById(\"head_col1\").innerHTML = document" +
-                        ".getElementById(\"head_col1\").innerHTML+\"<div class='eval_result'>script evaled" + (viewData.cnt++)
-                        + "</div>\";" +
-                        "</script></td>" +
-                        "</tr>" +
-                        "</thead>"));
+            } else if (op.trim().toLowerCase().equals(ILLEGAL_RESPONSE_2)) {
+                illegalResponse2(out);
+            } else if (op.trim().toLowerCase().equals(TABLE_REPLACE_HEAD)) {
+                TableResponseMockups.tableReplaceHead(viewData, out, root);
+
+            } else if (op.trim().toLowerCase().equals(TABLE_REPLACE_BODY)) {
+                TableResponseMockups.tableReplaceBody(viewData, out, root);
+            } else if (op.trim().toLowerCase().equals(TABLE_INSERT_ROW_HEAD)) {
+                TableResponseMockups.tableInsertRowHead(viewData, out, root);
+            } else if (op.trim().toLowerCase().equals(TABLE_INSERT_ROW_BODY)) {
+                TableResponseMockups.tableInsertRowBody(viewData, out, root);
+            } else if (op.trim().toLowerCase().equals(TABLE_INSERT_COLUMN_HEAD)) {
+                TableResponseMockups.tableInsetColumnHead(viewData, out, root);
+            } else if (op.trim().toLowerCase().equals(TABLE_INSERT_COLUMN_BODY)) {
+                TableResponseMockups.tableInsertColumnBody(viewData, out, root);
+            } else if (op.trim().toLowerCase().equals(TABLE_INSERT_FOOTER)) {
+                TableResponseMockups.tableInsertFooter(out, root);
+            } else if (op.trim().toLowerCase().equals(TABLE_INSERT_BODY)) {
+                TableResponseMockups.tableInsertBody(out, root);
+            } else if (op.trim().toLowerCase().equals(EXECUTE_NONE)) {
+                TableResponseMockups.execteNone(request, out, root);
+            }
 
-                root.addElement(changes);
-                out.println(root.toString());
+        } finally {
+            out.close();
+        }
+    }
 
-            } else if (op.trim().toLowerCase().equals("table_replace_body")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Update(changes, "tbody1", "<tbody id=\"tbody1\">" +
-                        "<tr id=\"body_row1\">" +
-                        "<td id=\"body_row1_col1\"><div id=\"col1_body\">column1 in line1 replaced</div></td>" +
-                        "<td id=\"body_row1_col2\">colum2 in line1 replaced<script " +
-                        "type=\"text/javascript\">document.getElementById(\"body_row1_col1\").innerHTML = document" +
-                        ".getElementById(\"body_row1_col1\").innerHTML+\"<div class='eval_result'>script " +
-                        "evaled" + (viewData.cnt++) + "</div>\";" +
-                        "</script></td>" +
-                        "</tr>" +
-                        "</tbody>"));
+    private void illegalResponse2(PrintWriter out) {
+        out.println("blablabl this is an illegal reponse, you should see an error");
+    }
 
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("table_insert_row_head")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Insert2(changes, "head_row1", " <tr class='insert_before' id=\"head_row1_" + (viewData.elemCnt++) + "\">\n" +
-                        "                <td id=\"head_col1_" + viewData.elemCnt + "\">column1 in line1 inserted " +
-                        "before</td>\n" +
-                        "                <td id=\"head_col2_" + viewData.elemCnt + "\">colum2 in line2 inserted before</td>\n" +
-                        "            </tr>", "head_row1", null));
-                changes.addChild(new Insert2(changes, "head_row2", " <tr class='insert_after' id=\"head_row" +
-                        (viewData.elemCnt++) + "\">\n" +
-                        "                <td id=\"head_col1_" + viewData.elemCnt + "\">column1 in line1 inserted after" +
-                        "                </td>" +
-                        "                <td id=\"head_col2_" + viewData.elemCnt + "\">" +
-                        "                  colum2 in line2 inserted after" +
-                        "                  <script type=\"text/javascript\">" +
-                        "                       document.getElementById(\"head_col1_" + viewData.elemCnt + "\").innerHTML = " +
-                        "                       document.getElementById(\"head_col1_" + viewData.elemCnt + "\")" +
-                        ".innerHTML+\"<div class='eval_result'>script " +
-                        "                       evaled" + (viewData.cnt++) + "</div>\"; " +
-                        "                  </script>" +
-                        "               </td>\n" +
-                        "            </tr>", null, "head_row1"));
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("table_insert_row_body")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Insert2(changes, "body_row1", " <tr class='insert_before' id=\"body_row1_" +
-                        (viewData.elemCnt++) +
-                        "\">\n" +
-                        "                <td id=\"body_row1_" + viewData.elemCnt + "_col1\">column1 in " +
-                        "line1 inserted before</td>\n" +
-                        "                <td id=\"body_row1_" + viewData.elemCnt + "_col2\">colum2 in line2 inserted " +
-                        "before</td>\n" +
-                        "            </tr>", "body_row1", null));
-                changes.addChild(new Insert2(changes, "body_row2", " <tr class='insert_after' id=\"body_row1_" +
-                        (viewData.elemCnt++) + "\">\n" +
-                        "                <td id=\"body_row1_" + viewData.elemCnt + "_col1\">column1 in line1 inserted after" +
-                        "                </td>" +
-                        "                <td id=\"body_row1_" + viewData.elemCnt + "_col2\">" +
-                        "                  colum2 in line2 inserted after" +
-                        "                  <script type=\"text/javascript\">" +
-                        "                       document.getElementById(\"body_row1_col1\").innerHTML = " +
-                        "                       document.getElementById(\"body_row1_" + viewData.elemCnt + "_col1\")" +
-                        ".innerHTML+\"<div class='eval_result'>script " +
-                        "                       evaled" + (viewData.cnt++) + "</div>\"; " +
-                        "                  </script>" +
-                        "               </td>\n" +
-                        "            </tr>", null, "body_row1"));
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("table_insert_column_head")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Insert2(changes, "head_col1", "<td id='head_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
-                        "before" + viewData.elemCnt + "</td>" + "<td id='head_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
-                        "before " + viewData.elemCnt + "</td>",
-                        "head_col1",
-                        null));
-                changes.addChild(new Insert2(changes, "head_col1", "<td id='head_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
-                        "after" + viewData.elemCnt + "</td>" + "<td id='head_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
-                        "after" + viewData.elemCnt + "</td>",
-                        null,
-                        "head_col2"));
+    private void viewRootReplacement1(PrintWriter out, PartialResponse root) throws IOException {
+        //TODO fix this properly, still references the absolute file position
+        File fIn = new File("/Users/werpu/development/workspace/TestRI20/TestRI20/src/main/webapp/34beta.html.html");
+        FileReader fRead = new FileReader(fIn);
+        BufferedReader reader = new BufferedReader(fRead);
+        String line = null;
+        StringBuilder replacement = new StringBuilder();
+        do {
+            line = reader.readLine();
+            if (line != null) {
+                replacement.append(line);
+                replacement.append("\n");
+            }
+        } while (line != null);
+        Changes changes = new Changes(root);
+        root.addElement(changes);
+        changes.addChild(new Update(changes, "javax.faces.ViewRoot", replacement.toString()));
+        out.println(root.toString());
+    }
 
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("table_insert_column_body")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Insert2(changes, "body_row1_col1", "<td id='body_row1_col1_1_" + (viewData.elemCnt++) +
-                        "'>inserted " +
-                        "before" + viewData.elemCnt + "</td>" + "<td id='body_row1_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
-                        "before " + viewData.elemCnt + "</td>",
-                        "body_row1_col1",
-                        null));
-                changes.addChild(new Insert2(changes, "body_row1_col1", "<td id='body_row1_col1_1_" + (viewData.elemCnt++) +
-                        "'>inserted " +
-                        "after" + viewData.elemCnt + "</td>" + "<td id='body_row1_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
-                        "after" + viewData.elemCnt + "</td>",
-                        null,
-                        "body_row1_col2"));
+    private void viewBodyWithOnlyBodyData(ViewData viewData, PrintWriter out, PartialResponse root) {
+        //we omit our xml builder for now
+        StringBuilder replacement = new StringBuilder();
 
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("table_insert_footer")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Insert2(changes, "body_row1_col1", "<tfooter>footer inserted</tfooter>",
-                        null,
-                        "tbody1"));
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("table_insert_body")) {
-                Changes changes = new Changes(root);
-                changes.addChild(new Insert2(changes, "body_row1_col1",
-                        "<tbody><tr><td colspan='2'>second body added</td></tr></tbody>",
-                        null,
-                        "tbody1"));
-                root.addElement(changes);
-                out.println(root.toString());
-            } else if (op.trim().toLowerCase().equals("executenone")) {
-                boolean execute = request.getParameter("javax.faces.partial.execute") != null;
-                boolean render = request.getParameter("javax.faces.partial.render") != null;
+        replacement.append("<body class=\"tundra\"> " +
+                "    <div id=\"myfaces.logging\"><div id = \"centerDiv\">\n" +
+                "        <h1>Selenium Test for body change done</h1>\n");
+        for (int cnt = 0; cnt < 300; viewData.cnt++) {
+            replacement.append("        <div id = \"testResults" + cnt + "\" ></div>\n");
+        }
+        replacement.append("            <h3>Body replacement test successful</h3>\n" +
+                //             "   <script type='text/javascript'>alert('hello from embedded script in replacement body');</script>            </div>" +
+                "    </div>" +
+                "</body>");
+
+        Changes changes = new Changes(root);
+        root.addElement(changes);
+        changes.addChild(new Update(changes, "javax.faces.ViewBody", replacement.toString()));
+        out.println(root.toString());
+    }
 
-                Changes changes = new Changes(root);
-                changes.addChild(new Update(changes, "result", (!execute && !render) ? "<div " +
-                        "id='result'>success</div>" : "<div " +
-                        "id='result'>fail</div>"));
-                root.addElement(changes);
-                out.println(root.toString());
-            }
+    private void viewBodyWithFullHTMLResponse(PrintWriter out, PartialResponse root) {
+        StringBuilder replacement = new StringBuilder();
+
+        replacement.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">" +
+                "<head>");
+        replacement.append("    <title></title>");
+        replacement.append("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
+        replacement.append("    <script type=\"text/javascript\" src=\"./myfaces/_impl/core/_Runtime.js\"></script>");
+
+        replacement.append("    <script type=\"text/javascript\" src=\"./myfaces/_impl/_util/_Lang.js\"></script>");
+        replacement.append("</head>" +
+                "<body class=\"tundra\">  <div id=\"myfaces.logging\">\n" +
+                "    </div>" +
+                "    <div id = \"centerDiv\">\n" +
+                "        <h1>Selenium Test for body change done</h1>\n" +
+                "        <div id = \"testResults\">\n" +
+                "            <h3>Body replacement test  successful</h3>" +
+                "<div id='scriptreceiver'></div>\n" +
+                "        " +
+                "   <script type='text/javascript'>var b = true && true; document.getElementById" +
+                "('scriptreceiver').innerHTML=" +
+                "'hello from embedded script & in the body'; " +
+                "</script>            </div>" +
+                "    </div>" +
+                "</body>" +
+                "</html>");
+
+        Changes changes = new Changes(root);
+        root.addElement(changes);
+        changes.addChild(new Update(changes, "javax.faces.ViewBody", replacement.toString()));
+        out.println(root.toString());
+    }
 
-        } finally {
-            out.close();
-        }
+    private void illegalResponse(PrintWriter out) {
+        out.println(">>>> xxxx >YYYY-!->>>");
+    }
+
+    private void errors(PrintWriter out, PartialResponse root) {
+        root.addElement(new ErrorResponse(root, "Error1", "Error1 Text"));
+        root.addElement(new ErrorResponse(root, "Error2", "Error2 Text"));
+
+        out.println(root.toString());
+    }
+
+    private void attributeHandling(ViewData viewData, PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        Attributes attr = new Attributes(changes, "attributeChange");
+        attr.addAttribute(new Attribute("style", "color:rgb(" + ((viewData.red += 10) % 255) + ",100,100);"));
+        attr.addAttribute(new Attribute("style", "border:1px solid black"));
+        attr.addAttribute(new Attribute("onclick", "document.getElementById('evalarea4').innerHTML = 'attributes onclick succeeded';"));
+
+        changes.addChild(attr);
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    private void viewstateHandling(PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Update(changes, "javax.faces.ViewState", "hello world"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    private void delete1(PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Delete(changes, "deleteable"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    private void updateInsert2(PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Update(changes, "changesArea", "<div id='changesArea'>update succeeded 1</div><script type='text/javascript'>document.getElementById('evalarea2').innerHTML='embedded script at update succeed';</script>"));
+        changes.addChild(new Insert2(changes, "inserted1", "<div id='insertbefore'>insert2 before succeeded " +
+                "should display before test1</div><script type='text/javascript'>document.getElementById('evalarea3').innerHTML='embedded script at insert succeed';</script>", "changesArea", null));
+        changes.addChild(new Insert2(changes, "inserted2", "<div  id='insertafter'>insert2 after succeeded " +
+                "should display after test1</div>", null, "changesArea"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    private void updateInsert1(ViewData viewData, PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Update(changes, "changesArea", "<div id='changesArea'>update succeeded " + (viewData.cnt++) + "</div><script type='text/javascript'>document.getElementById('evalarea2').innerHTML='embedded script at update succeed';</script>"));
+        changes.addChild(new Insert(changes, "inserted1", "<div id='insertbefore'>insert before succeeded should display before test1</div><script type='text/javascript'>document.getElementById('evalarea3').innerHTML='embedded script at insert succeed';</script>", "changesArea", null));
+        changes.addChild(new Insert(changes, "inserted2", "<div  id='insertafter'>insert after succeeded should display after test1</div>", null, "changesArea"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    private void embeddedJavascript1(PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Eval(changes, "document.getElementById('evalarea1').innerHTML = 'eval test succeeded';"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    private void resetInternalState(HttpServletRequest request, String origin, PrintWriter out) {
+        resetViewData(request, origin);
+        out.println(EMPTY_RESPONSE);
+    }
+
+    private void defaultResponse(PrintWriter out) {
+        out.println(DEFAULT_RESPONSE);
     }
 
     /**
diff --git a/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/ViewData.java b/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/ViewData.java
new file mode 100644
index 0000000..bb1f37e
--- /dev/null
+++ b/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/ViewData.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.core.integrationtests.ajax.test1Protocol;
+
+/**
+ * a helper model class storing the testing data
+ */
+public class ViewData {
+
+    public int cnt = 0;
+    public int elemCnt = 0;
+    public int red = 0;
+}
diff --git a/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/responses/TableResponseMockups.java b/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/responses/TableResponseMockups.java
new file mode 100644
index 0000000..b9001e9
--- /dev/null
+++ b/integration-tests/ajax/src/main/java/org/apache/myfaces/core/integrationtests/ajax/test1Protocol/responses/TableResponseMockups.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.core.integrationtests.ajax.test1Protocol.responses;
+
+import org.apache.myfaces.core.integrationtests.ajax.test1Protocol.ViewData;
+import org.apache.myfaces.core.integrationtests.ajax.test1Protocol.jsfxmlnodes.Changes;
+import org.apache.myfaces.core.integrationtests.ajax.test1Protocol.jsfxmlnodes.Insert2;
+import org.apache.myfaces.core.integrationtests.ajax.test1Protocol.jsfxmlnodes.PartialResponse;
+import org.apache.myfaces.core.integrationtests.ajax.test1Protocol.jsfxmlnodes.Update;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.PrintWriter;
+
+/**
+ * A helper class to encapsule the table responses
+ */
+public class TableResponseMockups {
+
+
+    public static void execteNone(HttpServletRequest request, PrintWriter out, PartialResponse root) {
+        boolean execute = request.getParameter("javax.faces.partial.execute") != null;
+        boolean render = request.getParameter("javax.faces.partial.render") != null;
+
+        Changes changes = new Changes(root);
+        changes.addChild(new Update(changes, "result", (!execute && !render) ? "<div " +
+                "id='result'>success</div>" : "<div " +
+                "id='result'>fail</div>"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    public static void tableInsertBody(PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Insert2(changes, "body_row1_col1",
+                "<tbody><tr><td colspan='2'>second body added</td></tr></tbody>",
+                null,
+                "tbody1"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    public static void tableInsertFooter(PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Insert2(changes, "body_row1_col1", "<tfooter>footer inserted</tfooter>",
+                null,
+                "tbody1"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    public static void tableInsertColumnBody(ViewData viewData, PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Insert2(changes, "body_row1_col1", "<td id='body_row1_col1_1_" + (viewData.elemCnt++) +
+                "'>inserted " +
+                "before" + viewData.elemCnt + "</td>" + "<td id='body_row1_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
+                "before " + viewData.elemCnt + "</td>",
+                "body_row1_col1",
+                null));
+        changes.addChild(new Insert2(changes, "body_row1_col1", "<td id='body_row1_col1_1_" + (viewData.elemCnt++) +
+                "'>inserted " +
+                "after" + viewData.elemCnt + "</td>" + "<td id='body_row1_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
+                "after" + viewData.elemCnt + "</td>",
+                null,
+                "body_row1_col2"));
+
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    public static void tableInsetColumnHead(ViewData viewData, PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Insert2(changes, "head_col1", "<td id='head_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
+                "before" + viewData.elemCnt + "</td>" + "<td id='head_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
+                "before " + viewData.elemCnt + "</td>",
+                "head_col1",
+                null));
+        changes.addChild(new Insert2(changes, "head_col1", "<td id='head_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
+                "after" + viewData.elemCnt + "</td>" + "<td id='head_col1_1_" + (viewData.elemCnt++) + "'>inserted " +
+                "after" + viewData.elemCnt + "</td>",
+                null,
+                "head_col2"));
+
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    public static void tableInsertRowBody(ViewData viewData, PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Insert2(changes, "body_row1", " <tr class='insert_before' id=\"body_row1_" +
+                (viewData.elemCnt++) +
+                "\">\n" +
+                "                <td id=\"body_row1_" + viewData.elemCnt + "_col1\">column1 in " +
+                "line1 inserted before</td>\n" +
+                "                <td id=\"body_row1_" + viewData.elemCnt + "_col2\">colum2 in line2 inserted " +
+                "before</td>\n" +
+                "            </tr>", "body_row1", null));
+        changes.addChild(new Insert2(changes, "body_row2", " <tr class='insert_after' id=\"body_row1_" +
+                (viewData.elemCnt++) + "\">\n" +
+                "                <td id=\"body_row1_" + viewData.elemCnt + "_col1\">column1 in line1 inserted after" +
+                "                </td>" +
+                "                <td id=\"body_row1_" + viewData.elemCnt + "_col2\">" +
+                "                  colum2 in line2 inserted after" +
+                "                  <script type=\"text/javascript\">" +
+                "                       document.getElementById(\"body_row1_col1\").innerHTML = " +
+                "                       document.getElementById(\"body_row1_" + viewData.elemCnt + "_col1\")" +
+                ".innerHTML+\"<div class='eval_result'>script " +
+                "                       evaled" + (viewData.cnt++) + "</div>\"; " +
+                "                  </script>" +
+                "               </td>\n" +
+                "            </tr>", null, "body_row1"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    public static void tableInsertRowHead(ViewData viewData, PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Insert2(changes, "head_row1", " <tr class='insert_before' id=\"head_row1_" + (viewData.elemCnt++) + "\">\n" +
+                "                <td id=\"head_col1_" + viewData.elemCnt + "\">column1 in line1 inserted " +
+                "before</td>\n" +
+                "                <td id=\"head_col2_" + viewData.elemCnt + "\">colum2 in line2 inserted before</td>\n" +
+                "            </tr>", "head_row1", null));
+        changes.addChild(new Insert2(changes, "head_row2", " <tr class='insert_after' id=\"head_row" +
+                (viewData.elemCnt++) + "\">\n" +
+                "                <td id=\"head_col1_" + viewData.elemCnt + "\">column1 in line1 inserted after" +
+                "                </td>" +
+                "                <td id=\"head_col2_" + viewData.elemCnt + "\">" +
+                "                  colum2 in line2 inserted after" +
+                "                  <script type=\"text/javascript\">" +
+                "                       document.getElementById(\"head_col1_" + viewData.elemCnt + "\").innerHTML = " +
+                "                       document.getElementById(\"head_col1_" + viewData.elemCnt + "\")" +
+                ".innerHTML+\"<div class='eval_result'>script " +
+                "                       evaled" + (viewData.cnt++) + "</div>\"; " +
+                "                  </script>" +
+                "               </td>\n" +
+                "            </tr>", null, "head_row1"));
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    public static void tableReplaceBody(ViewData viewData, PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Update(changes, "tbody1", "<tbody id=\"tbody1\">" +
+                "<tr id=\"body_row1\">" +
+                "<td id=\"body_row1_col1\"><div id=\"col1_body\">column1 in line1 replaced</div></td>" +
+                "<td id=\"body_row1_col2\">colum2 in line1 replaced<script " +
+                "type=\"text/javascript\">document.getElementById(\"body_row1_col1\").innerHTML = document" +
+                ".getElementById(\"body_row1_col1\").innerHTML+\"<div class='eval_result'>script " +
+                "evaled" + (viewData.cnt++) + "</div>\";" +
+                "</script></td>" +
+                "</tr>" +
+                "</tbody>"));
+
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+
+    public static void tableReplaceHead(ViewData viewData, PrintWriter out, PartialResponse root) {
+        Changes changes = new Changes(root);
+        changes.addChild(new Update(changes, "head1", "<thead id=\"head1\">" +
+                "<tr id=\"head_row1\">" +
+                "<td id=\"head_col1\"><div id=\"col1_head\">column1 in line1 replaced</div></td>" +
+                "<td id=\"head_col2\">colum2 in line1 replaced<script " +
+                "type=\"text/javascript\">document.getElementById(\"head_col1\").innerHTML = document" +
+                ".getElementById(\"head_col1\").innerHTML+\"<div class='eval_result'>script evaled" + (viewData.cnt++)
+                + "</div>\";" +
+                "</script></td>" +
+                "</tr>" +
+                "</thead>"));
+
+        root.addElement(changes);
+        out.println(root.toString());
+    }
+}
diff --git a/integration-tests/ajax/src/main/webapp/WEB-INF/web.xml b/integration-tests/ajax/src/main/webapp/WEB-INF/web.xml
index 043580f..7b736e7 100644
--- a/integration-tests/ajax/src/main/webapp/WEB-INF/web.xml
+++ b/integration-tests/ajax/src/main/webapp/WEB-INF/web.xml
@@ -52,6 +52,10 @@
         <url-pattern>*.mockup</url-pattern>
     </servlet-mapping>
 
+    <welcome-file-list>
+        <welcome-file>index.jsf</welcome-file>
+        <welcome-file>index.xhtml</welcome-file>
+    </welcome-file-list>
     <session-config>
         <tracking-mode>COOKIE</tracking-mode>
     </session-config>
diff --git a/integration-tests/ajax/src/main/webapp/scripts/testhelpers.js b/integration-tests/ajax/src/main/webapp/scripts/testhelpers.js
index 828cf25..57542fd 100644
--- a/integration-tests/ajax/src/main/webapp/scripts/testhelpers.js
+++ b/integration-tests/ajax/src/main/webapp/scripts/testhelpers.js
@@ -29,14 +29,16 @@
  * @param source the source item triggering the event
  * @param event an outer html event object
  * @param action the action to perform on the jsf side (additional parameter which can be interpreted on the server)
- * @param formName formName for the issuing form
+ * @param formId formName for the issuing form
  * @param target the action target (ootional)
  * @param onError onError handler
  * @param onEvent onEvent handler
  */
-function emitPPR(source, event, action, formName, target, onError, onEvent) {
+function emitPPR(source, event, action, formId, target, onError, onEvent) {
+
+    var oldAction = document.getElementById(formId || "form1").action;
+    document.getElementById(formId || "form1").action = target || "test.mockup";
 
-    document.getElementById(formName || "form1").action = target || "test.mockup";
 
     try {
         jsf.ajax.request(/*String|Dom Node*/ source, /*|EVENT|*/ (window.event) ? window.event : event, /*{|OPTIONS|}*/ {
@@ -52,6 +54,10 @@ function emitPPR(source, event, action, formName, target, onError, onEvent) {
         });
     } catch (e) {
         console.error(e);
+    } finally {
+        //setTimeout(function() {
+            document.getElementById(formId || "form1").action = oldAction;
+        // d}, 100);
     }
 
 }
@@ -64,8 +70,8 @@ function emitPPR(source, event, action, formName, target, onError, onEvent) {
  */
 function resetServerValues(evt) {
 
-    var formName = document.querySelectorAll("form").length ? document.querySelector("form")[0].name : null;
-    emitPPR(evt.target, evt, "reset_counters", formName)
+    var formId = document.querySelectorAll("form").length ? document.querySelectorAll("form")[0].id : null;
+    emitPPR(evt.target, evt, "reset_counters", formId)
 }
 
 
diff --git a/integration-tests/ajax/src/test/java/org/apache/myfaces/core/integrationtests/ajax/IntegrationTest.java b/integration-tests/ajax/src/test/java/org/apache/myfaces/core/integrationtests/ajax/IntegrationTest.java
index c9fb952..b30181c 100644
--- a/integration-tests/ajax/src/test/java/org/apache/myfaces/core/integrationtests/ajax/IntegrationTest.java
+++ b/integration-tests/ajax/src/test/java/org/apache/myfaces/core/integrationtests/ajax/IntegrationTest.java
@@ -84,15 +84,14 @@ public class IntegrationTest {
     RequestGuard guard;
 
 
-
-
     @After
     public void after() {
         webDriver.manage().deleteAllCookies();
     }
 
     @Before
-    public void before() {}
+    public void before() {
+    }
 
     public void resetServerValues() {
         waitAjax().withTimeout(10, TimeUnit.SECONDS).until(new Function<WebDriver, Object>() {
@@ -111,12 +110,7 @@ public class IntegrationTest {
         resetServerValues();
 
         webDriver.findElement(new ByIdOrName("mainForm:press")).click();
-        waitAjax().withTimeout(10, TimeUnit.SECONDS).until(new Function<WebDriver, Object>() {
-
-            public Object apply(WebDriver webDriver) {
-                return webDriver.getPageSource().contains("Action Performed");
-            }
-        });
+        waitAjax().withTimeout(10, TimeUnit.SECONDS).until((Function<WebDriver, Object>) webDriver -> webDriver.getPageSource().contains("Action Performed"));
         assertTrue(webDriver.getPageSource().contains("ViewState"));
         assertTrue(webDriver.getPageSource().contains("_ajax_found"));
         assertTrue(webDriver.getPageSource().contains("Action Performed"));
@@ -223,7 +217,7 @@ public class IntegrationTest {
             final WebElement headRow0 = webDriver.findElement(new By.ById("head_row1_0"));
             final WebElement headRow1 = webDriver.findElement(new By.ById("head_row1"));
 
-            return  headRow1.getLocation().y > headRow0.getLocation().y &&
+            return headRow1.getLocation().y > headRow0.getLocation().y &&
                     headRow0.getText().contains("column1 in line1 inserted before") &&
                     headRow0.getText().contains("colum2 in line2 inserted before");
         });