Revision: 10483
Author:   b...@google.com
Date:     Sat Jul 30 02:20:04 2011
Log:      Integrate r10482 into GWT 2.4 branch.
Issue 6628.

http://code.google.com/p/google-web-toolkit/source/detail?r=10483

Modified:
/releases/2.4/user/src/com/google/web/bindery/requestfactory/server/SimpleRequestProcessor.java /releases/2.4/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTest.java

=======================================
--- /releases/2.4/user/src/com/google/web/bindery/requestfactory/server/SimpleRequestProcessor.java Fri Jun 17 05:16:47 2011 +++ /releases/2.4/user/src/com/google/web/bindery/requestfactory/server/SimpleRequestProcessor.java Sat Jul 30 02:20:04 2011
@@ -126,7 +126,6 @@
     try {
       process(req, responseBean.as());
     } catch (ReportableException e) {
-      e.printStackTrace();
       // Create a new response envelope, since the state is unknown
       responseBean = FACTORY.response();
       responseBean.as().setGeneralFailure(createFailureMessage(e).as());
@@ -200,7 +199,12 @@
     final RequestState source = new RequestState(service);

     // Make sure the RequestFactory is valid
-    service.resolveRequestFactory(req.getRequestFactory());
+    String requestFactoryToken = req.getRequestFactory();
+    if (requestFactoryToken == null) {
+      // Tell old clients to go away
+ throw new ReportableException("The client payload version is out of sync with the server");
+    }
+    service.resolveRequestFactory(requestFactoryToken);

     // Apply operations
     processOperationMessages(source, req);
=======================================
--- /releases/2.4/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTest.java Fri Jun 17 05:16:47 2011 +++ /releases/2.4/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTest.java Sat Jul 30 02:20:04 2011
@@ -15,6 +15,7 @@
  */
 package com.google.web.bindery.requestfactory.gwt.client;

+import com.google.web.bindery.autobean.shared.AutoBeanCodex;
 import com.google.web.bindery.requestfactory.shared.EntityProxy;
 import com.google.web.bindery.requestfactory.shared.EntityProxyChange;
 import com.google.web.bindery.requestfactory.shared.EntityProxyId;
@@ -23,6 +24,8 @@
 import com.google.web.bindery.requestfactory.shared.Receiver;
 import com.google.web.bindery.requestfactory.shared.Request;
 import com.google.web.bindery.requestfactory.shared.RequestContext;
+import com.google.web.bindery.requestfactory.shared.RequestTransport;
+import com.google.web.bindery.requestfactory.shared.RequestTransport.TransportReceiver;
 import com.google.web.bindery.requestfactory.shared.ServerFailure;
 import com.google.web.bindery.requestfactory.shared.SimpleBarProxy;
 import com.google.web.bindery.requestfactory.shared.SimpleBarRequest;
@@ -31,7 +34,10 @@
 import com.google.web.bindery.requestfactory.shared.SimpleFooRequest;
 import com.google.web.bindery.requestfactory.shared.SimpleValueContext;
 import com.google.web.bindery.requestfactory.shared.SimpleValueProxy;
+import com.google.web.bindery.requestfactory.shared.impl.MessageFactoryHolder; import com.google.web.bindery.requestfactory.shared.impl.SimpleEntityProxyId; +import com.google.web.bindery.requestfactory.shared.messages.ResponseMessage; +import com.google.web.bindery.requestfactory.shared.messages.ServerFailureMessage;

 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -563,6 +569,49 @@
       }
     });
   }
+
+  /**
+   * Tests the server behavior when an empty JSON object is sent.
+   */
+  public void testEmptyRequestBlankObject() {
+    delayTestFinish(DELAY_TEST_FINISH);
+    RequestTransport transport = req.getRequestTransport();
+    transport.send("{}", new TransportReceiver() {
+      @Override
+      public void onTransportFailure(ServerFailure failure) {
+        fail();
+      }
+
+      @Override
+      public void onTransportSuccess(String payload) {
+        ResponseMessage resp =
+ AutoBeanCodex.decode(MessageFactoryHolder.FACTORY, ResponseMessage.class, payload).as();
+        ServerFailureMessage failure = resp.getGeneralFailure();
+        assertNotNull(failure);
+        finishTestAndReset();
+      }
+    });
+  }
+
+  /**
+   * Tests the server behavior when a zero-length payload is sent.
+   */
+  public void testEmptyRequestZeroLength() {
+    delayTestFinish(DELAY_TEST_FINISH);
+    RequestTransport transport = req.getRequestTransport();
+    transport.send("", new TransportReceiver() {
+      @Override
+      public void onTransportFailure(ServerFailure failure) {
+        // Expect a 500 since the payload is malformed
+        finishTestAndReset();
+      }
+
+      @Override
+      public void onTransportSuccess(String payload) {
+        fail("Should not have succeeded");
+      }
+    });
+  }

   /**
* Tests that enum values used only as method parameters in a RequestContext

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to