You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2011/08/29 19:50:31 UTC

svn commit: r1162917 - in /thrift/trunk: compiler/cpp/src/generate/t_java_generator.cc lib/java/test/org/apache/thrift/Fixtures.java lib/java/test/org/apache/thrift/scheme/ lib/java/test/org/apache/thrift/scheme/TestStandardScheme.java

Author: bryanduxbury
Date: Mon Aug 29 17:50:31 2011
New Revision: 1162917

URL: http://svn.apache.org/viewvc?rev=1162917&view=rev
Log:
THRIFT-1298. java: Standard scheme doesn't read or write metadata along with field values

This patch makes StandardScheme write metadata, and adds tests against a static known-good Binary-serialized struct for a reference.

Patch: Armaan Sarkar

Added:
    thrift/trunk/lib/java/test/org/apache/thrift/scheme/
    thrift/trunk/lib/java/test/org/apache/thrift/scheme/TestStandardScheme.java
Modified:
    thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
    thrift/trunk/lib/java/test/org/apache/thrift/Fixtures.java

Modified: thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc?rev=1162917&r1=1162916&r2=1162917&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc Mon Aug 29 17:50:31 2011
@@ -3812,7 +3812,7 @@ void t_java_generator::generate_standard
       "if (schemeField.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
     indent_up();
 
-    generate_deserialize_field(out, *f_iter, "struct.", false);
+    generate_deserialize_field(out, *f_iter, "struct.", true);
     indent(out) << "struct." << "set" << get_cap_name((*f_iter)->get_name()) << get_cap_name("isSet") << "(true);" << endl;
     indent_down();
     out <<
@@ -3889,7 +3889,7 @@ void t_java_generator::generate_standard
     indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
 
     // Write field contents
-    generate_serialize_field(out, *f_iter, "struct.", false);
+    generate_serialize_field(out, *f_iter, "struct.", true);
 
     // Write field closer
     indent(out) << "oprot.writeFieldEnd();" << endl;

Modified: thrift/trunk/lib/java/test/org/apache/thrift/Fixtures.java
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/java/test/org/apache/thrift/Fixtures.java?rev=1162917&r1=1162916&r2=1162917&view=diff
==============================================================================
--- thrift/trunk/lib/java/test/org/apache/thrift/Fixtures.java (original)
+++ thrift/trunk/lib/java/test/org/apache/thrift/Fixtures.java Mon Aug 29 17:50:31 2011
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-
 package org.apache.thrift;
 
 import java.nio.ByteBuffer;
