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 2010/03/27 07:13:10 UTC
svn commit: r928157 - in /incubator/thrift/trunk/lib/java: build.xml
test/org/apache/thrift/TestStruct.java
test/org/apache/thrift/test/DeepCopyTest.java
Author: bryanduxbury
Date: Sat Mar 27 06:13:09 2010
New Revision: 928157
URL: http://svn.apache.org/viewvc?rev=928157&view=rev
Log:
java: Move contents of DeepCopyTest to TestStruct; delete old version
Removed:
incubator/thrift/trunk/lib/java/test/org/apache/thrift/test/DeepCopyTest.java
Modified:
incubator/thrift/trunk/lib/java/build.xml
incubator/thrift/trunk/lib/java/test/org/apache/thrift/TestStruct.java
Modified: incubator/thrift/trunk/lib/java/build.xml
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/java/build.xml?rev=928157&r1=928156&r2=928157&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/java/build.xml (original)
+++ incubator/thrift/trunk/lib/java/build.xml Sat Mar 27 06:13:09 2010
@@ -195,8 +195,6 @@
classpathref="test.classpath" failonerror="true" />
<java classname="org.apache.thrift.test.ToStringTest"
classpathref="test.classpath" failonerror="true" />
- <java classname="org.apache.thrift.test.DeepCopyTest"
- classpathref="test.classpath" failonerror="true" />
<java classname="org.apache.thrift.test.CompareTest"
classpathref="test.classpath" failonerror="true" />
<java classname="org.apache.thrift.test.MetaDataTest"
Modified: incubator/thrift/trunk/lib/java/test/org/apache/thrift/TestStruct.java
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/java/test/org/apache/thrift/TestStruct.java?rev=928157&r1=928156&r2=928157&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/java/test/org/apache/thrift/TestStruct.java (original)
+++ incubator/thrift/trunk/lib/java/test/org/apache/thrift/TestStruct.java Sat Mar 27 06:13:09 2010
@@ -4,14 +4,12 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.util.Map;
import junit.framework.TestCase;
import org.apache.thrift.protocol.TBinaryProtocol;
import thrift.test.HolyMoley;
-import thrift.test.JavaTestHelper;
import thrift.test.Nesting;
import thrift.test.OneOfEach;
@@ -82,4 +80,29 @@ public class TestStruct extends TestCase
assertEquals(hm, hm2);
assertEquals(hm.hashCode(), hm2.hashCode());
}
+
+ public void testDeepCopy() throws Exception {
+ TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
+ TDeserializer binaryDeserializer = new TDeserializer(new TBinaryProtocol.Factory());
+
+ HolyMoley hm = Fixtures.holyMoley;
+
+ byte[] binaryCopy = binarySerializer.serialize(hm);
+ HolyMoley hmCopy = new HolyMoley();
+ binaryDeserializer.deserialize(hmCopy, binaryCopy);
+ HolyMoley hmCopy2 = new HolyMoley(hm);
+
+ assertEquals(hm, hmCopy);
+ assertEquals(hmCopy, hmCopy2);
+
+ // change binary value in original object
+ hm.big.get(0).base64[0]++;
+ // make sure the change didn't propagate to the copied object
+ assertFalse(hm.equals(hmCopy2));
+ hm.big.get(0).base64[0]--; // undo change
+
+ hmCopy2.bonks.get("two").get(1).message = "What else?";
+
+ assertFalse(hm.equals(hmCopy2));
+ }
}