Revision: 9495
Author: [email protected]
Date: Wed Jan  5 10:16:39 2011
Log: Issue 5582

Review at http://gwt-code-reviews.appspot.com/1257801

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

Added:
 /trunk/user/test/com/google/gwt/rpc/client/RpcRecursiveClassTest.java
 /trunk/user/test/com/google/gwt/user/client/rpc/RecursiveClassTest.java
/trunk/user/test/com/google/gwt/user/client/rpc/RecursiveClassTestService.java /trunk/user/test/com/google/gwt/user/client/rpc/RecursiveClassTestServiceAsync.java /trunk/user/test/com/google/gwt/user/server/rpc/RecursiveClassTestServiceImpl.java
Modified:
 /trunk/user/src/com/google/gwt/user/rebind/rpc/TypeConstrainer.java
 /trunk/user/test/com/google/gwt/user/RPCSuite.gwt.xml
 /trunk/user/test/com/google/gwt/user/RPCSuite.java
 /trunk/user/test/com/google/gwt/user/client/rpc/TestSetValidator.java

=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/rpc/client/RpcRecursiveClassTest.java Wed Jan 5 10:16:39 2011
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.rpc.client;
+
+import com.google.gwt.user.client.rpc.RecursiveClassTest;
+
+/**
+ * Tests RPC system using existing tests by overriding module name.
+ */
+public class RpcRecursiveClassTest extends RecursiveClassTest {
+
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.rpc.RPCSuite";
+  }
+
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/user/client/rpc/RecursiveClassTest.java Wed Jan 5 10:16:39 2011
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.user.client.rpc;
+
+import com.google.gwt.user.client.rpc.RecursiveClassTestService.ResultNode;
+import com.google.gwt.core.client.GWT;
+
+
+/**
+ * Class used to test generics with wild cards and recursive references.
+ */
+public class RecursiveClassTest extends RpcTestBase {
+
+  /**
+ * This method is used to test generics with wild cards and recursive references.
+   */
+  public void testRecursiveClass() {
+    RecursiveClassTestServiceAsync service = getServiceAsync();
+    delayTestFinishForRpc();
+
+    service.greetServer("Hello", new AsyncCallback<ResultNode>() {
+      public void onFailure(Throwable caught) {
+        TestSetValidator.rethrowException(caught);
+      }
+
+      public void onSuccess(ResultNode result) {
+        assertNotNull(result);
+        assertTrue(TestSetValidator.isValidRecurisveClassObject(result));
+        finishTest();
+      }
+    });
+  }
+
+  /**
+ * Create a remote service proxy to talk to the server-side Greeting service.
+   */
+  private RecursiveClassTestServiceAsync getServiceAsync() {
+    if (recursiveClassTestService == null) {
+ recursiveClassTestService = (RecursiveClassTestServiceAsync) GWT.create(RecursiveClassTestService.class); + ((ServiceDefTarget) recursiveClassTestService).setServiceEntryPoint(GWT.getModuleBaseURL()
+          + "recursiveclass");
+    }
+    return recursiveClassTestService;
+  }
+
+  private RecursiveClassTestServiceAsync recursiveClassTestService;
+
+}
+
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/user/client/rpc/RecursiveClassTestService.java Wed Jan 5 10:16:39 2011
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.user.client.rpc;
+
+import java.io.Serializable;
+
+/**
+ * Service used to test generics with wild cards and recursive references.
+ */
+public interface RecursiveClassTestService extends RemoteService {
+
+  /**
+ * This class has a self-reference and wild cards in its parameterization.
+   */
+ public class ResultNode<T extends ResultNode<?>> implements Serializable {
+    private static final long serialVersionUID = -3560238969723137110L;
+
+    public int dataType;
+    public int id1;
+    public int id2;
+    public int id3;
+    public int id4;
+    public int numChildren;
+    public String data;
+    public T next;
+
+
+    public ResultNode() {
+    }
+  }
+
+  /**
+ * Subclass of the self-referencing class; necessary to test a previous bug.
+   */
+ public class SubResultNode<S extends ResultNode<?>> extends ResultNode<S> {
+    int i;
+  }
+
+ <U extends ResultNode<U>> ResultNode<U> greetServer(String name) throws IllegalArgumentException;
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/user/client/rpc/RecursiveClassTestServiceAsync.java Wed Jan 5 10:16:39 2011
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.user.client.rpc;
+
+import com.google.gwt.user.client.rpc.RecursiveClassTestService.ResultNode;
+
+/**
+ * Service used to test generics with wild cards and recursive references
+ */
+public interface RecursiveClassTestServiceAsync {
+ <U extends ResultNode<?>> void greetServer(String input, AsyncCallback<ResultNode> callback)
+    throws IllegalArgumentException;
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/user/server/rpc/RecursiveClassTestServiceImpl.java Wed Jan 5 10:16:39 2011
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.user.server.rpc;
+
+import com.google.gwt.user.client.rpc.RecursiveClassTestService;
+
+/**
+ * The server side implementation of the RPC service.
+ *
+ */
+public class RecursiveClassTestServiceImpl extends RemoteServiceServlet
+    implements RecursiveClassTestService {
+
+  /* (non-Javadoc)
+ * @see com.google.gwt.user.client.rpc.RecursiveClassTestService#greetServer(java.lang.String)
+   */
+  public <T extends ResultNode<T>> ResultNode<T> greetServer(String name)
+      throws IllegalArgumentException {
+     return new ResultNode<T>();
+  }
+
+}
=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/rpc/TypeConstrainer.java Thu Dec 9 10:54:59 2010 +++ /trunk/user/src/com/google/gwt/user/rebind/rpc/TypeConstrainer.java Wed Jan 5 10:16:39 2011
@@ -355,9 +355,10 @@
       public void endVisit(JTypeParameter param) {
         JClassType constr = constraints.get(param);
         if (constr != null) {
-          replacement = constr;
-        }
-      }
+          // further transform the substituted type recursively
+          replacement = transform(constr);
+        }
+      }
     };
     return substituter.transform(type);
   }
