Enables wrapping of un-serializable exceptions in web mode.

Fixes issue 7847

Change-Id: Ida5ff71be9eb5c0076b367935d13b267b2a9ca3c
Review-Link: https://gwt-review.googlesource.com/#/c/1890/


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11511 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
index f9d58bf..1b0a2af 100644
--- a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
+++ b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
@@ -144,23 +144,6 @@
   }
 
   /**
-   * Convert unserializable exceptions (usually from dev mode) into generic
-   * serializable ones.
-   */
-  private static void ensureSerializable(ExceptionWrapper wrapper,
-      SerializationStreamWriter writer) {
-    if (wrapper == null) {
-      return;
-    }
-    ensureSerializable(wrapper.causeWrapper, writer);
-    try {
-      writer.writeObject(wrapper.exception);
-    } catch (SerializationException e) {
-      wrapper.exception = new Exception(wrapper.exception.toString());
-    }
-  }
-
-  /**
    * This client's info.
    */
   private ClientInfo clientInfo;
@@ -253,10 +236,8 @@
     if (result != null && failureMessage != null) {
       RuntimeException ex = new RuntimeException(failureMessage);
       result.setException(ex);
-    } else if (!GWT.isProdMode() && result.exceptionWrapper != null) {
-      SerializationStreamFactory fac = (SerializationStreamFactory) junitHost;
-      SerializationStreamWriter writer = fac.createStreamWriter();
-      ensureSerializable(result.exceptionWrapper, writer);
+    } else if (result.exceptionWrapper != null) {
+      ensureSerializable(result.exceptionWrapper);
     }
     TestInfo currentTest = getCurrentTest();
     currentResults.put(currentTest, result);
@@ -274,6 +255,25 @@
   }
 
   /**
+   * Convert unserializable exceptions into generic serializable ones.
+   */
+  private void ensureSerializable(ExceptionWrapper wrapper) {
+    if (wrapper == null) {
+      return;
+    }
+
+    ensureSerializable(wrapper.causeWrapper);
+    try {
+      SerializationStreamFactory fac = (SerializationStreamFactory) junitHost;
+      SerializationStreamWriter dummyWriter = fac.createStreamWriter();
+      dummyWriter.writeObject(wrapper.exception);
+    } catch (SerializationException e) {
+      wrapper.exception = new Exception(wrapper.exception.toString() +
+          " (unserializable exception)");
+    }
+  }
+
+  /**
    * Implemented by the generated subclass. Creates an instance of the specified
    * test class by fully qualified name.
    */
diff --git a/user/test/com/google/gwt/junit/client/GWTTestCaseTest.java b/user/test/com/google/gwt/junit/client/GWTTestCaseTest.java
index 1146b89..848f638 100644
--- a/user/test/com/google/gwt/junit/client/GWTTestCaseTest.java
+++ b/user/test/com/google/gwt/junit/client/GWTTestCaseTest.java
@@ -63,7 +63,7 @@
       fail("Expected failure for assertEquals(" + a + ", " + b + ", " + delta + ")");
     }
   }
-  
+
   private Object obj1 = Collections.nCopies(1, "data");
   private Object obj2 = Collections.nCopies(2, "data");
   private Object obj1Equal = Collections.nCopies(1, "data");
@@ -82,10 +82,8 @@
     throw new Exception();
   }
 
-  // Fails in 'web' mode.
-  // Issue: http://code.google.com/p/google-web-toolkit/issues/detail?id=7847
   @ExpectedFailure(withType = JavaScriptException.class)
-  public void _suppressed_testThrowsNonSerializableException() {
+  public void testThrowsNonSerializableException() {
     throw new JavaScriptException("name", "desc");
   }