java: Move contents of CompareTest into TestStruct; delete old version

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928159 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/java/build.xml b/lib/java/build.xml
index 0ca3200..b02b137 100644
--- a/lib/java/build.xml
+++ b/lib/java/build.xml
@@ -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.CompareTest"
-      classpathref="test.classpath" failonerror="true" />
     <java classname="org.apache.thrift.test.MetaDataTest"
       classpathref="test.classpath" failonerror="true" />
     <java classname="org.apache.thrift.test.JavaBeansTest"
diff --git a/lib/java/test/org/apache/thrift/TestStruct.java b/lib/java/test/org/apache/thrift/TestStruct.java
index bcce32e..9465090 100644
--- a/lib/java/test/org/apache/thrift/TestStruct.java
+++ b/lib/java/test/org/apache/thrift/TestStruct.java
@@ -9,6 +9,7 @@
 
 import org.apache.thrift.protocol.TBinaryProtocol;
 
+import thrift.test.Bonk;
 import thrift.test.HolyMoley;
 import thrift.test.Nesting;
 import thrift.test.OneOfEach;
@@ -105,4 +106,33 @@
 
     assertFalse(hm.equals(hmCopy2));
   }
+
+  public void testCompareTo() throws Exception {
+    Bonk bonk1 = new Bonk();
+    Bonk bonk2 = new Bonk();
+
+    // Compare empty thrift objects.
+    assertEquals(0, bonk1.compareTo(bonk2));
+
+    bonk1.setMessage("m");
+
+    // Compare one thrift object with a filled in field and another without it.
+    assertTrue(bonk1.compareTo(bonk2) > 0);
+    assertTrue(bonk2.compareTo(bonk1) < 0);
+
+    // Compare both have filled-in fields.
+    bonk2.setMessage("z");
+    assertTrue(bonk1.compareTo(bonk2) < 0);
+    assertTrue(bonk2.compareTo(bonk1) > 0);
+
+    // Compare bonk1 has a field filled in that bonk2 doesn't.
+    bonk1.setType(123);
+    assertTrue(bonk1.compareTo(bonk2) > 0);
+    assertTrue(bonk2.compareTo(bonk1) < 0);
+
+    // Compare bonk1 and bonk2 equal.
+    bonk2.setType(123);
+    bonk2.setMessage("m");
+    assertEquals(0, bonk1.compareTo(bonk2));
+  }
 }
diff --git a/lib/java/test/org/apache/thrift/test/CompareTest.java b/lib/java/test/org/apache/thrift/test/CompareTest.java
deleted file mode 100644
index 569d918..0000000
--- a/lib/java/test/org/apache/thrift/test/CompareTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.thrift.test;
-
-import org.apache.thrift.TDeserializer;
-import org.apache.thrift.TSerializer;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import thrift.test.*;
-
-public class CompareTest {
-  public static void main(String[] args) throws Exception {
-    Bonk bonk1 = new Bonk();
-    Bonk bonk2 = new Bonk();
-
-    // Compare empty thrift objects.
-    if (bonk1.compareTo(bonk2) != 0)
-      throw new RuntimeException("empty objects not equal according to compareTo");
-
-    bonk1.setMessage("m");
-
-    // Compare one thrift object with a filled in field and another without it.
-    if (bonk1.compareTo(bonk2) <= 0)
-      throw new RuntimeException("compare " + bonk1 + " to " + bonk2 + " returned " + bonk1.compareTo(bonk2));
-    if (bonk2.compareTo(bonk1) >= 0)
-      throw new RuntimeException("compare " + bonk2 + " to " + bonk1 + " returned " + bonk2.compareTo(bonk1));
-
-    // Compare both have filled-in fields.
-    bonk2.setMessage("z");
-    if (bonk1.compareTo(bonk2) >= 0)
-      throw new RuntimeException("compare " + bonk1 + " to " + bonk2 + " returned " + bonk1.compareTo(bonk2));
-    if (bonk2.compareTo(bonk1) <= 0)
-      throw new RuntimeException("compare " + bonk2 + " to " + bonk1 + " returned " + bonk2.compareTo(bonk1));
-
-    // Compare bonk1 has a field filled in that bonk2 doesn't.
-    bonk1.setType(123);
-    if (bonk1.compareTo(bonk2) <= 0)
-      throw new RuntimeException("compare " + bonk1 + " to " + bonk2 + " returned " + bonk1.compareTo(bonk2));
-    if (bonk2.compareTo(bonk1) >= 0)
-      throw new RuntimeException("compare " + bonk2 + " to " + bonk1 + " returned " + bonk2.compareTo(bonk1));
-
-    // Compare bonk1 and bonk2 equal.
-    bonk2.setType(123);
-    bonk2.setMessage("m");
-    if (bonk1.compareTo(bonk2) != 0)
-      throw new RuntimeException("compare " + bonk1 + " to " + bonk2 + " returned " + bonk1.compareTo(bonk2));
-  }
-}