]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/java/test/org/apache/thrift/scheme/TestStandardScheme.java
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / java / test / org / apache / thrift / scheme / TestStandardScheme.java
CommitLineData
f67539c2
TL
1package org.apache.thrift.scheme;
2
3import junit.framework.TestCase;
4
5import org.apache.thrift.Fixtures;
6import org.apache.thrift.TBase;
7import org.apache.thrift.TDeserializer;
8import org.apache.thrift.TException;
9import org.apache.thrift.TSerializer;
10import org.apache.thrift.protocol.TBinaryProtocol;
11import org.apache.thrift.protocol.TProtocol;
12import org.apache.thrift.transport.TMemoryBuffer;
13import org.apache.thrift.transport.TTransport;
14
15import thrift.test.HolyMoley;
16import thrift.test.Nesting;
17import thrift.test.OneOfEach;
18
19public class TestStandardScheme extends TestCase {
20 TSerializer serializer = new TSerializer();
21 TDeserializer deserializer = new TDeserializer();
22
23 /**
24 * This tests whether the Standard Scheme properly reads structs serialized
25 * using an older version of thrift.
26 */
27 public void testPersistentStructs() throws TException {
28 readAndCompare(new OneOfEach(), Fixtures.oneOfEach, Fixtures.persistentBytesOneOfEach);
29 readAndCompare(new HolyMoley(), Fixtures.holyMoley, Fixtures.persistentBytesHolyMoley);
30 readAndCompare(new Nesting(), Fixtures.nesting, Fixtures.persistentBytesNesting);
31 }
32
33 public void readAndCompare(TBase struct, TBase fixture, byte[] inputBytes) throws TException {
34 TTransport trans = new TMemoryBuffer(0);
35 trans.write(inputBytes, 0, inputBytes.length);
36 TProtocol iprot = new TBinaryProtocol(trans);
37 struct.read(iprot);
38 assertEquals(fixture, struct);
39 }
40}