You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2012/06/12 23:37:15 UTC

[2/2] git commit: TAP5-1873: JavaScript execution exception is not logged

TAP5-1873: JavaScript execution exception is not logged


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/464160fd
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/464160fd
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/464160fd

Branch: refs/heads/5.3
Commit: 464160fdd9044b9e61b2ba9187e13106ebde1244
Parents: 781da0b
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Jun 12 14:34:59 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Jun 12 14:35:57 2012 -0700

----------------------------------------------------------------------
 .../resources/org/apache/tapestry5/tapestry.js     |    6 +-
 .../apache/tapestry5/ioc/util/OrdererSpec.groovy   |  171 +++++++++++++++
 2 files changed, 176 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/464160fd/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
index f97fb03..f23a1e2 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
@@ -373,6 +373,10 @@ var Tapestry = {
 
         Tapestry.debug(Tapestry.Messages.ajaxFailure + exception, response);
 
+        // This covers just FireFox and Opera:
+        var trace = exception.stack || exception.stacktrace;
+        if (exception.stack) { Tapestry.debug(exception.stack); }
+
         throw exception;
     },
 
@@ -450,7 +454,7 @@ var Tapestry = {
                         /* Re-invoke the success handler, capturing any exceptions. */
                         successHandler.call(this, response, jsonResponse);
                     } catch (e) {
-                        finalOptions.get('onException').call(this, response);
+                        finalOptions.get('onException').call(this, response, e);
                     }
                 }
             });

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/464160fd/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OrdererSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OrdererSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OrdererSpec.groovy
new file mode 100644
index 0000000..49e5095
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OrdererSpec.groovy
@@ -0,0 +1,171 @@
+package org.apache.tapestry5.ioc.util
+
+import org.apache.tapestry5.ioc.internal.util.Orderer
+import org.apache.tapestry5.ioc.internal.util.UtilMessages
+import org.slf4j.Logger
+import spock.lang.Specification
+
+class OrdererSpec extends Specification {
+
+  Logger logger = Mock()
+
+  def "the order of the values is unchanged when there are no dependencies"() {
+
+    def orderer = new Orderer(logger)
+
+    when:
+
+    orderer.with {
+      add "fred", "FRED"
+      add "barney", "BARNEY"
+      add "wilma", "WILMA"
+      add "betty", "BETTY"
+    }
+
+    then:
+
+    orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
+  }
+
+  def "an override can change order and value"() {
+    def orderer = new Orderer(logger)
+
+    when:
+
+    orderer.with {
+      add "fred", "FRED"
+      add "barney", "BARNEY"
+      add "wilma", "WILMA"
+      add "betty", "BETTY"
+
+      override "barney", "Mr. Rubble", "before:*"
+    }
+
+    then:
+
+    orderer.ordered == ["Mr. Rubble", "FRED", "WILMA", "BETTY"]
+  }
+
+  def "an override must match a previously added id"() {
+    def orderer = new Orderer(logger)
+
+    when:
+
+    orderer.with {
+      add "fred", "FRED"
+      add "barney", "BARNEY"
+      add "wilma", "WILMA"
+      add "betty", "BETTY"
+
+      override "bambam", "Mr. Rubble JR.", "before:*"
+    }
+
+    then:
+
+    IllegalArgumentException e = thrown()
+
+    e.message == "Override for object 'bambam' is invalid as it does not match an existing object."
+  }
+
+  def "a missing constraint type is logged as a warning"() {
+
+    def orderer = new Orderer(logger)
+
+    when:
+
+    orderer.with {
+      add "fred", "FRED"
+      add "barney", "BARNEY", "fred"
+      add "wilma", "WILMA"
+      add "betty", "BETTY"
+    }
+
+    then:
+
+    logger.warn(UtilMessages.constraintFormat("fred", "barney"))
+
+    orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
+  }
+
+  def "an unknown constraint type is logged as a warning"() {
+    def orderer = new Orderer(logger)
+
+    when:
+
+    orderer.with {
+      add "fred", "FRED"
+      add "barney", "BARNEY", "nearby:fred"
+      add "wilma", "WILMA"
+      add "betty", "BETTY"
+    }
+
+    then:
+
+    logger.warn(UtilMessages.constraintFormat("nearby:fred", "barney"))
+
+    orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
+  }
+
+  def "null values are not included in the result"() {
+    def orderer = new Orderer(logger)
+
+    when:
+
+    orderer.with {
+      add "fred", "FRED"
+      add "barney", "BARNEY"
+      add "zippo", null
+      add "wilma", "WILMA"
+      add "groucho", null
+      add "betty", "BETTY"
+    }
+
+    then:
+
+    orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
+  }
+
+  def "duplicate ids are ignored"() {
+    def orderer = new Orderer(logger)
+
+    orderer.with {
+      add "fred", "FRED"
+      add "barney", "BARNEY"
+      add "wilma", "WILMA"
+    }
+
+    when:
+
+    orderer.add("Fred", "Fred 2")
+
+    then:
+
+    // Notice it uses the previously added id, whose case is considered canonical
+    logger.warn(UtilMessages.duplicateOrderer("fred"))
+
+    when:
+
+    orderer.add "betty", "BETTY"
+
+    then:
+
+    orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
+  }
+
+  def "the special before:* moves the value to the front of the list"() {
+    def orderer = new Orderer(logger)
+
+    when:
+
+    orderer.with {
+      add "fred", "FRED"
+      add "barney", "BARNEY", "before:*"
+      add "wilma", "WILMA"
+      add "betty", "BETTY"
+    }
+
+    then:
+
+    orderer.ordered == ["BARNEY", "FRED", "WILMA", "BETTY"]
+  }
+}