From: Bryan Duxbury Date: Fri, 26 Mar 2010 23:38:23 +0000 (+0000) Subject: java: convert PartialDeserializeTest to testcase of TestTDeserializer (new junit... X-Git-Tag: 0.3.0~55 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=dffa072afc5f5424dcec4744ef27021d7094fa3b;p=common%2Fthrift.git java: convert PartialDeserializeTest to testcase of TestTDeserializer (new junit test); add apache header to a few of the new test files. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928101 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/java/build.xml b/lib/java/build.xml index 9042922a..2a5c0004 100644 --- a/lib/java/build.xml +++ b/lib/java/build.xml @@ -207,8 +207,6 @@ classpathref="test.classpath" failonerror="true" /> - diff --git a/lib/java/test/org/apache/thrift/test/PartialDeserializeTest.java b/lib/java/test/org/apache/thrift/TestTDeserializer.java similarity index 85% rename from lib/java/test/org/apache/thrift/test/PartialDeserializeTest.java rename to lib/java/test/org/apache/thrift/TestTDeserializer.java index 831a4194..282b309a 100644 --- a/lib/java/test/org/apache/thrift/test/PartialDeserializeTest.java +++ b/lib/java/test/org/apache/thrift/TestTDeserializer.java @@ -16,19 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.thrift; - -package org.apache.thrift.test; - -import org.apache.thrift.TBase; -import org.apache.thrift.TDeserializer; -import org.apache.thrift.TException; -import org.apache.thrift.TSerializer; -import org.apache.thrift.TFieldIdEnum; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TCompactProtocol; import org.apache.thrift.protocol.TJSONProtocol; import org.apache.thrift.protocol.TProtocolFactory; +import org.apache.thrift.test.Fixtures; import thrift.test.Backwards; import thrift.test.OneOfEach; @@ -36,7 +30,9 @@ import thrift.test.PrimitiveThenStruct; import thrift.test.StructWithAUnion; import thrift.test.TestUnion; -public class PartialDeserializeTest { +import junit.framework.TestCase; + +public class TestTDeserializer extends TestCase { private static final TProtocolFactory[] PROTOCOLS = new TProtocolFactory[] { new TBinaryProtocol.Factory(), @@ -44,7 +40,7 @@ public class PartialDeserializeTest { new TJSONProtocol.Factory() }; - public static void main(String[] args) throws TException { + public void testPartialDeserialize() throws Exception { //Root:StructWithAUnion // 1:Union // 1.3:OneOfEach @@ -79,10 +75,9 @@ public class PartialDeserializeTest { for (int i = 0; i < 2; i++) { TBase outputCopy = output.deepCopy(); deserializer.partialDeserialize(outputCopy, record, fieldIdPath); - if(!outputCopy.equals(expected)) { - throw new RuntimeException("on attempt " + i + ", with " + protocolFactory.toString() + ", expected " + expected + " but got " + outputCopy); - } + assertEquals("on attempt " + i + ", with " + protocolFactory.toString() + + ", expected " + expected + " but got " + outputCopy, + expected, outputCopy); } } } - diff --git a/lib/java/test/org/apache/thrift/server/ServerTestBase.java b/lib/java/test/org/apache/thrift/server/ServerTestBase.java index 05d0d8da..ae567c27 100644 --- a/lib/java/test/org/apache/thrift/server/ServerTestBase.java +++ b/lib/java/test/org/apache/thrift/server/ServerTestBase.java @@ -1,3 +1,21 @@ +/* + * 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.server; import java.util.ArrayList; diff --git a/lib/java/test/org/apache/thrift/server/TestHsHaServer.java b/lib/java/test/org/apache/thrift/server/TestHsHaServer.java index c355d3ef..f80560bd 100644 --- a/lib/java/test/org/apache/thrift/server/TestHsHaServer.java +++ b/lib/java/test/org/apache/thrift/server/TestHsHaServer.java @@ -1,3 +1,21 @@ +/* + * 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.server; import org.apache.thrift.TProcessor; diff --git a/lib/java/test/org/apache/thrift/server/TestNonblockingServer.java b/lib/java/test/org/apache/thrift/server/TestNonblockingServer.java index 3aac5736..c43b4731 100644 --- a/lib/java/test/org/apache/thrift/server/TestNonblockingServer.java +++ b/lib/java/test/org/apache/thrift/server/TestNonblockingServer.java @@ -1,3 +1,21 @@ +/* + * 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.server; diff --git a/lib/java/test/org/apache/thrift/transport/ReadCountingTransport.java b/lib/java/test/org/apache/thrift/transport/ReadCountingTransport.java index fb27af6b..b2b1e57e 100644 --- a/lib/java/test/org/apache/thrift/transport/ReadCountingTransport.java +++ b/lib/java/test/org/apache/thrift/transport/ReadCountingTransport.java @@ -1,5 +1,20 @@ -/** - * +/* + * 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.transport; diff --git a/lib/java/test/org/apache/thrift/transport/TestTFramedTransport.java b/lib/java/test/org/apache/thrift/transport/TestTFramedTransport.java index 09b465cb..27dad804 100644 --- a/lib/java/test/org/apache/thrift/transport/TestTFramedTransport.java +++ b/lib/java/test/org/apache/thrift/transport/TestTFramedTransport.java @@ -1,3 +1,21 @@ +/* + * 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.transport; import java.io.ByteArrayInputStream; diff --git a/lib/java/test/org/apache/thrift/transport/WriteCountingTransport.java b/lib/java/test/org/apache/thrift/transport/WriteCountingTransport.java index c04acf37..39a78361 100644 --- a/lib/java/test/org/apache/thrift/transport/WriteCountingTransport.java +++ b/lib/java/test/org/apache/thrift/transport/WriteCountingTransport.java @@ -1,4 +1,21 @@ - +/* + * 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.transport; import org.apache.thrift.transport.TTransport;