=======================================
--- /trunk/user/test/com/google/gwt/user/RPCSuite.gwt.xml Tue Nov 23 13:47:33 2010 +++ /trunk/user/test/com/google/gwt/user/RPCSuite.gwt.xml Wed Jan 5 10:16:39 2011
@@ -39,5 +39,9 @@
class='com.google.gwt.user.server.rpc.AnnotatedRpcTokenTestServiceImpl' />
   <servlet path='/unicodeEscape'
     class='com.google.gwt.user.server.rpc.UnicodeEscapingServiceImpl' />
+  <servlet path='/recursiveclass'
+    class='com.google.gwt.user.server.rpc.RecursiveClassTestServiceImpl' />
+  <servlet path='/finalfields'
+    class='com.google.gwt.user.server.rpc.FinalFieldsTestServiceImpl' />

 </module>
=======================================
--- /trunk/user/test/com/google/gwt/user/RPCSuite.java Tue Nov 23 13:47:33 2010 +++ /trunk/user/test/com/google/gwt/user/RPCSuite.java Wed Jan 5 10:16:39 2011
@@ -38,6 +38,7 @@
 import com.google.gwt.user.client.rpc.InheritanceTestWithTypeObfuscation;
 import com.google.gwt.user.client.rpc.ObjectGraphTest;
 import com.google.gwt.user.client.rpc.ObjectGraphTestWithTypeObfuscation;
+import com.google.gwt.user.client.rpc.RecursiveClassTest;
 import com.google.gwt.user.client.rpc.RpcTokenTest;
 import com.google.gwt.user.client.rpc.RunTimeSerializationErrorsTest;
 import com.google.gwt.user.client.rpc.UnicodeEscapingTest;
@@ -101,6 +102,7 @@
     suite.addTestSuite(RpcTokenTest.class);
     suite.addTestSuite(UnicodeEscapingTest.class);
     suite.addTestSuite(RunTimeSerializationErrorsTest.class);
+    suite.addTestSuite(RecursiveClassTest.class);

     // This test turns on the type-elision feature of RPC
     suite.addTestSuite(ValueTypesTestWithTypeObfuscation.class);
=======================================
--- /trunk/user/test/com/google/gwt/user/client/rpc/TestSetValidator.java Mon Aug 30 04:31:11 2010 +++ /trunk/user/test/com/google/gwt/user/client/rpc/TestSetValidator.java Wed Jan 5 10:16:39 2011
@@ -23,6 +23,7 @@
import com.google.gwt.user.client.rpc.TestSetFactory.SerializableGraphWithCFS; import com.google.gwt.user.client.rpc.TestSetFactory.SerializablePrivateNoArg; import com.google.gwt.user.client.rpc.TestSetFactory.SerializableWithTwoArrays;
+import com.google.gwt.user.client.rpc.RecursiveClassTestService.ResultNode;

 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
@@ -560,6 +561,10 @@
     assertSame(result, child.getParent());
     return true;
   }
+
+ public static boolean isValidRecurisveClassObject(ResultNode<? extends ResultNode<?>> result) {
+    return (result != null);
+  }

public static boolean isValidSingletonList(List<MarkerTypeSingleton> list) {
     if (list == null || list.size() != 1) {

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

Reply via email to