Author: [EMAIL PROTECTED]
Date: Fri Oct 3 17:31:23 2008
New Revision: 3710
Added:
changes/jat/oophm-branch/user/test/com/google/gwt/user/shared/
changes/jat/oophm-branch/user/test/com/google/gwt/user/shared/rpc/
Modified:
changes/jat/oophm-branch/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStream.java
changes/jat/oophm-branch/user/test/com/google/gwt/user/RPCSuite.gwt.xml
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/TestSetValidator.java
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingService.java
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingServiceAsync.java
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingTest.java
changes/jat/oophm-branch/user/test/com/google/gwt/user/server/rpc/RPCTest.java
changes/jat/oophm-branch/user/test/com/google/gwt/user/server/rpc/UnicodeEscapingServiceImpl.java
Log:
RPC Unicode test and fix for RPCTest missing an update from the trunk merge.
Modified:
changes/jat/oophm-branch/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStream.java
==============================================================================
---
changes/jat/oophm-branch/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStream.java
(original)
+++
changes/jat/oophm-branch/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStream.java
Fri Oct 3 17:31:23 2008
@@ -22,12 +22,12 @@
*/
public abstract class AbstractSerializationStream {
+ public static final char RPC_SEPARATOR_CHAR = '|';
+
/**
* This is the only supported RPC protocol version.
*/
public static final int SERIALIZATION_STREAM_VERSION = 4;
-
- protected static final char RPC_SEPARATOR_CHAR = '|';
private int flags = 0;
private int version = SERIALIZATION_STREAM_VERSION;
Modified:
changes/jat/oophm-branch/user/test/com/google/gwt/user/RPCSuite.gwt.xml
==============================================================================
--- changes/jat/oophm-branch/user/test/com/google/gwt/user/RPCSuite.gwt.xml
(original)
+++ changes/jat/oophm-branch/user/test/com/google/gwt/user/RPCSuite.gwt.xml
Fri Oct 3 17:31:23 2008
@@ -35,5 +35,6 @@
class='com.google.gwt.user.server.rpc.RemoteServiceServletTestServiceImpl'
/>
<servlet path='/unicodeEscape'
class='com.google.gwt.user.server.rpc.UnicodeEscapingServiceImpl' />
-
+ <source path='client' />
+ <source path='shared' />
</module>
Modified:
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/TestSetValidator.java
==============================================================================
---
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/TestSetValidator.java
(original)
+++
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/TestSetValidator.java
Fri Oct 3 17:31:23 2008
@@ -446,6 +446,12 @@
return true;
}
+ /**
+ * Wrap an exception in RuntimeException if necessary so it doesn't have
to be listed in
+ * throws clauses.
+ *
+ * @param caught exception to wrap
+ */
public static void rethrowException(Throwable caught) {
if (caught instanceof RuntimeException) {
throw (RuntimeException) caught;
@@ -453,5 +459,4 @@
throw new RuntimeException(caught);
}
}
-
}
Modified:
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingService.java
==============================================================================
---
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingService.java
(original)
+++
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingService.java
Fri Oct 3 17:31:23 2008
@@ -19,12 +19,69 @@
* Service used to test unicode escaping.
*/
public interface UnicodeEscapingService extends RemoteService {
+
+ /**
+ * Exception for escaping errors.
+ */
+ public static class InvalidCharacterException extends Exception {
+
+ private static String toHex(int val) {
+ String hex = Integer.toHexString(val);
+ return "00000".substring(hex.length()) + hex;
+ }
+
+ private int index;
+ private int expected;
+ private int actual;
+
+ protected InvalidCharacterException() { }
+
+ public InvalidCharacterException(int index, int expected, int actual) {
+ super(index < 0 ? "String length mismatch: expected = " + expected
+ ", actual = " + actual
+ : "At index " + index + ", expected = U+" + toHex(expected) + ",
actual = U+"
+ + toHex(actual));
+ this.index = index;
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ public int getActual() {
+ return actual;
+ }
+
+ public int getExpected() {
+ return expected;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+ }
+
/**
* Returns a string containing the characters from start to end.
*
- * @param start start character value, inclusive
- * @param end end character value, exclusive
+ * Used to verify server->client escaping.
+ *
+ * @param start start character value, inclusive -- note if greater
+ * than [EMAIL PROTECTED] Character#MIN_SUPPLEMENTARY_CODE_POINT} it will
+ * be included as surrogate pairs in the returned string.
+ * @param end end character value, exclusive (see above comment)
* @return a string containing the characters from start to end
*/
String getStringContainingCharacterRange(int start, int end);
+
+ /**
+ * Verifies that the string contains the specified characters.
+ *
+ * Used to verify client->server escaping.
+ *
+ * @param start start code point value included
+ * @param end first code point not included
+ * @param str string to verify
+ * @throws InvalidCharacterException if the string does not contain the
specified characters
+ * @return true if the verification succeeded
+ */
+ boolean verifyStringContainingCharacterRange(int start, int end, String
str)
+ throws InvalidCharacterException;
}
Modified:
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingServiceAsync.java
==============================================================================
---
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingServiceAsync.java
(original)
+++
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingServiceAsync.java
Fri Oct 3 17:31:23 2008
@@ -15,10 +15,14 @@
*/
package com.google.gwt.user.client.rpc;
+import
com.google.gwt.user.client.rpc.UnicodeEscapingService.InvalidCharacterException;
+
/**
* Async version of the [EMAIL PROTECTED] UnicodeEscapingService} interface.
*/
public interface UnicodeEscapingServiceAsync {
void getStringContainingCharacterRange(int start, int end,
- AsyncCallback callback);
+ AsyncCallback<String> callback);
+ void verifyStringContainingCharacterRange(int start, int end, String str,
+ AsyncCallback<Boolean> callback) throws InvalidCharacterException;
}
Modified:
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingTest.java
==============================================================================
---
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingTest.java
(original)
+++
changes/jat/oophm-branch/user/test/com/google/gwt/user/client/rpc/UnicodeEscapingTest.java
Fri Oct 3 17:31:23 2008
@@ -17,68 +17,214 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
+import
com.google.gwt.user.client.rpc.UnicodeEscapingService.InvalidCharacterException;
/**
- * Test which verifies that we properly escape JSON strings sent back from
the
- * server.
+ * Test that any valid string can be sent via RPC in both directions.
+ *
+ * TODO(jat): make unpaired surrogates work properly, then add them to
this test.
*/
public class UnicodeEscapingTest extends GWTTestCase {
- private static final int DEFAULT_TEST_FINISH_DELAY_MS = 5000;
- private static final int CHARACTER_RANGE_SIZE = 1024;
- private static final int LAST_CHARACTER = 0x10000;
+ /** the size of a block of characters to test */
+ private static final int CHARACTER_BLOCK_SIZE = 64;
- private int start = 0;
+ /**
+ * When doing the non-BMP test, we don't test every block of characters
because it
+ * takes too long - this is the increment to use. It is not a power of
two so we
+ * alter the alignment of the block of characters we skip.
+ */
+ private static final int NON_BMP_TEST_INCREMENT = 8192 + 64;
+
+ /** the time to wait for the test of a block of characters */
+ private static final int TEST_FINISH_DELAY_MS = 500000;
+
+ /**
+ * Generates a string containing a sequence of code points.
+ *
+ * @param start first code point to include in the string
+ * @param end one past the last code point to include in the string
+ * @return a string containing all the requested code points
+ */
+ public static String getStringContainingCharacterRange(int start, int
end) {
+ StringBuffer buf = new StringBuffer();
+ for (int codePoint = start; codePoint < end; ++codePoint) {
+ if (Character.isSupplementaryCodePoint(codePoint)) {
+ buf.append(Character.toChars(codePoint));
+ } else {
+ buf.append((char) codePoint);
+ }
+ }
+
+ return buf.toString();
+ }
+ /**
+ * Verifies that the supplied string includes the requested code points.
+ *
+ * @param start first code point to include in the string
+ * @param end one past the last code point to include in the string
+ * @param str the string to test
+ * @throws InvalidCharacterException if a character doesn't match
+ * @throws RuntimeException if the string is too long
+ */
+ public static void verifyStringContainingCharacterRange(int start, int
end,
+ String str) throws InvalidCharacterException {
+ if (str == null) {
+ throw new NullPointerException("String is null");
+ }
+ int expectedLen = end - start;
+ int strLen = str.codePointCount(0, str.length());
+ for (int i = 0, codePoint = start; i < strLen; i =
Character.offsetByCodePoints(str, i, 1)) {
+ int strCodePoint = str.codePointAt(i);
+ if (strCodePoint != codePoint) {
+ throw new InvalidCharacterException(i, codePoint, strCodePoint);
+ }
+ ++codePoint;
+ }
+ if (strLen < expectedLen) {
+ throw new InvalidCharacterException(strLen, start + strLen, -1);
+ } else if (expectedLen != strLen) {
+ throw new RuntimeException("Too many characters returned on block
from U+"
+ + Integer.toHexString(start) + " to U+" +
Integer.toHexString(end) + ": expected="
+ + expectedLen + ", actual=" + strLen);
+ }
+ }
private static UnicodeEscapingServiceAsync getService() {
- UnicodeEscapingServiceAsync service = (UnicodeEscapingServiceAsync)
GWT.create(UnicodeEscapingService.class);
+ UnicodeEscapingServiceAsync service =
GWT.create(UnicodeEscapingService.class);
ServiceDefTarget target = (ServiceDefTarget) service;
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "unicodeEscape");
return service;
}
+ /** start of current block being tested */
+ private int current;
+
+ @Override
public String getModuleName() {
return "com.google.gwt.user.RPCSuite";
}
/**
+ * Generate strings containing ranges of characters and sends them to the
+ * server for verification. This ensures that client->server string
escaping
+ * properly handles all BMP characters (though currently unmatched
surrogates
+ * are not tested).
+ *
+ * Note that this does not test all possible combinations, which might
be an
+ * issue, particularly with combining marks, though they should be
logically
+ * equivalent in that case.
+ *
+ * @throws InvalidCharacterException
+ */
+ public void testClientToServerBMP() throws InvalidCharacterException {
+ delayTestFinish(TEST_FINISH_DELAY_MS);
+ // TODO(jat): consider how to handle unmatched surrogate characters
+ clientToServerVerifyRange(Character.MIN_CODE_POINT,
Character.MIN_SURROGATE,
+ CHARACTER_BLOCK_SIZE, CHARACTER_BLOCK_SIZE);
+ }
+
+ /**
+ * Generate strings containing ranges of characters and sends them to the
+ * server for verification. This ensures that client->server string
escaping
+ * properly handles all non-BMP characters.
+ *
+ * Note that this does not test all possible combinations, which might
be an
+ * issue, particularly with combining marks, though they should be
logically
+ * equivalent in that case.
+ *
+ * @throws InvalidCharacterException
+ */
+ public void testClientToServerNonBMP() throws InvalidCharacterException {
+ delayTestFinish(TEST_FINISH_DELAY_MS);
+ clientToServerVerifyRange(Character.MIN_SUPPLEMENTARY_CODE_POINT,
Character.MAX_CODE_POINT + 1,
+ CHARACTER_BLOCK_SIZE, NON_BMP_TEST_INCREMENT);
+ }
+
+ /**
* Requests strings of CHARACTER_RANGE_SIZE from the server and
validates that
* the returned string length matches CHARACTER_RANGE_SIZE and that all
of the
- * characters remain intact.
+ * characters remain intact. Note that this test verifies BMP
characters except
+ * unpaired surrogates.
+ *
+ * Note that this does not test all possible combinations, which might
be an
+ * issue, particularly with combining marks, though they should be
logically
+ * equivalent in that case.
*/
- public void testUnicodeEscaping() {
- delayTestFinish(DEFAULT_TEST_FINISH_DELAY_MS);
-
- getService().getStringContainingCharacterRange(0, CHARACTER_RANGE_SIZE,
- new AsyncCallback() {
- public void onFailure(Throwable caught) {
- TestSetValidator.rethrowException(caught);
- }
+ public void testServerToClientBMP() {
+ delayTestFinish(TEST_FINISH_DELAY_MS);
+ serverToClientVerify(Character.MIN_CODE_POINT,
Character.MIN_SURROGATE, CHARACTER_BLOCK_SIZE,
+ CHARACTER_BLOCK_SIZE);
+ }
- public void onSuccess(Object result) {
- String str = (String) result;
+ /**
+ * Requests strings of CHARACTER_RANGE_SIZE from the server and
validates that
+ * the returned string length matches CHARACTER_RANGE_SIZE and that all
of the
+ * characters remain intact. Note that this test verifies non-BMP
characters
+ * (ie, those which are represented as pairs of surrogates).
+ *
+ * Note that this does not test all possible combinations, which might
be an
+ * issue, particularly with combining marks, though they should be
logically
+ * equivalent in that case.
+ */
+ public void testServerToClientNonBMP() {
+ delayTestFinish(TEST_FINISH_DELAY_MS);
+ serverToClientVerify(Character.MIN_SUPPLEMENTARY_CODE_POINT,
Character.MAX_CODE_POINT + 1,
+ CHARACTER_BLOCK_SIZE, NON_BMP_TEST_INCREMENT);
+ }
- assertTrue("expected: " +
Integer.toString(CHARACTER_RANGE_SIZE)
- + " actual: " + str.length() + " for character range ["
- + Integer.toString(start) + ", "
- + Integer.toString(start + CHARACTER_RANGE_SIZE) + ")",
- CHARACTER_RANGE_SIZE == str.length());
-
- char[] chars = str.toCharArray();
- for (int i = 0; i < CHARACTER_RANGE_SIZE; ++i) {
- assertEquals(i + start, chars[i]);
- }
-
- start += CHARACTER_RANGE_SIZE;
- if (start < LAST_CHARACTER) {
- delayTestFinish(DEFAULT_TEST_FINISH_DELAY_MS);
-
- getService().getStringContainingCharacterRange(start,
- start + CHARACTER_RANGE_SIZE, this);
- } else {
- finishTest();
- }
+ private void clientToServerVerifyRange(final int start, final int end,
final int size,
+ final int step) throws InvalidCharacterException {
+ current = start;
+ int blockEnd = Math.min(end, current + size);
+ getService().verifyStringContainingCharacterRange(current, blockEnd,
+ getStringContainingCharacterRange(start, blockEnd), new
AsyncCallback<Boolean>() {
+ public void onFailure(Throwable caught) {
+ TestSetValidator.rethrowException(caught);
+ }
+
+ public void onSuccess(Boolean ignored) {
+ current += step;
+ if (current < end) {
+ delayTestFinish(TEST_FINISH_DELAY_MS);
+ int blockEnd = Math.min(end, current + size);
+ try {
+ getService().verifyStringContainingCharacterRange(current,
blockEnd,
+ getStringContainingCharacterRange(current, blockEnd),
this);
+ } catch (InvalidCharacterException e) {
+ TestSetValidator.rethrowException(e);
}
- });
+ } else {
+ finishTest();
+ }
+ }
+ });
+ }
+
+ private void serverToClientVerify(final int start, final int end, final
int size,
+ final int step) {
+ current = start;
+ getService().getStringContainingCharacterRange(start, Math.min(end,
current + size),
+ new AsyncCallback<String>() {
+ public void onFailure(Throwable caught) {
+ TestSetValidator.rethrowException(caught);
+ }
+
+ public void onSuccess(String str) {
+ try {
+ verifyStringContainingCharacterRange(current, Math.min(end,
current + size), str);
+ } catch (InvalidCharacterException e) {
+ TestSetValidator.rethrowException(e);
+ }
+ current += step;
+ if (current < end) {
+ delayTestFinish(TEST_FINISH_DELAY_MS);
+ getService().getStringContainingCharacterRange(current,
+ Math.min(end, current + size), this);
+ } else {
+ finishTest();
+ }
+ }
+ });
}
}
Modified:
changes/jat/oophm-branch/user/test/com/google/gwt/user/server/rpc/RPCTest.java
==============================================================================
---
changes/jat/oophm-branch/user/test/com/google/gwt/user/server/rpc/RPCTest.java
(original)
+++
changes/jat/oophm-branch/user/test/com/google/gwt/user/server/rpc/RPCTest.java
Fri Oct 3 17:31:23 2008
@@ -15,6 +15,8 @@
*/
package com.google.gwt.user.server.rpc;
+import static
com.google.gwt.user.client.rpc.impl.AbstractSerializationStream.RPC_SEPARATOR_CHAR;
+
import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.SerializableException;
@@ -27,9 +29,8 @@
/**
* Tests for the [EMAIL PROTECTED] com.google.gwt.user.server.rpc.RPC RPC}
class.
*/
[EMAIL PROTECTED]("deprecation")
public class RPCTest extends TestCase {
-
- private static char RPC_SEPARATOR = '|';
private static interface A extends RemoteService {
void method1() throws SerializableException;
@@ -43,53 +44,86 @@
void method1();
}
- private final String VALID_ENCODED_REQUEST = "3" + RPC_SEPARATOR + //
version
- "0" + RPC_SEPARATOR + // flags
- "4" + RPC_SEPARATOR + // string table entry count
- A.class.getName() + RPC_SEPARATOR + // string table entry #0
- "method2" + RPC_SEPARATOR + // string table entry #1
- "moduleBaseURL" + RPC_SEPARATOR + // string table entry #2
- "whitelistHashcode" + RPC_SEPARATOR + // string table entry #4
- "3" + RPC_SEPARATOR + // module base URL
- "4" + RPC_SEPARATOR + // whitelist hashcode
- "1" + RPC_SEPARATOR + // interface name
- "2" + RPC_SEPARATOR + // method name
- "0" + RPC_SEPARATOR; // param count
-
- private final String INVALID_METHOD_REQUEST = "3" + RPC_SEPARATOR + //
version
- "0" + RPC_SEPARATOR + // flags
- "4" + RPC_SEPARATOR + // string table entry count
- A.class.getName() + RPC_SEPARATOR + // string table entry #0
- "method3" + RPC_SEPARATOR + // string table entry #1
- "moduleBaseURL" + RPC_SEPARATOR + // string table entry #2
- "whitelistHashcode" + RPC_SEPARATOR + // string table entry #4
- "3" + RPC_SEPARATOR + // module base URL
- "4" + RPC_SEPARATOR + // whitelist hashcode
- "1" + RPC_SEPARATOR + // interface name
- "2" + RPC_SEPARATOR + // method name
- "0" + RPC_SEPARATOR; // param count
-
- private final String INVALID_INTERFACE_REQUEST = "3" + RPC_SEPARATOR +
// version
- "0" + RPC_SEPARATOR + // flags
- "4" + RPC_SEPARATOR + // string table entry count
- B.class.getName() + RPC_SEPARATOR + // string table entry #0
- "method1" + RPC_SEPARATOR + // string table entry #1
- "moduleBaseURL" + RPC_SEPARATOR + // string table entry #2
- "whitelistHashcode" + RPC_SEPARATOR + // string table entry #4
- "3" + RPC_SEPARATOR + // module base URL
- "4" + RPC_SEPARATOR + // whitelist hashcode
- "1" + RPC_SEPARATOR + // interface name
- "2" + RPC_SEPARATOR + // method name
- "0" + RPC_SEPARATOR; // param count
-
- private final String VALID_PRE_RPC_RESOURCE_ENCODED_REQUEST = "2" +
RPC_SEPARATOR + // version
- "0" + RPC_SEPARATOR + // flags
- "2" + RPC_SEPARATOR + // string table entry count
- A.class.getName() + RPC_SEPARATOR + // string table entry #0
- "method2" + RPC_SEPARATOR + // string table entry #1
- "1" + RPC_SEPARATOR + // interface name
- "2" + RPC_SEPARATOR + // method name
- "0" + RPC_SEPARATOR; // param count
+ private static final String VALID_ENCODED_REQUEST = "4" +
RPC_SEPARATOR_CHAR + // version
+ "0" + RPC_SEPARATOR_CHAR + // flags
+ "4" + RPC_SEPARATOR_CHAR + // string table entry count
+ A.class.getName() + RPC_SEPARATOR_CHAR + // string table entry #0
+ "method2" + RPC_SEPARATOR_CHAR + // string table entry #1
+ "moduleBaseURL" + RPC_SEPARATOR_CHAR + // string table entry #2
+ "whitelistHashcode" + RPC_SEPARATOR_CHAR + // string table entry #4
+ "3" + RPC_SEPARATOR_CHAR + // module base URL
+ "4" + RPC_SEPARATOR_CHAR + // whitelist hashcode
+ "1" + RPC_SEPARATOR_CHAR + // interface name
+ "2" + RPC_SEPARATOR_CHAR + // method name
+ "0" + RPC_SEPARATOR_CHAR; // param count
+
+ private static final String INVALID_METHOD_REQUEST = "4" +
RPC_SEPARATOR_CHAR + // version
+ "0" + RPC_SEPARATOR_CHAR + // flags
+ "4" + RPC_SEPARATOR_CHAR + // string table entry count
+ A.class.getName() + RPC_SEPARATOR_CHAR + // string table entry #0
+ "method3" + RPC_SEPARATOR_CHAR + // string table entry #1
+ "moduleBaseURL" + RPC_SEPARATOR_CHAR + // string table entry #2
+ "whitelistHashcode" + RPC_SEPARATOR_CHAR + // string table entry #4
+ "3" + RPC_SEPARATOR_CHAR + // module base URL
+ "4" + RPC_SEPARATOR_CHAR + // whitelist hashcode
+ "1" + RPC_SEPARATOR_CHAR + // interface name
+ "2" + RPC_SEPARATOR_CHAR + // method name
+ "0" + RPC_SEPARATOR_CHAR; // param count
+
+ private static final String INVALID_INTERFACE_REQUEST = "4" +
RPC_SEPARATOR_CHAR + // version
+ "0" + RPC_SEPARATOR_CHAR + // flags
+ "4" + RPC_SEPARATOR_CHAR + // string table entry count
+ B.class.getName() + RPC_SEPARATOR_CHAR + // string table entry #0
+ "method1" + RPC_SEPARATOR_CHAR + // string table entry #1
+ "moduleBaseURL" + RPC_SEPARATOR_CHAR + // string table entry #2
+ "whitelistHashcode" + RPC_SEPARATOR_CHAR + // string table entry #4
+ "3" + RPC_SEPARATOR_CHAR + // module base URL
+ "4" + RPC_SEPARATOR_CHAR + // whitelist hashcode
+ "1" + RPC_SEPARATOR_CHAR + // interface name
+ "2" + RPC_SEPARATOR_CHAR + // method name
+ "0" + RPC_SEPARATOR_CHAR; // param count
+
+ private static final String VALID_V2_ENCODED_REQUEST = "2" +
RPC_SEPARATOR_CHAR + // version
+ "0" + RPC_SEPARATOR_CHAR + // flags
+ "2" + RPC_SEPARATOR_CHAR + // string table entry count
+ A.class.getName() + RPC_SEPARATOR_CHAR + // string table entry #0
+ "method2" + RPC_SEPARATOR_CHAR + // string table entry #1
+ "1" + RPC_SEPARATOR_CHAR + // interface name
+ "2" + RPC_SEPARATOR_CHAR + // method name
+ "0" + RPC_SEPARATOR_CHAR; // param count
+
+ private static final String VALID_V3_ENCODED_REQUEST = "3" +
RPC_SEPARATOR_CHAR + // version
+ "0" + RPC_SEPARATOR_CHAR + // flags
+ "4" + RPC_SEPARATOR_CHAR + // string table entry count
+ A.class.getName() + RPC_SEPARATOR_CHAR + // string table entry #0
+ "method2" + RPC_SEPARATOR_CHAR + // string table entry #1
+ "moduleBaseURL" + RPC_SEPARATOR_CHAR + // string table entry #2
+ "whitelistHashcode" + RPC_SEPARATOR_CHAR + // string table entry #4
+ "3" + RPC_SEPARATOR_CHAR + // module base URL
+ "4" + RPC_SEPARATOR_CHAR + // whitelist hashcode
+ "1" + RPC_SEPARATOR_CHAR + // interface name
+ "2" + RPC_SEPARATOR_CHAR + // method name
+ "0" + RPC_SEPARATOR_CHAR; // param count
+
+ /**
+ * Tests that seeing obsolete RPC formats throws an
+ * [EMAIL PROTECTED] IncompatibleRemoteServiceException}.
+ */
+ public void testDecodeObsoleteFormats() {
+ try {
+ RPC.decodeRequest(VALID_V2_ENCODED_REQUEST, A.class, null);
+ fail("Should have thrown an IncompatibleRemoteServiceException");
+ } catch (IncompatibleRemoteServiceException e) {
+ // Expected
+ }
+
+ try {
+ RPC.decodeRequest(VALID_V3_ENCODED_REQUEST, A.class, null);
+ fail("Should have thrown an IncompatibleRemoteServiceException");
+ } catch (IncompatibleRemoteServiceException e) {
+ // Expected
+ }
+ }
/**
* Tests for method [EMAIL PROTECTED] RPC#decodeRequest(String)}
@@ -183,20 +217,6 @@
} catch (IncompatibleRemoteServiceException e) {
// should get here
}
- }
-
- /**
- * Tests that method
- * [EMAIL PROTECTED] RPC#decodeRequest(String, Class,
SerializationPolicyProvider)}
can
- * handle the decoding of requests from pre-RPC resource (whitelist)
clients.
- *
- * @throws SerializationException
- */
- public void testDecodeRequestPreRPCResourceFile() {
- RPCRequest rpcRequest = RPC.decodeRequest(
- VALID_PRE_RPC_RESOURCE_ENCODED_REQUEST, A.class, null);
- SerializationPolicy serializationPolicy =
rpcRequest.getSerializationPolicy();
- assertEquals(RPC.getDefaultSerializationPolicy(), serializationPolicy);
}
/**
Modified:
changes/jat/oophm-branch/user/test/com/google/gwt/user/server/rpc/UnicodeEscapingServiceImpl.java
==============================================================================
---
changes/jat/oophm-branch/user/test/com/google/gwt/user/server/rpc/UnicodeEscapingServiceImpl.java
(original)
+++
changes/jat/oophm-branch/user/test/com/google/gwt/user/server/rpc/UnicodeEscapingServiceImpl.java
Fri Oct 3 17:31:23 2008
@@ -16,6 +16,7 @@
package com.google.gwt.user.server.rpc;
import com.google.gwt.user.client.rpc.UnicodeEscapingService;
+import com.google.gwt.user.client.rpc.UnicodeEscapingTest;
/**
* Implementation of the [EMAIL PROTECTED] UnicodeEscapingService} interface.
@@ -24,18 +25,18 @@
UnicodeEscapingService {
/**
- * @see
com.google.gwt.user.client.rpc.UnicodeEscapingService#getStringContainingCharacterRange(int,
- * int)
+ * @see UnicodeEscapingService#getStringContainingCharacterRange(int,
int)
*/
public String getStringContainingCharacterRange(int start, int end) {
- int nChars = end - start;
-
- char[] chars = new char[nChars];
- for (int i = 0; i < nChars; ++i) {
- char ch = (char) (start + i);
- chars[i] = ch;
- }
+ return UnicodeEscapingTest.getStringContainingCharacterRange(start,
end);
+ }
- return new String(chars);
+ /**
+ * @see UnicodeEscapingService#verifyStringContainingCharacterRange(int,
int, String)
+ */
+ public boolean verifyStringContainingCharacterRange(int start, int end,
+ String str) throws InvalidCharacterException {
+ UnicodeEscapingTest.verifyStringContainingCharacterRange(start, end,
str);
+ return true;
}
}
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---