@@ -38,16 +37,224 @@ public class Fixtures {
   public static final HolyMoley holyMoley;
   public static final CompactProtoTestStruct compactProtoTestStruct;
 
-  private static final byte[] kUnicodeBytes = {
-    (byte)0xd3, (byte)0x80, (byte)0xe2, (byte)0x85, (byte)0xae, (byte)0xce,
-    (byte)0x9d, (byte)0x20, (byte)0xd0, (byte)0x9d, (byte)0xce, (byte)0xbf,
-    (byte)0xe2, (byte)0x85, (byte)0xbf, (byte)0xd0, (byte)0xbe, (byte)0xc9,
-    (byte)0xa1, (byte)0xd0, (byte)0xb3, (byte)0xd0, (byte)0xb0, (byte)0xcf,
-    (byte)0x81, (byte)0xe2, (byte)0x84, (byte)0x8e, (byte)0x20, (byte)0xce,
-    (byte)0x91, (byte)0x74, (byte)0x74, (byte)0xce, (byte)0xb1, (byte)0xe2,
-    (byte)0x85, (byte)0xbd, (byte)0xce, (byte)0xba, (byte)0x83, (byte)0xe2,
-    (byte)0x80, (byte)0xbc
-  };
+  // These byte arrays are serialized versions of the above structs.
+  // They were serialized in binary protocol using thrift 0.6.x and are used to
+  // test backwards compatibility with respect to the standard scheme.
+  public static final byte[] persistentBytesOneOfEach = new byte[] { (byte) 0x02, (byte) 0x00,
+    (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x02,
+    (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x03, (byte) 0xD6,
+    (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0x69, (byte) 0x78,
+    (byte) 0x08, (byte) 0x00, (byte) 0x05, (byte) 0x01, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x0A, (byte) 0x00, (byte) 0x06,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x65,
+    (byte) 0xA0, (byte) 0xBC, (byte) 0x00, (byte) 0x04, (byte) 0x00,
+    (byte) 0x07, (byte) 0x40, (byte) 0x09, (byte) 0x21, (byte) 0xFB,
+    (byte) 0x54, (byte) 0x44, (byte) 0x2D, (byte) 0x18, (byte) 0x0B,
+    (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x0D, (byte) 0x4A, (byte) 0x53, (byte) 0x4F, (byte) 0x4E,
+    (byte) 0x20, (byte) 0x54, (byte) 0x48, (byte) 0x49, (byte) 0x53,
+    (byte) 0x21, (byte) 0x20, (byte) 0x22, (byte) 0x01, (byte) 0x0B,
+    (byte) 0x00, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x2E, (byte) 0xD3, (byte) 0x80, (byte) 0xE2, (byte) 0x85,
+    (byte) 0xAE, (byte) 0xCE, (byte) 0x9D, (byte) 0x20, (byte) 0xD0,
+    (byte) 0x9D, (byte) 0xCE, (byte) 0xBF, (byte) 0xE2, (byte) 0x85,
+    (byte) 0xBF, (byte) 0xD0, (byte) 0xBE, (byte) 0xC9, (byte) 0xA1,
+    (byte) 0xD0, (byte) 0xB3, (byte) 0xD0, (byte) 0xB0, (byte) 0xCF,
+    (byte) 0x81, (byte) 0xE2, (byte) 0x84, (byte) 0x8E, (byte) 0x20,
+    (byte) 0xCE, (byte) 0x91, (byte) 0x74, (byte) 0x74, (byte) 0xCE,
+    (byte) 0xB1, (byte) 0xE2, (byte) 0x85, (byte) 0xBD, (byte) 0xCE,
+    (byte) 0xBA, (byte) 0xEF, (byte) 0xBF, (byte) 0xBD, (byte) 0xE2,
+    (byte) 0x80, (byte) 0xBC, (byte) 0x02, (byte) 0x00, (byte) 0x0A,
+    (byte) 0x00, (byte) 0x0B, (byte) 0x00, (byte) 0x0B, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x62, (byte) 0x61,
+    (byte) 0x73, (byte) 0x65, (byte) 0x36, (byte) 0x34, (byte) 0x0F,
+    (byte) 0x00, (byte) 0x0C, (byte) 0x03, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03,
+    (byte) 0x0F, (byte) 0x00, (byte) 0x0D, (byte) 0x06, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x01,
+    (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x03, (byte) 0x0F,
+    (byte) 0x00, (byte) 0x0E, (byte) 0x0A, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x03, (byte) 0x00 };
+  public static final byte[] persistentBytesNesting = new byte[] { (byte) 0x0C, (byte) 0x00,
+    (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0x01, (byte) 0x00,
+    (byte) 0x00, (byte) 0x7A, (byte) 0x69, (byte) 0x0B, (byte) 0x00,
+    (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x13,
+    (byte) 0x49, (byte) 0x20, (byte) 0x61, (byte) 0x6D, (byte) 0x20,
+    (byte) 0x61, (byte) 0x20, (byte) 0x62, (byte) 0x6F, (byte) 0x6E,
+    (byte) 0x6B, (byte) 0x2E, (byte) 0x2E, (byte) 0x2E, (byte) 0x20,
+    (byte) 0x78, (byte) 0x6F, (byte) 0x72, (byte) 0x21, (byte) 0x00,
+    (byte) 0x0C, (byte) 0x00, (byte) 0x02, (byte) 0x02, (byte) 0x00,
+    (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x02,
+    (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x03, (byte) 0xD6,
+    (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0x69, (byte) 0x78,
+    (byte) 0x08, (byte) 0x00, (byte) 0x05, (byte) 0x01, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x0A, (byte) 0x00, (byte) 0x06,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x65,
+    (byte) 0xA0, (byte) 0xBC, (byte) 0x00, (byte) 0x04, (byte) 0x00,
+    (byte) 0x07, (byte) 0x40, (byte) 0x09, (byte) 0x21, (byte) 0xFB,
+    (byte) 0x54, (byte) 0x44, (byte) 0x2D, (byte) 0x18, (byte) 0x0B,
+    (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x0D, (byte) 0x4A, (byte) 0x53, (byte) 0x4F, (byte) 0x4E,
+    (byte) 0x20, (byte) 0x54, (byte) 0x48, (byte) 0x49, (byte) 0x53,
+    (byte) 0x21, (byte) 0x20, (byte) 0x22, (byte) 0x01, (byte) 0x0B,
+    (byte) 0x00, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x2E, (byte) 0xD3, (byte) 0x80, (byte) 0xE2, (byte) 0x85,
+    (byte) 0xAE, (byte) 0xCE, (byte) 0x9D, (byte) 0x20, (byte) 0xD0,
+    (byte) 0x9D, (byte) 0xCE, (byte) 0xBF, (byte) 0xE2, (byte) 0x85,
+    (byte) 0xBF, (byte) 0xD0, (byte) 0xBE, (byte) 0xC9, (byte) 0xA1,
+    (byte) 0xD0, (byte) 0xB3, (byte) 0xD0, (byte) 0xB0, (byte) 0xCF,
+    (byte) 0x81, (byte) 0xE2, (byte) 0x84, (byte) 0x8E, (byte) 0x20,
+    (byte) 0xCE, (byte) 0x91, (byte) 0x74, (byte) 0x74, (byte) 0xCE,
+    (byte) 0xB1, (byte) 0xE2, (byte) 0x85, (byte) 0xBD, (byte) 0xCE,
+    (byte) 0xBA, (byte) 0xEF, (byte) 0xBF, (byte) 0xBD, (byte) 0xE2,
+    (byte) 0x80, (byte) 0xBC, (byte) 0x02, (byte) 0x00, (byte) 0x0A,
+    (byte) 0x00, (byte) 0x0B, (byte) 0x00, (byte) 0x0B, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x62, (byte) 0x61,
+    (byte) 0x73, (byte) 0x65, (byte) 0x36, (byte) 0x34, (byte) 0x0F,
+    (byte) 0x00, (byte) 0x0C, (byte) 0x03, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03,
+    (byte) 0x0F, (byte) 0x00, (byte) 0x0D, (byte) 0x06, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x01,
+    (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x03, (byte) 0x0F,
+    (byte) 0x00, (byte) 0x0E, (byte) 0x0A, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x03, (byte) 0x00, (byte) 0x00 };
+  public static final byte[] persistentBytesHolyMoley = new byte[] { (byte) 0x0F, (byte) 0x00,
+    (byte) 0x01, (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01,
+    (byte) 0x02, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x03,
+    (byte) 0x00, (byte) 0x03, (byte) 0x23, (byte) 0x06, (byte) 0x00,
+    (byte) 0x04, (byte) 0x69, (byte) 0x78, (byte) 0x08, (byte) 0x00,
+    (byte) 0x05, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x0A, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x01, (byte) 0x65, (byte) 0xA0, (byte) 0xBC,
+    (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x07, (byte) 0x40,
+    (byte) 0x09, (byte) 0x21, (byte) 0xFB, (byte) 0x54, (byte) 0x44,
+    (byte) 0x2D, (byte) 0x18, (byte) 0x0B, (byte) 0x00, (byte) 0x08,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0D, (byte) 0x4A,
+    (byte) 0x53, (byte) 0x4F, (byte) 0x4E, (byte) 0x20, (byte) 0x54,
+    (byte) 0x48, (byte) 0x49, (byte) 0x53, (byte) 0x21, (byte) 0x20,
+    (byte) 0x22, (byte) 0x01, (byte) 0x0B, (byte) 0x00, (byte) 0x09,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x2E, (byte) 0xD3,
+    (byte) 0x80, (byte) 0xE2, (byte) 0x85, (byte) 0xAE, (byte) 0xCE,
+    (byte) 0x9D, (byte) 0x20, (byte) 0xD0, (byte) 0x9D, (byte) 0xCE,
+    (byte) 0xBF, (byte) 0xE2, (byte) 0x85, (byte) 0xBF, (byte) 0xD0,
+    (byte) 0xBE, (byte) 0xC9, (byte) 0xA1, (byte) 0xD0, (byte) 0xB3,
+    (byte) 0xD0, (byte) 0xB0, (byte) 0xCF, (byte) 0x81, (byte) 0xE2,
+    (byte) 0x84, (byte) 0x8E, (byte) 0x20, (byte) 0xCE, (byte) 0x91,
+    (byte) 0x74, (byte) 0x74, (byte) 0xCE, (byte) 0xB1, (byte) 0xE2,
+    (byte) 0x85, (byte) 0xBD, (byte) 0xCE, (byte) 0xBA, (byte) 0xEF,
+    (byte) 0xBF, (byte) 0xBD, (byte) 0xE2, (byte) 0x80, (byte) 0xBC,
+    (byte) 0x02, (byte) 0x00, (byte) 0x0A, (byte) 0x00, (byte) 0x0B,
+    (byte) 0x00, (byte) 0x0B, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x06, (byte) 0x62, (byte) 0x61, (byte) 0x73, (byte) 0x65,
+    (byte) 0x36, (byte) 0x34, (byte) 0x0F, (byte) 0x00, (byte) 0x0C,
+    (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03,
+    (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x0F, (byte) 0x00,
+    (byte) 0x0D, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x02,
+    (byte) 0x00, (byte) 0x03, (byte) 0x0F, (byte) 0x00, (byte) 0x0E,
+    (byte) 0x0A, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00,
+    (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02,
+    (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x03, (byte) 0x00,
+    (byte) 0x03, (byte) 0xD6, (byte) 0x06, (byte) 0x00, (byte) 0x04,
+    (byte) 0x69, (byte) 0x78, (byte) 0x08, (byte) 0x00, (byte) 0x05,
+    (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0A,
+    (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x01, (byte) 0x65, (byte) 0xA0, (byte) 0xBC, (byte) 0x00,
+    (byte) 0x04, (byte) 0x00, (byte) 0x07, (byte) 0x40, (byte) 0x09,
+    (byte) 0x21, (byte) 0xFB, (byte) 0x54, (byte) 0x44, (byte) 0x2D,
+    (byte) 0x18, (byte) 0x0B, (byte) 0x00, (byte) 0x08, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x0D, (byte) 0x4A, (byte) 0x53,
+    (byte) 0x4F, (byte) 0x4E, (byte) 0x20, (byte) 0x54, (byte) 0x48,
+    (byte) 0x49, (byte) 0x53, (byte) 0x21, (byte) 0x20, (byte) 0x22,
+    (byte) 0x01, (byte) 0x0B, (byte) 0x00, (byte) 0x09, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x2E, (byte) 0xD3, (byte) 0x80,
+    (byte) 0xE2, (byte) 0x85, (byte) 0xAE, (byte) 0xCE, (byte) 0x9D,
+    (byte) 0x20, (byte) 0xD0, (byte) 0x9D, (byte) 0xCE, (byte) 0xBF,
+    (byte) 0xE2, (byte) 0x85, (byte) 0xBF, (byte) 0xD0, (byte) 0xBE,
+    (byte) 0xC9, (byte) 0xA1, (byte) 0xD0, (byte) 0xB3, (byte) 0xD0,
+    (byte) 0xB0, (byte) 0xCF, (byte) 0x81, (byte) 0xE2, (byte) 0x84,
+    (byte) 0x8E, (byte) 0x20, (byte) 0xCE, (byte) 0x91, (byte) 0x74,
+    (byte) 0x74, (byte) 0xCE, (byte) 0xB1, (byte) 0xE2, (byte) 0x85,
+    (byte) 0xBD, (byte) 0xCE, (byte) 0xBA, (byte) 0xEF, (byte) 0xBF,
+    (byte) 0xBD, (byte) 0xE2, (byte) 0x80, (byte) 0xBC, (byte) 0x02,
+    (byte) 0x00, (byte) 0x0A, (byte) 0x00, (byte) 0x0B, (byte) 0x00,
+    (byte) 0x0B, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06,
+    (byte) 0x62, (byte) 0x61, (byte) 0x73, (byte) 0x65, (byte) 0x36,
+    (byte) 0x34, (byte) 0x0F, (byte) 0x00, (byte) 0x0C, (byte) 0x03,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x01,
+    (byte) 0x02, (byte) 0x03, (byte) 0x0F, (byte) 0x00, (byte) 0x0D,
+    (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03,
+    (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x00,
+    (byte) 0x03, (byte) 0x0F, (byte) 0x00, (byte) 0x0E, (byte) 0x0A,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x0E,
+    (byte) 0x00, (byte) 0x02, (byte) 0x0F, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x03, (byte) 0x0B, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x0B, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x0F, (byte) 0x74, (byte) 0x68, (byte) 0x65, (byte) 0x6E,
+    (byte) 0x20, (byte) 0x61, (byte) 0x20, (byte) 0x6F, (byte) 0x6E,
+    (byte) 0x65, (byte) 0x2C, (byte) 0x20, (byte) 0x74, (byte) 0x77,
+    (byte) 0x6F, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06,
+    (byte) 0x74, (byte) 0x68, (byte) 0x72, (byte) 0x65, (byte) 0x65,
+    (byte) 0x21, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06,
+    (byte) 0x46, (byte) 0x4F, (byte) 0x55, (byte) 0x52, (byte) 0x21,
+    (byte) 0x21, (byte) 0x0B, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09,
+    (byte) 0x61, (byte) 0x6E, (byte) 0x64, (byte) 0x20, (byte) 0x61,
+    (byte) 0x20, (byte) 0x6F, (byte) 0x6E, (byte) 0x65, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x09, (byte) 0x61, (byte) 0x6E,
+    (byte) 0x64, (byte) 0x20, (byte) 0x61, (byte) 0x20, (byte) 0x74,
+    (byte) 0x77, (byte) 0x6F, (byte) 0x0D, (byte) 0x00, (byte) 0x03,
+    (byte) 0x0B, (byte) 0x0F, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03,
+    (byte) 0x74, (byte) 0x77, (byte) 0x6F, (byte) 0x0C, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x08, (byte) 0x00,
+    (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
+    (byte) 0x0B, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x05, (byte) 0x57, (byte) 0x61, (byte) 0x69,
+    (byte) 0x74, (byte) 0x2E, (byte) 0x00, (byte) 0x08, (byte) 0x00,
+    (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02,
+    (byte) 0x0B, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x05, (byte) 0x57, (byte) 0x68, (byte) 0x61,
+    (byte) 0x74, (byte) 0x3F, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x05, (byte) 0x74, (byte) 0x68, (byte) 0x72,
+    (byte) 0x65, (byte) 0x65, (byte) 0x0C, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x04, (byte) 0x7A, (byte) 0x65, (byte) 0x72, (byte) 0x6F,
+    (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+    (byte) 0x00 };
+
+  private static final byte[] kUnicodeBytes = { (byte) 0xd3, (byte) 0x80,
+      (byte) 0xe2, (byte) 0x85, (byte) 0xae, (byte) 0xce, (byte) 0x9d,
+      (byte) 0x20, (byte) 0xd0, (byte) 0x9d, (byte) 0xce, (byte) 0xbf,
+      (byte) 0xe2, (byte) 0x85, (byte) 0xbf, (byte) 0xd0, (byte) 0xbe,
+      (byte) 0xc9, (byte) 0xa1, (byte) 0xd0, (byte) 0xb3, (byte) 0xd0,
+      (byte) 0xb0, (byte) 0xcf, (byte) 0x81, (byte) 0xe2, (byte) 0x84,
+      (byte) 0x8e, (byte) 0x20, (byte) 0xce, (byte) 0x91, (byte) 0x74,
+      (byte) 0x74, (byte) 0xce, (byte) 0xb1, (byte) 0xe2, (byte) 0x85,
+      (byte) 0xbd, (byte) 0xce, (byte) 0xba, (byte) 0x83, (byte) 0xe2,
+      (byte) 0x80, (byte) 0xbc };
 
   static {
     try {
@@ -55,7 +262,7 @@ public class Fixtures {
       oneOfEach.setIm_true(true);
       oneOfEach.setIm_false(false);
       oneOfEach.setA_bite((byte) 0xd6);
-      oneOfEach.setInteger16((short)27000);
+      oneOfEach.setInteger16((short) 27000);
       oneOfEach.setInteger32(1 << 24);
       oneOfEach.setInteger64((long) 6000 * 1000 * 1000);
       oneOfEach.setDouble_precision(Math.PI);
@@ -104,7 +311,7 @@ public class Fixtures {
       b = new Bonk();
       b.setType(2);
       b.setMessage("What?");
-      stage2.add(b);      
+      stage2.add(b);
       holyMoley.getBonks().put("two", stage2);
 
       // one with three
@@ -121,8 +328,10 @@ public class Fixtures {
       holyMoley.getBonks().put("three", stage2);
 
       // superhuge compact proto test struct
-      compactProtoTestStruct = new CompactProtoTestStruct(thrift.test.Constants.COMPACT_TEST);
-      compactProtoTestStruct.setA_binary(ByteBuffer.wrap(new byte[]{0,1,2,3,4,5,6,7,8}));
+      compactProtoTestStruct = new CompactProtoTestStruct(
+          thrift.test.Constants.COMPACT_TEST);
+      compactProtoTestStruct.setA_binary(ByteBuffer.wrap(new byte[] { 0, 1, 2,
+          3, 4, 5, 6, 7, 8 }));
     } catch (Exception e) {
       throw new RuntimeException(e);
     }

Added: thrift/trunk/lib/java/test/org/apache/thrift/scheme/TestStandardScheme.java
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/java/test/org/apache/thrift/scheme/TestStandardScheme.java?rev=1162917&view=auto
==============================================================================
--- thrift/trunk/lib/java/test/org/apache/thrift/scheme/TestStandardScheme.java (added)
+++ thrift/trunk/lib/java/test/org/apache/thrift/scheme/TestStandardScheme.java Mon Aug 29 17:50:31 2011
@@ -0,0 +1,40 @@
+package org.apache.thrift.scheme;
+
+import junit.framework.TestCase;
+
+import org.apache.thrift.Fixtures;
+import org.apache.thrift.TBase;
+import org.apache.thrift.TDeserializer;
+import org.apache.thrift.TException;
+import org.apache.thrift.TSerializer;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TMemoryBuffer;
+import org.apache.thrift.transport.TTransport;
+
+import thrift.test.HolyMoley;
+import thrift.test.Nesting;
+import thrift.test.OneOfEach;
+
+public class TestStandardScheme extends TestCase {
+  TSerializer serializer = new TSerializer();
+  TDeserializer deserializer = new TDeserializer();
+
+  /**
+   * This tests whether the Standard Scheme properly reads structs serialized
+   * using an older version of thrift.
+   */
+  public void testPersistentStructs() throws TException {
+    readAndCompare(new OneOfEach(), Fixtures.oneOfEach, Fixtures.persistentBytesOneOfEach);
+    readAndCompare(new HolyMoley(), Fixtures.holyMoley, Fixtures.persistentBytesHolyMoley);
+    readAndCompare(new Nesting(), Fixtures.nesting, Fixtures.persistentBytesNesting);
+  }
+
+  public void readAndCompare(TBase struct, TBase fixture, byte[] inputBytes) throws TException {
+    TTransport trans = new TMemoryBuffer(0);
+    trans.write(inputBytes, 0, inputBytes.length);
+    TProtocol iprot = new TBinaryProtocol(trans);
+    struct.read(iprot);
+    assertEquals(fixture, struct);
+  }
+}