summaryrefslogtreecommitdiff
path: root/lib/java/src/test/java/org/apache/thrift
diff options
context:
space:
mode:
Diffstat (limited to 'lib/java/src/test/java/org/apache/thrift')
-rw-r--r--lib/java/src/test/java/org/apache/thrift/Fixtures.java1279
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestAnnotationMetadata.java61
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestDeepCopy.java24
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestEnumContainers.java96
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestFullCamel.java24
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java21
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestOptionType.java68
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestOptionals.java18
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestOptionalsWithJdk8.java76
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestRenderedDoubleConstants.java348
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestReuse.java12
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestStruct.java215
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestTBaseHelper.java53
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestTDeserializer.java148
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestTEnumHelper.java10
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestTUnion.java51
-rw-r--r--lib/java/src/test/java/org/apache/thrift/TestUnsafeBinaries.java42
-rw-r--r--lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClient.java17
-rw-r--r--lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClientManager.java654
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/EnumCacheTest.java16
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/PartialThriftComparerTest.java11
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/PartialThriftTestData.java175
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/TFieldDataTest.java4
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/TestData.java33
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/TestPartialThriftDeserializer.java159
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/ThriftFieldTest.java44
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/ThriftMetadataTest.java49
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/ThriftStructProcessorTest.java72
-rw-r--r--lib/java/src/test/java/org/apache/thrift/partial/ValidateTest.java13
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/BenchmarkProtocols.java71
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/ProtocolTestBase.java382
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/TestShortStack.java23
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/TestTBinaryProtocol.java2
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/TestTCompactProtocol.java11
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/TestTField.java22
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/TestTJSONProtocol.java7
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/TestTProtocolUtil.java25
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java38
-rw-r--r--lib/java/src/test/java/org/apache/thrift/protocol/TestTTupleProtocol.java6
-rw-r--r--lib/java/src/test/java/org/apache/thrift/scheme/TestStandardScheme.java17
-rw-r--r--lib/java/src/test/java/org/apache/thrift/server/ServerTestBase.java246
-rw-r--r--lib/java/src/test/java/org/apache/thrift/server/TestAsyncServer.java9
-rw-r--r--lib/java/src/test/java/org/apache/thrift/server/TestHsHaServer.java3
-rw-r--r--lib/java/src/test/java/org/apache/thrift/server/TestNonblockingServer.java61
-rw-r--r--lib/java/src/test/java/org/apache/thrift/server/TestSaslNonblockingServer.java59
-rw-r--r--lib/java/src/test/java/org/apache/thrift/server/TestThreadPoolServer.java23
-rw-r--r--lib/java/src/test/java/org/apache/thrift/server/TestThreadedSelectorServer.java6
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/EqualityTest.java272
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/JavaBeansTest.java12
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/ReadStruct.java14
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/SerializationBenchmark.java45
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/TestServlet.java21
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/WriteStruct.java13
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceAsyncImp.java31
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceBase.java1
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceSyncImp.java17
-rw-r--r--lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/TestVoidMethExceptions.java990
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/ReadCountingTransport.java1
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBuffer.java5
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferReadTransport.java12
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferWriteTransport.java88
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestNonblockingServerSocket.java7
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java23
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTFastFramedTransport.java5
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTFramedTransport.java46
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTIOStreamTransport.java71
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryInputTransport.java22
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryTransport.java29
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactory.java45
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient1.java9
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient2.java9
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryStreamedStore.java16
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java271
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTSimpleFileTransport.java38
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/TestTZlibTransport.java33
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/WriteCountingTransport.java7
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameReader.java24
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameWriter.java131
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameReader.java79
-rw-r--r--lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameWriter.java60
-rw-r--r--lib/java/src/test/java/org/apache/thrift/utils/TestStringUtils.java66
81 files changed, 4239 insertions, 3078 deletions
diff --git a/lib/java/src/test/java/org/apache/thrift/Fixtures.java b/lib/java/src/test/java/org/apache/thrift/Fixtures.java
index a8b051866..eace85322 100644
--- a/lib/java/src/test/java/org/apache/thrift/Fixtures.java
+++ b/lib/java/src/test/java/org/apache/thrift/Fixtures.java
@@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-
import thrift.test.Bonk;
import thrift.test.CompactProtoTestStruct;
import thrift.test.HolyMoley;
@@ -70,221 +69,1064 @@ public class Fixtures {
// 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.
- private 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 };
- private 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 };
- private 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[] 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
+ };
+ private 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
+ };
+ private 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 };
+ 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 {
@@ -358,10 +1200,9 @@ public class Fixtures {
holyMoley.getBonks().put("three", stage2);
// superhuge compact proto test struct
- compactProtoTestStruct = new CompactProtoTestStruct(
- thrift.test.DebugProtoTestConstants.COMPACT_TEST);
- compactProtoTestStruct.setA_binary(ByteBuffer.wrap(new byte[] { 0, 1, 2,
- 3, 4, 5, 6, 7, 8 }));
+ compactProtoTestStruct =
+ new CompactProtoTestStruct(thrift.test.DebugProtoTestConstants.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);
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestAnnotationMetadata.java b/lib/java/src/test/java/org/apache/thrift/TestAnnotationMetadata.java
index 83be6b95d..c40c49b90 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestAnnotationMetadata.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestAnnotationMetadata.java
@@ -19,44 +19,51 @@
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
import org.apache.thrift.meta_data.FieldMetaData;
import org.junit.jupiter.api.Test;
import thrift.test.OneOfEachBeans;
import thrift.test.annotations.OneOfEachBeansWithAnnotations;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class TestAnnotationMetadata {
- @Test
- public void testWithoutParamShouldGenerateEmpty() {
- Map<? extends TFieldIdEnum, FieldMetaData> structMetaDataMap = FieldMetaData.getStructMetaDataMap(OneOfEachBeans.class);
- {
- Map<String, String> metadata = structMetaDataMap.get(OneOfEachBeans._Fields.I16_LIST).getFieldAnnotations();
- assertEquals(Collections.emptyMap(), metadata);
- }
- {
- Map<String, String> metadata = structMetaDataMap.get(OneOfEachBeans._Fields.A_BITE).getFieldAnnotations();
- assertEquals(Collections.emptyMap(), metadata);
- }
+ @Test
+ public void testWithoutParamShouldGenerateEmpty() {
+ Map<? extends TFieldIdEnum, FieldMetaData> structMetaDataMap =
+ FieldMetaData.getStructMetaDataMap(OneOfEachBeans.class);
+ {
+ Map<String, String> metadata =
+ structMetaDataMap.get(OneOfEachBeans._Fields.I16_LIST).getFieldAnnotations();
+ assertEquals(Collections.emptyMap(), metadata);
+ }
+ {
+ Map<String, String> metadata =
+ structMetaDataMap.get(OneOfEachBeans._Fields.A_BITE).getFieldAnnotations();
+ assertEquals(Collections.emptyMap(), metadata);
}
+ }
- @Test
- public void testGeneratedAnnotations() {
- Map<? extends TFieldIdEnum, FieldMetaData> structMetaDataMap = FieldMetaData.getStructMetaDataMap(OneOfEachBeansWithAnnotations.class);
- {
- Map<String, String> metadata = structMetaDataMap.get(OneOfEachBeansWithAnnotations._Fields.I16_LIST).getFieldAnnotations();
- assertEquals(Collections.emptyMap(), metadata);
- }
- {
- Map<String, String> metadata = structMetaDataMap.get(OneOfEachBeansWithAnnotations._Fields.A_BITE).getFieldAnnotations();
- Map<String, String> expected = new HashMap<>();
- expected.put("compression", "false");
- assertEquals(expected, metadata);
- }
+ @Test
+ public void testGeneratedAnnotations() {
+ Map<? extends TFieldIdEnum, FieldMetaData> structMetaDataMap =
+ FieldMetaData.getStructMetaDataMap(OneOfEachBeansWithAnnotations.class);
+ {
+ Map<String, String> metadata =
+ structMetaDataMap
+ .get(OneOfEachBeansWithAnnotations._Fields.I16_LIST)
+ .getFieldAnnotations();
+ assertEquals(Collections.emptyMap(), metadata);
+ }
+ {
+ Map<String, String> metadata =
+ structMetaDataMap.get(OneOfEachBeansWithAnnotations._Fields.A_BITE).getFieldAnnotations();
+ Map<String, String> expected = new HashMap<>();
+ expected.put("compression", "false");
+ assertEquals(expected, metadata);
}
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestDeepCopy.java b/lib/java/src/test/java/org/apache/thrift/TestDeepCopy.java
index 8fd9a97c9..7f243b3fc 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestDeepCopy.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestDeepCopy.java
@@ -1,12 +1,12 @@
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+
import org.junit.jupiter.api.Test;
import thrift.test.DeepCopyBar;
import thrift.test.DeepCopyFoo;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-
-public class TestDeepCopy {
+public class TestDeepCopy {
@Test
public void testDeepCopy() throws Exception {
@@ -26,12 +26,16 @@ public class TestDeepCopy {
assertNotSame(foo.getBar(), deepCopyFoo.getBar());
- assertNotSame(foo.getL().get(0), deepCopyFoo.getL().get(0));
- assertNotSame(foo.getS().toArray(new DeepCopyBar[0])[0], deepCopyFoo.getS().toArray(new DeepCopyBar[0])[0]);
- assertNotSame(foo.getM().get("test 3"), deepCopyFoo.getM().get("test 3"));
-
- assertNotSame(foo.getLi().get(0), deepCopyFoo.getLi().get(0));
- assertNotSame(foo.getSi().toArray(new thrift.test.Object[0])[0], deepCopyFoo.getSi().toArray(new thrift.test.Object[0])[0]);
- assertNotSame(foo.getMi().get("test 3"), deepCopyFoo.getMi().get("test 3"));
+ assertNotSame(foo.getL().get(0), deepCopyFoo.getL().get(0));
+ assertNotSame(
+ foo.getS().toArray(new DeepCopyBar[0])[0],
+ deepCopyFoo.getS().toArray(new DeepCopyBar[0])[0]);
+ assertNotSame(foo.getM().get("test 3"), deepCopyFoo.getM().get("test 3"));
+
+ assertNotSame(foo.getLi().get(0), deepCopyFoo.getLi().get(0));
+ assertNotSame(
+ foo.getSi().toArray(new thrift.test.Object[0])[0],
+ deepCopyFoo.getSi().toArray(new thrift.test.Object[0])[0]);
+ assertNotSame(foo.getMi().get("test 3"), deepCopyFoo.getMi().get("test 3"));
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestEnumContainers.java b/lib/java/src/test/java/org/apache/thrift/TestEnumContainers.java
index b7b291396..5e3a9938d 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestEnumContainers.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestEnumContainers.java
@@ -19,70 +19,70 @@
package org.apache.thrift;
-import org.junit.jupiter.api.Test;
-import thrift.test.enumcontainers.EnumContainersTestConstants;
-import thrift.test.enumcontainers.GodBean;
-import thrift.test.enumcontainers.GreekGodGoddess;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
+import org.junit.jupiter.api.Test;
+import thrift.test.enumcontainers.EnumContainersTestConstants;
+import thrift.test.enumcontainers.GodBean;
+import thrift.test.enumcontainers.GreekGodGoddess;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class TestEnumContainers {
+public class TestEnumContainers {
- @Test
- public void testEnumContainers() throws Exception {
- final GodBean b1 = new GodBean();
- b1.addToGoddess(GreekGodGoddess.HERA);
- b1.getGoddess().add(GreekGodGoddess.APHRODITE);
- b1.putToPower(GreekGodGoddess.ZEUS, 1000);
- b1.getPower().put(GreekGodGoddess.HERA, 333);
- b1.putToByAlias("Mr. Z", GreekGodGoddess.ZEUS);
- b1.addToImages("Baths of Aphrodite 01.jpeg");
+ @Test
+ public void testEnumContainers() throws Exception {
+ final GodBean b1 = new GodBean();
+ b1.addToGoddess(GreekGodGoddess.HERA);
+ b1.getGoddess().add(GreekGodGoddess.APHRODITE);
+ b1.putToPower(GreekGodGoddess.ZEUS, 1000);
+ b1.getPower().put(GreekGodGoddess.HERA, 333);
+ b1.putToByAlias("Mr. Z", GreekGodGoddess.ZEUS);
+ b1.addToImages("Baths of Aphrodite 01.jpeg");
- final GodBean b2 = new GodBean(b1);
+ final GodBean b2 = new GodBean(b1);
- final GodBean b3 = new GodBean();
- {
- final TSerializer serializer = new TSerializer();
- final TDeserializer deserializer = new TDeserializer();
+ final GodBean b3 = new GodBean();
+ {
+ final TSerializer serializer = new TSerializer();
+ final TDeserializer deserializer = new TDeserializer();
- final byte[] bytes = serializer.serialize(b1);
- deserializer.deserialize(b3, bytes);
- }
+ final byte[] bytes = serializer.serialize(b1);
+ deserializer.deserialize(b3, bytes);
+ }
- assertNotSame(b1.getGoddess(), b2.getGoddess());
- assertNotSame(b1.getPower(), b2.getPower());
+ assertNotSame(b1.getGoddess(), b2.getGoddess());
+ assertNotSame(b1.getPower(), b2.getPower());
- assertNotSame(b1.getGoddess(), b3.getGoddess());
- assertNotSame(b1.getPower(), b3.getPower());
+ assertNotSame(b1.getGoddess(), b3.getGoddess());
+ assertNotSame(b1.getPower(), b3.getPower());
- for (GodBean each : new GodBean[]{b1, b2, b3}) {
- assertTrue(each.getGoddess().contains(GreekGodGoddess.HERA));
- assertFalse(each.getGoddess().contains(GreekGodGoddess.POSEIDON));
- assertTrue(each.getGoddess() instanceof EnumSet);
+ for (GodBean each : new GodBean[] {b1, b2, b3}) {
+ assertTrue(each.getGoddess().contains(GreekGodGoddess.HERA));
+ assertFalse(each.getGoddess().contains(GreekGodGoddess.POSEIDON));
+ assertTrue(each.getGoddess() instanceof EnumSet);
- assertEquals(Integer.valueOf(1000), each.getPower().get(GreekGodGoddess.ZEUS));
- assertEquals(Integer.valueOf(333), each.getPower().get(GreekGodGoddess.HERA));
- assertTrue(each.getPower() instanceof EnumMap);
+ assertEquals(Integer.valueOf(1000), each.getPower().get(GreekGodGoddess.ZEUS));
+ assertEquals(Integer.valueOf(333), each.getPower().get(GreekGodGoddess.HERA));
+ assertTrue(each.getPower() instanceof EnumMap);
- assertTrue(each.getByAlias() instanceof HashMap);
- assertTrue(each.getImages() instanceof HashSet);
- }
+ assertTrue(each.getByAlias() instanceof HashMap);
+ assertTrue(each.getImages() instanceof HashSet);
}
+ }
- @Test
- public void testEnumConstants() {
- assertEquals("lightning bolt", EnumContainersTestConstants.ATTRIBUTES.get(GreekGodGoddess.ZEUS));
- assertTrue(EnumContainersTestConstants.ATTRIBUTES instanceof EnumMap);
+ @Test
+ public void testEnumConstants() {
+ assertEquals(
+ "lightning bolt", EnumContainersTestConstants.ATTRIBUTES.get(GreekGodGoddess.ZEUS));
+ assertTrue(EnumContainersTestConstants.ATTRIBUTES instanceof EnumMap);
- assertTrue(EnumContainersTestConstants.BEAUTY.contains(GreekGodGoddess.APHRODITE));
- assertTrue(EnumContainersTestConstants.BEAUTY instanceof EnumSet);
- }
+ assertTrue(EnumContainersTestConstants.BEAUTY.contains(GreekGodGoddess.APHRODITE));
+ assertTrue(EnumContainersTestConstants.BEAUTY instanceof EnumSet);
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestFullCamel.java b/lib/java/src/test/java/org/apache/thrift/TestFullCamel.java
index 45662045d..008195c04 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestFullCamel.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestFullCamel.java
@@ -19,21 +19,21 @@
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.thrift.protocol.TBinaryProtocol;
import org.junit.jupiter.api.Test;
import thrift.test.fullcamel.OneOfEachZZ;
import thrift.test.fullcamel.UnderscoreSrv;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
// Sanity check for the code generated by 'fullcamel'.
//
-public class TestFullCamel {
+public class TestFullCamel {
@Test
public void testCamelCaseSyntax() throws Exception {
- TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
+ TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
TDeserializer binaryDeserializer = new TDeserializer(new TBinaryProtocol.Factory());
OneOfEachZZ obj = new OneOfEachZZ();
@@ -47,13 +47,13 @@ public class TestFullCamel {
@Test
public void testCamelCaseRpcMethods() throws Exception {
- final UnderscoreSrv.Iface srv = new UnderscoreSrv.Iface() {
- @Override
- public long someRpcCall(String message) {
- return 1l;
- }
- };
+ final UnderscoreSrv.Iface srv =
+ new UnderscoreSrv.Iface() {
+ @Override
+ public long someRpcCall(String message) {
+ return 1l;
+ }
+ };
assertTrue(1l == srv.someRpcCall("test"));
}
}
-
diff --git a/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java b/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java
index 7b00cca2a..efd1882bf 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java
@@ -19,18 +19,18 @@
package org.apache.thrift;
-import org.apache.thrift.protocol.TMessage;
-import org.apache.thrift.protocol.TMessageType;
-import org.apache.thrift.protocol.TProtocol;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import org.apache.thrift.protocol.TMessage;
+import org.apache.thrift.protocol.TMessageType;
+import org.apache.thrift.protocol.TProtocol;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
public class TestMultiplexedProcessor {
private TMultiplexedProcessor mp;
private TProtocol iprot;
@@ -45,22 +45,22 @@ public class TestMultiplexedProcessor {
@Test
public void testWrongMessageType() throws TException {
- when (iprot.readMessageBegin()).thenReturn(new TMessage("service:func", TMessageType.REPLY, 42));
- assertThrows(TException.class, ()->mp.process(iprot, oprot));
+ when(iprot.readMessageBegin()).thenReturn(new TMessage("service:func", TMessageType.REPLY, 42));
+ assertThrows(TException.class, () -> mp.process(iprot, oprot));
}
@Test
public void testNoSuchService() throws TException {
when(iprot.readMessageBegin()).thenReturn(new TMessage("service:func", TMessageType.CALL, 42));
- assertThrows(TException.class, ()->mp.process(iprot, oprot));
+ assertThrows(TException.class, () -> mp.process(iprot, oprot));
}
static class StubProcessor implements TProcessor {
@Override
public void process(TProtocol in, TProtocol out) throws TException {
TMessage msg = in.readMessageBegin();
- if (!"func".equals(msg.name) || msg.type!=TMessageType.CALL || msg.seqid!=42) {
+ if (!"func".equals(msg.name) || msg.type != TMessageType.CALL || msg.seqid != 42) {
throw new TException("incorrect parameters");
}
out.writeMessageBegin(new TMessage("func", TMessageType.REPLY, 42));
@@ -82,5 +82,4 @@ public class TestMultiplexedProcessor {
mp.process(iprot, oprot);
verify(oprot).writeMessageBegin(any(TMessage.class));
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestOptionType.java b/lib/java/src/test/java/org/apache/thrift/TestOptionType.java
index 6365203af..e0ac9cb39 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestOptionType.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestOptionType.java
@@ -19,49 +19,49 @@
package org.apache.thrift;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+
// Tests and documents behavior for the "Option<T>" type
-public class TestOptionType {
- @Test
- public void testSome() {
- String name = "Chuck Norris";
- Option<String> option = Option.fromNullable(name);
+public class TestOptionType {
+ @Test
+ public void testSome() {
+ String name = "Chuck Norris";
+ Option<String> option = Option.fromNullable(name);
- assertTrue(option instanceof Option.Some);
- assertTrue(option.isDefined());
- assertEquals("Some(Chuck Norris)", option.toString());
- assertEquals(option.or("default value"), "Chuck Norris");
- assertEquals(option.get(),"Chuck Norris");
- }
+ assertTrue(option instanceof Option.Some);
+ assertTrue(option.isDefined());
+ assertEquals("Some(Chuck Norris)", option.toString());
+ assertEquals(option.or("default value"), "Chuck Norris");
+ assertEquals(option.get(), "Chuck Norris");
+ }
- @Test
- public void testNone() throws Exception {
- String name = null;
- Option<String> option = Option.fromNullable(name);
+ @Test
+ public void testNone() throws Exception {
+ String name = null;
+ Option<String> option = Option.fromNullable(name);
- assertTrue(option instanceof Option.None);
- assertFalse(option.isDefined());
- assertEquals("None", option.toString());
- assertEquals(option.or("default value"), "default value");
- // Expect exception
- assertThrows(IllegalStateException.class, option::get);
- }
+ assertTrue(option instanceof Option.None);
+ assertFalse(option.isDefined());
+ assertEquals("None", option.toString());
+ assertEquals(option.or("default value"), "default value");
+ // Expect exception
+ assertThrows(IllegalStateException.class, option::get);
+ }
- @Test
- public void testMakeSome() throws Exception {
- Option<String> some = Option.some("wee");
- assertTrue(some.isDefined());
- }
+ @Test
+ public void testMakeSome() throws Exception {
+ Option<String> some = Option.some("wee");
+ assertTrue(some.isDefined());
+ }
- @Test
- public void testMakeNone() throws Exception {
- Option<Integer> none = Option.none();
- assertFalse(none.isDefined());
- }
+ @Test
+ public void testMakeNone() throws Exception {
+ Option<Integer> none = Option.none();
+ assertFalse(none.isDefined());
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestOptionals.java b/lib/java/src/test/java/org/apache/thrift/TestOptionals.java
index 38322eeee..5d83a1b9d 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestOptionals.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestOptionals.java
@@ -19,27 +19,27 @@
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.junit.jupiter.api.Test;
import thrift.test.Opt30;
import thrift.test.Opt4;
import thrift.test.Opt64;
import thrift.test.Opt80;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
// Exercises the isSet methods using structs from ManyOptionals.thrift
-public class TestOptionals {
+public class TestOptionals {
@Test
public void testEncodingUtils() throws Exception {
- assertEquals((short)0x8, EncodingUtils.setBit((short)0, 3, true));
- assertEquals((short)0, EncodingUtils.setBit((short)0x8, 3, false));
+ assertEquals((short) 0x8, EncodingUtils.setBit((short) 0, 3, true));
+ assertEquals((short) 0, EncodingUtils.setBit((short) 0x8, 3, false));
assertTrue(EncodingUtils.testBit((short) 0x8, 3));
assertFalse(EncodingUtils.testBit((short) 0x8, 4));
- assertEquals(Short.MIN_VALUE, EncodingUtils.setBit((short)0, 15, true));
- assertEquals((short)0, EncodingUtils.setBit(Short.MIN_VALUE, 15, false));
+ assertEquals(Short.MIN_VALUE, EncodingUtils.setBit((short) 0, 15, true));
+ assertEquals((short) 0, EncodingUtils.setBit(Short.MIN_VALUE, 15, false));
assertTrue(EncodingUtils.testBit(Short.MIN_VALUE, 15));
assertFalse(EncodingUtils.testBit(Short.MIN_VALUE, 14));
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestOptionalsWithJdk8.java b/lib/java/src/test/java/org/apache/thrift/TestOptionalsWithJdk8.java
index 2f3cf3bad..e025910a1 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestOptionalsWithJdk8.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestOptionalsWithJdk8.java
@@ -19,52 +19,52 @@
package org.apache.thrift;
-import org.junit.jupiter.api.Test;
-import thrift.test.optiontypejdk8.Person;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+import thrift.test.optiontypejdk8.Person;
+
// Tests and documents behavior for the JDK8 "Option<T>" type
-public class TestOptionalsWithJdk8 {
+public class TestOptionalsWithJdk8 {
- @Test
- public void testConstruction() {
- Person person = new Person(1L, "name");
- assertFalse(person.getAge().isPresent());
- assertFalse(person.isSetAge());
- assertFalse(person.getPhone().isPresent());
- assertFalse(person.isSetPhone());
- assertEquals(1L, person.getId());
- assertTrue(person.isSetId());
- assertEquals("name", person.getName());
- assertTrue(person.isSetName());
+ @Test
+ public void testConstruction() {
+ Person person = new Person(1L, "name");
+ assertFalse(person.getAge().isPresent());
+ assertFalse(person.isSetAge());
+ assertFalse(person.getPhone().isPresent());
+ assertFalse(person.isSetPhone());
+ assertEquals(1L, person.getId());
+ assertTrue(person.isSetId());
+ assertEquals("name", person.getName());
+ assertTrue(person.isSetName());
- assertFalse(person.getAddresses().isPresent());
- assertEquals(Integer.valueOf(0), person.getAddressesSize().orElse(0));
- assertFalse(person.getPets().isPresent());
- assertEquals(Integer.valueOf(0), person.getPetsSize().orElse(0));
- }
+ assertFalse(person.getAddresses().isPresent());
+ assertEquals(Integer.valueOf(0), person.getAddressesSize().orElse(0));
+ assertFalse(person.getPets().isPresent());
+ assertEquals(Integer.valueOf(0), person.getPetsSize().orElse(0));
+ }
- @Test
- public void testEmpty() {
- Person person = new Person();
- person.setPhone("phone");
- assertFalse(person.getAge().isPresent());
- assertFalse(person.isSetAge());
- assertTrue(person.getPhone().isPresent());
- assertEquals("phone", person.getPhone().get());
- assertTrue(person.isSetPhone());
- assertEquals(0L, person.getId());
- assertFalse(person.isSetId());
- assertNull(person.getName());
- assertFalse(person.isSetName());
+ @Test
+ public void testEmpty() {
+ Person person = new Person();
+ person.setPhone("phone");
+ assertFalse(person.getAge().isPresent());
+ assertFalse(person.isSetAge());
+ assertTrue(person.getPhone().isPresent());
+ assertEquals("phone", person.getPhone().get());
+ assertTrue(person.isSetPhone());
+ assertEquals(0L, person.getId());
+ assertFalse(person.isSetId());
+ assertNull(person.getName());
+ assertFalse(person.isSetName());
- assertFalse(person.getAddresses().isPresent());
- assertEquals(Integer.valueOf(0), person.getAddressesSize().orElse(0));
- assertFalse(person.getPets().isPresent());
- assertEquals(Integer.valueOf(0), person.getPetsSize().orElse(0));
- }
+ assertFalse(person.getAddresses().isPresent());
+ assertEquals(Integer.valueOf(0), person.getAddressesSize().orElse(0));
+ assertFalse(person.getPets().isPresent());
+ assertEquals(Integer.valueOf(0), person.getPetsSize().orElse(0));
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestRenderedDoubleConstants.java b/lib/java/src/test/java/org/apache/thrift/TestRenderedDoubleConstants.java
index b38f39c8f..2afc6ffdd 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestRenderedDoubleConstants.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestRenderedDoubleConstants.java
@@ -19,163 +19,209 @@
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import thrift.test.DoubleConstantsTestConstants;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class TestRenderedDoubleConstants {
- private static final double EPSILON = 0.0000001;
- private static final String ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST =
- "failed to verify a double constant generated by Thrift (expected = %f, got = %f)";
- private static final String ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_LIST_TEST =
- "failed to verify a list item by Thrift (expected = %f, got = %f)";
- private static final String ASSERTION_MESSAGE_FOR_TYPE_CHECKS =
- "the rendered variable with name %s is not of double type";
+ private static final double EPSILON = 0.0000001;
+ private static final String ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST =
+ "failed to verify a double constant generated by Thrift (expected = %f, got = %f)";
+ private static final String ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_LIST_TEST =
+ "failed to verify a list item by Thrift (expected = %f, got = %f)";
+ private static final String ASSERTION_MESSAGE_FOR_TYPE_CHECKS =
+ "the rendered variable with name %s is not of double type";
- // to make sure lists containing doubles are generated correctly
- @Test
- public void testRenderedDoubleList() throws Exception {
- final double[] EXPECTED_LIST =
- {1d, -100d, 100d, 9223372036854775807d, -9223372036854775807d, 3.14159265359, 1000000.1, -1000000.1, 1.7e+308,
- -1.7e+308, 9223372036854775816.43, -9223372036854775816.43};
- assertEquals(EXPECTED_LIST.length, DoubleConstantsTestConstants.DOUBLE_LIST_TEST.size());
- for (int i = 0; i < EXPECTED_LIST.length; ++i) {
- assertEquals(
- EXPECTED_LIST[i],
- DoubleConstantsTestConstants.DOUBLE_LIST_TEST.get(i), EPSILON, String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_LIST_TEST,
- EXPECTED_LIST[i],
- DoubleConstantsTestConstants.DOUBLE_LIST_TEST.get(i)));
- }
+ // to make sure lists containing doubles are generated correctly
+ @Test
+ public void testRenderedDoubleList() throws Exception {
+ final double[] EXPECTED_LIST = {
+ 1d,
+ -100d,
+ 100d,
+ 9223372036854775807d,
+ -9223372036854775807d,
+ 3.14159265359,
+ 1000000.1,
+ -1000000.1,
+ 1.7e+308,
+ -1.7e+308,
+ 9223372036854775816.43,
+ -9223372036854775816.43
+ };
+ assertEquals(EXPECTED_LIST.length, DoubleConstantsTestConstants.DOUBLE_LIST_TEST.size());
+ for (int i = 0; i < EXPECTED_LIST.length; ++i) {
+ assertEquals(
+ EXPECTED_LIST[i],
+ DoubleConstantsTestConstants.DOUBLE_LIST_TEST.get(i),
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_LIST_TEST,
+ EXPECTED_LIST[i],
+ DoubleConstantsTestConstants.DOUBLE_LIST_TEST.get(i)));
}
+ }
- // to make sure the variables inside Thrift files are generated correctly
- @Test
- public void testRenderedDoubleConstants() throws Exception {
- final double EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT = 1.0;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT = -100.0;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT = 9223372036854775807.0;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT = -9223372036854775807.0;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS = 3.14159265359;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE = 1000000.1;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE = -1000000.1;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE = 1.7e+308;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE = 9223372036854775816.43;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE = -1.7e+308;
- final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE = -9223372036854775816.43;
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST, EPSILON, String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST));
- assertEquals(
- EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST, EPSILON,
- String.format(
- ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
- EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE,
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST));
- assertTrue(
- Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST),
- String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST"));
- assertTrue(
- Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST),
- String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST"));
- assertTrue(
- Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST),
- String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST"));
- assertTrue(
- Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST),
- String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST"));
- assertTrue(
- Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST),
- String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST"));
- assertTrue(
- Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST),
- String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST"));
- assertTrue(
- Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST),
- String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST"));
- //assertTrue(
- // String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST"),
- // Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST));
- assertTrue(
- Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST),
- String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST"));
- //assertTrue(
- // String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST"),
- // Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST));
- assertTrue(
- Double.class.isInstance(
- DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST),
- String.format(
- ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST"));
- }
+ // to make sure the variables inside Thrift files are generated correctly
+ @Test
+ public void testRenderedDoubleConstants() throws Exception {
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT = 1.0;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT = -100.0;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT = 9223372036854775807.0;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT = -9223372036854775807.0;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS = 3.14159265359;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE = 1000000.1;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE = -1000000.1;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE = 1.7e+308;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE = 9223372036854775816.43;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE = -1.7e+308;
+ final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE =
+ -9223372036854775816.43;
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST));
+ assertEquals(
+ EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE,
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST,
+ EPSILON,
+ String.format(
+ ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
+ EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE,
+ DoubleConstantsTestConstants
+ .DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST));
+ assertTrue(
+ Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST),
+ String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST"));
+ assertTrue(
+ Double.class.isInstance(
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST),
+ String.format(
+ ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST"));
+ assertTrue(
+ Double.class.isInstance(
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST),
+ String.format(
+ ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST"));
+ assertTrue(
+ Double.class.isInstance(
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST),
+ String.format(
+ ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST"));
+ assertTrue(
+ Double.class.isInstance(
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST),
+ String.format(
+ ASSERTION_MESSAGE_FOR_TYPE_CHECKS,
+ "DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST"));
+ assertTrue(
+ Double.class.isInstance(
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST),
+ String.format(
+ ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST"));
+ assertTrue(
+ Double.class.isInstance(
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST),
+ String.format(
+ ASSERTION_MESSAGE_FOR_TYPE_CHECKS,
+ "DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST"));
+ // assertTrue(
+ // String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST"),
+ //
+ // Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST));
+ assertTrue(
+ Double.class.isInstance(
+ DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST),
+ String.format(
+ ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST"));
+ // assertTrue(
+ // String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST"),
+ //
+ // Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST));
+ assertTrue(
+ Double.class.isInstance(
+ DoubleConstantsTestConstants
+ .DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST),
+ String.format(
+ ASSERTION_MESSAGE_FOR_TYPE_CHECKS,
+ "DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST"));
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestReuse.java b/lib/java/src/test/java/org/apache/thrift/TestReuse.java
index 56dc1d4ed..4fa81db38 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestReuse.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestReuse.java
@@ -19,22 +19,21 @@
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
+import java.util.HashSet;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.junit.jupiter.api.Test;
import thrift.test.Reuse;
-import java.util.HashSet;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertSame;
-
// Tests reusing objects for deserialization.
//
public class TestReuse extends TestStruct {
@Test
public void testReuseObject() throws Exception {
- TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
+ TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
TDeserializer binaryDeserializer = new TDeserializer(new TBinaryProtocol.Factory());
Reuse ru1 = new Reuse();
@@ -57,5 +56,4 @@ public class TestReuse extends TestStruct {
assertSame(hs1, ru1.getVal2());
assertEquals(2, hs1.size());
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestStruct.java b/lib/java/src/test/java/org/apache/thrift/TestStruct.java
index 84b00b4fb..17a00f159 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestStruct.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestStruct.java
@@ -18,6 +18,21 @@
*/
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.thrift.meta_data.FieldMetaData;
import org.apache.thrift.meta_data.ListMetaData;
import org.apache.thrift.meta_data.MapMetaData;
@@ -38,26 +53,10 @@ import thrift.test.StructA;
import thrift.test.StructB;
import thrift.test.Xtruct;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class TestStruct {
@Test
public void testIdentity() throws Exception {
- TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
+ TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
TDeserializer binaryDeserializer = new TDeserializer(new TBinaryProtocol.Factory());
OneOfEach ooe = Fixtures.getOneOfEach();
@@ -67,37 +66,31 @@ public class TestStruct {
n.my_ooe.integer16 = 16;
n.my_ooe.integer32 = 32;
n.my_ooe.integer64 = 64;
- n.my_ooe.double_precision = (Math.sqrt(5)+1)/2;
- n.my_ooe.some_characters = ":R (me going \"rrrr\")";
- n.my_ooe.zomg_unicode = "\u04c0\u216e\u039d\u0020\u041d\u03bf\u217f"+
- "\u043e\u0261\u0433\u0430\u03c1\u210e\u0020"+
- "\u0391\u0074\u0074\u03b1\u217d\u03ba\u01c3"+
- "\u203c";
+ n.my_ooe.double_precision = (Math.sqrt(5) + 1) / 2;
+ n.my_ooe.some_characters = ":R (me going \"rrrr\")";
+ n.my_ooe.zomg_unicode =
+ "\u04c0\u216e\u039d\u0020\u041d\u03bf\u217f"
+ + "\u043e\u0261\u0433\u0430\u03c1\u210e\u0020"
+ + "\u0391\u0074\u0074\u03b1\u217d\u03ba\u01c3"
+ + "\u203c";
n.my_bonk = Fixtures.getNesting().my_bonk;
HolyMoley hm = Fixtures.getHolyMoley();
OneOfEach ooe2 = new OneOfEach();
- binaryDeserializer.deserialize(
- ooe2,
- binarySerializer.serialize(ooe));
+ binaryDeserializer.deserialize(ooe2, binarySerializer.serialize(ooe));
assertEquals(ooe, ooe2);
assertEquals(ooe.hashCode(), ooe2.hashCode());
-
Nesting n2 = new Nesting();
- binaryDeserializer.deserialize(
- n2,
- binarySerializer.serialize(n));
+ binaryDeserializer.deserialize(n2, binarySerializer.serialize(n));
assertEquals(n, n2);
assertEquals(n.hashCode(), n2.hashCode());
HolyMoley hm2 = new HolyMoley();
- binaryDeserializer.deserialize(
- hm2,
- binarySerializer.serialize(hm));
+ binaryDeserializer.deserialize(hm2, binarySerializer.serialize(hm));
assertEquals(hm, hm2);
assertEquals(hm.hashCode(), hm2.hashCode());
@@ -105,7 +98,7 @@ public class TestStruct {
@Test
public void testDeepCopy() throws Exception {
- TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
+ TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory());
TDeserializer binaryDeserializer = new TDeserializer(new TBinaryProtocol.Factory());
HolyMoley hm = Fixtures.getHolyMoley();
@@ -195,17 +188,21 @@ public class TestStruct {
private void expectLessThan(Insanity insanity1, Insanity insanity2) {
int compareTo = insanity1.compareTo(insanity2);
- assertTrue(compareTo < 0, insanity1 + " should be less than " + insanity2 + ", but is: " + compareTo);
+ assertTrue(
+ compareTo < 0, insanity1 + " should be less than " + insanity2 + ", but is: " + compareTo);
}
private void expectGreaterThan(Insanity insanity1, Insanity insanity2) {
int compareTo = insanity1.compareTo(insanity2);
- assertTrue(compareTo > 0, insanity1 + " should be greater than " + insanity2 + ", but is: " + compareTo);
+ assertTrue(
+ compareTo > 0,
+ insanity1 + " should be greater than " + insanity2 + ", but is: " + compareTo);
}
private void expectEquals(Insanity insanity1, Insanity insanity2) {
int compareTo = insanity1.compareTo(insanity2);
- assertEquals(0, compareTo, insanity1 + " should be equal to " + insanity2 + ", but is: " + compareTo);
+ assertEquals(
+ 0, compareTo, insanity1 + " should be equal to " + insanity2 + ", but is: " + compareTo);
}
@Test
@@ -225,9 +222,13 @@ public class TestStruct {
assertEquals("set_field", mdMap.get(CrazyNesting._Fields.SET_FIELD).fieldName);
assertEquals("binary_field", mdMap.get(CrazyNesting._Fields.BINARY_FIELD).fieldName);
- assertEquals(TFieldRequirementType.DEFAULT, mdMap.get(CrazyNesting._Fields.STRING_FIELD).requirementType);
- assertEquals(TFieldRequirementType.REQUIRED, mdMap.get(CrazyNesting._Fields.LIST_FIELD).requirementType);
- assertEquals(TFieldRequirementType.OPTIONAL, mdMap.get(CrazyNesting._Fields.SET_FIELD).requirementType);
+ assertEquals(
+ TFieldRequirementType.DEFAULT,
+ mdMap.get(CrazyNesting._Fields.STRING_FIELD).requirementType);
+ assertEquals(
+ TFieldRequirementType.REQUIRED, mdMap.get(CrazyNesting._Fields.LIST_FIELD).requirementType);
+ assertEquals(
+ TFieldRequirementType.OPTIONAL, mdMap.get(CrazyNesting._Fields.SET_FIELD).requirementType);
assertEquals(TType.STRING, mdMap.get(CrazyNesting._Fields.STRING_FIELD).valueMetaData.type);
assertFalse(mdMap.get(CrazyNesting._Fields.STRING_FIELD).valueMetaData.isBinary());
@@ -241,9 +242,44 @@ public class TestStruct {
assertFalse(mdMap.get(CrazyNesting._Fields.LIST_FIELD).valueMetaData.isStruct());
- assertEquals(TType.STRUCT, ((MapMetaData)((ListMetaData)((SetMetaData)((MapMetaData)((MapMetaData)((ListMetaData)mdMap.get(CrazyNesting._Fields.LIST_FIELD).valueMetaData).elemMetaData).valueMetaData).valueMetaData).elemMetaData).elemMetaData).keyMetaData.type);
-
- assertEquals(Insanity.class, ((StructMetaData)((MapMetaData)((ListMetaData)((SetMetaData)((MapMetaData)((MapMetaData)((ListMetaData)mdMap.get(CrazyNesting._Fields.LIST_FIELD).valueMetaData).elemMetaData).valueMetaData).valueMetaData).elemMetaData).elemMetaData).keyMetaData).structClass);
+ assertEquals(
+ TType.STRUCT,
+ ((MapMetaData)
+ ((ListMetaData)
+ ((SetMetaData)
+ ((MapMetaData)
+ ((MapMetaData)
+ ((ListMetaData)
+ mdMap.get(CrazyNesting._Fields.LIST_FIELD)
+ .valueMetaData)
+ .elemMetaData)
+ .valueMetaData)
+ .valueMetaData)
+ .elemMetaData)
+ .elemMetaData)
+ .keyMetaData
+ .type);
+
+ assertEquals(
+ Insanity.class,
+ ((StructMetaData)
+ ((MapMetaData)
+ ((ListMetaData)
+ ((SetMetaData)
+ ((MapMetaData)
+ ((MapMetaData)
+ ((ListMetaData)
+ mdMap.get(
+ CrazyNesting._Fields
+ .LIST_FIELD)
+ .valueMetaData)
+ .elemMetaData)
+ .valueMetaData)
+ .valueMetaData)
+ .elemMetaData)
+ .elemMetaData)
+ .keyMetaData)
+ .structClass);
// Check that FieldMetaData contains a map with metadata for all generated struct classes
assertNotNull(FieldMetaData.getStructMetaDataMap(CrazyNesting.class));
@@ -257,7 +293,8 @@ public class TestStruct {
assertEquals(mdEntry.getKey(), CrazyNesting._Fields.findByName(mdEntry.getValue().fieldName));
}
- MapMetaData vmd = (MapMetaData)Insanity.metaDataMap.get(Insanity._Fields.USER_MAP).valueMetaData;
+ MapMetaData vmd =
+ (MapMetaData) Insanity.metaDataMap.get(Insanity._Fields.USER_MAP).valueMetaData;
assertTrue(vmd.valueMetaData.isTypedef());
assertFalse(vmd.keyMetaData.isTypedef());
}
@@ -268,56 +305,56 @@ public class TestStruct {
object.req_int = 0;
object.req_obj = "";
- object.req_bin = ByteBuffer.wrap(new byte[] {
- 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15,
- 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29,
- 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44,
- -45, 46, -47, 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58, -59,
- 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71, 72, -73, 74,
- -75, 76, -77, 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89,
- 90, -91, 92, -93, 94, -95, 96, -97, 98, -99, 100, -101, 102, -103,
- 104, -105, 106, -107, 108, -109, 110, -111, 112, -113, 114, -115,
- 116, -117, 118, -119, 120, -121, 122, -123, 124, -125, 126, -127,
- });
-
- assertEquals("JavaTestHelper(req_int:0, req_obj:, req_bin:"+
- "00 FF 02 FD 04 FB 06 F9 08 F7 0A F5 0C F3 0E F1 10 EF 12 ED 14 "+
- "EB 16 E9 18 E7 1A E5 1C E3 1E E1 20 DF 22 DD 24 DB 26 D9 28 D7 "+
- "2A D5 2C D3 2E D1 30 CF 32 CD 34 CB 36 C9 38 C7 3A C5 3C C3 3E "+
- "C1 40 BF 42 BD 44 BB 46 B9 48 B7 4A B5 4C B3 4E B1 50 AF 52 AD "+
- "54 AB 56 A9 58 A7 5A A5 5C A3 5E A1 60 9F 62 9D 64 9B 66 99 68 "+
- "97 6A 95 6C 93 6E 91 70 8F 72 8D 74 8B 76 89 78 87 7A 85 7C 83 "+
- "7E 81)",
+ object.req_bin =
+ ByteBuffer.wrap(
+ new byte[] {
+ 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20,
+ -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39,
+ 40, -41, 42, -43, 44, -45, 46, -47, 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58,
+ -59, 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71, 72, -73, 74, -75, 76, -77,
+ 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89, 90, -91, 92, -93, 94, -95, 96,
+ -97, 98, -99, 100, -101, 102, -103, 104, -105, 106, -107, 108, -109, 110, -111, 112,
+ -113, 114, -115, 116, -117, 118, -119, 120, -121, 122, -123, 124, -125, 126, -127,
+ });
+
+ assertEquals(
+ "JavaTestHelper(req_int:0, req_obj:, req_bin:"
+ + "00 FF 02 FD 04 FB 06 F9 08 F7 0A F5 0C F3 0E F1 10 EF 12 ED 14 "
+ + "EB 16 E9 18 E7 1A E5 1C E3 1E E1 20 DF 22 DD 24 DB 26 D9 28 D7 "
+ + "2A D5 2C D3 2E D1 30 CF 32 CD 34 CB 36 C9 38 C7 3A C5 3C C3 3E "
+ + "C1 40 BF 42 BD 44 BB 46 B9 48 B7 4A B5 4C B3 4E B1 50 AF 52 AD "
+ + "54 AB 56 A9 58 A7 5A A5 5C A3 5E A1 60 9F 62 9D 64 9B 66 99 68 "
+ + "97 6A 95 6C 93 6E 91 70 8F 72 8D 74 8B 76 89 78 87 7A 85 7C 83 "
+ + "7E 81)",
object.toString());
- object.req_bin = ByteBuffer.wrap(new byte[] {
- 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15,
- 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29,
- 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44,
- -45, 46, -47, 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58, -59,
- 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71, 72, -73, 74,
- -75, 76, -77, 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89,
- 90, -91, 92, -93, 94, -95, 96, -97, 98, -99, 100, -101, 102, -103,
- 104, -105, 106, -107, 108, -109, 110, -111, 112, -113, 114, -115,
- 116, -117, 118, -119, 120, -121, 122, -123, 124, -125, 126, -127,
- 0,
- });
-
- assertEquals("JavaTestHelper(req_int:0, req_obj:, req_bin:"+
- "00 FF 02 FD 04 FB 06 F9 08 F7 0A F5 0C F3 0E F1 10 EF 12 ED 14 "+
- "EB 16 E9 18 E7 1A E5 1C E3 1E E1 20 DF 22 DD 24 DB 26 D9 28 D7 "+
- "2A D5 2C D3 2E D1 30 CF 32 CD 34 CB 36 C9 38 C7 3A C5 3C C3 3E "+
- "C1 40 BF 42 BD 44 BB 46 B9 48 B7 4A B5 4C B3 4E B1 50 AF 52 AD "+
- "54 AB 56 A9 58 A7 5A A5 5C A3 5E A1 60 9F 62 9D 64 9B 66 99 68 "+
- "97 6A 95 6C 93 6E 91 70 8F 72 8D 74 8B 76 89 78 87 7A 85 7C 83 "+
- "7E 81...)",
+ object.req_bin =
+ ByteBuffer.wrap(
+ new byte[] {
+ 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20,
+ -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39,
+ 40, -41, 42, -43, 44, -45, 46, -47, 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58,
+ -59, 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71, 72, -73, 74, -75, 76, -77,
+ 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89, 90, -91, 92, -93, 94, -95, 96,
+ -97, 98, -99, 100, -101, 102, -103, 104, -105, 106, -107, 108, -109, 110, -111, 112,
+ -113, 114, -115, 116, -117, 118, -119, 120, -121, 122, -123, 124, -125, 126, -127, 0,
+ });
+
+ assertEquals(
+ "JavaTestHelper(req_int:0, req_obj:, req_bin:"
+ + "00 FF 02 FD 04 FB 06 F9 08 F7 0A F5 0C F3 0E F1 10 EF 12 ED 14 "
+ + "EB 16 E9 18 E7 1A E5 1C E3 1E E1 20 DF 22 DD 24 DB 26 D9 28 D7 "
+ + "2A D5 2C D3 2E D1 30 CF 32 CD 34 CB 36 C9 38 C7 3A C5 3C C3 3E "
+ + "C1 40 BF 42 BD 44 BB 46 B9 48 B7 4A B5 4C B3 4E B1 50 AF 52 AD "
+ + "54 AB 56 A9 58 A7 5A A5 5C A3 5E A1 60 9F 62 9D 64 9B 66 99 68 "
+ + "97 6A 95 6C 93 6E 91 70 8F 72 8D 74 8B 76 89 78 87 7A 85 7C 83 "
+ + "7E 81...)",
object.toString());
object.req_bin = ByteBuffer.wrap(new byte[] {});
object.setOpt_binIsSet(true);
- assertEquals("JavaTestHelper(req_int:0, req_obj:, req_bin:)",
- object.toString());
+ assertEquals("JavaTestHelper(req_int:0, req_obj:, req_bin:)", object.toString());
}
@Test
@@ -326,13 +363,13 @@ public class TestStruct {
final String testString = "testBytesBufferFeatures";
final JavaTestHelper o = new JavaTestHelper();
- o.setReq_bin((ByteBuffer)null);
+ o.setReq_bin((ByteBuffer) null);
assertNull(o.getReq_bin());
o.setReq_bin(ByteBuffer.wrap(testString.getBytes()));
assertArrayEquals(testString.getBytes(), o.getReq_bin());
- o.setReq_bin((byte[])null);
+ o.setReq_bin((byte[]) null);
assertNull(o.getReq_bin());
o.setReq_bin(testString.getBytes());
diff --git a/lib/java/src/test/java/org/apache/thrift/TestTBaseHelper.java b/lib/java/src/test/java/org/apache/thrift/TestTBaseHelper.java
index b877afa3b..90ed6fda8 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestTBaseHelper.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestTBaseHelper.java
@@ -18,7 +18,10 @@
*/
package org.apache.thrift;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -27,18 +30,12 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-
-
-public class TestTBaseHelper {
+public class TestTBaseHelper {
@Test
public void testByteArrayComparison() {
- assertTrue(TBaseHelper.compareTo(new byte[]{'a','b'}, new byte[]{'a','c'}) < 0);
+ assertTrue(TBaseHelper.compareTo(new byte[] {'a', 'b'}, new byte[] {'a', 'c'}) < 0);
}
@Test
@@ -70,10 +67,10 @@ public class TestTBaseHelper {
Set<List<String>> a = new HashSet<>();
Set<List<String>> b = new HashSet<>();
- a.add(Arrays.asList("a","b"));
- b.add(Arrays.asList("a","b", "c"));
- a.add(Arrays.asList("a","b"));
- b.add(Arrays.asList("a","b", "c"));
+ a.add(Arrays.asList("a", "b"));
+ b.add(Arrays.asList("a", "b", "c"));
+ a.add(Arrays.asList("a", "b"));
+ b.add(Arrays.asList("a", "b", "c"));
assertTrue(TBaseHelper.compareTo(a, b) < 0);
}
@@ -103,10 +100,10 @@ public class TestTBaseHelper {
assertEquals(0, TBaseHelper.compareTo(a, b));
- a.put(new byte[]{'a','b'}, 1000L);
- b.put(new byte[]{'a','b'}, 1000L);
- a.put(new byte[]{'a','b', 'd'}, 1000L);
- b.put(new byte[]{'a','b', 'a'}, 1000L);
+ a.put(new byte[] {'a', 'b'}, 1000L);
+ b.put(new byte[] {'a', 'b'}, 1000L);
+ a.put(new byte[] {'a', 'b', 'd'}, 1000L);
+ b.put(new byte[] {'a', 'b', 'a'}, 1000L);
assertTrue(TBaseHelper.compareTo(a, b) > 0);
}
@@ -150,16 +147,16 @@ public class TestTBaseHelper {
if (TBaseHelper.compareTo(a, b) != 0)
throw new RuntimeException("Set compare failed:" + a + " vs. " + b);
- a.add(new byte[]{'a','b'});
- b.add(new byte[]{'a','b'});
- a.add(new byte[]{'a','b', 'd'});
- b.add(new byte[]{'a','b', 'a'});
+ a.add(new byte[] {'a', 'b'});
+ b.add(new byte[] {'a', 'b'});
+ a.add(new byte[] {'a', 'b', 'd'});
+ b.add(new byte[] {'a', 'b', 'a'});
assertTrue(TBaseHelper.compareTo(a, b) > 0);
}
@Test
public void testByteBufferToByteArray() throws Exception {
- byte[] b1 = {10,9,8,7,6,5,4,3,2,1,0};
+ byte[] b1 = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
byte[] b2 = TBaseHelper.byteBufferToByteArray(ByteBuffer.wrap(b1));
assertEquals(b1, b2, "b1 and b2 should be the exact same array (identity) due to fast path");
@@ -175,7 +172,7 @@ public class TestTBaseHelper {
@Test
public void testByteBufferToString() {
- byte[] array = new byte[]{1, 2, 3};
+ byte[] array = new byte[] {1, 2, 3};
ByteBuffer bb = ByteBuffer.wrap(array, 1, 2);
StringBuilder sb = new StringBuilder();
TBaseHelper.toString(bb, sb);
@@ -193,7 +190,7 @@ public class TestTBaseHelper {
@Test
public void testCopyBinaryWithByteBuffer() throws Exception {
- byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5};
+ byte[] bytes = new byte[] {0, 1, 2, 3, 4, 5};
ByteBuffer b = ByteBuffer.wrap(bytes);
ByteBuffer bCopy = TBaseHelper.copyBinary(b);
assertEquals(b, bCopy);
@@ -215,16 +212,16 @@ public class TestTBaseHelper {
b.reset();
assertEquals(0, b.position());
- assertNull(TBaseHelper.copyBinary((ByteBuffer)null));
+ assertNull(TBaseHelper.copyBinary((ByteBuffer) null));
}
@Test
public void testCopyBinaryWithByteArray() throws Exception {
- byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5};
+ byte[] bytes = new byte[] {0, 1, 2, 3, 4, 5};
byte[] copy = TBaseHelper.copyBinary(bytes);
assertEquals(ByteBuffer.wrap(bytes), ByteBuffer.wrap(copy));
assertNotSame(bytes, copy);
- assertNull(TBaseHelper.copyBinary((byte[])null));
+ assertNull(TBaseHelper.copyBinary((byte[]) null));
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestTDeserializer.java b/lib/java/src/test/java/org/apache/thrift/TestTDeserializer.java
index c3b588e61..8a02e3a75 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestTDeserializer.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestTDeserializer.java
@@ -18,6 +18,9 @@
*/
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.nio.ByteBuffer;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TJSONProtocol;
@@ -29,21 +32,16 @@ import thrift.test.PrimitiveThenStruct;
import thrift.test.StructWithAUnion;
import thrift.test.TestUnion;
-import java.nio.ByteBuffer;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class TestTDeserializer {
+public class TestTDeserializer {
- private static final TProtocolFactory[] PROTOCOLS = new TProtocolFactory[] {
- new TBinaryProtocol.Factory(),
- new TCompactProtocol.Factory(),
- new TJSONProtocol.Factory()
- };
+ private static final TProtocolFactory[] PROTOCOLS =
+ new TProtocolFactory[] {
+ new TBinaryProtocol.Factory(), new TCompactProtocol.Factory(), new TJSONProtocol.Factory()
+ };
@Test
public void testPartialDeserialize() throws Exception {
- //Root:StructWithAUnion
+ // Root:StructWithAUnion
// 1:Union
// 1.3:OneOfEach
OneOfEach level3OneOfEach = Fixtures.getOneOfEach();
@@ -55,73 +53,149 @@ public class TestTDeserializer {
for (TProtocolFactory factory : PROTOCOLS) {
- //Level 2 test
- testPartialDeserialize(factory, level1SWU, new TestUnion(), level2TestUnion, StructWithAUnion._Fields.TEST_UNION);
-
- //Level 3 on 3rd field test
- testPartialDeserialize(factory, level1SWU, new OneOfEach(), level3OneOfEach, StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD);
-
- //Test early termination when traversed path Field.id exceeds the one being searched for
- testPartialDeserialize(factory, level1SWU, new OneOfEach(), new OneOfEach(), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.I32_FIELD);
-
- //Test that readStructBegin isn't called on primitive
+ // Level 2 test
+ testPartialDeserialize(
+ factory,
+ level1SWU,
+ new TestUnion(),
+ level2TestUnion,
+ StructWithAUnion._Fields.TEST_UNION);
+
+ // Level 3 on 3rd field test
+ testPartialDeserialize(
+ factory,
+ level1SWU,
+ new OneOfEach(),
+ level3OneOfEach,
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD);
+
+ // Test early termination when traversed path Field.id exceeds the one being searched for
+ testPartialDeserialize(
+ factory,
+ level1SWU,
+ new OneOfEach(),
+ new OneOfEach(),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.I32_FIELD);
+
+ // Test that readStructBegin isn't called on primitive
testPartialDeserialize(factory, pts, new Backwards(), bw, PrimitiveThenStruct._Fields.BW);
- //Test primitive types
+ // Test primitive types
TDeserializer deserializer = new TDeserializer(factory);
Boolean expectedBool = level3OneOfEach.isIm_true();
- Boolean resultBool = deserializer.partialDeserializeBool(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD, OneOfEach._Fields.IM_TRUE);
+ Boolean resultBool =
+ deserializer.partialDeserializeBool(
+ serialize(level1SWU, factory),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD,
+ OneOfEach._Fields.IM_TRUE);
assertEquals(expectedBool, resultBool);
Byte expectedByte = level3OneOfEach.getA_bite();
- Byte resultByte = deserializer.partialDeserializeByte(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD, OneOfEach._Fields.A_BITE);
+ Byte resultByte =
+ deserializer.partialDeserializeByte(
+ serialize(level1SWU, factory),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD,
+ OneOfEach._Fields.A_BITE);
assertEquals(expectedByte, resultByte);
Double expectedDouble = level3OneOfEach.getDouble_precision();
- Double resultDouble = deserializer.partialDeserializeDouble(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD, OneOfEach._Fields.DOUBLE_PRECISION);
+ Double resultDouble =
+ deserializer.partialDeserializeDouble(
+ serialize(level1SWU, factory),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD,
+ OneOfEach._Fields.DOUBLE_PRECISION);
assertEquals(expectedDouble, resultDouble);
Short expectedI16 = level3OneOfEach.getInteger16();
- Short resultI16 = deserializer.partialDeserializeI16(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD, OneOfEach._Fields.INTEGER16);
+ Short resultI16 =
+ deserializer.partialDeserializeI16(
+ serialize(level1SWU, factory),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD,
+ OneOfEach._Fields.INTEGER16);
assertEquals(expectedI16, resultI16);
Integer expectedI32 = level3OneOfEach.getInteger32();
- Integer resultI32 = deserializer.partialDeserializeI32(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD, OneOfEach._Fields.INTEGER32);
+ Integer resultI32 =
+ deserializer.partialDeserializeI32(
+ serialize(level1SWU, factory),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD,
+ OneOfEach._Fields.INTEGER32);
assertEquals(expectedI32, resultI32);
Long expectedI64 = level3OneOfEach.getInteger64();
- Long resultI64= deserializer.partialDeserializeI64(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD, OneOfEach._Fields.INTEGER64);
+ Long resultI64 =
+ deserializer.partialDeserializeI64(
+ serialize(level1SWU, factory),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD,
+ OneOfEach._Fields.INTEGER64);
assertEquals(expectedI64, resultI64);
String expectedString = level3OneOfEach.getSome_characters();
- String resultString = deserializer.partialDeserializeString(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD, OneOfEach._Fields.SOME_CHARACTERS);
+ String resultString =
+ deserializer.partialDeserializeString(
+ serialize(level1SWU, factory),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD,
+ OneOfEach._Fields.SOME_CHARACTERS);
assertEquals(expectedString, resultString);
byte[] expectedBinary = level3OneOfEach.getBase64();
- ByteBuffer resultBinary = deserializer.partialDeserializeByteArray(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION, TestUnion._Fields.STRUCT_FIELD, OneOfEach._Fields.BASE64);
- assertEquals(expectedBinary.length, resultBinary.limit() - resultBinary.position() - resultBinary.arrayOffset());
+ ByteBuffer resultBinary =
+ deserializer.partialDeserializeByteArray(
+ serialize(level1SWU, factory),
+ StructWithAUnion._Fields.TEST_UNION,
+ TestUnion._Fields.STRUCT_FIELD,
+ OneOfEach._Fields.BASE64);
+ assertEquals(
+ expectedBinary.length,
+ resultBinary.limit() - resultBinary.position() - resultBinary.arrayOffset());
assertEquals(ByteBuffer.wrap(expectedBinary), resultBinary);
// Test field id in Union
- short id = deserializer.partialDeserializeSetFieldIdInUnion(serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION);
+ short id =
+ deserializer.partialDeserializeSetFieldIdInUnion(
+ serialize(level1SWU, factory), StructWithAUnion._Fields.TEST_UNION);
assertEquals(level2TestUnion.getSetField().getThriftFieldId(), id);
}
}
- private void testPartialDeserialize(TProtocolFactory protocolFactory, TBase input, TBase output, TBase expected, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+ private void testPartialDeserialize(
+ TProtocolFactory protocolFactory,
+ TBase input,
+ TBase output,
+ TBase expected,
+ TFieldIdEnum fieldIdPathFirst,
+ TFieldIdEnum... fieldIdPathRest)
+ throws TException {
byte[] record = serialize(input, protocolFactory);
TDeserializer deserializer = new TDeserializer(protocolFactory);
for (int i = 0; i < 2; i++) {
TBase outputCopy = output.deepCopy();
deserializer.partialDeserialize(outputCopy, record, fieldIdPathFirst, fieldIdPathRest);
- assertEquals(expected,
- outputCopy, "on attempt " + i + ", with " + protocolFactory
- + ", expected " + expected + " but got " + outputCopy);
+ assertEquals(
+ expected,
+ outputCopy,
+ "on attempt "
+ + i
+ + ", with "
+ + protocolFactory
+ + ", expected "
+ + expected
+ + " but got "
+ + outputCopy);
}
}
- private static byte[] serialize(TBase input, TProtocolFactory protocolFactory) throws TException{
+ private static byte[] serialize(TBase input, TProtocolFactory protocolFactory) throws TException {
return new TSerializer(protocolFactory).serialize(input);
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestTEnumHelper.java b/lib/java/src/test/java/org/apache/thrift/TestTEnumHelper.java
index e61b1794b..a05910358 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestTEnumHelper.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestTEnumHelper.java
@@ -18,17 +18,17 @@
*/
package org.apache.thrift;
-import org.junit.jupiter.api.Test;
-import thrift.test.Numberz;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
-public class TestTEnumHelper {
+import org.junit.jupiter.api.Test;
+import thrift.test.Numberz;
+
+public class TestTEnumHelper {
@Test
public void testGetByValue_ValidValues() {
- for (Numberz n: Numberz.values()) {
+ for (Numberz n : Numberz.values()) {
int value = n.getValue();
assertEquals(n, TEnumHelper.getByValue(Numberz.class, value));
}
diff --git a/lib/java/src/test/java/org/apache/thrift/TestTUnion.java b/lib/java/src/test/java/org/apache/thrift/TestTUnion.java
index 36e87c027..9018f47e3 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestTUnion.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestTUnion.java
@@ -18,18 +18,12 @@
*/
package org.apache.thrift;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.protocol.TTupleProtocol;
-import org.apache.thrift.transport.TMemoryBuffer;
-import org.junit.jupiter.api.Test;
-import thrift.test.ComparableUnion;
-import thrift.test.Empty;
-import thrift.test.RandomStuff;
-import thrift.test.SomeEnum;
-import thrift.test.StructWithAUnion;
-import thrift.test.TestUnion;
-import thrift.test.TestUnionMinusStringField;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -42,15 +36,20 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.transport.TMemoryBuffer;
+import org.junit.jupiter.api.Test;
+import thrift.test.ComparableUnion;
+import thrift.test.Empty;
+import thrift.test.RandomStuff;
+import thrift.test.SomeEnum;
+import thrift.test.StructWithAUnion;
+import thrift.test.TestUnion;
+import thrift.test.TestUnionMinusStringField;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class TestTUnion {
+public class TestTUnion {
@Test
public void testBasic() throws Exception {
@@ -65,7 +64,9 @@ public class TestTUnion {
assertEquals(25, union.getFieldValue());
assertEquals(25, union.getFieldValue(TestUnion._Fields.I32_FIELD));
assertTrue(union.isSetI32_field());
- assertThrows(IllegalArgumentException.class, () -> union.getFieldValue(TestUnion._Fields.STRING_FIELD));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> union.getFieldValue(TestUnion._Fields.STRING_FIELD));
}
{
TestUnion union = new TestUnion();
@@ -104,12 +105,12 @@ public class TestTUnion {
assertTrue(cu.compareTo(cu2) < 0);
assertTrue(cu2.compareTo(cu) > 0);
- cu2 = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{2}));
+ cu2 = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[] {2}));
assertTrue(cu.compareTo(cu2) < 0);
assertTrue(cu2.compareTo(cu) > 0);
- cu = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{1}));
+ cu = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[] {1}));
assertTrue(cu.compareTo(cu2) < 0);
assertTrue(cu2.compareTo(cu) > 0);
@@ -125,7 +126,7 @@ public class TestTUnion {
assertTrue(union3.compareTo(union4) < 0);
Map<Integer, Integer> i32_map = new HashMap<Integer, Integer>();
- i32_map.put(1,1);
+ i32_map.put(1, 1);
TestUnion union5 = new TestUnion(TestUnion._Fields.I32_MAP, i32_map);
TestUnion union6 = new TestUnion(TestUnion._Fields.I32_MAP, new HashMap<Integer, Integer>());
assertTrue(union5.compareTo(union6) > 0);
@@ -185,7 +186,7 @@ public class TestTUnion {
}
@Test
- public void testTupleProtocolSerialization () throws Exception {
+ public void testTupleProtocolSerialization() throws Exception {
TestUnion union = new TestUnion(TestUnion._Fields.I32_FIELD, 25);
union.setI32_set(Collections.singleton(42));
diff --git a/lib/java/src/test/java/org/apache/thrift/TestUnsafeBinaries.java b/lib/java/src/test/java/org/apache/thrift/TestUnsafeBinaries.java
index 7e7fc4b9c..15acf9a32 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestUnsafeBinaries.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestUnsafeBinaries.java
@@ -19,20 +19,19 @@
package org.apache.thrift;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+
+import java.nio.ByteBuffer;
import org.junit.jupiter.api.Test;
import thrift.test.SafeBytes;
import thrift.test.UnsafeBytes;
-import java.nio.ByteBuffer;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-
// test generating types with un-copied byte[]/ByteBuffer input/output
//
public class TestUnsafeBinaries {
private static byte[] input() {
- return new byte[]{1, 1};
+ return new byte[] {1, 1};
}
//
@@ -48,27 +47,26 @@ public class TestUnsafeBinaries {
input[0] = 2;
- assertArrayEquals(new byte[]{2, 1}, struct.getBytes());
-
+ assertArrayEquals(new byte[] {2, 1}, struct.getBytes());
}
// getter doesn't copy
- // note: this behavior is the same with/without the flag, but if this default ever changes, the current behavior
+ // note: this behavior is the same with/without the flag, but if this default ever changes, the
+ // current behavior
// should be retained when using this flag
@Test
- public void testUnsafeGetter(){
+ public void testUnsafeGetter() {
UnsafeBytes struct = new UnsafeBytes(ByteBuffer.wrap(input()));
byte[] val = struct.getBytes();
val[0] = 2;
- assertArrayEquals(new byte[]{2, 1}, struct.getBytes());
-
+ assertArrayEquals(new byte[] {2, 1}, struct.getBytes());
}
// setter doesn't copy
@Test
- public void testUnsafeSetter(){
+ public void testUnsafeSetter() {
UnsafeBytes struct = new UnsafeBytes();
byte[] val = input();
@@ -76,20 +74,18 @@ public class TestUnsafeBinaries {
val[0] = 2;
- assertArrayEquals(new byte[]{2, 1}, struct.getBytes());
-
+ assertArrayEquals(new byte[] {2, 1}, struct.getBytes());
}
// buffer doens't copy
@Test
- public void testUnsafeBufferFor(){
+ public void testUnsafeBufferFor() {
UnsafeBytes struct = new UnsafeBytes(ByteBuffer.wrap(input()));
ByteBuffer val = struct.bufferForBytes();
val.array()[0] = 2;
- assertArrayEquals(new byte[]{2, 1}, struct.getBytes());
-
+ assertArrayEquals(new byte[] {2, 1}, struct.getBytes());
}
//
@@ -104,8 +100,7 @@ public class TestUnsafeBinaries {
input[0] = 2;
- assertArrayEquals(new byte[]{1, 1}, struct.getBytes());
-
+ assertArrayEquals(new byte[] {1, 1}, struct.getBytes());
}
@Test
@@ -116,19 +111,16 @@ public class TestUnsafeBinaries {
input[0] = 2;
- assertArrayEquals(new byte[]{1, 1}, struct.getBytes());
-
+ assertArrayEquals(new byte[] {1, 1}, struct.getBytes());
}
@Test
- public void testSafeBufferFor(){
+ public void testSafeBufferFor() {
SafeBytes struct = new SafeBytes(ByteBuffer.wrap(input()));
ByteBuffer val = struct.bufferForBytes();
val.array()[0] = 2;
- assertArrayEquals(new byte[]{1, 1}, struct.getBytes());
-
+ assertArrayEquals(new byte[] {1, 1}, struct.getBytes());
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClient.java b/lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClient.java
index 9a755d3be..863c42ef4 100644
--- a/lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClient.java
+++ b/lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClient.java
@@ -1,23 +1,22 @@
package org.apache.thrift.async;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.thrift.TException;
import org.junit.jupiter.api.Test;
import thrift.test.Srv;
import thrift.test.Srv.AsyncClient;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-
public class TestTAsyncClient {
@Test
public void testRaisesExceptionWhenUsedConcurrently() throws Exception {
- TAsyncClientManager mockClientManager = new TAsyncClientManager() {
- @Override
- public void call(TAsyncMethodCall method) throws TException {
- // do nothing
- }
- };
+ TAsyncClientManager mockClientManager =
+ new TAsyncClientManager() {
+ @Override
+ public void call(TAsyncMethodCall method) throws TException {
+ // do nothing
+ }
+ };
Srv.AsyncClient c = new AsyncClient(null, mockClientManager, null);
c.Janky(0, null);
diff --git a/lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClientManager.java b/lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClientManager.java
index 8d12429f7..4dacb0f3b 100644
--- a/lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClientManager.java
+++ b/lib/java/src/test/java/org/apache/thrift/async/TestTAsyncClientManager.java
@@ -18,6 +18,23 @@
*/
package org.apache.thrift.async;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.server.ServerTestBase;
@@ -35,363 +52,358 @@ import thrift.test.ExceptionWithAMap;
import thrift.test.Srv;
import thrift.test.Srv.Iface;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class TestTAsyncClientManager {
- private THsHaServer server_;
- private Thread serverThread_;
- private TAsyncClientManager clientManager_;
-
- @BeforeEach
- public void setUp() throws Exception {
- server_ = new THsHaServer(new Args(new TNonblockingServerSocket(
- new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs().port(ServerTestBase.PORT))).
- processor(new Srv.Processor(new SrvHandler())));
- serverThread_ = new Thread(new Runnable() {
- public void run() {
+ private THsHaServer server_;
+ private Thread serverThread_;
+ private TAsyncClientManager clientManager_;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ server_ =
+ new THsHaServer(
+ new Args(
+ new TNonblockingServerSocket(
+ new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs()
+ .port(ServerTestBase.PORT)))
+ .processor(new Srv.Processor(new SrvHandler())));
+ serverThread_ =
+ new Thread(
+ new Runnable() {
+ public void run() {
server_.serve();
- }
- });
- serverThread_.start();
- clientManager_ = new TAsyncClientManager();
- Thread.sleep(500);
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- server_.stop();
- clientManager_.stop();
- serverThread_.join();
- }
-
- @Test
- public void testBasicCall() throws Exception {
- Srv.AsyncClient client = getClient();
- basicCall(client);
- }
-
- @Test
- public void testBasicCallWithTimeout() throws Exception {
- Srv.AsyncClient client = getClient();
- client.setTimeout(5000);
- basicCall(client);
- }
-
- private static abstract class ErrorCallTest<C extends TAsyncClient, R> {
- final void runTest() throws Exception {
- final CountDownLatch latch = new CountDownLatch(1);
- final AtomicReference<Exception> error = new AtomicReference<Exception>();
- C client = executeErroringCall(new AsyncMethodCallback<R>() {
+ }
+ });
+ serverThread_.start();
+ clientManager_ = new TAsyncClientManager();
+ Thread.sleep(500);
+ }
+
+ @AfterEach
+ public void tearDown() throws Exception {
+ server_.stop();
+ clientManager_.stop();
+ serverThread_.join();
+ }
+
+ @Test
+ public void testBasicCall() throws Exception {
+ Srv.AsyncClient client = getClient();
+ basicCall(client);
+ }
+
+ @Test
+ public void testBasicCallWithTimeout() throws Exception {
+ Srv.AsyncClient client = getClient();
+ client.setTimeout(5000);
+ basicCall(client);
+ }
+
+ private abstract static class ErrorCallTest<C extends TAsyncClient, R> {
+ final void runTest() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ final AtomicReference<Exception> error = new AtomicReference<Exception>();
+ C client =
+ executeErroringCall(
+ new AsyncMethodCallback<R>() {
@Override
public void onComplete(R response) {
- latch.countDown();
+ latch.countDown();
}
@Override
public void onError(Exception exception) {
- error.set(exception);
- latch.countDown();
+ error.set(exception);
+ latch.countDown();
}
- });
- latch.await(2, TimeUnit.SECONDS);
- assertTrue(client.hasError());
- Exception exception = error.get();
- assertNotNull(exception);
- assertSame(exception, client.getError());
- validateError(client, exception);
- }
-
- /**
- * Executes a call that is expected to raise an exception.
- *
- * @param callback The testing callback that should be installed.
- * @return The client the call was made against.
- * @throws Exception if there was a problem setting up the client or making the call.
- */
- abstract C executeErroringCall(AsyncMethodCallback<R> callback) throws Exception;
-
- /**
- * Further validates the properties of the error raised in the remote call and the state of the
- * client after that call.
- *
- * @param client The client returned from {@link #executeErroringCall(AsyncMethodCallback)}.
- * @param error The exception raised by the remote call.
- */
- abstract void validateError(C client, Exception error);
- }
-
- @Test
- public void testUnexpectedRemoteExceptionCall() throws Exception {
- new ErrorCallTest<Srv.AsyncClient, Boolean>() {
- @Override
- Srv.AsyncClient executeErroringCall(AsyncMethodCallback<Boolean> callback) throws Exception {
- Srv.AsyncClient client = getClient();
- client.declaredExceptionMethod(false, callback);
- return client;
- }
-
- @Override
- void validateError(Srv.AsyncClient client, Exception error) {
- assertFalse(client.hasTimeout());
- assertTrue(error instanceof TException);
- }
- }.runTest();
- }
-
- @Test
- public void testDeclaredRemoteExceptionCall() throws Exception {
- new ErrorCallTest<Srv.AsyncClient, Boolean>() {
- @Override
- Srv.AsyncClient executeErroringCall(AsyncMethodCallback<Boolean> callback) throws Exception {
- Srv.AsyncClient client = getClient();
- client.declaredExceptionMethod(true, callback);
- return client;
- }
-
- @Override
- void validateError(Srv.AsyncClient client, Exception error) {
- assertFalse(client.hasTimeout());
- assertEquals(ExceptionWithAMap.class, error.getClass());
- ExceptionWithAMap exceptionWithAMap = (ExceptionWithAMap) error;
- assertEquals("blah", exceptionWithAMap.getBlah());
- assertEquals(new HashMap<String, String>(), exceptionWithAMap.getMap_field());
- }
- }.runTest();
+ });
+ latch.await(2, TimeUnit.SECONDS);
+ assertTrue(client.hasError());
+ Exception exception = error.get();
+ assertNotNull(exception);
+ assertSame(exception, client.getError());
+ validateError(client, exception);
}
- @Test
- public void testTimeoutCall() throws Exception {
- new ErrorCallTest<Srv.AsyncClient, Integer>() {
- @Override
- Srv.AsyncClient executeErroringCall(AsyncMethodCallback<Integer> callback) throws Exception {
- Srv.AsyncClient client = getClient();
- client.setTimeout(100);
- client.primitiveMethod(callback);
- return client;
- }
-
- @Override
- void validateError(Srv.AsyncClient client, Exception error) {
- assertTrue(client.hasTimeout());
- assertTrue(error instanceof TimeoutException);
- }
- }.runTest();
- }
-
- @Test
- public void testVoidCall() throws Exception {
- final CountDownLatch latch = new CountDownLatch(1);
- final AtomicBoolean returned = new AtomicBoolean(false);
+ /**
+ * Executes a call that is expected to raise an exception.
+ *
+ * @param callback The testing callback that should be installed.
+ * @return The client the call was made against.
+ * @throws Exception if there was a problem setting up the client or making the call.
+ */
+ abstract C executeErroringCall(AsyncMethodCallback<R> callback) throws Exception;
+
+ /**
+ * Further validates the properties of the error raised in the remote call and the state of the
+ * client after that call.
+ *
+ * @param client The client returned from {@link #executeErroringCall(AsyncMethodCallback)}.
+ * @param error The exception raised by the remote call.
+ */
+ abstract void validateError(C client, Exception error);
+ }
+
+ @Test
+ public void testUnexpectedRemoteExceptionCall() throws Exception {
+ new ErrorCallTest<Srv.AsyncClient, Boolean>() {
+ @Override
+ Srv.AsyncClient executeErroringCall(AsyncMethodCallback<Boolean> callback) throws Exception {
Srv.AsyncClient client = getClient();
- client.voidMethod(new FailureLessCallback<Void>() {
- @Override
- public void onComplete(Void response) {
- returned.set(true);
- latch.countDown();
- }
- });
- latch.await(1, TimeUnit.SECONDS);
- assertTrue(returned.get());
- }
-
- @Test
- public void testOnewayCall() throws Exception {
- final CountDownLatch latch = new CountDownLatch(1);
- final AtomicBoolean returned = new AtomicBoolean(false);
+ client.declaredExceptionMethod(false, callback);
+ return client;
+ }
+
+ @Override
+ void validateError(Srv.AsyncClient client, Exception error) {
+ assertFalse(client.hasTimeout());
+ assertTrue(error instanceof TException);
+ }
+ }.runTest();
+ }
+
+ @Test
+ public void testDeclaredRemoteExceptionCall() throws Exception {
+ new ErrorCallTest<Srv.AsyncClient, Boolean>() {
+ @Override
+ Srv.AsyncClient executeErroringCall(AsyncMethodCallback<Boolean> callback) throws Exception {
Srv.AsyncClient client = getClient();
- client.onewayMethod(new FailureLessCallback<Void>() {
- @Override
- public void onComplete(Void response) {
- returned.set(true);
- latch.countDown();
- }
+ client.declaredExceptionMethod(true, callback);
+ return client;
+ }
+
+ @Override
+ void validateError(Srv.AsyncClient client, Exception error) {
+ assertFalse(client.hasTimeout());
+ assertEquals(ExceptionWithAMap.class, error.getClass());
+ ExceptionWithAMap exceptionWithAMap = (ExceptionWithAMap) error;
+ assertEquals("blah", exceptionWithAMap.getBlah());
+ assertEquals(new HashMap<String, String>(), exceptionWithAMap.getMap_field());
+ }
+ }.runTest();
+ }
+
+ @Test
+ public void testTimeoutCall() throws Exception {
+ new ErrorCallTest<Srv.AsyncClient, Integer>() {
+ @Override
+ Srv.AsyncClient executeErroringCall(AsyncMethodCallback<Integer> callback) throws Exception {
+ Srv.AsyncClient client = getClient();
+ client.setTimeout(100);
+ client.primitiveMethod(callback);
+ return client;
+ }
+
+ @Override
+ void validateError(Srv.AsyncClient client, Exception error) {
+ assertTrue(client.hasTimeout());
+ assertTrue(error instanceof TimeoutException);
+ }
+ }.runTest();
+ }
+
+ @Test
+ public void testVoidCall() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ final AtomicBoolean returned = new AtomicBoolean(false);
+ Srv.AsyncClient client = getClient();
+ client.voidMethod(
+ new FailureLessCallback<Void>() {
+ @Override
+ public void onComplete(Void response) {
+ returned.set(true);
+ latch.countDown();
+ }
});
- latch.await(1, TimeUnit.SECONDS);
- assertTrue(returned.get());
+ latch.await(1, TimeUnit.SECONDS);
+ assertTrue(returned.get());
+ }
+
+ @Test
+ public void testOnewayCall() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ final AtomicBoolean returned = new AtomicBoolean(false);
+ Srv.AsyncClient client = getClient();
+ client.onewayMethod(
+ new FailureLessCallback<Void>() {
+ @Override
+ public void onComplete(Void response) {
+ returned.set(true);
+ latch.countDown();
+ }
+ });
+ latch.await(1, TimeUnit.SECONDS);
+ assertTrue(returned.get());
+ }
+
+ @Test
+ public void testParallelCalls() throws Exception {
+ // make multiple calls with deserialization in the selector thread (repro Eric's issue)
+ int numThreads = 50;
+ int numCallsPerThread = 100;
+ List<JankyRunnable> runnables = new ArrayList<JankyRunnable>();
+ List<Thread> threads = new ArrayList<Thread>();
+ for (int i = 0; i < numThreads; i++) {
+ JankyRunnable runnable = new JankyRunnable(numCallsPerThread);
+ Thread thread = new Thread(runnable);
+ thread.start();
+ threads.add(thread);
+ runnables.add(runnable);
}
-
- @Test
- public void testParallelCalls() throws Exception {
- // make multiple calls with deserialization in the selector thread (repro Eric's issue)
- int numThreads = 50;
- int numCallsPerThread = 100;
- List<JankyRunnable> runnables = new ArrayList<JankyRunnable>();
- List<Thread> threads = new ArrayList<Thread>();
- for (int i = 0; i < numThreads; i++) {
- JankyRunnable runnable = new JankyRunnable(numCallsPerThread);
- Thread thread = new Thread(runnable);
- thread.start();
- threads.add(thread);
- runnables.add(runnable);
- }
- for (Thread thread : threads) {
- thread.join();
- }
- int numSuccesses = 0;
- for (JankyRunnable runnable : runnables) {
- numSuccesses += runnable.getNumSuccesses();
- }
- assertEquals(numThreads * numCallsPerThread, numSuccesses);
+ for (Thread thread : threads) {
+ thread.join();
}
-
- private Srv.AsyncClient getClient() throws IOException, TTransportException {
- TNonblockingSocket clientSocket = new TNonblockingSocket(ServerTestBase.HOST, ServerTestBase.PORT);
- return new Srv.AsyncClient(new TBinaryProtocol.Factory(), clientManager_, clientSocket);
+ int numSuccesses = 0;
+ for (JankyRunnable runnable : runnables) {
+ numSuccesses += runnable.getNumSuccesses();
}
-
- private void basicCall(Srv.AsyncClient client) throws Exception {
- final CountDownLatch latch = new CountDownLatch(1);
- final AtomicBoolean returned = new AtomicBoolean(false);
- client.Janky(1, new FailureLessCallback<Integer>() {
- @Override
- public void onComplete(Integer response) {
- assertEquals(3, response.intValue());
- returned.set(true);
- latch.countDown();
- }
-
- @Override
- public void onError(Exception exception) {
- try {
- StringWriter sink = new StringWriter();
- exception.printStackTrace(new PrintWriter(sink, true));
- Assertions.fail("unexpected onError with exception " + sink.toString());
- } finally {
- latch.countDown();
- }
+ assertEquals(numThreads * numCallsPerThread, numSuccesses);
+ }
+
+ private Srv.AsyncClient getClient() throws IOException, TTransportException {
+ TNonblockingSocket clientSocket =
+ new TNonblockingSocket(ServerTestBase.HOST, ServerTestBase.PORT);
+ return new Srv.AsyncClient(new TBinaryProtocol.Factory(), clientManager_, clientSocket);
+ }
+
+ private void basicCall(Srv.AsyncClient client) throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ final AtomicBoolean returned = new AtomicBoolean(false);
+ client.Janky(
+ 1,
+ new FailureLessCallback<Integer>() {
+ @Override
+ public void onComplete(Integer response) {
+ assertEquals(3, response.intValue());
+ returned.set(true);
+ latch.countDown();
+ }
+
+ @Override
+ public void onError(Exception exception) {
+ try {
+ StringWriter sink = new StringWriter();
+ exception.printStackTrace(new PrintWriter(sink, true));
+ Assertions.fail("unexpected onError with exception " + sink.toString());
+ } finally {
+ latch.countDown();
}
+ }
});
- latch.await(100, TimeUnit.SECONDS);
- assertTrue(returned.get());
+ latch.await(100, TimeUnit.SECONDS);
+ assertTrue(returned.get());
+ }
+
+ public static class SrvHandler implements Iface {
+ // Use this method for a standard call testing
+ @Override
+ public int Janky(int arg) throws TException {
+ assertEquals(1, arg);
+ return 3;
}
- public static class SrvHandler implements Iface {
- // Use this method for a standard call testing
- @Override
- public int Janky(int arg) throws TException {
- assertEquals(1, arg);
- return 3;
- }
-
- // Using this method for timeout testing - sleeps for 1 second before returning
- @Override
- public int primitiveMethod() throws TException {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return 0;
- }
+ // Using this method for timeout testing - sleeps for 1 second before returning
+ @Override
+ public int primitiveMethod() throws TException {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return 0;
+ }
- @Override
- public void methodWithDefaultArgs(int something) throws TException {
- }
+ @Override
+ public void methodWithDefaultArgs(int something) throws TException {}
- @Override
- public CompactProtoTestStruct structMethod() throws TException {
- return null;
- }
+ @Override
+ public CompactProtoTestStruct structMethod() throws TException {
+ return null;
+ }
- @Override
- public void voidMethod() throws TException {
- }
+ @Override
+ public void voidMethod() throws TException {}
- @Override
- public void onewayMethod() throws TException {
- }
+ @Override
+ public void onewayMethod() throws TException {}
- @Override
- public boolean declaredExceptionMethod(boolean shouldThrowDeclared) throws TException {
- if (shouldThrowDeclared) {
- throw new ExceptionWithAMap("blah", new HashMap<String, String>());
- } else {
- throw new TException("Unexpected!");
- }
- }
+ @Override
+ public boolean declaredExceptionMethod(boolean shouldThrowDeclared) throws TException {
+ if (shouldThrowDeclared) {
+ throw new ExceptionWithAMap("blah", new HashMap<String, String>());
+ } else {
+ throw new TException("Unexpected!");
+ }
}
+ }
- private static abstract class FailureLessCallback<T> implements AsyncMethodCallback<T> {
- @Override
- public void onError(Exception exception) {
- fail(exception);
- }
+ private abstract static class FailureLessCallback<T> implements AsyncMethodCallback<T> {
+ @Override
+ public void onError(Exception exception) {
+ fail(exception);
+ }
+ }
+
+ private static void fail(Exception exception) {
+ StringWriter sink = new StringWriter();
+ exception.printStackTrace(new PrintWriter(sink, true));
+ Assertions.fail("unexpected error " + sink);
+ }
+
+ private class JankyRunnable implements Runnable {
+ private final int numCalls_;
+ private int numSuccesses_ = 0;
+ private final Srv.AsyncClient client_;
+
+ public JankyRunnable(int numCalls) throws Exception {
+ numCalls_ = numCalls;
+ client_ = getClient();
+ client_.setTimeout(20000);
}
- private static void fail(Exception exception) {
- StringWriter sink = new StringWriter();
- exception.printStackTrace(new PrintWriter(sink, true));
- Assertions.fail("unexpected error " + sink);
+ public int getNumSuccesses() {
+ return numSuccesses_;
}
- private class JankyRunnable implements Runnable {
- private final int numCalls_;
- private int numSuccesses_ = 0;
- private final Srv.AsyncClient client_;
+ public void run() {
+ for (int i = 0; i < numCalls_ && !client_.hasError(); i++) {
+ final int iteration = i;
+ try {
+ // connect an async client
+ final CountDownLatch latch = new CountDownLatch(1);
+ final AtomicBoolean returned = new AtomicBoolean(false);
+ client_.Janky(
+ 1,
+ new AsyncMethodCallback<Integer>() {
- public JankyRunnable(int numCalls) throws Exception {
- numCalls_ = numCalls;
- client_ = getClient();
- client_.setTimeout(20000);
- }
-
- public int getNumSuccesses() {
- return numSuccesses_;
- }
+ @Override
+ public void onComplete(Integer result) {
+ assertEquals(3, result.intValue());
+ returned.set(true);
+ latch.countDown();
+ }
- public void run() {
- for (int i = 0; i < numCalls_ && !client_.hasError(); i++) {
- final int iteration = i;
- try {
- // connect an async client
- final CountDownLatch latch = new CountDownLatch(1);
- final AtomicBoolean returned = new AtomicBoolean(false);
- client_.Janky(1, new AsyncMethodCallback<Integer>() {
-
- @Override
- public void onComplete(Integer result) {
- assertEquals(3, result.intValue());
- returned.set(true);
- latch.countDown();
- }
-
- @Override
- public void onError(Exception exception) {
- try {
- StringWriter sink = new StringWriter();
- exception.printStackTrace(new PrintWriter(sink, true));
- Assertions.fail("unexpected onError on iteration " + iteration + ": " + sink.toString());
- } finally {
- latch.countDown();
- }
- }
- });
-
- boolean calledBack = latch.await(30, TimeUnit.SECONDS);
- assertTrue(calledBack, "wasn't called back in time on iteration " + iteration);
- assertTrue(returned.get(), "onComplete not called on iteration " + iteration);
- this.numSuccesses_++;
- } catch (Exception e) {
- fail(e);
+ @Override
+ public void onError(Exception exception) {
+ try {
+ StringWriter sink = new StringWriter();
+ exception.printStackTrace(new PrintWriter(sink, true));
+ Assertions.fail(
+ "unexpected onError on iteration " + iteration + ": " + sink.toString());
+ } finally {
+ latch.countDown();
+ }
}
- }
+ });
+
+ boolean calledBack = latch.await(30, TimeUnit.SECONDS);
+ assertTrue(calledBack, "wasn't called back in time on iteration " + iteration);
+ assertTrue(returned.get(), "onComplete not called on iteration " + iteration);
+ this.numSuccesses_++;
+ } catch (Exception e) {
+ fail(e);
}
+ }
}
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/EnumCacheTest.java b/lib/java/src/test/java/org/apache/thrift/partial/EnumCacheTest.java
index 152bf4851..3cca54d28 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/EnumCacheTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/EnumCacheTest.java
@@ -19,16 +19,14 @@
package org.apache.thrift.partial;
-import org.apache.thrift.TEnum;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
-/**
- * Test ThriftCodec serializes and deserializes thrift objects correctly.
- */
+import org.apache.thrift.TEnum;
+import org.junit.jupiter.api.Test;
+
+/** Test ThriftCodec serializes and deserializes thrift objects correctly. */
public class EnumCacheTest {
enum TestEnum implements TEnum {
@@ -54,7 +52,7 @@ public class EnumCacheTest {
public static final NotEnum Bob = new NotEnum(10);
public static final NotEnum Charlie = new NotEnum(11);
- private static final NotEnum[] allValues = { Alice, Bob, Charlie };
+ private static final NotEnum[] allValues = {Alice, Bob, Charlie};
private int value;
@@ -86,9 +84,7 @@ public class EnumCacheTest {
// Verify it throws.
assertThrows(
- IllegalArgumentException.class,
- () -> cache.get(null, 1),
- "'enumClass' must not be null");
+ IllegalArgumentException.class, () -> cache.get(null, 1), "'enumClass' must not be null");
}
@Test
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/PartialThriftComparerTest.java b/lib/java/src/test/java/org/apache/thrift/partial/PartialThriftComparerTest.java
index 4498e332a..1888b59b4 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/PartialThriftComparerTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/PartialThriftComparerTest.java
@@ -19,18 +19,17 @@
package org.apache.thrift.partial;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
import org.apache.thrift.TDeserializer;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TCompactProtocol;
import org.junit.jupiter.api.Test;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class PartialThriftComparerTest {
private ThriftSerDe serde;
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/PartialThriftTestData.java b/lib/java/src/test/java/org/apache/thrift/partial/PartialThriftTestData.java
index 6376075da..14cada1e7 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/PartialThriftTestData.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/PartialThriftTestData.java
@@ -28,12 +28,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-/**
- * Helpers for creating test data related to partial deserialization.
- */
+/** Helpers for creating test data related to partial deserialization. */
public class PartialThriftTestData {
- public final byte[] BYTES = new byte[] { 1, 2, 3 };
+ public final byte[] BYTES = new byte[] {1, 2, 3};
public SmallStruct createSmallStruct(int id) {
return new SmallStruct()
@@ -48,16 +46,17 @@ public class PartialThriftTestData {
public TestStruct createTestStruct(int id, int numItems) {
- TestStruct ts = new TestStruct()
- .setByteField((byte) id)
- .setI16Field((short) id)
- .setI32Field(id)
- .setI64Field(id)
- .setDoubleField(id)
- .setStringField(Integer.toString(id))
- .setEnumField(TstEnum.E_ONE)
- .setBinaryField(BYTES)
- .setStructField(createSmallStruct(id));
+ TestStruct ts =
+ new TestStruct()
+ .setByteField((byte) id)
+ .setI16Field((short) id)
+ .setI32Field(id)
+ .setI64Field(id)
+ .setDoubleField(id)
+ .setStringField(Integer.toString(id))
+ .setEnumField(TstEnum.E_ONE)
+ .setBinaryField(BYTES)
+ .setStructField(createSmallStruct(id));
initListFields(ts, id, numItems);
initSetFields(ts, id, numItems);
@@ -85,7 +84,7 @@ public class PartialThriftTestData {
byteList.add((byte) i);
i16List.add((short) i);
i32List.add(i);
- i64List.add((long)i);
+ i64List.add((long) i);
doubleList.add((double) i);
stringList.add(Integer.toString(i));
enumList.add(TstEnum.E_ONE);
@@ -141,7 +140,7 @@ public class PartialThriftTestData {
byteSet.add((byte) i);
i16Set.add((short) i);
i32Set.add(i);
- i64Set.add((long)i);
+ i64Set.add((long) i);
doubleSet.add((double) i);
stringSet.add(Integer.toString(i));
enumSet.add(TstEnum.E_ONE);
@@ -234,78 +233,76 @@ public class PartialThriftTestData {
}
public List<String> allFieldsOfTestStruct() {
- return new ArrayList<>(
- Arrays.asList(
- "byteField",
- "i16Field",
- "i32Field",
- "i64Field",
- "doubleField",
- "stringField",
- "structField.byteField",
- "structField.i16Field",
- "structField.i32Field",
- "structField.i64Field",
- "structField.doubleField",
- "structField.stringField",
- "structField.enumField",
- "enumField",
- "binaryField",
- "byteList",
- "i16List",
- "i32List",
- "i64List",
- "doubleList",
- "stringList",
- "enumList",
- "listList",
- "setList",
- "mapList",
- "structList.byteField",
- "structList.i16Field",
- "structList.i32Field",
- "structList.i64Field",
- "structList.doubleField",
- "structList.stringField",
- "structList.enumField",
- "binaryList",
- "byteSet",
- "i16Set",
- "i32Set",
- "i64Set",
- "doubleSet",
- "stringSet",
- "enumSet",
- "listSet",
- "setSet",
- "mapSet",
- "structSet.byteField",
- "structSet.i16Field",
- "structSet.i32Field",
- "structSet.i64Field",
- "structSet.doubleField",
- "structSet.stringField",
- "structSet.enumField",
- "binarySet",
- "byteMap",
- "i16Map",
- "i32Map",
- "i64Map",
- "doubleMap",
- "stringMap",
- "enumMap",
- "listMap",
- "setMap",
- "mapMap",
- "structMap.byteField",
- "structMap.i16Field",
- "structMap.i32Field",
- "structMap.i64Field",
- "structMap.doubleField",
- "structMap.stringField",
- "structMap.enumField",
- "binaryMap"
- )
- );
+ return new ArrayList<>(
+ Arrays.asList(
+ "byteField",
+ "i16Field",
+ "i32Field",
+ "i64Field",
+ "doubleField",
+ "stringField",
+ "structField.byteField",
+ "structField.i16Field",
+ "structField.i32Field",
+ "structField.i64Field",
+ "structField.doubleField",
+ "structField.stringField",
+ "structField.enumField",
+ "enumField",
+ "binaryField",
+ "byteList",
+ "i16List",
+ "i32List",
+ "i64List",
+ "doubleList",
+ "stringList",
+ "enumList",
+ "listList",
+ "setList",
+ "mapList",
+ "structList.byteField",
+ "structList.i16Field",
+ "structList.i32Field",
+ "structList.i64Field",
+ "structList.doubleField",
+ "structList.stringField",
+ "structList.enumField",
+ "binaryList",
+ "byteSet",
+ "i16Set",
+ "i32Set",
+ "i64Set",
+ "doubleSet",
+ "stringSet",
+ "enumSet",
+ "listSet",
+ "setSet",
+ "mapSet",
+ "structSet.byteField",
+ "structSet.i16Field",
+ "structSet.i32Field",
+ "structSet.i64Field",
+ "structSet.doubleField",
+ "structSet.stringField",
+ "structSet.enumField",
+ "binarySet",
+ "byteMap",
+ "i16Map",
+ "i32Map",
+ "i64Map",
+ "doubleMap",
+ "stringMap",
+ "enumMap",
+ "listMap",
+ "setMap",
+ "mapMap",
+ "structMap.byteField",
+ "structMap.i16Field",
+ "structMap.i32Field",
+ "structMap.i64Field",
+ "structMap.doubleField",
+ "structMap.stringField",
+ "structMap.enumField",
+ "binaryMap"));
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/TFieldDataTest.java b/lib/java/src/test/java/org/apache/thrift/partial/TFieldDataTest.java
index 860f515dd..b4b6c87e4 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/TFieldDataTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/TFieldDataTest.java
@@ -19,12 +19,12 @@
package org.apache.thrift.partial;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import org.apache.thrift.protocol.TField;
import org.apache.thrift.protocol.TType;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class TFieldDataTest {
@Test
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/TestData.java b/lib/java/src/test/java/org/apache/thrift/partial/TestData.java
index 1779346f7..dc511d8b8 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/TestData.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/TestData.java
@@ -23,35 +23,32 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-/**
- * Frequently used test data items.
- */
+/** Frequently used test data items. */
public final class TestData {
private TestData() {}
-
// Array data.
- public static Object[] nullArray = null;
- public static Object[] emptyArray = new Object[0];
+ public static Object[] nullArray = null;
+ public static Object[] emptyArray = new Object[0];
public static Object[] nonEmptyArray = new Object[1];
- public static byte[] nullByteArray = null;
- public static byte[] emptyByteArray = new byte[0];
- public static byte[] nonEmptyByteArray = new byte[1];
+ public static byte[] nullByteArray = null;
+ public static byte[] emptyByteArray = new byte[0];
+ public static byte[] nonEmptyByteArray = new byte[1];
- public static short[] nullShortArray = null;
- public static short[] emptyShortArray = new short[0];
+ public static short[] nullShortArray = null;
+ public static short[] emptyShortArray = new short[0];
public static short[] nonEmptyShortArray = new short[1];
- public static int[] nullIntArray = null;
- public static int[] emptyIntArray = new int[0];
- public static int[] nonEmptyIntArray = new int[1];
+ public static int[] nullIntArray = null;
+ public static int[] emptyIntArray = new int[0];
+ public static int[] nonEmptyIntArray = new int[1];
- public static long[] nullLongArray = null;
- public static long[] emptyLongArray = new long[0];
- public static long[] nonEmptyLongArray = new long[1];
+ public static long[] nullLongArray = null;
+ public static long[] emptyLongArray = new long[0];
+ public static long[] nonEmptyLongArray = new long[1];
- public static List<Object> nullList = null;
+ public static List<Object> nullList = null;
public static List<Object> emptyList = new ArrayList<Object>();
public static List<Object> validList = Arrays.asList(new Object[1]);
}
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/TestPartialThriftDeserializer.java b/lib/java/src/test/java/org/apache/thrift/partial/TestPartialThriftDeserializer.java
index 722e108ad..e5bdd0fb1 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/TestPartialThriftDeserializer.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/TestPartialThriftDeserializer.java
@@ -19,11 +19,12 @@
package org.apache.thrift.partial;
-import org.apache.thrift.TDeserializer;
-import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TCompactProtocol;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -36,13 +37,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.apache.thrift.TDeserializer;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.junit.jupiter.api.Test;
public class TestPartialThriftDeserializer {
@@ -52,8 +51,7 @@ public class TestPartialThriftDeserializer {
private PartialThriftTestData testData = new PartialThriftTestData();
- public TestPartialThriftDeserializer() throws TException {
- }
+ public TestPartialThriftDeserializer() throws TException {}
@Test
public void testArgChecks() throws TException {
@@ -79,8 +77,8 @@ public class TestPartialThriftDeserializer {
}
/**
- * This test does not use partial deserialization. It is used to establish correctness
- * of full serialization used in the other tests.
+ * This test does not use partial deserialization. It is used to establish correctness of full
+ * serialization used in the other tests.
*/
@Test
public void testRoundTripFull() throws TException {
@@ -89,7 +87,7 @@ public class TestPartialThriftDeserializer {
byte[] bytesBinary = serde.serializeBinary(ts1);
byte[] bytesCompact = serde.serializeCompact(ts1);
- TestStruct ts2 = serde.deserializeBinary(bytesBinary, TestStruct.class);
+ TestStruct ts2 = serde.deserializeBinary(bytesBinary, TestStruct.class);
assertEquals(ts1, ts2);
ts2 = serde.deserializeCompact(bytesCompact, TestStruct.class);
@@ -140,62 +138,61 @@ public class TestPartialThriftDeserializer {
byte[] bytesBinary = serde.serializeBinary(ts1);
byte[] bytesCompact = serde.serializeCompact(ts1);
- List<String> fieldNames = Arrays.asList(
- "byteField",
- "i16Field",
- "i32Field",
- "i64Field",
- "doubleField",
- "stringField",
-
- "enumField",
- "binaryField",
-
- // List fields
- "byteList",
- "i16List",
- "i32List",
- "i64List",
- "doubleList",
- "stringList",
- "enumList",
- "listList",
- "setList",
- "mapList",
- "structList",
- "binaryList",
-
- // Set fields
- "byteSet",
- "i16Set",
- "i32Set",
- "i64Set",
- "doubleSet",
- "stringSet",
- "enumSet",
- "listSet",
- "setSet",
- "mapSet",
- "structSet",
- "binarySet",
-
- // Map fields
- "byteMap",
- "i16Map",
- "i32Map",
- "i64Map",
- "doubleMap",
- "stringMap",
- "enumMap",
- "listMap",
- "setMap",
- "mapMap",
- "structMap",
- "binaryMap",
-
- // Struct field
- "structField"
- );
+ List<String> fieldNames =
+ Arrays.asList(
+ "byteField",
+ "i16Field",
+ "i32Field",
+ "i64Field",
+ "doubleField",
+ "stringField",
+ "enumField",
+ "binaryField",
+
+ // List fields
+ "byteList",
+ "i16List",
+ "i32List",
+ "i64List",
+ "doubleList",
+ "stringList",
+ "enumList",
+ "listList",
+ "setList",
+ "mapList",
+ "structList",
+ "binaryList",
+
+ // Set fields
+ "byteSet",
+ "i16Set",
+ "i32Set",
+ "i64Set",
+ "doubleSet",
+ "stringSet",
+ "enumSet",
+ "listSet",
+ "setSet",
+ "mapSet",
+ "structSet",
+ "binarySet",
+
+ // Map fields
+ "byteMap",
+ "i16Map",
+ "i32Map",
+ "i64Map",
+ "doubleMap",
+ "stringMap",
+ "enumMap",
+ "listMap",
+ "setMap",
+ "mapMap",
+ "structMap",
+ "binaryMap",
+
+ // Struct field
+ "structField");
StringBuilder sb = new StringBuilder();
TDeserializer partialBinaryDeserializer =
new TDeserializer(TestStruct.class, fieldNames, binaryProtocolFactory);
@@ -381,15 +378,15 @@ public class TestPartialThriftDeserializer {
for (int i = 0; i < numItems; i++) {
if (clasz == Byte.class) {
- assertTrue(set.contains((byte)i));
+ assertTrue(set.contains((byte) i));
} else if (clasz == Short.class) {
- assertTrue(set.contains((short)i));
+ assertTrue(set.contains((short) i));
} else if (clasz == Integer.class) {
assertTrue(set.contains(i));
} else if (clasz == Long.class) {
- assertTrue(set.contains((long)i));
+ assertTrue(set.contains((long) i));
} else if (clasz == Double.class) {
- assertTrue(set.contains((double)i));
+ assertTrue(set.contains((double) i));
}
}
}
@@ -472,19 +469,19 @@ public class TestPartialThriftDeserializer {
for (int i = 0; i < numItems; i++) {
if (clasz == Byte.class) {
- assertTrue(map.containsKey((byte)i));
+ assertTrue(map.containsKey((byte) i));
assertEquals((byte) i, map.get((byte) i));
} else if (clasz == Short.class) {
- assertTrue(map.containsKey((short)i));
+ assertTrue(map.containsKey((short) i));
assertEquals((short) i, map.get((short) i));
} else if (clasz == Integer.class) {
assertTrue(map.containsKey(i));
assertEquals(i, map.get(i));
} else if (clasz == Long.class) {
- assertTrue(map.containsKey((long)i));
+ assertTrue(map.containsKey((long) i));
assertEquals((long) i, map.get((long) i));
} else if (clasz == Double.class) {
- assertTrue(map.containsKey((double)i));
+ assertTrue(map.containsKey((double) i));
assertEquals((double) i, map.get((double) i));
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/ThriftFieldTest.java b/lib/java/src/test/java/org/apache/thrift/partial/ThriftFieldTest.java
index 115726ed0..0e0f1a669 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/ThriftFieldTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/ThriftFieldTest.java
@@ -19,18 +19,16 @@
package org.apache.thrift.partial;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.junit.jupiter.api.Test;
public class ThriftFieldTest {
@@ -46,9 +44,9 @@ public class ThriftFieldTest {
// Verify it throws.
assertThrows(
- IllegalArgumentException.class,
- () -> new ThriftField(null, Collections.emptyList()),
- "'name' must not be null");
+ IllegalArgumentException.class,
+ () -> new ThriftField(null, Collections.emptyList()),
+ "'name' must not be null");
assertThrows(
IllegalArgumentException.class,
@@ -68,13 +66,8 @@ public class ThriftFieldTest {
@Test
public void testFromNames() {
- List<String> fieldNames = Arrays.asList(
- "f1",
- "f2.f21",
- "f3.f31.f311",
- "f3.f32.f321",
- "f3.f32.f322"
- );
+ List<String> fieldNames =
+ Arrays.asList("f1", "f2.f21", "f3.f31.f311", "f3.f32.f321", "f3.f32.f322");
List<ThriftField> testFields = ThriftField.fromNames(fieldNames);
@@ -113,16 +106,10 @@ public class ThriftFieldTest {
assertEquals(0, f322.fields.size());
}
-
@Test
public void testEquality() {
- List<String> fieldNames = Arrays.asList(
- "f1",
- "f2.f21",
- "f3.f31.f311",
- "f3.f32.f321",
- "f3.f32.f322"
- );
+ List<String> fieldNames =
+ Arrays.asList("f1", "f2.f21", "f3.f31.f311", "f3.f32.f321", "f3.f32.f322");
List<ThriftField> testFields = ThriftField.fromNames(fieldNames);
List<ThriftField> testFields2 = testFields;
@@ -135,13 +122,8 @@ public class ThriftFieldTest {
assertEquals(testFields, testFields3);
assertEquals(testFields.hashCode(), testFields3.hashCode());
- List<String> fieldNamesDiff = Arrays.asList(
- "f1",
- "f2.f21",
- "f3.f31.f311",
- "f3.f32.f323",
- "f3.f32.f322"
- );
+ List<String> fieldNamesDiff =
+ Arrays.asList("f1", "f2.f21", "f3.f31.f311", "f3.f32.f323", "f3.f32.f322");
List<ThriftField> testFields4 = ThriftField.fromNames(fieldNamesDiff);
assertNotSame(testFields, testFields4);
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/ThriftMetadataTest.java b/lib/java/src/test/java/org/apache/thrift/partial/ThriftMetadataTest.java
index f47657245..5180578b4 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/ThriftMetadataTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/ThriftMetadataTest.java
@@ -19,6 +19,15 @@
package org.apache.thrift.partial;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
import org.apache.thrift.TBase;
import org.apache.thrift.meta_data.EnumMetaData;
import org.apache.thrift.meta_data.FieldValueMetaData;
@@ -29,16 +38,6 @@ import org.apache.thrift.meta_data.StructMetaData;
import org.apache.thrift.protocol.TType;
import org.junit.jupiter.api.Test;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class ThriftMetadataTest {
private PartialThriftTestData testData = new PartialThriftTestData();
@@ -122,9 +121,7 @@ public class ThriftMetadataTest {
}
private ThriftMetadata.ThriftObject validateBasicFieldMetadata(
- ThriftMetadata.ThriftStruct testStruct,
- int id,
- String fieldName) {
+ ThriftMetadata.ThriftStruct testStruct, int id, String fieldName) {
return validateBasicFieldMetadata(testStruct, TestStruct.class, id, fieldName);
}
@@ -153,17 +150,14 @@ public class ThriftMetadataTest {
}
private void validateBasicFieldValueMetadata(
- ThriftMetadata.ThriftObject fieldMetadata,
- String fieldName,
- byte ttype) {
+ ThriftMetadata.ThriftObject fieldMetadata, String fieldName, byte ttype) {
assertEquals(ttype, fieldMetadata.data.valueMetaData.type);
assertEquals(getMetaDataClassForTType(ttype), fieldMetadata.data.valueMetaData.getClass());
Class<? extends ThriftMetadata.ThriftObject> fieldMetadataClass = getClassForTType(ttype);
assertEquals(fieldMetadataClass, fieldMetadata.getClass());
if (fieldMetadataClass == ThriftMetadata.ThriftPrimitive.class) {
- ThriftMetadata.ThriftPrimitive primitive
- = (ThriftMetadata.ThriftPrimitive) fieldMetadata;
+ ThriftMetadata.ThriftPrimitive primitive = (ThriftMetadata.ThriftPrimitive) fieldMetadata;
if (fieldName.startsWith("binary") && (ttype == TType.STRING)) {
assertTrue(primitive.isBinary());
} else {
@@ -173,10 +167,7 @@ public class ThriftMetadataTest {
}
private void validateFieldMetadata(
- ThriftMetadata.ThriftStruct testStruct,
- int id,
- String fieldName,
- byte ttype) {
+ ThriftMetadata.ThriftStruct testStruct, int id, String fieldName, byte ttype) {
ThriftMetadata.ThriftObject fieldMetadata =
validateBasicFieldMetadata(testStruct, id, fieldName);
@@ -184,10 +175,7 @@ public class ThriftMetadataTest {
}
private void validateListFieldMetadata(
- ThriftMetadata.ThriftStruct testStruct,
- int id,
- String fieldName,
- byte ttype) {
+ ThriftMetadata.ThriftStruct testStruct, int id, String fieldName, byte ttype) {
ThriftMetadata.ThriftObject fieldMetadata =
validateBasicFieldMetadata(testStruct, id, fieldName);
@@ -199,10 +187,7 @@ public class ThriftMetadataTest {
}
private void validateSetFieldMetadata(
- ThriftMetadata.ThriftStruct testStruct,
- int id,
- String fieldName,
- byte ttype) {
+ ThriftMetadata.ThriftStruct testStruct, int id, String fieldName, byte ttype) {
ThriftMetadata.ThriftObject fieldMetadata =
validateBasicFieldMetadata(testStruct, id, fieldName);
@@ -234,7 +219,7 @@ public class ThriftMetadataTest {
private Class<? extends FieldValueMetaData> getMetaDataClassForTType(byte ttype) {
switch (ttype) {
case TType.STRUCT:
- return StructMetaData.class;
+ return StructMetaData.class;
case TType.LIST:
return ListMetaData.class;
@@ -265,7 +250,7 @@ public class ThriftMetadataTest {
private Class<? extends ThriftMetadata.ThriftObject> getClassForTType(byte ttype) {
switch (ttype) {
case TType.STRUCT:
- return ThriftMetadata.ThriftStruct.class;
+ return ThriftMetadata.ThriftStruct.class;
case TType.LIST:
return ThriftMetadata.ThriftList.class;
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/ThriftStructProcessorTest.java b/lib/java/src/test/java/org/apache/thrift/partial/ThriftStructProcessorTest.java
index a8b0dac8f..210263f1e 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/ThriftStructProcessorTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/ThriftStructProcessorTest.java
@@ -19,10 +19,13 @@
package org.apache.thrift.partial;
-import org.apache.thrift.TBase;
-import org.apache.thrift.TException;
-import org.apache.thrift.TFieldIdEnum;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@@ -34,14 +37,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.apache.thrift.TBase;
+import org.apache.thrift.TException;
+import org.apache.thrift.TFieldIdEnum;
+import org.junit.jupiter.api.Test;
public class ThriftStructProcessorTest {
@@ -160,18 +159,17 @@ public class ThriftStructProcessorTest {
@Test
public void testStructPrimitiveFields() throws TException {
- List<ThriftField> fields = ThriftField.fromNames(
- Arrays.asList(
- "byteField",
- "i16Field",
- "i32Field",
- "i64Field",
- "doubleField",
- "stringField",
-
- "enumField",
- "binaryField"
- ));
+ List<ThriftField> fields =
+ ThriftField.fromNames(
+ Arrays.asList(
+ "byteField",
+ "i16Field",
+ "i32Field",
+ "i64Field",
+ "doubleField",
+ "stringField",
+ "enumField",
+ "binaryField"));
ThriftMetadata.ThriftStruct metadata =
ThriftMetadata.ThriftStruct.fromFields(TestStruct.class, fields);
@@ -233,20 +231,20 @@ public class ThriftStructProcessorTest {
@Test
public void testStructContainerFields() throws TException {
- List<ThriftField> fields = ThriftField.fromNames(
- Arrays.asList(
- // List field
- "i32List",
+ List<ThriftField> fields =
+ ThriftField.fromNames(
+ Arrays.asList(
+ // List field
+ "i32List",
- // Set field
- "stringSet",
+ // Set field
+ "stringSet",
- // Map field
- "stringMap",
+ // Map field
+ "stringMap",
- // Struct field
- "structField"
- ));
+ // Struct field
+ "structField"));
ThriftMetadata.ThriftStruct metadata =
ThriftMetadata.ThriftStruct.fromFields(TestStruct.class, fields);
@@ -261,7 +259,7 @@ public class ThriftStructProcessorTest {
// list
TFieldIdEnum fieldId = findFieldId(metadata, "i32List");
assertNull(getFieldValue(struct, fieldId));
- Integer[] ints = new Integer[] { 1, 2, 3 };
+ Integer[] ints = new Integer[] {1, 2, 3};
List<Integer> intList = Arrays.asList(ints);
processor.setListField(struct, fieldId, intList);
assertArrayEquals(ints, struct.getI32List().toArray());
@@ -269,7 +267,7 @@ public class ThriftStructProcessorTest {
// set
fieldId = findFieldId(metadata, "stringSet");
assertNull(getFieldValue(struct, fieldId));
- String[] strings = new String[] { "Hello", "World!" };
+ String[] strings = new String[] {"Hello", "World!"};
Set<String> stringSet = new HashSet<>(Arrays.asList(strings));
processor.setSetField(struct, fieldId, stringSet);
assertEquals(stringSet, struct.getStringSet());
diff --git a/lib/java/src/test/java/org/apache/thrift/partial/ValidateTest.java b/lib/java/src/test/java/org/apache/thrift/partial/ValidateTest.java
index d2e8eaa18..861d03e19 100644
--- a/lib/java/src/test/java/org/apache/thrift/partial/ValidateTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/partial/ValidateTest.java
@@ -19,15 +19,14 @@
package org.apache.thrift.partial;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import org.junit.jupiter.api.Test;
public class ValidateTest {
@Test
@@ -212,15 +211,13 @@ public class ValidateTest {
assertThrows(
IllegalArgumentException.class,
() -> Validate.checkNotNullAndNumberOfElements(null, 3, "arg"),
- "'arg' must not be null"
- );
+ "'arg' must not be null");
// Verify it throws.
assertThrows(
IllegalArgumentException.class,
() -> Validate.checkNotNullAndNumberOfElements(Arrays.asList(1, 2), 3, "arg"),
- "Number of elements in 'arg' must be exactly 3, 2 given."
- );
+ "Number of elements in 'arg' must be exactly 3, 2 given.");
}
@Test
@@ -292,7 +289,7 @@ public class ValidateTest {
@Test
public void testCheckPathExists() throws IOException {
Path tempFile = Files.createTempFile("foo", "bar");
- Path tempDir = tempFile.getParent();
+ Path tempDir = tempFile.getParent();
Path notFound = Paths.get("<not-found>");
// Should not throw.
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/BenchmarkProtocols.java b/lib/java/src/test/java/org/apache/thrift/protocol/BenchmarkProtocols.java
index 6b60c99bb..493214fc7 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/BenchmarkProtocols.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/BenchmarkProtocols.java
@@ -7,18 +7,20 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import org.apache.thrift.Fixtures;
import org.apache.thrift.TException;
import org.apache.thrift.transport.TMemoryBuffer;
public class BenchmarkProtocols {
- private static final Set<TProtocolFactory> FACTORIES = new LinkedHashSet<TProtocolFactory>(){{
- add(new TTupleProtocol.Factory());
- add(new TCompactProtocol.Factory());
- add(new TBinaryProtocol.Factory());
- }};
+ private static final Set<TProtocolFactory> FACTORIES =
+ new LinkedHashSet<TProtocolFactory>() {
+ {
+ add(new TTupleProtocol.Factory());
+ add(new TCompactProtocol.Factory());
+ add(new TBinaryProtocol.Factory());
+ }
+ };
private static final int NUM_REPS = 100000;
private static final int NUM_TRIALS = 10;
@@ -30,30 +32,29 @@ public class BenchmarkProtocols {
for (int i = 0; i < 16; i++) {
System.gc();
}
-// TProtocol proto = factory.getProtocol(new TTransport() {
-// @Override
-// public void write(byte[] buf, int off, int len) throws TTransportException {
-// }
-//
-// @Override
-// public int read(byte[] buf, int off, int len) throws TTransportException {
-// return 0;
-// }
-//
-// @Override
-// public void open() throws TTransportException {
-// }
-//
-// @Override
-// public boolean isOpen() {
-// return true;
-// }
-//
-// @Override
-// public void close() {
-// }
-// });
-
+ // TProtocol proto = factory.getProtocol(new TTransport() {
+ // @Override
+ // public void write(byte[] buf, int off, int len) throws TTransportException {
+ // }
+ //
+ // @Override
+ // public int read(byte[] buf, int off, int len) throws TTransportException {
+ // return 0;
+ // }
+ //
+ // @Override
+ // public void open() throws TTransportException {
+ // }
+ //
+ // @Override
+ // public boolean isOpen() {
+ // return true;
+ // }
+ //
+ // @Override
+ // public void close() {
+ // }
+ // });
for (TProtocolFactory factory : FACTORIES) {
if (timesByFactory.get(factory) == null) {
@@ -62,27 +63,27 @@ public class BenchmarkProtocols {
long start = System.currentTimeMillis();
for (int rep = 0; rep < NUM_REPS; rep++) {
- TProtocol proto = factory.getProtocol(new TMemoryBuffer(128*1024));
+ TProtocol proto = factory.getProtocol(new TMemoryBuffer(128 * 1024));
Fixtures.getCompactProtoTestStruct().write(proto);
Fixtures.getNesting().write(proto);
}
long end = System.currentTimeMillis();
- timesByFactory.get(factory).add(end-start);
+ timesByFactory.get(factory).add(end - start);
}
}
for (TProtocolFactory factory : FACTORIES) {
List<Long> times = timesByFactory.get(factory);
-// System.out.println("raw times pre-drop: " + times );
+ // System.out.println("raw times pre-drop: " + times );
times.remove(Collections.max(times));
long total = 0;
for (long t : times) {
total += t;
}
Collections.sort(times);
- System.out.println(factory.getClass().getName() + " average time: " + (total / times.size()) + "ms");
+ System.out.println(
+ factory.getClass().getName() + " average time: " + (total / times.size()) + "ms");
System.out.println("raw times: " + times);
}
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/ProtocolTestBase.java b/lib/java/src/test/java/org/apache/thrift/protocol/ProtocolTestBase.java
index 8bf5c6e44..a111292d3 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/ProtocolTestBase.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/ProtocolTestBase.java
@@ -18,6 +18,17 @@
*/
package org.apache.thrift.protocol;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.thrift.Fixtures;
import org.apache.thrift.TBase;
import org.apache.thrift.TConfiguration;
@@ -35,18 +46,6 @@ import thrift.test.OneOfEach;
import thrift.test.Srv;
import thrift.test.ThriftTest;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
public abstract class ProtocolTestBase {
/** Does it make sense to call methods like writeI32 directly on your protocol? */
@@ -64,17 +63,18 @@ public abstract class ProtocolTestBase {
assertEquals(123.456, proto.readDouble());
}
- internalTestStructField(new StructFieldTestCase(TType.DOUBLE, (short)15) {
- @Override
- public void readMethod(TProtocol proto) throws TException {
- assertEquals(123.456, proto.readDouble());
- }
+ internalTestStructField(
+ new StructFieldTestCase(TType.DOUBLE, (short) 15) {
+ @Override
+ public void readMethod(TProtocol proto) throws TException {
+ assertEquals(123.456, proto.readDouble());
+ }
- @Override
- public void writeMethod(TProtocol proto) throws TException {
- proto.writeDouble(123.456);
- }
- });
+ @Override
+ public void writeMethod(TProtocol proto) throws TException {
+ proto.writeDouble(123.456);
+ }
+ });
}
@Test
@@ -87,13 +87,15 @@ public abstract class ProtocolTestBase {
@Test
public void testBinary() throws Exception {
- for (byte[] b : Arrays.asList(new byte[0],
- new byte[]{0,1,2,3,4,5,6,7,8,9,10},
- new byte[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14},
- new byte[]{0x5D},
- new byte[]{(byte)0xD5,(byte)0x5D},
- new byte[]{(byte)0xFF,(byte)0xD5,(byte)0x5D},
- new byte[128])) {
+ for (byte[] b :
+ Arrays.asList(
+ new byte[0],
+ new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
+ new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14},
+ new byte[] {0x5D},
+ new byte[] {(byte) 0xD5, (byte) 0x5D},
+ new byte[] {(byte) 0xFF, (byte) 0xD5, (byte) 0x5D},
+ new byte[128])) {
if (canBeUsedNaked()) {
internalTestNakedBinary(b);
}
@@ -111,9 +113,11 @@ public abstract class ProtocolTestBase {
assertEquals(ByteBuffer.wrap(data, 1, 5), proto.readBinary());
}
}
-@Test
+
+ @Test
public void testString() throws Exception {
- for (String s : Arrays.asList("", "short", "borderlinetiny", "a bit longer than the smallest possible")) {
+ for (String s :
+ Arrays.asList("", "short", "borderlinetiny", "a bit longer than the smallest possible")) {
if (canBeUsedNaked()) {
internalTestNakedString(s);
}
@@ -139,7 +143,10 @@ public abstract class ProtocolTestBase {
@Test
public void testInt() throws Exception {
- for (int i : Arrays.asList(0, 1, 7, 150, 15000, 31337, 0xffff, 0xffffff, -1, -7, -150, -15000, -0xffff, -0xffffff)) {
+ for (int i :
+ Arrays.asList(
+ 0, 1, 7, 150, 15000, 31337, 0xffff, 0xffffff, -1, -7, -150, -15000, -0xffff,
+ -0xffffff)) {
if (canBeUsedNaked()) {
internalTestNakedI32(i);
}
@@ -151,9 +158,9 @@ public abstract class ProtocolTestBase {
public void testShort() throws Exception {
for (int s : Arrays.asList(0, 1, 7, 150, 15000, 0x7fff, -1, -7, -150, -15000, -0x7fff)) {
if (canBeUsedNaked()) {
- internalTestNakedI16((short)s);
+ internalTestNakedI16((short) s);
}
- internalTestI16Field((short)s);
+ internalTestI16Field((short) s);
}
}
@@ -163,28 +170,29 @@ public abstract class ProtocolTestBase {
internalTestNakedByte();
}
for (int i = 0; i < 128; i++) {
- internalTestByteField((byte)i);
- internalTestByteField((byte)-i);
+ internalTestByteField((byte) i);
+ internalTestByteField((byte) -i);
}
}
private void internalTestNakedByte() throws Exception {
TMemoryBuffer buf = new TMemoryBuffer(1000);
TProtocol proto = getFactory().getProtocol(buf);
- proto.writeByte((byte)123);
+ proto.writeByte((byte) 123);
assertEquals((byte) 123, proto.readByte());
}
private void internalTestByteField(final byte b) throws Exception {
- internalTestStructField(new StructFieldTestCase(TType.BYTE, (short)15) {
- public void writeMethod(TProtocol proto) throws TException {
- proto.writeByte(b);
- }
+ internalTestStructField(
+ new StructFieldTestCase(TType.BYTE, (short) 15) {
+ public void writeMethod(TProtocol proto) throws TException {
+ proto.writeByte(b);
+ }
- public void readMethod(TProtocol proto) throws TException {
- assertEquals(b, proto.readByte());
- }
- });
+ public void readMethod(TProtocol proto) throws TException {
+ assertEquals(b, proto.readByte());
+ }
+ });
}
private void internalTestNakedI16(short n) throws Exception {
@@ -195,15 +203,16 @@ public abstract class ProtocolTestBase {
}
private void internalTestI16Field(final short n) throws Exception {
- internalTestStructField(new StructFieldTestCase(TType.I16, (short)15) {
- public void writeMethod(TProtocol proto) throws TException {
- proto.writeI16(n);
- }
+ internalTestStructField(
+ new StructFieldTestCase(TType.I16, (short) 15) {
+ public void writeMethod(TProtocol proto) throws TException {
+ proto.writeI16(n);
+ }
- public void readMethod(TProtocol proto) throws TException {
- assertEquals(n, proto.readI16());
- }
- });
+ public void readMethod(TProtocol proto) throws TException {
+ assertEquals(n, proto.readI16());
+ }
+ });
}
private void internalTestNakedI32(int n) throws Exception {
@@ -214,15 +223,16 @@ public abstract class ProtocolTestBase {
}
private void internalTestI32Field(final int n) throws Exception {
- internalTestStructField(new StructFieldTestCase(TType.I32, (short)15) {
- public void writeMethod(TProtocol proto) throws TException {
- proto.writeI32(n);
- }
+ internalTestStructField(
+ new StructFieldTestCase(TType.I32, (short) 15) {
+ public void writeMethod(TProtocol proto) throws TException {
+ proto.writeI32(n);
+ }
- public void readMethod(TProtocol proto) throws TException {
- assertEquals(n, proto.readI32());
- }
- });
+ public void readMethod(TProtocol proto) throws TException {
+ assertEquals(n, proto.readI32());
+ }
+ });
}
private void internalTestNakedI64(long n) throws Exception {
@@ -233,15 +243,16 @@ public abstract class ProtocolTestBase {
}
private void internalTestI64Field(final long n) throws Exception {
- internalTestStructField(new StructFieldTestCase(TType.I64, (short)15) {
- public void writeMethod(TProtocol proto) throws TException {
- proto.writeI64(n);
- }
+ internalTestStructField(
+ new StructFieldTestCase(TType.I64, (short) 15) {
+ public void writeMethod(TProtocol proto) throws TException {
+ proto.writeI64(n);
+ }
- public void readMethod(TProtocol proto) throws TException {
- assertEquals(n, proto.readI64());
- }
- });
+ public void readMethod(TProtocol proto) throws TException {
+ assertEquals(n, proto.readI64());
+ }
+ });
}
private void internalTestNakedString(String str) throws Exception {
@@ -252,15 +263,16 @@ public abstract class ProtocolTestBase {
}
private void internalTestStringField(final String str) throws Exception {
- internalTestStructField(new StructFieldTestCase(TType.STRING, (short)15) {
- public void writeMethod(TProtocol proto) throws TException {
- proto.writeString(str);
- }
+ internalTestStructField(
+ new StructFieldTestCase(TType.STRING, (short) 15) {
+ public void writeMethod(TProtocol proto) throws TException {
+ proto.writeString(str);
+ }
- public void readMethod(TProtocol proto) throws TException {
- assertEquals(str, proto.readString());
- }
- });
+ public void readMethod(TProtocol proto) throws TException {
+ assertEquals(str, proto.readString());
+ }
+ });
}
private void internalTestNakedBinary(byte[] data) throws Exception {
@@ -271,18 +283,20 @@ public abstract class ProtocolTestBase {
}
private void internalTestBinaryField(final byte[] data) throws Exception {
- internalTestStructField(new StructFieldTestCase(TType.STRING, (short)15) {
- public void writeMethod(TProtocol proto) throws TException {
- proto.writeBinary(ByteBuffer.wrap(data));
- }
+ internalTestStructField(
+ new StructFieldTestCase(TType.STRING, (short) 15) {
+ public void writeMethod(TProtocol proto) throws TException {
+ proto.writeBinary(ByteBuffer.wrap(data));
+ }
- public void readMethod(TProtocol proto) throws TException {
- assertEquals(ByteBuffer.wrap(data), proto.readBinary());
- }
- });
+ public void readMethod(TProtocol proto) throws TException {
+ assertEquals(ByteBuffer.wrap(data), proto.readBinary());
+ }
+ });
}
- private <T extends TBase> void internalTestSerialization(Class<T> klass, T expected) throws Exception {
+ private <T extends TBase> void internalTestSerialization(Class<T> klass, T expected)
+ throws Exception {
TMemoryBuffer buf = new TMemoryBuffer(0);
TBinaryProtocol binproto = new TBinaryProtocol(buf);
@@ -292,7 +306,7 @@ public abstract class ProtocolTestBase {
TProtocol proto = getFactory().getProtocol(buf);
expected.write(proto);
- System.out.println("Size in " + proto.getClass().getSimpleName() + ": " + buf.length());
+ System.out.println("Size in " + proto.getClass().getSimpleName() + ": " + buf.length());
T actual = klass.newInstance();
actual.read(proto);
@@ -301,12 +315,15 @@ public abstract class ProtocolTestBase {
@Test
public void testMessage() throws Exception {
- List<TMessage> msgs = Arrays.asList(new TMessage[]{
- new TMessage("short message name", TMessageType.CALL, 0),
- new TMessage("1", TMessageType.REPLY, 12345),
- new TMessage("loooooooooooooooooooooooooooooooooong", TMessageType.EXCEPTION, 1 << 16),
- new TMessage("Janky", TMessageType.CALL, 0),
- });
+ List<TMessage> msgs =
+ Arrays.asList(
+ new TMessage[] {
+ new TMessage("short message name", TMessageType.CALL, 0),
+ new TMessage("1", TMessageType.REPLY, 12345),
+ new TMessage(
+ "loooooooooooooooooooooooooooooooooong", TMessageType.EXCEPTION, 1 << 16),
+ new TMessage("Janky", TMessageType.CALL, 0),
+ });
for (TMessage msg : msgs) {
TMemoryBuffer buf = new TMemoryBuffer(0);
@@ -324,34 +341,32 @@ public abstract class ProtocolTestBase {
@Test
public void testServerRequest() throws Exception {
- Srv.Iface handler = new Srv.Iface() {
- public int Janky(int i32arg) throws TException {
- return i32arg * 2;
- }
+ Srv.Iface handler =
+ new Srv.Iface() {
+ public int Janky(int i32arg) throws TException {
+ return i32arg * 2;
+ }
- public int primitiveMethod() throws TException {
- return 0;
- }
+ public int primitiveMethod() throws TException {
+ return 0;
+ }
- public CompactProtoTestStruct structMethod() throws TException {
- return null;
- }
+ public CompactProtoTestStruct structMethod() throws TException {
+ return null;
+ }
- public void voidMethod() throws TException {
- }
+ public void voidMethod() throws TException {}
- public void methodWithDefaultArgs(int something) throws TException {
- }
+ public void methodWithDefaultArgs(int something) throws TException {}
- @Override
- public void onewayMethod() throws TException {
- }
+ @Override
+ public void onewayMethod() throws TException {}
- @Override
- public boolean declaredExceptionMethod(boolean shouldThrow) throws TException {
- return shouldThrow;
- }
- };
+ @Override
+ public boolean declaredExceptionMethod(boolean shouldThrow) throws TException {
+ return shouldThrow;
+ }
+ };
Srv.Processor testProcessor = new Srv.Processor(handler);
@@ -404,15 +419,17 @@ public abstract class ProtocolTestBase {
proto.readStructEnd();
}
- private static abstract class StructFieldTestCase {
+ private abstract static class StructFieldTestCase {
byte type_;
short id_;
+
public StructFieldTestCase(byte type, short id) {
type_ = type;
id_ = id;
}
public abstract void writeMethod(TProtocol proto) throws TException;
+
public abstract void readMethod(TProtocol proto) throws TException;
}
@@ -429,8 +446,12 @@ public abstract class ProtocolTestBase {
}
long serEnd = System.currentTimeMillis();
long serElapsed = serEnd - serStart;
- System.out.println("Ser:\t" + serElapsed + "ms\t"
- + ((double)serElapsed / NUM_REPS) + "ms per serialization");
+ System.out.println(
+ "Ser:\t"
+ + serElapsed
+ + "ms\t"
+ + ((double) serElapsed / NUM_REPS)
+ + "ms per serialization");
HolyMoley cpts = new HolyMoley();
TDeserializer deser = new TDeserializer(getFactory());
@@ -440,52 +461,57 @@ public abstract class ProtocolTestBase {
}
long deserEnd = System.currentTimeMillis();
long deserElapsed = deserEnd - deserStart;
- System.out.println("Des:\t" + deserElapsed + "ms\t"
- + ((double)deserElapsed / NUM_REPS) + "ms per deserialization");
+ System.out.println(
+ "Des:\t"
+ + deserElapsed
+ + "ms\t"
+ + ((double) deserElapsed / NUM_REPS)
+ + "ms per deserialization");
}
}
- private final ServerTestBase.TestHandler testHandler = new ServerTestBase.TestHandler() {
- @Override
- public String testString(String thing) {
- thing = thing + " Apache Thrift Java " + thing;
- return thing;
- }
-
- @Override
- public List<Integer> testList(List<Integer> thing) {
- thing.addAll(thing);
- thing.addAll(thing);
- return thing;
- }
-
- @Override
- public Set<Integer> testSet(Set<Integer> thing) {
- thing.addAll(thing.stream().map( x -> x + 100).collect(Collectors.toSet()));
- return thing;
- }
-
- @Override
- public Map<String, String> testStringMap(Map<String, String> thing) {
- thing.put("a", "123");
- thing.put(" x y ", " with spaces ");
- thing.put("same", "same");
- thing.put("0", "numeric key");
- thing.put("1", "");
- thing.put("ok", "2355555");
- thing.put("end", "0");
- return thing;
- }
- };
-
- private TProtocol initConfig(int maxSize) throws TException{
+ private final ServerTestBase.TestHandler testHandler =
+ new ServerTestBase.TestHandler() {
+ @Override
+ public String testString(String thing) {
+ thing = thing + " Apache Thrift Java " + thing;
+ return thing;
+ }
+
+ @Override
+ public List<Integer> testList(List<Integer> thing) {
+ thing.addAll(thing);
+ thing.addAll(thing);
+ return thing;
+ }
+
+ @Override
+ public Set<Integer> testSet(Set<Integer> thing) {
+ thing.addAll(thing.stream().map(x -> x + 100).collect(Collectors.toSet()));
+ return thing;
+ }
+
+ @Override
+ public Map<String, String> testStringMap(Map<String, String> thing) {
+ thing.put("a", "123");
+ thing.put(" x y ", " with spaces ");
+ thing.put("same", "same");
+ thing.put("0", "numeric key");
+ thing.put("1", "");
+ thing.put("ok", "2355555");
+ thing.put("end", "0");
+ return thing;
+ }
+ };
+
+ private TProtocol initConfig(int maxSize) throws TException {
TConfiguration config = TConfiguration.custom().setMaxMessageSize(maxSize).build();
TMemoryBuffer bufferTrans = new TMemoryBuffer(config, 0);
return getFactory().getProtocol(bufferTrans);
}
@Test
- public void testReadCheckMaxMessageRequestForString() throws TException{
+ public void testReadCheckMaxMessageRequestForString() throws TException {
TProtocol clientOutProto = initConfig(15);
TProtocol clientInProto = initConfig(15);
ThriftTest.Client testClient = new ThriftTest.Client(clientInProto, clientOutProto);
@@ -494,28 +520,32 @@ public abstract class ProtocolTestBase {
testClient.send_testString("test");
testProcessor.process(clientOutProto, clientInProto);
String result = testClient.recv_testString();
- System.out.println("----result: "+result);
+ System.out.println("----result: " + result);
} catch (TException e) {
assertEquals("MaxMessageSize reached", e.getMessage());
}
}
@Test
- public void testReadCheckMaxMessageRequestForList() throws TException{
+ public void testReadCheckMaxMessageRequestForList() throws TException {
TProtocol clientOutProto = initConfig(15);
TProtocol clientInProto = initConfig(15);
ThriftTest.Client testClient = new ThriftTest.Client(clientInProto, clientOutProto);
ThriftTest.Processor testProcessor = new ThriftTest.Processor(testHandler);
- TTransportException e = assertThrows(TTransportException.class, () -> {
- testClient.send_testList(Arrays.asList(1, 23242346, 888888, 90));
- testProcessor.process(clientOutProto, clientInProto);
- testClient.recv_testList();
- }, "Limitations not achieved as expected");
+ TTransportException e =
+ assertThrows(
+ TTransportException.class,
+ () -> {
+ testClient.send_testList(Arrays.asList(1, 23242346, 888888, 90));
+ testProcessor.process(clientOutProto, clientInProto);
+ testClient.recv_testList();
+ },
+ "Limitations not achieved as expected");
assertEquals("MaxMessageSize reached", e.getMessage());
}
@Test
- public void testReadCheckMaxMessageRequestForMap() throws TException{
+ public void testReadCheckMaxMessageRequestForMap() throws TException {
TProtocol clientOutProto = initConfig(13);
TProtocol clientInProto = initConfig(13);
ThriftTest.Client testClient = new ThriftTest.Client(clientInProto, clientOutProto);
@@ -523,27 +553,35 @@ public abstract class ProtocolTestBase {
Map<String, String> thing = new HashMap<>();
thing.put("key", "Thrift");
- TTransportException e = assertThrows(TTransportException.class, () -> {
- testClient.send_testStringMap(thing);
- testProcessor.process(clientOutProto, clientInProto);
- testClient.recv_testStringMap();
- }, "Limitations not achieved as expected");
+ TTransportException e =
+ assertThrows(
+ TTransportException.class,
+ () -> {
+ testClient.send_testStringMap(thing);
+ testProcessor.process(clientOutProto, clientInProto);
+ testClient.recv_testStringMap();
+ },
+ "Limitations not achieved as expected");
assertEquals("MaxMessageSize reached", e.getMessage());
}
@Test
- public void testReadCheckMaxMessageRequestForSet() throws TException{
+ public void testReadCheckMaxMessageRequestForSet() throws TException {
TProtocol clientOutProto = initConfig(10);
TProtocol clientInProto = initConfig(10);
ThriftTest.Client testClient = new ThriftTest.Client(clientInProto, clientOutProto);
ThriftTest.Processor testProcessor = new ThriftTest.Processor(testHandler);
TTransportException e =
- assertThrows(TTransportException.class, () -> {
- testClient.send_testSet(Stream.of(234, 0, 987087, 45, 88888888, 9).collect(Collectors.toSet()));
+ assertThrows(
+ TTransportException.class,
+ () -> {
+ testClient.send_testSet(
+ Stream.of(234, 0, 987087, 45, 88888888, 9).collect(Collectors.toSet()));
testProcessor.process(clientOutProto, clientInProto);
testClient.recv_testSet();
- }, "Limitations not achieved as expected");
+ },
+ "Limitations not achieved as expected");
assertEquals("MaxMessageSize reached", e.getMessage());
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestShortStack.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestShortStack.java
index 24541ebef..d2a458fb1 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/TestShortStack.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestShortStack.java
@@ -18,25 +18,24 @@
*/
package org.apache.thrift.protocol;
-
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
-public class TestShortStack {
+import org.junit.jupiter.api.Test;
+
+public class TestShortStack {
@Test
public void testOps() throws Exception {
ShortStack s = new ShortStack(1);
- s.push((short)10);
- s.push((short)11);
- s.push((short)12);
- assertEquals((short)12, s.pop());
- assertEquals((short)11, s.pop());
- s.push((short)40);
- assertEquals((short)40, s.pop());
- assertEquals((short)10, s.pop());
+ s.push((short) 10);
+ s.push((short) 11);
+ s.push((short) 12);
+ assertEquals((short) 12, s.pop());
+ assertEquals((short) 11, s.pop());
+ s.push((short) 40);
+ assertEquals((short) 40, s.pop());
+ assertEquals((short) 10, s.pop());
assertThrows(Exception.class, s::pop);
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestTBinaryProtocol.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestTBinaryProtocol.java
index acc46e9d8..0cfd9377a 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/TestTBinaryProtocol.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestTBinaryProtocol.java
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.thrift.protocol;
public class TestTBinaryProtocol extends ProtocolTestBase {
@@ -30,5 +29,4 @@ public class TestTBinaryProtocol extends ProtocolTestBase {
protected boolean canBeUsedNaked() {
return true;
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestTCompactProtocol.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestTCompactProtocol.java
index b2c29f7dd..4aa71db82 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/TestTCompactProtocol.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestTCompactProtocol.java
@@ -17,12 +17,10 @@
* under the License.
*/
-
package org.apache.thrift.protocol;
import org.apache.thrift.TDeserializer;
import org.apache.thrift.TException;
-
import org.junit.jupiter.api.Test;
import thrift.test.Bonk;
@@ -41,14 +39,13 @@ public class TestTCompactProtocol extends ProtocolTestBase {
public void testOOMDenialOfService() throws Exception {
// Struct header, Integer.MAX_VALUE length, and only one real
// byte of data
- byte [] bytes = {24, -1, -1, -1, -17, 49};
- TDeserializer deser = new TDeserializer(new TCompactProtocol
- .Factory(1000));
+ byte[] bytes = {24, -1, -1, -1, -17, 49};
+ TDeserializer deser = new TDeserializer(new TCompactProtocol.Factory(1000));
Bonk bonk = new Bonk();
try {
- deser.deserialize(bonk, bytes);
+ deser.deserialize(bonk, bytes);
} catch (TException e) {
- // Ignore as we are only checking for OOM in the failure case
+ // Ignore as we are only checking for OOM in the failure case
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestTField.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestTField.java
index 62b8d3f66..0b71f47d2 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/TestTField.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestTField.java
@@ -18,13 +18,12 @@
*/
package org.apache.thrift.protocol;
-
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
-public abstract class TestTField {
+import org.junit.jupiter.api.Test;
+
+public abstract class TestTField {
@Test
public void testConstructor() {
@@ -33,7 +32,7 @@ public abstract class TestTField {
assertEquals(TType.STOP, uut.type);
assertEquals(0, uut.id);
- uut = new TField("foo", TType.VOID, (short)42);
+ uut = new TField("foo", TType.VOID, (short) 42);
assertEquals("foo", uut.name);
assertEquals(TType.VOID, uut.type);
assertEquals(42, uut.id);
@@ -46,20 +45,19 @@ public abstract class TestTField {
assertEquals(uut1, uut2);
assertEquals(uut1.hashCode(), uut2.hashCode());
- uut1 = new TField("foo", TType.I32, (short)1);
- uut2 = new TField("foo", TType.I32, (short)2);
+ uut1 = new TField("foo", TType.I32, (short) 1);
+ uut2 = new TField("foo", TType.I32, (short) 2);
assertNotEquals(uut1, uut2);
assertNotEquals(uut1.hashCode(), uut2.hashCode());
- uut1 = new TField("foo", TType.VOID, (short)1);
- uut2 = new TField("foo", TType.I32, (short)1);
+ uut1 = new TField("foo", TType.VOID, (short) 1);
+ uut2 = new TField("foo", TType.I32, (short) 1);
assertNotEquals(uut1, uut2);
assertNotEquals(uut1.hashCode(), uut2.hashCode());
- uut1 = new TField("foo", TType.VOID, (short)5);
- uut2 = new TField("bar", TType.I32, (short)5);
+ uut1 = new TField("foo", TType.VOID, (short) 5);
+ uut2 = new TField("bar", TType.I32, (short) 5);
assertEquals(uut1, uut2); // name field is ignored
assertEquals(uut1.hashCode(), uut2.hashCode());
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestTJSONProtocol.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestTJSONProtocol.java
index 993362993..9f5f4a09c 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/TestTJSONProtocol.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestTJSONProtocol.java
@@ -18,14 +18,13 @@
*/
package org.apache.thrift.protocol;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.nio.charset.StandardCharsets;
import org.apache.thrift.TException;
import org.apache.thrift.transport.TMemoryBuffer;
import org.junit.jupiter.api.Test;
-import java.nio.charset.StandardCharsets;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class TestTJSONProtocol extends ProtocolTestBase {
@Override
protected TProtocolFactory getFactory() {
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestTProtocolUtil.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestTProtocolUtil.java
index 937e9130e..f37627df7 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/TestTProtocolUtil.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestTProtocolUtil.java
@@ -18,27 +18,28 @@
*/
package org.apache.thrift.protocol;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.thrift.TSerializer;
import org.junit.jupiter.api.Test;
import thrift.test.GuessProtocolStruct;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class TestTProtocolUtil {
+public class TestTProtocolUtil {
@Test
public void testGuessProtocolFactory_JSON() throws Exception {
byte[] data = "{foo}".getBytes();
- TProtocolFactory factory = TProtocolUtil.guessProtocolFactory(data, new TCompactProtocol.Factory());
+ TProtocolFactory factory =
+ TProtocolUtil.guessProtocolFactory(data, new TCompactProtocol.Factory());
assertTrue(factory instanceof TJSONProtocol.Factory);
// Make sure data serialized with TCompact and which starts with '{'
// is not mistakenly guessed as serialized with JSON.
GuessProtocolStruct s = new GuessProtocolStruct();
- s.putToMap_field("}","}");
+ s.putToMap_field("}", "}");
byte[] ser = new TSerializer(new TCompactProtocol.Factory()).serialize(s);
factory = TProtocolUtil.guessProtocolFactory(ser, new TCompactProtocol.Factory());
assertFalse(factory instanceof TJSONProtocol.Factory);
@@ -51,13 +52,15 @@ public class TestTProtocolUtil {
byte[] buf = new byte[1];
for (int i = 1; i < 256; i++) {
buf[0] = (byte) i;
- TProtocolFactory factory = TProtocolUtil.guessProtocolFactory(buf, new TCompactProtocol.Factory());
+ TProtocolFactory factory =
+ TProtocolUtil.guessProtocolFactory(buf, new TCompactProtocol.Factory());
assertTrue(factory instanceof TBinaryProtocol.Factory);
}
// Check that a second byte set to 0 is reported as Binary
buf = new byte[2];
- TProtocolFactory factory = TProtocolUtil.guessProtocolFactory(buf, new TCompactProtocol.Factory());
+ TProtocolFactory factory =
+ TProtocolUtil.guessProtocolFactory(buf, new TCompactProtocol.Factory());
assertTrue(factory instanceof TBinaryProtocol.Factory);
}
@@ -66,7 +69,8 @@ public class TestTProtocolUtil {
// Check that a first byte > 0x10 is reported as Compact
byte[] buf = new byte[3];
buf[0] = 0x11;
- TProtocolFactory factory = TProtocolUtil.guessProtocolFactory(buf, new TBinaryProtocol.Factory());
+ TProtocolFactory factory =
+ TProtocolUtil.guessProtocolFactory(buf, new TBinaryProtocol.Factory());
assertTrue(factory instanceof TCompactProtocol.Factory);
// Check that second byte >= 0x80 is reported as Compact
@@ -82,7 +86,8 @@ public class TestTProtocolUtil {
public void testGuessProtocolFactory_Undecided() throws Exception {
byte[] buf = new byte[3];
buf[1] = 0x7e;
- TProtocolFactory factory = TProtocolUtil.guessProtocolFactory(buf, new TSimpleJSONProtocol.Factory());
+ TProtocolFactory factory =
+ TProtocolUtil.guessProtocolFactory(buf, new TSimpleJSONProtocol.Factory());
assertTrue(factory instanceof TSimpleJSONProtocol.Factory);
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java
index b1fc04e4f..7fe5ba769 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java
@@ -18,6 +18,10 @@
*/
package org.apache.thrift.protocol;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.nio.charset.StandardCharsets;
import org.apache.thrift.Fixtures;
import org.apache.thrift.TDeserializer;
import org.apache.thrift.TException;
@@ -28,11 +32,6 @@ import org.junit.jupiter.api.Test;
import thrift.test.CompactProtoTestStruct;
import thrift.test.HolyMoley;
-import java.nio.charset.StandardCharsets;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
public class TestTSimpleJSONProtocol {
private TMemoryBuffer buf;
private TSimpleJSONProtocol proto;
@@ -54,19 +53,25 @@ public class TestTSimpleJSONProtocol {
holyMoley.unsetBonks();
holyMoley.unsetContain();
holyMoley.write(proto);
- assertEquals("{\"big\":[{\"im_true\":1,\"im_false\":0,\"a_bite\":35,\"integer16\":27000,\"integer32\":16777216,\"integer64\":6000000000,\"double_precision\":3.141592653589793,\"some_characters\":\"JSON THIS! \\\"\\u0001\",\"zomg_unicode\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκ�‼\",\"what_who\":0,\"base64\":\"base64\",\"byte_list\":[1,2,3],\"i16_list\":[1,2,3],\"i64_list\":[1,2,3]},{\"im_true\":1,\"im_false\":0,\"a_bite\":-42,\"integer16\":27000,\"integer32\":16777216,\"integer64\":6000000000,\"double_precision\":3.141592653589793,\"some_characters\":\"JSON THIS! \\\"\\u0001\",\"zomg_unicode\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκ�‼\",\"what_who\":0,\"base64\":\"base64\",\"byte_list\":[1,2,3],\"i16_list\":[1,2,3],\"i64_list\":[1,2,3]}]}", bufToString());
+ assertEquals(
+ "{\"big\":[{\"im_true\":1,\"im_false\":0,\"a_bite\":35,\"integer16\":27000,\"integer32\":16777216,\"integer64\":6000000000,\"double_precision\":3.141592653589793,\"some_characters\":\"JSON THIS! \\\"\\u0001\",\"zomg_unicode\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκ�‼\",\"what_who\":0,\"base64\":\"base64\",\"byte_list\":[1,2,3],\"i16_list\":[1,2,3],\"i64_list\":[1,2,3]},{\"im_true\":1,\"im_false\":0,\"a_bite\":-42,\"integer16\":27000,\"integer32\":16777216,\"integer64\":6000000000,\"double_precision\":3.141592653589793,\"some_characters\":\"JSON THIS! \\\"\\u0001\",\"zomg_unicode\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκ�‼\",\"what_who\":0,\"base64\":\"base64\",\"byte_list\":[1,2,3],\"i16_list\":[1,2,3],\"i64_list\":[1,2,3]}]}",
+ bufToString());
}
@Test
public void testNesting() throws TException {
Fixtures.getNesting().write(proto);
- assertEquals("{\"my_bonk\":{\"type\":31337,\"message\":\"I am a bonk... xor!\"},\"my_ooe\":{\"im_true\":1,\"im_false\":0,\"a_bite\":-42,\"integer16\":27000,\"integer32\":16777216,\"integer64\":6000000000,\"double_precision\":3.141592653589793,\"some_characters\":\"JSON THIS! \\\"\\u0001\",\"zomg_unicode\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκ�‼\",\"what_who\":0,\"base64\":\"base64\",\"byte_list\":[1,2,3],\"i16_list\":[1,2,3],\"i64_list\":[1,2,3]}}", bufToString());
+ assertEquals(
+ "{\"my_bonk\":{\"type\":31337,\"message\":\"I am a bonk... xor!\"},\"my_ooe\":{\"im_true\":1,\"im_false\":0,\"a_bite\":-42,\"integer16\":27000,\"integer32\":16777216,\"integer64\":6000000000,\"double_precision\":3.141592653589793,\"some_characters\":\"JSON THIS! \\\"\\u0001\",\"zomg_unicode\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκ�‼\",\"what_who\":0,\"base64\":\"base64\",\"byte_list\":[1,2,3],\"i16_list\":[1,2,3],\"i64_list\":[1,2,3]}}",
+ bufToString());
}
@Test
public void testOneOfEach() throws TException {
Fixtures.getOneOfEach().write(proto);
- assertEquals("{\"im_true\":1,\"im_false\":0,\"a_bite\":-42,\"integer16\":27000,\"integer32\":16777216,\"integer64\":6000000000,\"double_precision\":3.141592653589793,\"some_characters\":\"JSON THIS! \\\"\\u0001\",\"zomg_unicode\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκ�‼\",\"what_who\":0,\"base64\":\"base64\",\"byte_list\":[1,2,3],\"i16_list\":[1,2,3],\"i64_list\":[1,2,3]}", bufToString());
+ assertEquals(
+ "{\"im_true\":1,\"im_false\":0,\"a_bite\":-42,\"integer16\":27000,\"integer32\":16777216,\"integer64\":6000000000,\"double_precision\":3.141592653589793,\"some_characters\":\"JSON THIS! \\\"\\u0001\",\"zomg_unicode\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκ�‼\",\"what_who\":0,\"base64\":\"base64\",\"byte_list\":[1,2,3],\"i16_list\":[1,2,3],\"i64_list\":[1,2,3]}",
+ bufToString());
}
@Test
@@ -88,21 +93,28 @@ public class TestTSimpleJSONProtocol {
struct.unsetDouble_byte_map();
struct.unsetString_byte_map();
struct.write(proto);
- assertEquals("{\"a_byte\":127,\"a_i16\":32000,\"a_i32\":1000000000,\"a_i64\":1099511627775,\"a_double\":5.6789,\"a_string\":\"my string\",\"a_binary\":\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\",\"true_field\":1,\"false_field\":0,\"empty_struct_field\":{},\"byte_list\":[-127,-1,0,1,127],\"i16_list\":[-1,0,1,32767],\"i32_list\":[-1,0,255,65535,16777215,2147483647],\"i64_list\":[-1,0,255,65535,16777215,4294967295,1099511627775,281474976710655,72057594037927935,9223372036854775807],\"double_list\":[0.1,0.2,0.3],\"string_list\":[\"first\",\"second\",\"third\"],\"boolean_list\":[1,1,1,0,0,0],\"struct_list\":[{},{}],\"i32_set\":[1,2,3],\"boolean_set\":[0,1],\"struct_set\":[{}],\"byte_byte_map\":{\"1\":2},\"boolean_byte_map\":{\"0\":0,\"1\":1},\"byte_i16_map\":{\"1\":1,\"2\":-1,\"3\":32767},\"byte_i32_map\":{\"1\":1,\"2\":-1,\"3\":2147483647},\"byte_i64_map\":{\"1\":1,\"2\":-1,\"3\":9223372036854775807},\"byte_double_map\":{\"1\":0.1,\"2\":-0.1,\"3\":1000000.1},\"byte_string_map\":{\"1\":\"\",\"2\":\"blah\",\"3\":\"loooooooooooooong string\"},\"byte_boolean_map\":{\"1\":1,\"2\":0},\"byte_map_map\":{\"0\":{},\"1\":{\"1\":1},\"2\":{\"1\":1,\"2\":2}},\"byte_set_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"byte_list_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"field500\":500,\"field5000\":5000,\"field20000\":20000}", bufToString());
+ assertEquals(
+ "{\"a_byte\":127,\"a_i16\":32000,\"a_i32\":1000000000,\"a_i64\":1099511627775,\"a_double\":5.6789,\"a_string\":\"my string\",\"a_binary\":\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\",\"true_field\":1,\"false_field\":0,\"empty_struct_field\":{},\"byte_list\":[-127,-1,0,1,127],\"i16_list\":[-1,0,1,32767],\"i32_list\":[-1,0,255,65535,16777215,2147483647],\"i64_list\":[-1,0,255,65535,16777215,4294967295,1099511627775,281474976710655,72057594037927935,9223372036854775807],\"double_list\":[0.1,0.2,0.3],\"string_list\":[\"first\",\"second\",\"third\"],\"boolean_list\":[1,1,1,0,0,0],\"struct_list\":[{},{}],\"i32_set\":[1,2,3],\"boolean_set\":[0,1],\"struct_set\":[{}],\"byte_byte_map\":{\"1\":2},\"boolean_byte_map\":{\"0\":0,\"1\":1},\"byte_i16_map\":{\"1\":1,\"2\":-1,\"3\":32767},\"byte_i32_map\":{\"1\":1,\"2\":-1,\"3\":2147483647},\"byte_i64_map\":{\"1\":1,\"2\":-1,\"3\":9223372036854775807},\"byte_double_map\":{\"1\":0.1,\"2\":-0.1,\"3\":1000000.1},\"byte_string_map\":{\"1\":\"\",\"2\":\"blah\",\"3\":\"loooooooooooooong string\"},\"byte_boolean_map\":{\"1\":1,\"2\":0},\"byte_map_map\":{\"0\":{},\"1\":{\"1\":1},\"2\":{\"1\":1,\"2\":2}},\"byte_set_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"byte_list_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"field500\":500,\"field5000\":5000,\"field20000\":20000}",
+ bufToString());
}
@Test
public void testThrowsOnCollectionKeys() throws TException {
- assertThrows(TSimpleJSONProtocol.CollectionMapKeyException.class, () -> Fixtures.getCompactProtoTestStruct().write(proto));
+ assertThrows(
+ TSimpleJSONProtocol.CollectionMapKeyException.class,
+ () -> Fixtures.getCompactProtoTestStruct().write(proto));
}
@Test
public void testReadingThrows() throws TTransportException {
String input = "{\"test\": \"value\"}";
TDeserializer deserializer = new TDeserializer(new TSimpleJSONProtocol.Factory());
- TException e = assertThrows(TException.class, ()->{
- deserializer.fromString(Fixtures.getOneOfEach(), input);
- });
+ TException e =
+ assertThrows(
+ TException.class,
+ () -> {
+ deserializer.fromString(Fixtures.getOneOfEach(), input);
+ });
assertEquals("Not implemented", e.getMessage());
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestTTupleProtocol.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestTTupleProtocol.java
index b0e3bcda5..f39ca65da 100644
--- a/lib/java/src/test/java/org/apache/thrift/protocol/TestTTupleProtocol.java
+++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestTTupleProtocol.java
@@ -5,7 +5,6 @@ import org.apache.thrift.TSerializer;
import org.junit.jupiter.api.Test;
import thrift.test.TupleProtocolTestStruct;
-
public class TestTTupleProtocol extends ProtocolTestBase {
@Override
@@ -23,6 +22,9 @@ public class TestTTupleProtocol extends ProtocolTestBase {
final TupleProtocolTestStruct t1 = new TupleProtocolTestStruct();
t1.setField1(0);
t1.setField2(12);
- new TDeserializer(new TTupleProtocol.Factory()).deserialize(new TupleProtocolTestStruct(), new TSerializer(new TTupleProtocol.Factory()).serialize(t1));
+ new TDeserializer(new TTupleProtocol.Factory())
+ .deserialize(
+ new TupleProtocolTestStruct(),
+ new TSerializer(new TTupleProtocol.Factory()).serialize(t1));
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/scheme/TestStandardScheme.java b/lib/java/src/test/java/org/apache/thrift/scheme/TestStandardScheme.java
index f5f0e0bb8..76efc6c48 100644
--- a/lib/java/src/test/java/org/apache/thrift/scheme/TestStandardScheme.java
+++ b/lib/java/src/test/java/org/apache/thrift/scheme/TestStandardScheme.java
@@ -1,5 +1,7 @@
package org.apache.thrift.scheme;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import org.apache.thrift.Fixtures;
import org.apache.thrift.TBase;
import org.apache.thrift.TDeserializer;
@@ -15,23 +17,22 @@ import thrift.test.HolyMoley;
import thrift.test.Nesting;
import thrift.test.OneOfEach;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class TestStandardScheme {
TSerializer serializer = new TSerializer();
TDeserializer deserializer = new TDeserializer();
- public TestStandardScheme() throws TTransportException {
- }
+ public TestStandardScheme() throws TTransportException {}
/**
- * This tests whether the Standard Scheme properly reads structs serialized
- * using an older version of thrift.
+ * This tests whether the Standard Scheme properly reads structs serialized using an older version
+ * of thrift.
*/
@Test
public void testPersistentStructs() throws TException {
- readAndCompare(new OneOfEach(), Fixtures.getOneOfEach(), Fixtures.getPersistentBytesOneOfEach());
- readAndCompare(new HolyMoley(), Fixtures.getHolyMoley(), Fixtures.getPersistentBytesHolyMoley());
+ readAndCompare(
+ new OneOfEach(), Fixtures.getOneOfEach(), Fixtures.getPersistentBytesOneOfEach());
+ readAndCompare(
+ new HolyMoley(), Fixtures.getHolyMoley(), Fixtures.getPersistentBytesHolyMoley());
readAndCompare(new Nesting(), Fixtures.getNesting(), Fixtures.getPersistentBytesNesting());
}
diff --git a/lib/java/src/test/java/org/apache/thrift/server/ServerTestBase.java b/lib/java/src/test/java/org/apache/thrift/server/ServerTestBase.java
index 3c40262b4..a1e19ebdf 100644
--- a/lib/java/src/test/java/org/apache/thrift/server/ServerTestBase.java
+++ b/lib/java/src/test/java/org/apache/thrift/server/ServerTestBase.java
@@ -18,6 +18,17 @@
*/
package org.apache.thrift.server;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.thrift.TException;
import org.apache.thrift.TProcessor;
import org.apache.thrift.async.AsyncMethodCallback;
@@ -40,19 +51,7 @@ import thrift.test.Xception2;
import thrift.test.Xtruct;
import thrift.test.Xtruct2;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public abstract class ServerTestBase {
+public abstract class ServerTestBase {
public static class TestHandler implements ThriftTest.Iface {
@@ -103,12 +102,12 @@ public abstract class ServerTestBase {
public ByteBuffer testBinary(ByteBuffer thing) {
StringBuilder sb = new StringBuilder(thing.remaining() * 3);
thing.mark();
- int limit = 0; // limit output to keep the log size sane
+ int limit = 0; // limit output to keep the log size sane
while ((thing.remaining() > 0) && (++limit < 1024)) {
sb.append(String.format("%02X ", thing.get()));
}
- if(thing.remaining() > 0) {
- sb.append("..."); // indicate we have more date
+ if (thing.remaining() > 0) {
+ sb.append("..."); // indicate we have more date
}
System.out.print("testBinary(" + sb + ")\n");
thing.reset();
@@ -117,29 +116,43 @@ public abstract class ServerTestBase {
@Override
public Xtruct testStruct(Xtruct thing) {
- System.out.print("testStruct({" +
- "\"" + thing.string_thing + "\", " +
- thing.byte_thing + ", " +
- thing.i32_thing + ", " +
- thing.i64_thing + "})\n");
+ System.out.print(
+ "testStruct({"
+ + "\""
+ + thing.string_thing
+ + "\", "
+ + thing.byte_thing
+ + ", "
+ + thing.i32_thing
+ + ", "
+ + thing.i64_thing
+ + "})\n");
return thing;
}
@Override
public Xtruct2 testNest(Xtruct2 nest) {
Xtruct thing = nest.struct_thing;
- System.out.print("testNest({" +
- nest.byte_thing + ", {" +
- "\"" + thing.string_thing + "\", " +
- thing.byte_thing + ", " +
- thing.i32_thing + ", " +
- thing.i64_thing + "}, " +
- nest.i32_thing + "})\n");
+ System.out.print(
+ "testNest({"
+ + nest.byte_thing
+ + ", {"
+ + "\""
+ + thing.string_thing
+ + "\", "
+ + thing.byte_thing
+ + ", "
+ + thing.i32_thing
+ + ", "
+ + thing.i64_thing
+ + "}, "
+ + nest.i32_thing
+ + "})\n");
return nest;
}
@Override
- public Map<Integer,Integer> testMap(Map<Integer,Integer> thing) {
+ public Map<Integer, Integer> testMap(Map<Integer, Integer> thing) {
System.out.print("testMap({");
System.out.print(thing);
System.out.print("})\n");
@@ -147,7 +160,7 @@ public abstract class ServerTestBase {
}
@Override
- public Map<String,String> testStringMap(Map<String,String> thing) {
+ public Map<String, String> testStringMap(Map<String, String> thing) {
System.out.print("testStringMap({");
System.out.print(thing);
System.out.print("})\n");
@@ -199,13 +212,12 @@ public abstract class ServerTestBase {
}
@Override
- public Map<Integer,Map<Integer,Integer>> testMapMap(int hello) {
+ public Map<Integer, Map<Integer, Integer>> testMapMap(int hello) {
System.out.print("testMapMap(" + hello + ")\n");
- Map<Integer,Map<Integer,Integer>> mapmap =
- new HashMap<>();
+ Map<Integer, Map<Integer, Integer>> mapmap = new HashMap<>();
- HashMap<Integer,Integer> pos = new HashMap<>();
- HashMap<Integer,Integer> neg = new HashMap<>();
+ HashMap<Integer, Integer> pos = new HashMap<>();
+ HashMap<Integer, Integer> neg = new HashMap<>();
for (int i = 1; i < 5; i++) {
pos.put(i, i);
neg.put(-i, -i);
@@ -218,11 +230,11 @@ public abstract class ServerTestBase {
}
@Override
- public Map<Long, Map<Numberz,Insanity>> testInsanity(Insanity argument) {
+ public Map<Long, Map<Numberz, Insanity>> testInsanity(Insanity argument) {
System.out.print("testInsanity()\n");
- HashMap<Numberz,Insanity> first_map = new HashMap<>();
- HashMap<Numberz,Insanity> second_map = new HashMap<>();
+ HashMap<Numberz, Insanity> first_map = new HashMap<>();
+ HashMap<Numberz, Insanity> second_map = new HashMap<>();
first_map.put(Numberz.TWO, argument);
first_map.put(Numberz.THREE, argument);
@@ -230,16 +242,16 @@ public abstract class ServerTestBase {
Insanity looney = new Insanity();
second_map.put(Numberz.SIX, looney);
- Map<Long,Map<Numberz,Insanity>> insane =
- new HashMap<>();
- insane.put((long)1, first_map);
- insane.put((long)2, second_map);
+ Map<Long, Map<Numberz, Insanity>> insane = new HashMap<>();
+ insane.put((long) 1, first_map);
+ insane.put((long) 2, second_map);
return insane;
}
@Override
- public Xtruct testMulti(byte arg0, int arg1, long arg2, Map<Short,String> arg3, Numberz arg4, long arg5) {
+ public Xtruct testMulti(
+ byte arg0, int arg1, long arg2, Map<Short, String> arg3, Numberz arg4, long arg5) {
System.out.print("testMulti()\n");
Xtruct hello = new Xtruct();
@@ -252,7 +264,7 @@ public abstract class ServerTestBase {
@Override
public void testException(String arg) throws TException {
- System.out.print("testException("+arg+")\n");
+ System.out.print("testException(" + arg + ")\n");
if ("Xception".equals(arg)) {
Xception x = new Xception();
x.errorCode = 1001;
@@ -291,8 +303,7 @@ public abstract class ServerTestBase {
@Override
public void testOneway(int sleepFor) {
- System.out.println("testOneway(" + sleepFor +
- ") => sleeping...");
+ System.out.println("testOneway(" + sleepFor + ") => sleeping...");
try {
Thread.sleep(sleepFor * SLEEP_DELAY);
System.out.println("Done sleeping!");
@@ -302,23 +313,23 @@ public abstract class ServerTestBase {
}
} // class TestHandler
- private static final List<TProtocolFactory> PROTOCOLS = Arrays.asList(
- new TBinaryProtocol.Factory(),
- new TCompactProtocol.Factory());
+ private static final List<TProtocolFactory> PROTOCOLS =
+ Arrays.asList(new TBinaryProtocol.Factory(), new TCompactProtocol.Factory());
public static final String HOST = "localhost";
- public static final int PORT = Integer.parseInt(
- System.getProperty("test.port", "9090"));
+ public static final int PORT = Integer.parseInt(System.getProperty("test.port", "9090"));
protected static final long SLEEP_DELAY = 1000;
protected static final int SOCKET_TIMEOUT = 1500;
private static final Xtruct XSTRUCT = new Xtruct("Zero", (byte) 1, -3, -5);
- private static final Xtruct2 XSTRUCT2 = new Xtruct2((byte)1, XSTRUCT, 5);
+ private static final Xtruct2 XSTRUCT2 = new Xtruct2((byte) 1, XSTRUCT, 5);
- public void startServer(TProcessor processor, TProtocolFactory protoFactory) throws Exception{
+ public void startServer(TProcessor processor, TProtocolFactory protoFactory) throws Exception {
startServer(processor, protoFactory, null);
}
- public abstract void startServer(TProcessor processor, TProtocolFactory protoFactory, TTransportFactory factory) throws Exception;
+ public abstract void startServer(
+ TProcessor processor, TProtocolFactory protoFactory, TTransportFactory factory)
+ throws Exception;
public abstract void stopServer() throws Exception;
@@ -332,7 +343,7 @@ public abstract class ServerTestBase {
}
private void testByte(ThriftTest.Client testClient) throws TException {
- byte i8 = testClient.testByte((byte)1);
+ byte i8 = testClient.testByte((byte) 1);
assertEquals(1, i8);
}
@@ -365,20 +376,19 @@ public abstract class ServerTestBase {
insane = new Insanity();
insane.userMap = new HashMap<>();
- insane.userMap.put(Numberz.FIVE, (long)5000);
+ insane.userMap.put(Numberz.FIVE, (long) 5000);
Xtruct truck = new Xtruct();
truck.string_thing = "Truck";
- truck.byte_thing = (byte)8;
+ truck.byte_thing = (byte) 8;
truck.i32_thing = 8;
truck.i64_thing = 8;
insane.xtructs = new ArrayList<>();
insane.xtructs.add(truck);
System.out.print("testInsanity()");
- Map<Long,Map<Numberz,Insanity>> whoa =
- testClient.testInsanity(insane);
+ Map<Long, Map<Numberz, Insanity>> whoa = testClient.testInsanity(insane);
System.out.print(" = {");
for (long key : whoa.keySet()) {
- Map<Numberz,Insanity> val = whoa.get(key);
+ Map<Numberz, Insanity> val = whoa.get(key);
System.out.print(key + " => {");
for (Numberz k2 : val.keySet()) {
@@ -397,7 +407,17 @@ public abstract class ServerTestBase {
System.out.print("{");
if (xtructs != null) {
for (Xtruct x : xtructs) {
- System.out.print("{" + "\"" + x.string_thing + "\", " + x.byte_thing + ", " + x.i32_thing + ", "+ x.i64_thing + "}, ");
+ System.out.print(
+ "{"
+ + "\""
+ + x.string_thing
+ + "\", "
+ + x.byte_thing
+ + ", "
+ + x.i32_thing
+ + ", "
+ + x.i64_thing
+ + "}, ");
}
}
System.out.print("}");
@@ -410,14 +430,17 @@ public abstract class ServerTestBase {
}
public boolean useAsyncProcessor() {
- return false;
+ return false;
}
@Test
public void testIt() throws Exception {
for (TProtocolFactory protoFactory : getProtocols()) {
- TProcessor processor = useAsyncProcessor() ? new ThriftTest.AsyncProcessor<>(new AsyncTestHandler()) : new ThriftTest.Processor<>(new TestHandler());
+ TProcessor processor =
+ useAsyncProcessor()
+ ? new ThriftTest.AsyncProcessor<>(new AsyncTestHandler())
+ : new ThriftTest.Processor<>(new TestHandler());
startServer(processor, protoFactory);
@@ -474,32 +497,30 @@ public abstract class ServerTestBase {
}
private void testMap(ThriftTest.Client testClient) throws TException {
- Map<Integer,Integer> mapout = new HashMap<>();
+ Map<Integer, Integer> mapout = new HashMap<>();
for (int i = 0; i < 5; ++i) {
- mapout.put(i, i-10);
+ mapout.put(i, i - 10);
}
- Map<Integer,Integer> mapin = testClient.testMap(mapout);
+ Map<Integer, Integer> mapin = testClient.testMap(mapout);
assertEquals(mapout, mapin);
}
private void testStringMap(ThriftTest.Client testClient) throws TException {
- Map<String,String> mapout = new HashMap<>();
+ Map<String, String> mapout = new HashMap<>();
mapout.put("a", "123");
mapout.put(" x y ", " with spaces ");
mapout.put("same", "same");
mapout.put("0", "numeric key");
- Map<String,String> mapin = testClient.testStringMap(mapout);
+ Map<String, String> mapin = testClient.testStringMap(mapout);
assertEquals(mapout, mapin);
}
private void testNestedMap(ThriftTest.Client testClient) throws TException {
- Map<Integer,Map<Integer,Integer>> mm =
- testClient.testMapMap(1);
- Map<Integer,Map<Integer,Integer>> mapmap =
- new HashMap<>();
+ Map<Integer, Map<Integer, Integer>> mm = testClient.testMapMap(1);
+ Map<Integer, Map<Integer, Integer>> mapmap = new HashMap<>();
- HashMap<Integer,Integer> pos = new HashMap<>();
- HashMap<Integer,Integer> neg = new HashMap<>();
+ HashMap<Integer, Integer> pos = new HashMap<>();
+ HashMap<Integer, Integer> neg = new HashMap<>();
for (int i = 1; i < 5; i++) {
pos.put(i, i);
neg.put(-i, -i);
@@ -569,7 +590,8 @@ public abstract class ServerTestBase {
TestHandler handler = new TestHandler();
ThriftTest.Processor<TestHandler> processor = new ThriftTest.Processor<>(handler);
- final CallCountingTransportFactory factory = new CallCountingTransportFactory(new TFramedTransport.Factory());
+ final CallCountingTransportFactory factory =
+ new CallCountingTransportFactory(new TFramedTransport.Factory());
startServer(processor, protoFactory, factory);
assertEquals(0, factory.count);
@@ -592,19 +614,18 @@ public abstract class ServerTestBase {
try {
testClient.testException("Xception");
assert false;
- } catch(Xception e) {
+ } catch (Xception e) {
assertEquals(e.message, "Xception");
assertEquals(e.errorCode, 1001);
}
try {
testClient.testException("TException");
assert false;
- } catch(TException e) {
+ } catch (TException e) {
}
testClient.testException("no Exception");
}
-
public static class AsyncTestHandler implements ThriftTest.AsyncIface {
TestHandler handler = new TestHandler();
@@ -615,12 +636,14 @@ public abstract class ServerTestBase {
}
@Override
- public void testString(String thing, AsyncMethodCallback<String> resultHandler) throws TException {
+ public void testString(String thing, AsyncMethodCallback<String> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testString(thing));
}
@Override
- public void testBool(boolean thing, AsyncMethodCallback<Boolean> resultHandler) throws TException {
+ public void testBool(boolean thing, AsyncMethodCallback<Boolean> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testBool(thing));
}
@@ -640,47 +663,58 @@ public abstract class ServerTestBase {
}
@Override
- public void testDouble(double thing, AsyncMethodCallback<Double> resultHandler) throws TException {
+ public void testDouble(double thing, AsyncMethodCallback<Double> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testDouble(thing));
}
@Override
- public void testBinary(ByteBuffer thing, AsyncMethodCallback<ByteBuffer> resultHandler) throws TException {
+ public void testBinary(ByteBuffer thing, AsyncMethodCallback<ByteBuffer> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testBinary(thing));
}
@Override
- public void testStruct(Xtruct thing, AsyncMethodCallback<Xtruct> resultHandler) throws TException {
+ public void testStruct(Xtruct thing, AsyncMethodCallback<Xtruct> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testStruct(thing));
}
@Override
- public void testNest(Xtruct2 thing, AsyncMethodCallback<Xtruct2> resultHandler) throws TException {
+ public void testNest(Xtruct2 thing, AsyncMethodCallback<Xtruct2> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testNest(thing));
}
@Override
- public void testMap(Map<Integer, Integer> thing, AsyncMethodCallback<Map<Integer, Integer>> resultHandler) throws TException {
+ public void testMap(
+ Map<Integer, Integer> thing, AsyncMethodCallback<Map<Integer, Integer>> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testMap(thing));
}
@Override
- public void testStringMap(Map<String, String> thing, AsyncMethodCallback<Map<String, String>> resultHandler) throws TException {
+ public void testStringMap(
+ Map<String, String> thing, AsyncMethodCallback<Map<String, String>> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testStringMap(thing));
}
@Override
- public void testSet(Set<Integer> thing, AsyncMethodCallback<Set<Integer>> resultHandler) throws TException {
+ public void testSet(Set<Integer> thing, AsyncMethodCallback<Set<Integer>> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testSet(thing));
}
@Override
- public void testList(List<Integer> thing, AsyncMethodCallback<List<Integer>> resultHandler) throws TException {
+ public void testList(List<Integer> thing, AsyncMethodCallback<List<Integer>> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testList(thing));
}
@Override
- public void testEnum(Numberz thing, AsyncMethodCallback<Numberz> resultHandler) throws TException {
+ public void testEnum(Numberz thing, AsyncMethodCallback<Numberz> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testEnum(thing));
}
@@ -690,23 +724,36 @@ public abstract class ServerTestBase {
}
@Override
- public void testMapMap(int hello, AsyncMethodCallback<Map<Integer,Map<Integer,Integer>>> resultHandler) throws TException {
+ public void testMapMap(
+ int hello, AsyncMethodCallback<Map<Integer, Map<Integer, Integer>>> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testMapMap(hello));
}
@Override
- public void testInsanity(Insanity argument, AsyncMethodCallback<Map<Long, Map<Numberz,Insanity>>> resultHandler) throws TException {
+ public void testInsanity(
+ Insanity argument, AsyncMethodCallback<Map<Long, Map<Numberz, Insanity>>> resultHandler)
+ throws TException {
resultHandler.onComplete(handler.testInsanity(argument));
}
@Override
- public void testMulti(byte arg0, int arg1, long arg2, Map<Short, String> arg3, Numberz arg4, long arg5, AsyncMethodCallback<Xtruct> resultHandler) throws TException {
- resultHandler.onComplete(handler.testMulti(arg0,arg1,arg2,arg3,arg4,arg5));
+ public void testMulti(
+ byte arg0,
+ int arg1,
+ long arg2,
+ Map<Short, String> arg3,
+ Numberz arg4,
+ long arg5,
+ AsyncMethodCallback<Xtruct> resultHandler)
+ throws TException {
+ resultHandler.onComplete(handler.testMulti(arg0, arg1, arg2, arg3, arg4, arg5));
}
@Override
- public void testException(String arg, AsyncMethodCallback<Void> resultHandler) throws TException {
- System.out.print("testException("+arg+")\n");
+ public void testException(String arg, AsyncMethodCallback<Void> resultHandler)
+ throws TException {
+ System.out.print("testException(" + arg + ")\n");
if ("Xception".equals(arg)) {
Xception x = new Xception();
x.errorCode = 1001;
@@ -726,15 +773,16 @@ public abstract class ServerTestBase {
}
@Override
- public void testMultiException(String arg0, String arg1, AsyncMethodCallback<Xtruct> resultHandler) throws TException {
- //To change body of implemented methods use File | Settings | File Templates.
+ public void testMultiException(
+ String arg0, String arg1, AsyncMethodCallback<Xtruct> resultHandler) throws TException {
+ // To change body of implemented methods use File | Settings | File Templates.
}
@Override
- public void testOneway(int secondsToSleep, AsyncMethodCallback<Void> resultHandler) throws TException {
+ public void testOneway(int secondsToSleep, AsyncMethodCallback<Void> resultHandler)
+ throws TException {
handler.testOneway(secondsToSleep);
resultHandler.onComplete(null);
}
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/server/TestAsyncServer.java b/lib/java/src/test/java/org/apache/thrift/server/TestAsyncServer.java
index 29c54cbbc..f8b538304 100644
--- a/lib/java/src/test/java/org/apache/thrift/server/TestAsyncServer.java
+++ b/lib/java/src/test/java/org/apache/thrift/server/TestAsyncServer.java
@@ -20,9 +20,8 @@ package org.apache.thrift.server;
public class TestAsyncServer extends TestNonblockingServer {
- @Override
- public boolean useAsyncProcessor(){
- return true;
- }
-
+ @Override
+ public boolean useAsyncProcessor() {
+ return true;
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/server/TestHsHaServer.java b/lib/java/src/test/java/org/apache/thrift/server/TestHsHaServer.java
index 6638a333f..2ea818d7e 100644
--- a/lib/java/src/test/java/org/apache/thrift/server/TestHsHaServer.java
+++ b/lib/java/src/test/java/org/apache/thrift/server/TestHsHaServer.java
@@ -24,7 +24,8 @@ import org.apache.thrift.server.THsHaServer.Args;
import org.apache.thrift.transport.TNonblockingServerSocket;
public class TestHsHaServer extends TestNonblockingServer {
- protected TServer getServer(TProcessor processor, TNonblockingServerSocket socket, TProtocolFactory protoFactory) {
+ protected TServer getServer(
+ TProcessor processor, TNonblockingServerSocket socket, TProtocolFactory protoFactory) {
return new THsHaServer(new Args(socket).processor(processor).protocolFactory(protoFactory));
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/server/TestNonblockingServer.java b/lib/java/src/test/java/org/apache/thrift/server/TestNonblockingServer.java
index 927635b61..29a81ef80 100644
--- a/lib/java/src/test/java/org/apache/thrift/server/TestNonblockingServer.java
+++ b/lib/java/src/test/java/org/apache/thrift/server/TestNonblockingServer.java
@@ -18,6 +18,8 @@
*/
package org.apache.thrift.server;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
@@ -31,15 +33,17 @@ import org.apache.thrift.transport.layered.TFramedTransport;
import org.junit.jupiter.api.Test;
import thrift.test.ThriftTest;
-import static org.junit.jupiter.api.Assertions.fail;
-
public class TestNonblockingServer extends ServerTestBase {
private Thread serverThread;
private TServer server;
private static final int NUM_QUERIES = 1000;
- protected TServer getServer(TProcessor processor, TNonblockingServerSocket socket, TProtocolFactory protoFactory, TTransportFactory factory) {
+ protected TServer getServer(
+ TProcessor processor,
+ TNonblockingServerSocket socket,
+ TProtocolFactory protoFactory,
+ TTransportFactory factory) {
final Args args = new Args(socket).processor(processor).protocolFactory(protoFactory);
if (factory != null) {
args.transportFactory(factory);
@@ -48,25 +52,32 @@ public class TestNonblockingServer extends ServerTestBase {
}
@Override
- public void startServer(final TProcessor processor, final TProtocolFactory protoFactory, final TTransportFactory factory) throws Exception {
- serverThread = new Thread() {
- public void run() {
- try {
- // Transport
- TNonblockingServerSocket tServerSocket =
- new TNonblockingServerSocket(new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs().port(PORT));
-
- server = getServer(processor, tServerSocket, protoFactory, factory);
-
- // Run it
- System.out.println("Starting the server on port " + PORT + "...");
- server.serve();
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- }
- }
- };
+ public void startServer(
+ final TProcessor processor,
+ final TProtocolFactory protoFactory,
+ final TTransportFactory factory)
+ throws Exception {
+ serverThread =
+ new Thread() {
+ public void run() {
+ try {
+ // Transport
+ TNonblockingServerSocket tServerSocket =
+ new TNonblockingServerSocket(
+ new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs()
+ .port(PORT));
+
+ server = getServer(processor, tServerSocket, protoFactory, factory);
+
+ // Run it
+ System.out.println("Starting the server on port " + PORT + "...");
+ server.serve();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ };
serverThread.start();
Thread.sleep(1000);
}
@@ -76,7 +87,8 @@ public class TestNonblockingServer extends ServerTestBase {
server.stop();
try {
serverThread.join();
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ }
}
@Override
@@ -84,7 +96,6 @@ public class TestNonblockingServer extends ServerTestBase {
return new TFramedTransport(underlyingTransport);
}
-
@Test
public void testCleanupAllSelectionKeys() throws Exception {
for (TProtocolFactory protoFactory : getProtocols()) {
@@ -109,7 +120,7 @@ public class TestNonblockingServer extends ServerTestBase {
for (int i = 0; i < NUM_QUERIES; ++i) {
try {
testClient.testI32(1);
- } catch(TTransportException e) {
+ } catch (TTransportException e) {
System.err.println(e);
e.printStackTrace();
if (e.getCause() instanceof java.net.SocketTimeoutException) {
diff --git a/lib/java/src/test/java/org/apache/thrift/server/TestSaslNonblockingServer.java b/lib/java/src/test/java/org/apache/thrift/server/TestSaslNonblockingServer.java
index fb7bbdc13..42afcd3c7 100644
--- a/lib/java/src/test/java/org/apache/thrift/server/TestSaslNonblockingServer.java
+++ b/lib/java/src/test/java/org/apache/thrift/server/TestSaslNonblockingServer.java
@@ -19,6 +19,10 @@
package org.apache.thrift.server;
+import static org.apache.thrift.transport.sasl.TSaslNegotiationException.ErrorType.AUTHENTICATION_FAILURE;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
@@ -34,26 +38,28 @@ import org.apache.thrift.transport.sasl.TSaslNegotiationException;
import org.junit.jupiter.api.Test;
import thrift.test.ThriftTest;
-import static org.apache.thrift.transport.sasl.TSaslNegotiationException.ErrorType.AUTHENTICATION_FAILURE;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class TestSaslNonblockingServer extends TestTSaslTransports.TestTSaslTransportsWithServer {
private TSaslNonblockingServer server;
@Override
- public void startServer(TProcessor processor, TProtocolFactory protoFactory, TTransportFactory factory)
+ public void startServer(
+ TProcessor processor, TProtocolFactory protoFactory, TTransportFactory factory)
throws Exception {
- TNonblockingServerTransport serverSocket = new TNonblockingServerSocket(
- new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs().port(PORT));
- TSaslNonblockingServer.Args args = new TSaslNonblockingServer.Args(serverSocket)
- .processor(processor)
- .transportFactory(factory)
- .protocolFactory(protoFactory)
- .addSaslMechanism(TestTSaslTransports.WRAPPED_MECHANISM, TestTSaslTransports.SERVICE,
- TestTSaslTransports.HOST, TestTSaslTransports.WRAPPED_PROPS,
- new TestSaslCallbackHandler(TestTSaslTransports.PASSWORD));
+ TNonblockingServerTransport serverSocket =
+ new TNonblockingServerSocket(
+ new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs().port(PORT));
+ TSaslNonblockingServer.Args args =
+ new TSaslNonblockingServer.Args(serverSocket)
+ .processor(processor)
+ .transportFactory(factory)
+ .protocolFactory(protoFactory)
+ .addSaslMechanism(
+ TestTSaslTransports.WRAPPED_MECHANISM,
+ TestTSaslTransports.SERVICE,
+ TestTSaslTransports.HOST,
+ TestTSaslTransports.WRAPPED_PROPS,
+ new TestSaslCallbackHandler(TestTSaslTransports.PASSWORD));
server = new TSaslNonblockingServer(args);
server.serve();
}
@@ -77,14 +83,25 @@ public class TestSaslNonblockingServer extends TestTSaslTransports.TestTSaslTran
TSocket socket = new TSocket(HOST, PORT);
socket.setTimeout(SOCKET_TIMEOUT);
- try (TSaslClientTransport client = new TSaslClientTransport(TestTSaslTransports.WRAPPED_MECHANISM,
- TestTSaslTransports.PRINCIPAL, TestTSaslTransports.SERVICE, TestTSaslTransports.HOST,
- TestTSaslTransports.WRAPPED_PROPS, new TestSaslCallbackHandler("bad_password"), socket)) {
- TTransportException error = assertThrows(TTransportException.class, client::open, "Client should fail with sasl negotiation.");
- TSaslNegotiationException serverSideError = new TSaslNegotiationException(AUTHENTICATION_FAILURE,
+ try (TSaslClientTransport client =
+ new TSaslClientTransport(
+ TestTSaslTransports.WRAPPED_MECHANISM,
+ TestTSaslTransports.PRINCIPAL,
+ TestTSaslTransports.SERVICE,
+ TestTSaslTransports.HOST,
+ TestTSaslTransports.WRAPPED_PROPS,
+ new TestSaslCallbackHandler("bad_password"),
+ socket)) {
+ TTransportException error =
+ assertThrows(
+ TTransportException.class, client::open, "Client should fail with sasl negotiation.");
+ TSaslNegotiationException serverSideError =
+ new TSaslNegotiationException(
+ AUTHENTICATION_FAILURE,
"Authentication failed with " + TestTSaslTransports.WRAPPED_MECHANISM);
- assertTrue(error.getMessage().contains(serverSideError.getSummary()),
- "Server should return error message \"" + serverSideError.getSummary() + "\"");
+ assertTrue(
+ error.getMessage().contains(serverSideError.getSummary()),
+ "Server should return error message \"" + serverSideError.getSummary() + "\"");
} finally {
stopServer();
}
diff --git a/lib/java/src/test/java/org/apache/thrift/server/TestThreadPoolServer.java b/lib/java/src/test/java/org/apache/thrift/server/TestThreadPoolServer.java
index f532ed4c2..74205c735 100644
--- a/lib/java/src/test/java/org/apache/thrift/server/TestThreadPoolServer.java
+++ b/lib/java/src/test/java/org/apache/thrift/server/TestThreadPoolServer.java
@@ -19,6 +19,10 @@
package org.apache.thrift.server;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.ThreadPoolExecutor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
@@ -26,16 +30,9 @@ import org.apache.thrift.transport.TSocket;
import org.junit.jupiter.api.Test;
import thrift.test.ThriftTest;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class TestThreadPoolServer {
- /**
- * Test server is shut down properly even with some open clients.
- */
+ /** Test server is shut down properly even with some open clients. */
@Test
public void testStopServerWithOpenClient() throws Exception {
TServerSocket serverSocket = new TServerSocket(0, 3000);
@@ -53,7 +50,8 @@ public class TestThreadPoolServer {
assertTrue(server.waitForShutdown());
// After server is stopped, the executor thread pool should be shut down
- assertTrue(server.getExecutorService().isTerminated(), "Server thread pool should be terminated");
+ assertTrue(
+ server.getExecutorService().isTerminated(), "Server thread pool should be terminated");
// TODO: The socket is actually closed (timeout) but the client code
// ignores the timeout Exception and maintains the socket open state
@@ -62,9 +60,10 @@ public class TestThreadPoolServer {
}
private TThreadPoolServer buildServer(TServerTransport serverSocket) {
- TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverSocket)
- .protocolFactory(new TBinaryProtocol.Factory())
- .processor(new ThriftTest.Processor<>(new ServerTestBase.TestHandler()));
+ TThreadPoolServer.Args args =
+ new TThreadPoolServer.Args(serverSocket)
+ .protocolFactory(new TBinaryProtocol.Factory())
+ .processor(new ThriftTest.Processor<>(new ServerTestBase.TestHandler()));
return new TThreadPoolServer(args);
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/server/TestThreadedSelectorServer.java b/lib/java/src/test/java/org/apache/thrift/server/TestThreadedSelectorServer.java
index ed729a296..390f6a0db 100644
--- a/lib/java/src/test/java/org/apache/thrift/server/TestThreadedSelectorServer.java
+++ b/lib/java/src/test/java/org/apache/thrift/server/TestThreadedSelectorServer.java
@@ -24,7 +24,9 @@ import org.apache.thrift.server.TThreadedSelectorServer.Args;
import org.apache.thrift.transport.TNonblockingServerSocket;
public class TestThreadedSelectorServer extends TestNonblockingServer {
- protected TServer getServer(TProcessor processor, TNonblockingServerSocket socket, TProtocolFactory protoFactory) {
- return new TThreadedSelectorServer(new Args(socket).processor(processor).protocolFactory(protoFactory));
+ protected TServer getServer(
+ TProcessor processor, TNonblockingServerSocket socket, TProtocolFactory protoFactory) {
+ return new TThreadedSelectorServer(
+ new Args(socket).processor(processor).protocolFactory(protoFactory));
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/test/EqualityTest.java b/lib/java/src/test/java/org/apache/thrift/test/EqualityTest.java
index 94ba543a8..fee495ca7 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/EqualityTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/EqualityTest.java
@@ -130,26 +130,21 @@ package org.apache.thrift.test;
// Generated code
import java.nio.ByteBuffer;
-
import thrift.test.JavaTestHelper;
-/**
- */
+/** */
public class EqualityTest {
public static void main(String[] args) throws Exception {
JavaTestHelper lhs, rhs;
-
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
lhs.req_int = 1;
rhs.req_int = 1;
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -157,8 +152,7 @@ public class EqualityTest {
rhs.req_int = 2;
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -167,10 +161,8 @@ public class EqualityTest {
rhs.setReq_intIsSet(true);
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -179,8 +171,7 @@ public class EqualityTest {
rhs.setReq_intIsSet(true);
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -189,10 +180,8 @@ public class EqualityTest {
lhs.setReq_intIsSet(true);
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -201,8 +190,7 @@ public class EqualityTest {
lhs.setReq_intIsSet(true);
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -212,10 +200,8 @@ public class EqualityTest {
rhs.setReq_intIsSet(true);
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -225,8 +211,7 @@ public class EqualityTest {
rhs.setReq_intIsSet(true);
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -234,10 +219,8 @@ public class EqualityTest {
rhs.opt_int = 1;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -245,10 +228,8 @@ public class EqualityTest {
rhs.opt_int = 2;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -257,8 +238,7 @@ public class EqualityTest {
rhs.setOpt_intIsSet(true);
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -267,8 +247,7 @@ public class EqualityTest {
rhs.setOpt_intIsSet(true);
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -277,8 +256,7 @@ public class EqualityTest {
lhs.setOpt_intIsSet(true);
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -287,8 +265,7 @@ public class EqualityTest {
lhs.setOpt_intIsSet(true);
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -298,10 +275,8 @@ public class EqualityTest {
rhs.setOpt_intIsSet(true);
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -311,8 +286,7 @@ public class EqualityTest {
rhs.setOpt_intIsSet(true);
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -322,10 +296,8 @@ public class EqualityTest {
rhs.req_obj = null;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -335,10 +307,8 @@ public class EqualityTest {
rhs.req_obj = null;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -347,8 +317,7 @@ public class EqualityTest {
lhs.req_obj = null;
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -357,8 +326,7 @@ public class EqualityTest {
lhs.req_obj = null;
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -367,8 +335,7 @@ public class EqualityTest {
rhs.req_obj = null;
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -377,8 +344,7 @@ public class EqualityTest {
rhs.req_obj = null;
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -386,10 +352,8 @@ public class EqualityTest {
rhs.req_obj = "foo";
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -397,8 +361,7 @@ public class EqualityTest {
rhs.req_obj = "bar";
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -408,10 +371,8 @@ public class EqualityTest {
rhs.opt_obj = null;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -421,10 +382,8 @@ public class EqualityTest {
rhs.opt_obj = null;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -433,8 +392,7 @@ public class EqualityTest {
lhs.opt_obj = null;
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -443,8 +401,7 @@ public class EqualityTest {
lhs.opt_obj = null;
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -453,8 +410,7 @@ public class EqualityTest {
rhs.opt_obj = null;
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -463,8 +419,7 @@ public class EqualityTest {
rhs.opt_obj = null;
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -472,10 +427,8 @@ public class EqualityTest {
rhs.opt_obj = "foo";
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
@@ -483,181 +436,156 @@ public class EqualityTest {
rhs.opt_obj = "bar";
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
+ lhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
lhs.req_bin = null;
rhs.req_bin = null;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.req_bin = ByteBuffer.wrap(new byte[]{3,4});
+ lhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.req_bin = ByteBuffer.wrap(new byte[] {3, 4});
lhs.req_bin = null;
rhs.req_bin = null;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
+ lhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
lhs.req_bin = null;
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.req_bin = ByteBuffer.wrap(new byte[]{3,4});
+ lhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.req_bin = ByteBuffer.wrap(new byte[] {3, 4});
lhs.req_bin = null;
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
+ lhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
rhs.req_bin = null;
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.req_bin = ByteBuffer.wrap(new byte[]{3,4});
+ lhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.req_bin = ByteBuffer.wrap(new byte[] {3, 4});
rhs.req_bin = null;
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
+ lhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.req_bin = ByteBuffer.wrap(new byte[]{3,4});
+ lhs.req_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.req_bin = ByteBuffer.wrap(new byte[] {3, 4});
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
+ lhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
lhs.opt_bin = null;
rhs.opt_bin = null;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.opt_bin = ByteBuffer.wrap(new byte[]{3,4});
+ lhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.opt_bin = ByteBuffer.wrap(new byte[] {3, 4});
lhs.opt_bin = null;
rhs.opt_bin = null;
// this_present = False
// that_present = False
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
+ lhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
lhs.opt_bin = null;
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.opt_bin = ByteBuffer.wrap(new byte[]{3,4});
+ lhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.opt_bin = ByteBuffer.wrap(new byte[] {3, 4});
lhs.opt_bin = null;
// this_present = False
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
+ lhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
rhs.opt_bin = null;
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.opt_bin = ByteBuffer.wrap(new byte[]{3,4});
+ lhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.opt_bin = ByteBuffer.wrap(new byte[] {3, 4});
rhs.opt_bin = null;
// this_present = True
// that_present = False
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
+ lhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != true)
- throw new RuntimeException("Failure");
- if (lhs.hashCode() != rhs.hashCode())
- throw new RuntimeException("Failure");
+ if (lhs.equals(rhs) != true) throw new RuntimeException("Failure");
+ if (lhs.hashCode() != rhs.hashCode()) throw new RuntimeException("Failure");
lhs = new JavaTestHelper();
rhs = new JavaTestHelper();
- lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
- rhs.opt_bin = ByteBuffer.wrap(new byte[]{3,4});
+ lhs.opt_bin = ByteBuffer.wrap(new byte[] {1, 2});
+ rhs.opt_bin = ByteBuffer.wrap(new byte[] {3, 4});
// this_present = True
// that_present = True
- if (lhs.equals(rhs) != false)
- throw new RuntimeException("Failure");
-
+ if (lhs.equals(rhs) != false) throw new RuntimeException("Failure");
}
}
-
diff --git a/lib/java/src/test/java/org/apache/thrift/test/JavaBeansTest.java b/lib/java/src/test/java/org/apache/thrift/test/JavaBeansTest.java
index 0bfcefec0..f5d81ca03 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/JavaBeansTest.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/JavaBeansTest.java
@@ -21,7 +21,6 @@ package org.apache.thrift.test;
import java.nio.ByteBuffer;
import java.util.LinkedList;
-
import thrift.test.OneOfEachBeans;
public class JavaBeansTest {
@@ -53,7 +52,7 @@ public class JavaBeansTest {
if (ooe.is_set_some_characters())
throw new RuntimeException("isSet method error: unset field returned as set!");
- for (int i = 1; i < 12; i++){
+ for (int i = 1; i < 12; i++) {
if (ooe.isSet(ooe.fieldForId(i)))
throw new RuntimeException("isSet method error: unset field " + i + " returned as set!");
}
@@ -94,19 +93,20 @@ public class JavaBeansTest {
if (!ooe.is_set_some_characters())
throw new RuntimeException("isSet method error: set field returned as unset!");
- for (int i = 1; i < 12; i++){
+ for (int i = 1; i < 12; i++) {
if (!ooe.isSet(ooe.fieldForId(i)))
throw new RuntimeException("isSet method error: set field " + i + " returned as unset!");
}
// Should throw exception when field doesn't exist
boolean exceptionThrown = false;
- try{
+ try {
ooe.isSet(ooe.fieldForId(100));
- } catch (IllegalArgumentException e){
+ } catch (IllegalArgumentException e) {
exceptionThrown = true;
}
if (!exceptionThrown)
- throw new RuntimeException("isSet method error: non-existent field provided as agument but no exception thrown!");
+ throw new RuntimeException(
+ "isSet method error: non-existent field provided as agument but no exception thrown!");
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/test/ReadStruct.java b/lib/java/src/test/java/org/apache/thrift/test/ReadStruct.java
index 4cc8f8003..f1e14e256 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/ReadStruct.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/ReadStruct.java
@@ -21,25 +21,26 @@ package org.apache.thrift.test;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
-
import org.apache.thrift.Fixtures;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransport;
-
import thrift.test.CompactProtoTestStruct;
public class ReadStruct {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
- System.out.println("usage: java -cp build/classes org.apache.thrift.test.ReadStruct filename proto_factory_class");
- System.out.println("Read in an instance of CompactProtocolTestStruct from 'file', making sure that it is equivalent to Fixtures.compactProtoTestStruct. Use a protocol from 'proto_factory_class'.");
+ System.out.println(
+ "usage: java -cp build/classes org.apache.thrift.test.ReadStruct filename proto_factory_class");
+ System.out.println(
+ "Read in an instance of CompactProtocolTestStruct from 'file', making sure that it is equivalent to Fixtures.compactProtoTestStruct. Use a protocol from 'proto_factory_class'.");
}
- TTransport trans = new TIOStreamTransport(new BufferedInputStream(new FileInputStream(args[0])));
+ TTransport trans =
+ new TIOStreamTransport(new BufferedInputStream(new FileInputStream(args[0])));
- TProtocolFactory factory = (TProtocolFactory)Class.forName(args[1]).newInstance();
+ TProtocolFactory factory = (TProtocolFactory) Class.forName(args[1]).newInstance();
TProtocol proto = factory.getProtocol(trans);
@@ -58,5 +59,4 @@ public class ReadStruct {
System.out.println("Expected: " + Fixtures.getCompactProtoTestStruct() + " but got " + cpts);
}
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/test/SerializationBenchmark.java b/lib/java/src/test/java/org/apache/thrift/test/SerializationBenchmark.java
index 8085ef485..50c64924b 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/SerializationBenchmark.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/SerializationBenchmark.java
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.thrift.test;
import org.apache.thrift.Fixtures;
@@ -30,11 +29,10 @@ import org.apache.thrift.transport.TMemoryBuffer;
import org.apache.thrift.transport.TMemoryInputTransport;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
-
import thrift.test.OneOfEach;
public class SerializationBenchmark {
- private final static int HOW_MANY = 10000000;
+ private static final int HOW_MANY = 10000000;
public static void main(String[] args) throws Exception {
TProtocolFactory factory = new TBinaryProtocol.Factory();
@@ -44,16 +42,30 @@ public class SerializationBenchmark {
}
public static void testSerialization(TProtocolFactory factory, TBase object) throws Exception {
- TTransport trans = new TTransport() {
- public void write(byte[] bin, int x, int y) throws TTransportException {}
- public TConfiguration getConfiguration() {return new TConfiguration(); }
- public void updateKnownMessageSize(long size) throws TTransportException {}
- public void checkReadBytesAvailable(long numBytes) throws TTransportException {}
- public int read(byte[] bin, int x, int y) throws TTransportException {return 0;}
- public void close() {}
- public void open() {}
- public boolean isOpen() {return true;}
- };
+ TTransport trans =
+ new TTransport() {
+ public void write(byte[] bin, int x, int y) throws TTransportException {}
+
+ public TConfiguration getConfiguration() {
+ return new TConfiguration();
+ }
+
+ public void updateKnownMessageSize(long size) throws TTransportException {}
+
+ public void checkReadBytesAvailable(long numBytes) throws TTransportException {}
+
+ public int read(byte[] bin, int x, int y) throws TTransportException {
+ return 0;
+ }
+
+ public void close() {}
+
+ public void open() {}
+
+ public boolean isOpen() {
+ return true;
+ }
+ };
TProtocol proto = factory.getProtocol(trans);
@@ -66,11 +78,12 @@ public class SerializationBenchmark {
System.out.println("Serialization test time: " + (endTime - startTime) + " ms");
}
- public static <T extends TBase> void testDeserialization(TProtocolFactory factory, T object, Class<T> klass) throws Exception {
+ public static <T extends TBase> void testDeserialization(
+ TProtocolFactory factory, T object, Class<T> klass) throws Exception {
TMemoryBuffer buf = new TMemoryBuffer(0);
object.write(factory.getProtocol(buf));
- byte[] serialized = new byte[100*1024];
- buf.read(serialized, 0, 100*1024);
+ byte[] serialized = new byte[100 * 1024];
+ buf.read(serialized, 0, 100 * 1024);
long startTime = System.currentTimeMillis();
for (int i = 0; i < HOW_MANY; i++) {
diff --git a/lib/java/src/test/java/org/apache/thrift/test/TestServlet.java b/lib/java/src/test/java/org/apache/thrift/test/TestServlet.java
index e63109da8..a23cc69e1 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/TestServlet.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/TestServlet.java
@@ -24,29 +24,28 @@ import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.server.ServerTestBase.TestHandler;
import org.apache.thrift.server.TExtensibleServlet;
-
import thrift.test.ThriftTest;
@SuppressWarnings("serial")
public class TestServlet extends TExtensibleServlet {
@Override
- protected TProtocolFactory getInProtocolFactory(){
- TProtocolFactory tProtocolFactory = new TCompactProtocol.Factory();
- return tProtocolFactory;
+ protected TProtocolFactory getInProtocolFactory() {
+ TProtocolFactory tProtocolFactory = new TCompactProtocol.Factory();
+ return tProtocolFactory;
}
@Override
- protected TProtocolFactory getOutProtocolFactory(){
- TProtocolFactory tProtocolFactory = new TCompactProtocol.Factory();
- return tProtocolFactory;
+ protected TProtocolFactory getOutProtocolFactory() {
+ TProtocolFactory tProtocolFactory = new TCompactProtocol.Factory();
+ return tProtocolFactory;
}
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
- protected TProcessor getProcessor(){
- TestHandler testHandler = new TestHandler();
- ThriftTest.Processor testProcessor = new ThriftTest.Processor(testHandler);
- return testProcessor;
+ protected TProcessor getProcessor() {
+ TestHandler testHandler = new TestHandler();
+ ThriftTest.Processor testProcessor = new ThriftTest.Processor(testHandler);
+ return testProcessor;
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/test/WriteStruct.java b/lib/java/src/test/java/org/apache/thrift/test/WriteStruct.java
index cb60bcaa7..c17cdaad4 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/WriteStruct.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/WriteStruct.java
@@ -21,7 +21,6 @@ package org.apache.thrift.test;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
-
import org.apache.thrift.Fixtures;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
@@ -31,18 +30,20 @@ import org.apache.thrift.transport.TTransport;
public class WriteStruct {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
- System.out.println("usage: java -cp build/classes org.apache.thrift.test.WriteStruct filename proto_factory_class");
- System.out.println("Write out an instance of Fixtures.compactProtocolTestStruct to 'file'. Use a protocol from 'proto_factory_class'.");
+ System.out.println(
+ "usage: java -cp build/classes org.apache.thrift.test.WriteStruct filename proto_factory_class");
+ System.out.println(
+ "Write out an instance of Fixtures.compactProtocolTestStruct to 'file'. Use a protocol from 'proto_factory_class'.");
}
- TTransport trans = new TIOStreamTransport(new BufferedOutputStream(new FileOutputStream(args[0])));
+ TTransport trans =
+ new TIOStreamTransport(new BufferedOutputStream(new FileOutputStream(args[0])));
- TProtocolFactory factory = (TProtocolFactory)Class.forName(args[1]).newInstance();
+ TProtocolFactory factory = (TProtocolFactory) Class.forName(args[1]).newInstance();
TProtocol proto = factory.getProtocol(trans);
Fixtures.getCompactProtoTestStruct().write(proto);
trans.flush();
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceAsyncImp.java b/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceAsyncImp.java
index 419e327de..9f0733f07 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceAsyncImp.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceAsyncImp.java
@@ -28,9 +28,9 @@ import thrift.test.voidmethexceptions.TExampleException;
public class ServiceAsyncImp extends ServiceBase implements TAppService01.AsyncIface {
@Override
- public void returnString(String msg,
- boolean throwException,
- AsyncMethodCallback<String> resultHandler) throws TException {
+ public void returnString(
+ String msg, boolean throwException, AsyncMethodCallback<String> resultHandler)
+ throws TException {
if (throwException) {
resultHandler.onError(new TExampleException(msg));
} else {
@@ -39,9 +39,9 @@ public class ServiceAsyncImp extends ServiceBase implements TAppService01.AsyncI
}
@Override
- public void returnVoidThrows(String msg,
- boolean throwException,
- AsyncMethodCallback<Void> resultHandler) throws TException {
+ public void returnVoidThrows(
+ String msg, boolean throwException, AsyncMethodCallback<Void> resultHandler)
+ throws TException {
if (throwException) {
resultHandler.onError(new TExampleException(msg));
} else {
@@ -50,9 +50,9 @@ public class ServiceAsyncImp extends ServiceBase implements TAppService01.AsyncI
}
@Override
- public void returnVoidNoThrowsRuntimeException(String msg,
- boolean throwException,
- AsyncMethodCallback<Void> resultHandler) throws TException {
+ public void returnVoidNoThrowsRuntimeException(
+ String msg, boolean throwException, AsyncMethodCallback<Void> resultHandler)
+ throws TException {
if (throwException) {
resultHandler.onError(new RuntimeException(msg));
} else {
@@ -61,9 +61,9 @@ public class ServiceAsyncImp extends ServiceBase implements TAppService01.AsyncI
}
@Override
- public void returnVoidNoThrowsTApplicationException(String msg,
- boolean throwException,
- AsyncMethodCallback<Void> resultHandler) throws TException {
+ public void returnVoidNoThrowsTApplicationException(
+ String msg, boolean throwException, AsyncMethodCallback<Void> resultHandler)
+ throws TException {
if (throwException) {
resultHandler.onError(new TApplicationException(TApplicationException.INTERNAL_ERROR, msg));
} else {
@@ -72,14 +72,13 @@ public class ServiceAsyncImp extends ServiceBase implements TAppService01.AsyncI
}
@Override
- public void onewayVoidNoThrows(String msg,
- boolean throwException,
- AsyncMethodCallback<Void> resultHandler) throws TException {
+ public void onewayVoidNoThrows(
+ String msg, boolean throwException, AsyncMethodCallback<Void> resultHandler)
+ throws TException {
if (throwException) {
resultHandler.onError(new TApplicationException(TApplicationException.INTERNAL_ERROR, msg));
} else {
// simulate hang up
}
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceBase.java b/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceBase.java
index 5502b09cd..e12a29a52 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceBase.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceBase.java
@@ -40,5 +40,4 @@ public class ServiceBase {
}
}
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceSyncImp.java b/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceSyncImp.java
index a8a08b5b9..502dc8fef 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceSyncImp.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/ServiceSyncImp.java
@@ -27,8 +27,8 @@ import thrift.test.voidmethexceptions.TExampleException;
public class ServiceSyncImp extends ServiceBase implements TAppService01.Iface {
@Override
- public String returnString(String msg,
- boolean throwException) throws TExampleException, TException {
+ public String returnString(String msg, boolean throwException)
+ throws TExampleException, TException {
if (throwException) {
throw new TExampleException(msg);
}
@@ -36,24 +36,24 @@ public class ServiceSyncImp extends ServiceBase implements TAppService01.Iface {
}
@Override
- public void returnVoidThrows(String msg,
- boolean throwException) throws TExampleException, TException {
+ public void returnVoidThrows(String msg, boolean throwException)
+ throws TExampleException, TException {
if (throwException) {
throw new TExampleException(msg);
}
}
@Override
- public void returnVoidNoThrowsRuntimeException(String msg,
- boolean throwException) throws TException {
+ public void returnVoidNoThrowsRuntimeException(String msg, boolean throwException)
+ throws TException {
if (throwException) {
throw new RuntimeException(msg);
}
}
@Override
- public void returnVoidNoThrowsTApplicationException(String msg,
- boolean throwException) throws TException {
+ public void returnVoidNoThrowsTApplicationException(String msg, boolean throwException)
+ throws TException {
if (throwException) {
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, msg);
}
@@ -68,5 +68,4 @@ public class ServiceSyncImp extends ServiceBase implements TAppService01.Iface {
waitForCancel();
}
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/TestVoidMethExceptions.java b/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/TestVoidMethExceptions.java
index b6853bd2b..a85c4d12c 100644
--- a/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/TestVoidMethExceptions.java
+++ b/lib/java/src/test/java/org/apache/thrift/test/voidmethexceptions/TestVoidMethExceptions.java
@@ -19,6 +19,15 @@
package org.apache.thrift.test.voidmethexceptions;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.thrift.TApplicationException;
import org.apache.thrift.TConfiguration;
@@ -40,521 +49,554 @@ import org.slf4j.LoggerFactory;
import thrift.test.voidmethexceptions.TAppService01;
import thrift.test.voidmethexceptions.TExampleException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Supplier;
-import java.util.stream.Stream;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
public class TestVoidMethExceptions {
- private static final Logger log = LoggerFactory.getLogger(TestVoidMethExceptions.class);
-
- private static Stream<TestParameters> provideParameters() throws Exception {
- return Stream.<TestParameters>builder()
- .add(new TestParameters(ServerImplementationType.SYNC_SERVER))
- .add(new TestParameters(ServerImplementationType.ASYNC_SERVER))
- .build();
+ private static final Logger log = LoggerFactory.getLogger(TestVoidMethExceptions.class);
+
+ private static Stream<TestParameters> provideParameters() throws Exception {
+ return Stream.<TestParameters>builder()
+ .add(new TestParameters(ServerImplementationType.SYNC_SERVER))
+ .add(new TestParameters(ServerImplementationType.ASYNC_SERVER))
+ .build();
+ }
+
+ public static class TestParameters {
+ private static final int TIMEOUT_MILLIS = 5_000;
+ private final TServer server;
+ private final Thread serverThread;
+ private final TNonblockingServerSocket serverTransport;
+ private int serverPort;
+ private final ServerImplementationType serverImplementationType;
+ private final CompletableFuture<Void> futureServerStarted = new CompletableFuture<>();
+
+ TestParameters(ServerImplementationType serverImplementationType) throws Exception {
+ this.serverImplementationType = serverImplementationType;
+ serverPort = -1;
+ serverImplementationType.service.setCancelled(false);
+ serverTransport = new TNonblockingServerSocket(0);
+ TNonblockingServer.Args args = new TNonblockingServer.Args(serverTransport);
+ args.processor(serverImplementationType.processor);
+ server =
+ new TNonblockingServer(args) {
+ @Override
+ protected void setServing(boolean serving) {
+ super.setServing(serving);
+
+ if (serving) {
+ serverPort = serverTransport.getPort();
+ futureServerStarted.complete(null);
+ }
+ }
+ };
+ serverThread = new Thread(server::serve, "thrift-server");
+ serverThread.setDaemon(true);
}
- public static class TestParameters {
- private static final int TIMEOUT_MILLIS = 5_000;
- private final TServer server;
- private final Thread serverThread;
- private final TNonblockingServerSocket serverTransport;
- private int serverPort;
- private final ServerImplementationType serverImplementationType;
- private final CompletableFuture<Void> futureServerStarted = new CompletableFuture<>();
-
- TestParameters(ServerImplementationType serverImplementationType) throws Exception {
- this.serverImplementationType = serverImplementationType;
- serverPort = -1;
- serverImplementationType.service.setCancelled(false);
- serverTransport = new TNonblockingServerSocket(0);
- TNonblockingServer.Args args = new TNonblockingServer.Args(serverTransport);
- args.processor(serverImplementationType.processor);
- server = new TNonblockingServer(args) {
- @Override
- protected void setServing(boolean serving) {
- super.setServing(serving);
-
- if (serving) {
- serverPort = serverTransport.getPort();
- futureServerStarted.complete(null);
- }
- }
+ public AutoCloseable start() throws Exception {
+ serverThread.start();
+ futureServerStarted.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ return () -> {
+ serverImplementationType.service.setCancelled(true);
+ server.stop();
+ serverThread.join(TIMEOUT_MILLIS);
+ };
+ }
- };
- serverThread = new Thread(server::serve, "thrift-server");
- serverThread.setDaemon(true);
+ private void checkSyncClient(
+ String desc,
+ String msg,
+ boolean throwException,
+ String expectedResult,
+ Class<? extends Exception> expectedExceptionClass,
+ String expectedExceptionMsg,
+ SyncCall<TAppService01.Iface, String, Boolean, String> call)
+ throws Exception {
+ if (log.isInfoEnabled()) {
+ log.info(
+ "start test checkSyncClient::"
+ + desc
+ + ", throwException: "
+ + throwException
+ + ", serverImplementationType: "
+ + serverImplementationType);
+ }
+ assertNotEquals(-1, serverPort);
+ try (TTransport clientTransport =
+ new TFramedTransport(
+ new TSocket(new TConfiguration(), "localhost", serverPort, TIMEOUT_MILLIS))) {
+ clientTransport.open();
+ TAppService01.Iface client = new TAppService01.Client(new TBinaryProtocol(clientTransport));
+ if (throwException && expectedExceptionClass != null) {
+ Exception ex =
+ assertThrows(
+ expectedExceptionClass,
+ () -> {
+ call.apply(client, msg, throwException);
+ });
+ assertEquals(expectedExceptionClass, ex.getClass());
+ if (expectedExceptionMsg != null) {
+ assertEquals(expectedExceptionMsg, ex.getMessage());
+ }
+ } else {
+ // expected
+ String result = call.apply(client, msg, throwException);
+ assertEquals(expectedResult, result);
}
+ }
+ }
- public AutoCloseable start() throws Exception {
- serverThread.start();
- futureServerStarted.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- return () -> {
- serverImplementationType.service.setCancelled(true);
- server.stop();
- serverThread.join(TIMEOUT_MILLIS);
- };
- }
+ private <T> void checkAsyncClient(
+ String desc,
+ String msg,
+ boolean throwException,
+ T expectedResult,
+ Class<? extends Exception> expectedExceptionClass,
+ String expectedExceptionMsg,
+ AsyncCall<TAppService01.AsyncClient, String, Boolean, AsyncMethodCallback<T>> call)
+ throws Throwable {
+ if (log.isInfoEnabled()) {
+ log.info(
+ "start test checkAsyncClient::"
+ + desc
+ + ", throwException: "
+ + throwException
+ + ", serverImplementationType: "
+ + serverImplementationType);
+ }
+ assertNotEquals(serverPort, -1);
+ try (TNonblockingSocket clientTransportAsync =
+ new TNonblockingSocket("localhost", serverPort, TIMEOUT_MILLIS)) {
+ TAsyncClientManager asyncClientManager = new TAsyncClientManager();
+ try {
+ TAppService01.AsyncClient asyncClient =
+ new TAppService01.AsyncClient(
+ new TBinaryProtocol.Factory(), asyncClientManager, clientTransportAsync);
+ asyncClient.setTimeout(TIMEOUT_MILLIS);
+
+ CompletableFuture<T> futureResult = new CompletableFuture<>();
+
+ call.apply(
+ asyncClient,
+ msg,
+ throwException,
+ new AsyncMethodCallback<T>() {
- private void checkSyncClient(String desc,
- String msg,
- boolean throwException,
- String expectedResult,
- Class<? extends Exception> expectedExceptionClass,
- String expectedExceptionMsg,
- SyncCall<TAppService01.Iface, String, Boolean, String> call) throws Exception {
- if (log.isInfoEnabled()) {
- log.info("start test checkSyncClient::" + desc + ", throwException: " + throwException
- + ", serverImplementationType: "
- + serverImplementationType);
- }
- assertNotEquals(-1, serverPort);
- try (TTransport clientTransport = new TFramedTransport(new TSocket(new TConfiguration(),
- "localhost",
- serverPort,
- TIMEOUT_MILLIS))) {
- clientTransport.open();
- TAppService01.Iface client = new TAppService01.Client(new TBinaryProtocol(clientTransport));
- if (throwException && expectedExceptionClass != null) {
- Exception ex = assertThrows(expectedExceptionClass, () -> {
- call.apply(client, msg, throwException);
- });
- assertEquals(expectedExceptionClass, ex.getClass());
- if (expectedExceptionMsg != null) {
- assertEquals(expectedExceptionMsg, ex.getMessage());
- }
- } else {
- // expected
- String result = call.apply(client, msg, throwException);
- assertEquals(expectedResult, result);
+ @Override
+ public void onError(Exception exception) {
+ futureResult.completeExceptionally(exception);
}
- }
- }
-
- private <T> void checkAsyncClient(String desc,
- String msg,
- boolean throwException,
- T expectedResult,
- Class<? extends Exception> expectedExceptionClass,
- String expectedExceptionMsg,
- AsyncCall<TAppService01.AsyncClient, String, Boolean, AsyncMethodCallback<T>> call) throws Throwable {
- if (log.isInfoEnabled()) {
- log.info("start test checkAsyncClient::" + desc + ", throwException: " + throwException
- + ", serverImplementationType: "
- + serverImplementationType);
- }
- assertNotEquals(serverPort, -1);
- try (TNonblockingSocket clientTransportAsync = new TNonblockingSocket("localhost", serverPort, TIMEOUT_MILLIS)) {
- TAsyncClientManager asyncClientManager = new TAsyncClientManager();
- try {
- TAppService01.AsyncClient asyncClient = new TAppService01.AsyncClient(new TBinaryProtocol.Factory(),
- asyncClientManager,
- clientTransportAsync);
- asyncClient.setTimeout(TIMEOUT_MILLIS);
- CompletableFuture<T> futureResult = new CompletableFuture<>();
-
- call.apply(asyncClient, msg, throwException, new AsyncMethodCallback<T>() {
-
- @Override
- public void onError(Exception exception) {
- futureResult.completeExceptionally(exception);
- }
-
- @Override
- public void onComplete(T response) {
- futureResult.complete(response);
- }
-
- });
- if (throwException && expectedExceptionClass != null) {
- Exception ex = assertThrows(expectedExceptionClass, () -> {
- try {
- futureResult.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- } catch (ExecutionException x) {
- throw x.getCause();
- }
- });
- assertEquals(expectedExceptionClass, ex.getClass());
- if (expectedExceptionMsg != null) {
- assertEquals(expectedExceptionMsg, ex.getMessage());
- }
- } else {
- T result;
- try {
- result = futureResult.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- } catch (ExecutionException x) {
- throw x.getCause();
- }
- assertEquals(expectedResult, result);
- }
- } finally {
- asyncClientManager.stop();
+ @Override
+ public void onComplete(T response) {
+ futureResult.complete(response);
}
+ });
+ if (throwException && expectedExceptionClass != null) {
+ Exception ex =
+ assertThrows(
+ expectedExceptionClass,
+ () -> {
+ try {
+ futureResult.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException x) {
+ throw x.getCause();
+ }
+ });
+ assertEquals(expectedExceptionClass, ex.getClass());
+ if (expectedExceptionMsg != null) {
+ assertEquals(expectedExceptionMsg, ex.getMessage());
}
+ } else {
+ T result;
+ try {
+ result = futureResult.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException x) {
+ throw x.getCause();
+ }
+ assertEquals(expectedResult, result);
+ }
+ } finally {
+ asyncClientManager.stop();
}
-
- public TServer getServer() {
- return server;
- }
+ }
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientMustReturnResultReturnString(TestParameters p) throws Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("returnString",
- "sent msg",
- false,
- "sent msg",
- null,
- null,
- TAppService01.Iface::returnString);
- }
+ public TServer getServer() {
+ return server;
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientMustReturnResultReturnVoidThrows(TestParameters p) throws Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("returnVoidThrows",
- "sent msg",
- false,
- null,
- null,
- null,
- (client, msg, throwException) -> {
- client.returnVoidThrows(msg, throwException);
- return null;
- });
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientMustReturnResultReturnString(TestParameters p) throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "returnString",
+ "sent msg",
+ false,
+ "sent msg",
+ null,
+ null,
+ TAppService01.Iface::returnString);
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientMustReturnResultReturnVoidNoThrowsRuntimeException(TestParameters p) throws Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("returnVoidNoThrowsRuntimeException",
- "sent msg",
- false,
- null,
- null,
- null,
- (client, msg, throwException) -> {
- client.returnVoidNoThrowsRuntimeException(msg, throwException);
- return null;
- });
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientMustReturnResultReturnVoidThrows(TestParameters p) throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "returnVoidThrows",
+ "sent msg",
+ false,
+ null,
+ null,
+ null,
+ (client, msg, throwException) -> {
+ client.returnVoidThrows(msg, throwException);
+ return null;
+ });
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientMustReturnResultReturnVoidNoThrowsTApplicationException(TestParameters p) throws Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("returnVoidNoThrowsTApplicationException",
- "sent msg",
- false,
- null,
- null,
- null,
- (client, msg, throwException) -> {
- client.returnVoidNoThrowsTApplicationException(msg, throwException);
- return null;
- });
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientMustReturnResultReturnVoidNoThrowsRuntimeException(TestParameters p)
+ throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "returnVoidNoThrowsRuntimeException",
+ "sent msg",
+ false,
+ null,
+ null,
+ null,
+ (client, msg, throwException) -> {
+ client.returnVoidNoThrowsRuntimeException(msg, throwException);
+ return null;
+ });
}
-
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientMustThrowExceptionReturnString(TestParameters p) throws Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("returnString",
- "sent msg",
- true,
- null,
- TExampleException.class,
- "sent msg",
- TAppService01.Iface::returnString);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientMustReturnResultReturnVoidNoThrowsTApplicationException(
+ TestParameters p) throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "returnVoidNoThrowsTApplicationException",
+ "sent msg",
+ false,
+ null,
+ null,
+ null,
+ (client, msg, throwException) -> {
+ client.returnVoidNoThrowsTApplicationException(msg, throwException);
+ return null;
+ });
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientMustThrowExceptionReturnVoidThrows(TestParameters p) throws Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("returnVoidThrows",
- "sent msg",
- true,
- null,
- TExampleException.class,
- "sent msg",
- (client, msg, throwException) -> {
- client.returnVoidThrows(msg, throwException);
- return null;
- });
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientMustThrowExceptionReturnString(TestParameters p) throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "returnString",
+ "sent msg",
+ true,
+ null,
+ TExampleException.class,
+ "sent msg",
+ TAppService01.Iface::returnString);
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientMustThrowExceptionReturnVoidNoThrowsRuntimeException(TestParameters p) throws
- Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("returnVoidNoThrowsRuntimeException",
- "sent msg",
- true,
- null,
- TApplicationException.class,
- p.serverImplementationType == ServerImplementationType.ASYNC_SERVER ? "sent msg"
- : null, // sync server return "Internal error processing returnVoidNoThrowsRuntimeException" message
- (client, msg, throwException) -> {
- client.returnVoidNoThrowsRuntimeException(msg, throwException);
- return null;
- });
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientMustThrowExceptionReturnVoidThrows(TestParameters p) throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "returnVoidThrows",
+ "sent msg",
+ true,
+ null,
+ TExampleException.class,
+ "sent msg",
+ (client, msg, throwException) -> {
+ client.returnVoidThrows(msg, throwException);
+ return null;
+ });
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientMustThrowExceptionReturnVoidNoThrowsTApplicationException(TestParameters p) throws
- Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("returnVoidNoThrowsTApplicationException",
- "sent msg",
- true,
- null,
- TApplicationException.class,
- "sent msg",
- (client, msg, throwException) -> {
- client.returnVoidNoThrowsTApplicationException(msg, throwException);
- return null;
- });
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientMustThrowExceptionReturnVoidNoThrowsRuntimeException(TestParameters p)
+ throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "returnVoidNoThrowsRuntimeException",
+ "sent msg",
+ true,
+ null,
+ TApplicationException.class,
+ p.serverImplementationType == ServerImplementationType.ASYNC_SERVER
+ ? "sent msg"
+ : null, // sync server return "Internal error processing
+ // returnVoidNoThrowsRuntimeException" message
+ (client, msg, throwException) -> {
+ client.returnVoidNoThrowsRuntimeException(msg, throwException);
+ return null;
+ });
}
-
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientMustReturnResultReturnString(TestParameters p) throws Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("returnString",
- "sent msg",
- false,
- "sent msg",
- null,
- null,
- TAppService01.AsyncClient::returnString);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientMustThrowExceptionReturnVoidNoThrowsTApplicationException(
+ TestParameters p) throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "returnVoidNoThrowsTApplicationException",
+ "sent msg",
+ true,
+ null,
+ TApplicationException.class,
+ "sent msg",
+ (client, msg, throwException) -> {
+ client.returnVoidNoThrowsTApplicationException(msg, throwException);
+ return null;
+ });
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientMustReturnResultReturnVoidThrows(TestParameters p) throws Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("returnVoidThrows",
- "sent msg",
- false,
- null,
- null,
- null,
- TAppService01.AsyncClient::returnVoidThrows);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientMustReturnResultReturnString(TestParameters p) throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "returnString",
+ "sent msg",
+ false,
+ "sent msg",
+ null,
+ null,
+ TAppService01.AsyncClient::returnString);
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientMustReturnResultReturnVoidNoThrowsRuntimeException(TestParameters p) throws
- Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("returnVoidNoThrowsRuntimeException",
- "sent msg",
- false,
- null,
- null,
- null,
- TAppService01.AsyncClient::returnVoidNoThrowsRuntimeException);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientMustReturnResultReturnVoidThrows(TestParameters p) throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "returnVoidThrows",
+ "sent msg",
+ false,
+ null,
+ null,
+ null,
+ TAppService01.AsyncClient::returnVoidThrows);
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientMustReturnResultReturnVoidNoThrowsTApplicationException(TestParameters p) throws
- Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("returnVoidNoThrowsTApplicationException",
- "sent msg",
- false,
- null,
- null,
- null,
- TAppService01.AsyncClient::returnVoidNoThrowsTApplicationException);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientMustReturnResultReturnVoidNoThrowsRuntimeException(TestParameters p)
+ throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "returnVoidNoThrowsRuntimeException",
+ "sent msg",
+ false,
+ null,
+ null,
+ null,
+ TAppService01.AsyncClient::returnVoidNoThrowsRuntimeException);
}
-
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientMustThrowExceptionReturnString(TestParameters p) throws Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("returnString",
- "sent msg",
- true,
- null,
- TExampleException.class,
- "sent msg",
- TAppService01.AsyncClient::returnString);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientMustReturnResultReturnVoidNoThrowsTApplicationException(
+ TestParameters p) throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "returnVoidNoThrowsTApplicationException",
+ "sent msg",
+ false,
+ null,
+ null,
+ null,
+ TAppService01.AsyncClient::returnVoidNoThrowsTApplicationException);
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientMustThrowExceptionReturnVoidThrows(TestParameters p) throws Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("returnVoidThrows",
- "sent msg",
- true,
- null,
- TExampleException.class,
- "sent msg",
- TAppService01.AsyncClient::returnVoidThrows);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientMustThrowExceptionReturnString(TestParameters p) throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "returnString",
+ "sent msg",
+ true,
+ null,
+ TExampleException.class,
+ "sent msg",
+ TAppService01.AsyncClient::returnString);
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientMustThrowExceptionReturnVoidNoThrowsRuntimeException(TestParameters p) throws
- Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("returnVoidNoThrowsRuntimeException",
- "sent msg",
- true,
- null,
- TApplicationException.class,
- p.serverImplementationType == ServerImplementationType.ASYNC_SERVER ? "sent msg"
- : null, // sync server return "Internal error processing returnVoidNoThrowsRuntimeException" message
- TAppService01.AsyncClient::returnVoidNoThrowsRuntimeException);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientMustThrowExceptionReturnVoidThrows(TestParameters p) throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "returnVoidThrows",
+ "sent msg",
+ true,
+ null,
+ TExampleException.class,
+ "sent msg",
+ TAppService01.AsyncClient::returnVoidThrows);
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientMustThrowExceptionReturnVoidNoThrowsTApplicationException(TestParameters p) throws
- Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("returnVoidNoThrowsTApplicationException",
- "sent msg",
- true,
- null,
- TApplicationException.class,
- "sent msg",
- TAppService01.AsyncClient::returnVoidNoThrowsTApplicationException);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientMustThrowExceptionReturnVoidNoThrowsRuntimeException(TestParameters p)
+ throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "returnVoidNoThrowsRuntimeException",
+ "sent msg",
+ true,
+ null,
+ TApplicationException.class,
+ p.serverImplementationType == ServerImplementationType.ASYNC_SERVER
+ ? "sent msg"
+ : null, // sync server return "Internal error processing
+ // returnVoidNoThrowsRuntimeException" message
+ TAppService01.AsyncClient::returnVoidNoThrowsRuntimeException);
}
-
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientNoWaitForResultNoExceptionOnewayVoidNoThrows(TestParameters p) throws Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("onewayVoidNoThrows",
- "sent msg",
- false,
- null,
- null,
- null,
- (client, msg, throwException) -> {
- client.onewayVoidNoThrows(msg, throwException);
- return null;
- });
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientMustThrowExceptionReturnVoidNoThrowsTApplicationException(
+ TestParameters p) throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "returnVoidNoThrowsTApplicationException",
+ "sent msg",
+ true,
+ null,
+ TApplicationException.class,
+ "sent msg",
+ TAppService01.AsyncClient::returnVoidNoThrowsTApplicationException);
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testSyncClientNoWaitForResultExceptionOnewayVoidNoThrows(TestParameters p) throws Exception {
- try (AutoCloseable ignored = p.start()) {
- p.checkSyncClient("onewayVoidNoThrows",
- "sent msg",
- true,
- null,
- null,
- null,
- (client, msg, throwException) -> {
- client.onewayVoidNoThrows(msg, throwException);
- return null;
- });
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientNoWaitForResultNoExceptionOnewayVoidNoThrows(TestParameters p)
+ throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "onewayVoidNoThrows",
+ "sent msg",
+ false,
+ null,
+ null,
+ null,
+ (client, msg, throwException) -> {
+ client.onewayVoidNoThrows(msg, throwException);
+ return null;
+ });
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientNoWaitForResultNoExceptionOnewayVoidNoThrows(TestParameters p) throws Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("onewayVoidNoThrows",
- "sent msg",
- false,
- null,
- null,
- null,
- TAppService01.AsyncClient::onewayVoidNoThrows);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testSyncClientNoWaitForResultExceptionOnewayVoidNoThrows(TestParameters p)
+ throws Exception {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkSyncClient(
+ "onewayVoidNoThrows",
+ "sent msg",
+ true,
+ null,
+ null,
+ null,
+ (client, msg, throwException) -> {
+ client.onewayVoidNoThrows(msg, throwException);
+ return null;
+ });
}
-
- @ParameterizedTest
- @MethodSource("provideParameters")
- public void testAsyncClientNoWaitForResultExceptionOnewayVoidNoThrows(TestParameters p) throws Throwable {
- try (AutoCloseable ignored = p.start()) {
- p.checkAsyncClient("onewayVoidNoThrows",
- "sent msg",
- true,
- null,
- null,
- null,
- TAppService01.AsyncClient::onewayVoidNoThrows);
- }
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientNoWaitForResultNoExceptionOnewayVoidNoThrows(TestParameters p)
+ throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "onewayVoidNoThrows",
+ "sent msg",
+ false,
+ null,
+ null,
+ null,
+ TAppService01.AsyncClient::onewayVoidNoThrows);
}
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideParameters")
+ public void testAsyncClientNoWaitForResultExceptionOnewayVoidNoThrows(TestParameters p)
+ throws Throwable {
+ try (AutoCloseable ignored = p.start()) {
+ p.checkAsyncClient(
+ "onewayVoidNoThrows",
+ "sent msg",
+ true,
+ null,
+ null,
+ null,
+ TAppService01.AsyncClient::onewayVoidNoThrows);
+ }
+ }
-
- private enum ServerImplementationType {
-
- SYNC_SERVER(() -> {
- ServiceSyncImp service = new ServiceSyncImp();
- return Pair.of(new TAppService01.Processor<>(service), service);
+ private enum ServerImplementationType {
+ SYNC_SERVER(
+ () -> {
+ ServiceSyncImp service = new ServiceSyncImp();
+ return Pair.of(new TAppService01.Processor<>(service), service);
}),
- ASYNC_SERVER(() -> {
- ServiceAsyncImp service = new ServiceAsyncImp();
- return Pair.of(new TAppService01.AsyncProcessor<>(service), service);
+ ASYNC_SERVER(
+ () -> {
+ ServiceAsyncImp service = new ServiceAsyncImp();
+ return Pair.of(new TAppService01.AsyncProcessor<>(service), service);
});
- final TProcessor processor;
- final ServiceBase service;
+ final TProcessor processor;
+ final ServiceBase service;
- ServerImplementationType(Supplier<Pair<TProcessor, ServiceBase>> supplier) {
- Pair<TProcessor, ServiceBase> pair = supplier.get();
- this.processor = pair.getLeft();
- this.service = pair.getRight();
- }
- }
-
-
- @FunctionalInterface
- private interface SyncCall<T, U, V, R> {
- R apply(T t, U u, V v) throws Exception;
+ ServerImplementationType(Supplier<Pair<TProcessor, ServiceBase>> supplier) {
+ Pair<TProcessor, ServiceBase> pair = supplier.get();
+ this.processor = pair.getLeft();
+ this.service = pair.getRight();
}
+ }
+ @FunctionalInterface
+ private interface SyncCall<T, U, V, R> {
+ R apply(T t, U u, V v) throws Exception;
+ }
- @FunctionalInterface
- private interface AsyncCall<T, U, V, X> {
- void apply(T t, U u, V v, X x) throws Exception;
- }
-
+ @FunctionalInterface
+ private interface AsyncCall<T, U, V, X> {
+ void apply(T t, U u, V v, X x) throws Exception;
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/ReadCountingTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/ReadCountingTransport.java
index 1b2073cb5..078287f1e 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/ReadCountingTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/ReadCountingTransport.java
@@ -18,7 +18,6 @@
*/
package org.apache.thrift.transport;
-
import org.apache.thrift.TConfiguration;
public class ReadCountingTransport extends TTransport {
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBuffer.java b/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBuffer.java
index 0b7e4ada8..621ea094d 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBuffer.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBuffer.java
@@ -18,13 +18,12 @@
*/
package org.apache.thrift.transport;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
-public class TestAutoExpandingBuffer {
+public class TestAutoExpandingBuffer {
@Test
public void testExpands() throws Exception {
// has expected initial capacity
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferReadTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferReadTransport.java
index 090191312..8d5783c5d 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferReadTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferReadTransport.java
@@ -18,14 +18,13 @@
*/
package org.apache.thrift.transport;
-import org.apache.thrift.TConfiguration;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.ByteBuffer;
+import org.apache.thrift.TConfiguration;
+import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class TestAutoExpandingBufferReadTransport {
+public class TestAutoExpandingBufferReadTransport {
private static final byte[] HUNDRED_BYTES = new byte[100];
static {
@@ -36,7 +35,8 @@ public class TestAutoExpandingBufferReadTransport {
@Test
public void testIt() throws Exception {
- AutoExpandingBufferReadTransport t = new AutoExpandingBufferReadTransport(new TConfiguration(), 150);
+ AutoExpandingBufferReadTransport t =
+ new AutoExpandingBufferReadTransport(new TConfiguration(), 150);
TMemoryInputTransport membuf = new TMemoryInputTransport(new TConfiguration(), HUNDRED_BYTES);
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferWriteTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferWriteTransport.java
index 24249908a..44ac63f8a 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferWriteTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestAutoExpandingBufferWriteTransport.java
@@ -18,59 +18,61 @@
*/
package org.apache.thrift.transport;
-import org.apache.thrift.TConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.nio.ByteBuffer;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.nio.ByteBuffer;
+import org.apache.thrift.TConfiguration;
+import org.junit.jupiter.api.Test;
+
public class TestAutoExpandingBufferWriteTransport {
- private final TConfiguration config = new TConfiguration();
+ private final TConfiguration config = new TConfiguration();
- @Test
- public void testIt() throws Exception {
- AutoExpandingBufferWriteTransport t = new AutoExpandingBufferWriteTransport(config, 1, 0);
- assertEquals(0, t.getLength());
- assertEquals(1, t.getBuf().array().length);
- byte[] b1 = new byte[]{1, 2, 3};
- t.write(b1);
- assertEquals(3, t.getLength());
- assertTrue(t.getBuf().array().length >= 3);
- assertEquals(ByteBuffer.wrap(b1), ByteBuffer.wrap(t.getBuf().array(), 0, 3));
+ @Test
+ public void testIt() throws Exception {
+ AutoExpandingBufferWriteTransport t = new AutoExpandingBufferWriteTransport(config, 1, 0);
+ assertEquals(0, t.getLength());
+ assertEquals(1, t.getBuf().array().length);
+ byte[] b1 = new byte[] {1, 2, 3};
+ t.write(b1);
+ assertEquals(3, t.getLength());
+ assertTrue(t.getBuf().array().length >= 3);
+ assertEquals(ByteBuffer.wrap(b1), ByteBuffer.wrap(t.getBuf().array(), 0, 3));
- t.reset();
- assertEquals(0, t.getLength());
- assertTrue(t.getBuf().array().length >= 3);
- byte[] b2 = new byte[]{4, 5};
- t.write(b2);
- assertEquals(2, t.getLength());
- assertEquals(ByteBuffer.wrap(b2), ByteBuffer.wrap(t.getBuf().array(), 0, 2));
+ t.reset();
+ assertEquals(0, t.getLength());
+ assertTrue(t.getBuf().array().length >= 3);
+ byte[] b2 = new byte[] {4, 5};
+ t.write(b2);
+ assertEquals(2, t.getLength());
+ assertEquals(ByteBuffer.wrap(b2), ByteBuffer.wrap(t.getBuf().array(), 0, 2));
- AutoExpandingBufferWriteTransport uut = new AutoExpandingBufferWriteTransport(config, 8, 4);
- assertEquals(4, uut.getLength());
- assertEquals(8, uut.getBuf().array().length);
- uut.write(b1);
- assertEquals(7, uut.getLength());
- assertEquals(8, uut.getBuf().array().length);
- assertEquals(ByteBuffer.wrap(b1), ByteBuffer.wrap(uut.getBuf().array(), 4, 3));
- }
+ AutoExpandingBufferWriteTransport uut = new AutoExpandingBufferWriteTransport(config, 8, 4);
+ assertEquals(4, uut.getLength());
+ assertEquals(8, uut.getBuf().array().length);
+ uut.write(b1);
+ assertEquals(7, uut.getLength());
+ assertEquals(8, uut.getBuf().array().length);
+ assertEquals(ByteBuffer.wrap(b1), ByteBuffer.wrap(uut.getBuf().array(), 4, 3));
+ }
- @Test
- public void testBadInitialSize() throws TTransportException {
- assertThrows(IllegalArgumentException.class, () -> new AutoExpandingBufferWriteTransport(config, 0, 0));
- }
+ @Test
+ public void testBadInitialSize() throws TTransportException {
+ assertThrows(
+ IllegalArgumentException.class, () -> new AutoExpandingBufferWriteTransport(config, 0, 0));
+ }
- @Test
- public void testBadFrontReserveSize() throws IllegalArgumentException, TTransportException {
- assertThrows(IllegalArgumentException.class, () -> new AutoExpandingBufferWriteTransport(config, 4, -1));
- }
+ @Test
+ public void testBadFrontReserveSize() throws IllegalArgumentException, TTransportException {
+ assertThrows(
+ IllegalArgumentException.class, () -> new AutoExpandingBufferWriteTransport(config, 4, -1));
+ }
- @Test
- public void testTooSmallFrontReserveSize() throws IllegalArgumentException, TTransportException {
- assertThrows(IllegalArgumentException.class, () -> new AutoExpandingBufferWriteTransport(config, 4, 5));
- }
+ @Test
+ public void testTooSmallFrontReserveSize() throws IllegalArgumentException, TTransportException {
+ assertThrows(
+ IllegalArgumentException.class, () -> new AutoExpandingBufferWriteTransport(config, 4, 5));
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestNonblockingServerSocket.java b/lib/java/src/test/java/org/apache/thrift/transport/TestNonblockingServerSocket.java
index 6bde36c15..57a3739cb 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestNonblockingServerSocket.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestNonblockingServerSocket.java
@@ -19,17 +19,16 @@
package org.apache.thrift.transport;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import java.nio.channels.ServerSocketChannel;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
+import org.junit.jupiter.api.Test;
public class TestNonblockingServerSocket {
@Test
public void testSocketChannelBlockingMode() throws TTransportException {
- try (TNonblockingServerSocket nonblockingServer = new TNonblockingServerSocket(0)){
+ try (TNonblockingServerSocket nonblockingServer = new TNonblockingServerSocket(0)) {
ServerSocketChannel socketChannel = nonblockingServer.getServerSocketChannel();
assertFalse(socketChannel.isBlocking(), "Socket channel should be nonblocking");
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java
index 33977645d..748de121e 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java
@@ -1,37 +1,42 @@
package org.apache.thrift.transport;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
+import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-public class TestTByteBuffer {
+public class TestTByteBuffer {
@Test
public void testReadWrite() throws Exception {
final TByteBuffer byteBuffer = new TByteBuffer(ByteBuffer.allocate(16));
byteBuffer.write("Hello World".getBytes(StandardCharsets.UTF_8));
- assertEquals("Hello World", new String(byteBuffer.flip().toByteArray(), StandardCharsets.UTF_8));
+ assertEquals(
+ "Hello World", new String(byteBuffer.flip().toByteArray(), StandardCharsets.UTF_8));
}
@Test
public void testReuseReadWrite() throws Exception {
final TByteBuffer byteBuffer = new TByteBuffer(ByteBuffer.allocate(16));
byteBuffer.write("Hello World".getBytes(StandardCharsets.UTF_8));
- assertEquals("Hello World", new String(byteBuffer.flip().toByteArray(), StandardCharsets.UTF_8));
+ assertEquals(
+ "Hello World", new String(byteBuffer.flip().toByteArray(), StandardCharsets.UTF_8));
byteBuffer.clear();
byteBuffer.write("Goodbye Horses".getBytes(StandardCharsets.UTF_8));
- assertEquals("Goodbye Horses", new String(byteBuffer.flip().toByteArray(), StandardCharsets.UTF_8));
+ assertEquals(
+ "Goodbye Horses", new String(byteBuffer.flip().toByteArray(), StandardCharsets.UTF_8));
}
@Test
public void testOverflow() throws Exception {
final TByteBuffer byteBuffer = new TByteBuffer(ByteBuffer.allocate(4));
- TTransportException e = assertThrows(TTransportException.class, ()-> byteBuffer.write("Hello World".getBytes(StandardCharsets.UTF_8)));
+ TTransportException e =
+ assertThrows(
+ TTransportException.class,
+ () -> byteBuffer.write("Hello World".getBytes(StandardCharsets.UTF_8)));
assertEquals("Not enough room in output buffer", e.getMessage());
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTFastFramedTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTFastFramedTransport.java
index 6fa23807b..51568fdbe 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTFastFramedTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTFastFramedTransport.java
@@ -21,7 +21,7 @@ package org.apache.thrift.transport;
import org.apache.thrift.transport.layered.TFastFramedTransport;
public class TestTFastFramedTransport extends TestTFramedTransport {
- protected final static int INITIAL_CAPACITY = 50;
+ protected static final int INITIAL_CAPACITY = 50;
@Override
protected TTransport getTransport(TTransport underlying) throws TTransportException {
@@ -29,7 +29,8 @@ public class TestTFastFramedTransport extends TestTFramedTransport {
}
@Override
- protected TTransport getTransport(TTransport underlying, int maxLength) throws TTransportException {
+ protected TTransport getTransport(TTransport underlying, int maxLength)
+ throws TTransportException {
return new TFastFramedTransport(underlying, INITIAL_CAPACITY, maxLength);
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTFramedTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTFramedTransport.java
index 0d861bdc6..5ceefa711 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTFramedTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTFramedTransport.java
@@ -18,9 +18,12 @@
*/
package org.apache.thrift.transport;
-import org.apache.thrift.transport.layered.TFastFramedTransport;
-import org.apache.thrift.transport.layered.TFramedTransport;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -28,13 +31,9 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.apache.thrift.transport.layered.TFastFramedTransport;
+import org.apache.thrift.transport.layered.TFramedTransport;
+import org.junit.jupiter.api.Test;
public class TestTFramedTransport {
@@ -42,14 +41,15 @@ public class TestTFramedTransport {
return new TFramedTransport(underlying);
}
- protected TTransport getTransport(TTransport underlying, int maxLength) throws TTransportException {
+ protected TTransport getTransport(TTransport underlying, int maxLength)
+ throws TTransportException {
return new TFramedTransport(underlying, maxLength);
}
public static byte[] byteSequence(int start, int end) {
- byte[] result = new byte[end-start+1];
- for (int i = 0; i <= (end-start); i++) {
- result[i] = (byte)(start+i);
+ byte[] result = new byte[end - start + 1];
+ for (int i = 0; i <= (end - start); i++) {
+ result[i] = (byte) (start + i);
}
return result;
}
@@ -105,12 +105,15 @@ public class TestTFramedTransport {
TTransport trans = getTransport(countTrans, maxLength);
byte[] readBuf = new byte[10];
- TTransportException e = assertThrows(TTransportException.class, () -> trans.read(readBuf, 0, 4));
- // We expect this exception because the frame we're trying to read is larger than our max frame length
+ TTransportException e =
+ assertThrows(TTransportException.class, () -> trans.read(readBuf, 0, 4));
+ // We expect this exception because the frame we're trying to read is larger than our max frame
+ // length
assertEquals(TTransportException.CORRUPTED_DATA, e.getType());
assertFalse(trans.isOpen());
- TTransportException e2 = assertThrows(TTransportException.class, () -> trans.read(readBuf, 0, 4));
+ TTransportException e2 =
+ assertThrows(TTransportException.class, () -> trans.read(readBuf, 0, 4));
// This time we get an exception indicating the connection was closed
assertEquals(TTransportException.NOT_OPEN, e2.getType());
}
@@ -118,13 +121,14 @@ public class TestTFramedTransport {
@Test
public void testWrite() throws TTransportException, IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- WriteCountingTransport countingTrans = new WriteCountingTransport(new TIOStreamTransport(new BufferedOutputStream(baos)));
+ WriteCountingTransport countingTrans =
+ new WriteCountingTransport(new TIOStreamTransport(new BufferedOutputStream(baos)));
TTransport trans = getTransport(countingTrans);
- trans.write(byteSequence(0,100));
+ trans.write(byteSequence(0, 100));
assertEquals(0, countingTrans.writeCount);
- trans.write(byteSequence(101,200));
- trans.write(byteSequence(201,255));
+ trans.write(byteSequence(101, 200));
+ trans.write(byteSequence(201, 255));
assertEquals(0, countingTrans.writeCount);
trans.flush();
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTIOStreamTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTIOStreamTransport.java
index 4e66cf5fa..f5ae3ccad 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTIOStreamTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTIOStreamTransport.java
@@ -18,50 +18,49 @@
package org.apache.thrift.transport;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
public class TestTIOStreamTransport {
- // THRIFT-5022
- @Test
- public void testOpenClose_2streams() throws TTransportException {
- byte[] dummy = {20}; // So the input stream isn't EOF immediately.
- InputStream input = new ByteArrayInputStream(dummy);
- OutputStream output = new ByteArrayOutputStream();
- TTransport transport = new TIOStreamTransport(input, output);
- runOpenClose(transport);
- }
+ // THRIFT-5022
+ @Test
+ public void testOpenClose_2streams() throws TTransportException {
+ byte[] dummy = {20}; // So the input stream isn't EOF immediately.
+ InputStream input = new ByteArrayInputStream(dummy);
+ OutputStream output = new ByteArrayOutputStream();
+ TTransport transport = new TIOStreamTransport(input, output);
+ runOpenClose(transport);
+ }
- // THRIFT-5022
- @Test
- public void testOpenClose_1input() throws TTransportException {
- byte[] dummy = {20};
- InputStream input = new ByteArrayInputStream(dummy);
- TTransport transport = new TIOStreamTransport(input);
- runOpenClose(transport);
- }
+ // THRIFT-5022
+ @Test
+ public void testOpenClose_1input() throws TTransportException {
+ byte[] dummy = {20};
+ InputStream input = new ByteArrayInputStream(dummy);
+ TTransport transport = new TIOStreamTransport(input);
+ runOpenClose(transport);
+ }
- // THRIFT-5022
- @Test
- public void testIOpenClose_1output() throws TTransportException {
- OutputStream output = new ByteArrayOutputStream();
- TTransport transport = new TIOStreamTransport(output);
- runOpenClose(transport);
- }
+ // THRIFT-5022
+ @Test
+ public void testIOpenClose_1output() throws TTransportException {
+ OutputStream output = new ByteArrayOutputStream();
+ TTransport transport = new TIOStreamTransport(output);
+ runOpenClose(transport);
+ }
- private void runOpenClose(TTransport transport) throws TTransportException {
- transport.open();
- boolean b1 = transport.isOpen();
- assertTrue(b1);
- transport.close();
- boolean b2 = transport.isOpen();
- assertFalse(b2);
- }
+ private void runOpenClose(TTransport transport) throws TTransportException {
+ transport.open();
+ boolean b1 = transport.isOpen();
+ assertTrue(b1);
+ transport.close();
+ boolean b2 = transport.isOpen();
+ assertFalse(b2);
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryInputTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryInputTransport.java
index 482bb3a3a..888eef159 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryInputTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryInputTransport.java
@@ -18,16 +18,16 @@
*/
package org.apache.thrift.transport;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
-public class TestTMemoryInputTransport {
+import org.junit.jupiter.api.Test;
+
+public class TestTMemoryInputTransport {
@Test
public void testFresh() throws Exception {
- byte[] input_buf = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ byte[] input_buf = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
TMemoryInputTransport trans = new TMemoryInputTransport(input_buf);
assertEquals(0, trans.getBufferPosition());
assertEquals(input_buf, trans.getBuffer());
@@ -35,7 +35,7 @@ public class TestTMemoryInputTransport {
byte[] buf1 = new byte[4];
trans.readAll(buf1, 0, 4);
- assertArrayEquals(new byte[]{1, 2, 3, 4}, buf1);
+ assertArrayEquals(new byte[] {1, 2, 3, 4}, buf1);
assertEquals(4, trans.getBufferPosition());
assertEquals(6, trans.getBytesRemainingInBuffer());
@@ -45,20 +45,20 @@ public class TestTMemoryInputTransport {
assertEquals(4, trans.getBytesRemainingInBuffer());
trans.readAll(buf1, 0, 4);
- assertArrayEquals(new byte[]{7, 8, 9, 10}, buf1);
+ assertArrayEquals(new byte[] {7, 8, 9, 10}, buf1);
assertEquals(10, trans.getBufferPosition());
assertEquals(0, trans.getBytesRemainingInBuffer());
}
@Test
public void testReused() throws Exception {
- byte[] input_buf = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ byte[] input_buf = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
TMemoryInputTransport trans = new TMemoryInputTransport(input_buf);
assertEquals(0, trans.getBufferPosition());
assertEquals(input_buf, trans.getBuffer());
assertEquals(10, trans.getBytesRemainingInBuffer());
- byte[] new_buf = new byte[]{10, 9, 8};
+ byte[] new_buf = new byte[] {10, 9, 8};
trans.reset(new_buf);
assertEquals(0, trans.getBufferPosition());
assertEquals(new_buf, trans.getBuffer());
@@ -67,7 +67,7 @@ public class TestTMemoryInputTransport {
@Test
public void testWithOffsetAndLength() throws TTransportException {
- byte[] input_buf = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ byte[] input_buf = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
TMemoryInputTransport trans = new TMemoryInputTransport(input_buf, 1, 3);
assertEquals(1, trans.getBufferPosition());
assertEquals(3, trans.getBytesRemainingInBuffer());
@@ -75,7 +75,7 @@ public class TestTMemoryInputTransport {
{
byte[] readBuffer = new byte[3];
trans.readAll(readBuffer, 0, 3);
- assertArrayEquals(new byte[]{2, 3, 4}, readBuffer);
+ assertArrayEquals(new byte[] {2, 3, 4}, readBuffer);
assertThrows(Exception.class, () -> trans.readAll(readBuffer, 0, 3));
}
@@ -83,7 +83,7 @@ public class TestTMemoryInputTransport {
trans.reset(input_buf, 3, 4);
byte[] readBuffer2 = new byte[4];
trans.readAll(readBuffer2, 0, 4);
- assertArrayEquals(new byte[]{4, 5, 6, 7}, readBuffer2);
+ assertArrayEquals(new byte[] {4, 5, 6, 7}, readBuffer2);
}
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryTransport.java
index 6d221db96..9575610a0 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTMemoryTransport.java
@@ -19,15 +19,14 @@
package org.apache.thrift.transport;
-import org.apache.thrift.TByteArrayOutputStream;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.function.Executable;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.nio.ByteBuffer;
import java.util.Random;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import org.apache.thrift.TByteArrayOutputStream;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
public class TestTMemoryTransport {
@@ -51,12 +50,14 @@ public class TestTMemoryTransport {
public void testReadMoreThanRemaining() throws TTransportException {
TMemoryTransport transport = new TMemoryTransport(new byte[] {0x00, 0x32});
byte[] read = new byte[3];
- assertThrows(TTransportException.class, new Executable() {
- @Override
- public void execute() throws Throwable {
- transport.read(read, 0, 3);
- }
- });
+ assertThrows(
+ TTransportException.class,
+ new Executable() {
+ @Override
+ public void execute() throws Throwable {
+ transport.read(read, 0, 3);
+ }
+ });
}
@Test
@@ -68,6 +69,8 @@ public class TestTMemoryTransport {
transport.write(output2, 0, 2);
byte[] expected = {0x72, 0x56, 0x29, (byte) 0xAF, (byte) 0x9B, (byte) 0x83, 0x10};
TByteArrayOutputStream outputByteArray = transport.getOutput();
- assertEquals(ByteBuffer.wrap(expected), ByteBuffer.wrap(outputByteArray.get(), 0, outputByteArray.len()));
+ assertEquals(
+ ByteBuffer.wrap(expected),
+ ByteBuffer.wrap(outputByteArray.get(), 0, outputByteArray.len()));
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactory.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactory.java
index b5186c060..b0f709b9a 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactory.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactory.java
@@ -19,10 +19,8 @@
package org.apache.thrift.transport;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
@@ -36,12 +34,15 @@ public class TestTSSLTransportFactory extends ServerTestBase {
private TServer server;
// TODO: Only supported on TBinaryProtocol. Doesn't work for TCompactProtocol
- private static final List<TProtocolFactory> protocols = Collections.singletonList(new TBinaryProtocol.Factory());
+ private static final List<TProtocolFactory> protocols =
+ Collections.singletonList(new TBinaryProtocol.Factory());
private static final String keyStoreLocation = System.getProperty("javax.net.ssl.keyStore");
- private static final String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
+ private static final String keyStorePassword =
+ System.getProperty("javax.net.ssl.keyStorePassword");
private static final String trustStoreLocation = System.getProperty("javax.net.ssl.trustStore");
- private static final String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
+ private static final String trustStorePassword =
+ System.getProperty("javax.net.ssl.trustStorePassword");
protected final String getKeyStoreLocation() {
return keyStoreLocation;
@@ -60,8 +61,7 @@ public class TestTSSLTransportFactory extends ServerTestBase {
}
@Override
- public TTransport getClientTransport(TTransport underlyingTransport)
- throws Exception {
+ public TTransport getClientTransport(TTransport underlyingTransport) throws Exception {
return TSSLTransportFactory.getClientSocket(HOST, PORT);
}
@@ -70,19 +70,24 @@ public class TestTSSLTransportFactory extends ServerTestBase {
}
@Override
- public void startServer(final TProcessor processor, final TProtocolFactory protoFactory, final TTransportFactory factory)
- throws Exception {
- serverThread = new Thread(() -> {
- try {
- TServerTransport serverTransport = getServerTransport();
- final Args args = new Args(serverTransport).processor(processor);
- server = new TSimpleServer(args);
- server.serve();
- } catch (Exception e) {
- e.printStackTrace();
- assert false;
- }
- });
+ public void startServer(
+ final TProcessor processor,
+ final TProtocolFactory protoFactory,
+ final TTransportFactory factory)
+ throws Exception {
+ serverThread =
+ new Thread(
+ () -> {
+ try {
+ TServerTransport serverTransport = getServerTransport();
+ final Args args = new Args(serverTransport).processor(processor);
+ server = new TSimpleServer(args);
+ server.serve();
+ } catch (Exception e) {
+ e.printStackTrace();
+ assert false;
+ }
+ });
serverThread.start();
Thread.sleep(SLEEP_DELAY);
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient1.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient1.java
index 6b543e3a3..6a69872e8 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient1.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient1.java
@@ -22,11 +22,10 @@ package org.apache.thrift.transport;
public class TestTSSLTransportFactoryCustomClient1 extends TestTSSLTransportFactory {
@Override
- public TTransport getClientTransport(TTransport underlyingTransport)
- throws Exception {
- TSSLTransportFactory.TSSLTransportParameters params = new
- TSSLTransportFactory.TSSLTransportParameters();
+ public TTransport getClientTransport(TTransport underlyingTransport) throws Exception {
+ TSSLTransportFactory.TSSLTransportParameters params =
+ new TSSLTransportFactory.TSSLTransportParameters();
params.setTrustStore(getTrustStoreLocation(), getTrustStorePassword());
- return TSSLTransportFactory.getClientSocket(HOST, PORT, 0/*timeout*/, params);
+ return TSSLTransportFactory.getClientSocket(HOST, PORT, 0 /*timeout*/, params);
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient2.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient2.java
index 2427b9be3..cd0229f2a 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient2.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryCustomClient2.java
@@ -22,11 +22,10 @@ package org.apache.thrift.transport;
public class TestTSSLTransportFactoryCustomClient2 extends TestTSSLTransportFactory {
@Override
- public TTransport getClientTransport(TTransport underlyingTransport)
- throws Exception {
- TSSLTransportFactory.TSSLTransportParameters params = new
- TSSLTransportFactory.TSSLTransportParameters();
+ public TTransport getClientTransport(TTransport underlyingTransport) throws Exception {
+ TSSLTransportFactory.TSSLTransportParameters params =
+ new TSSLTransportFactory.TSSLTransportParameters();
params.setTrustStore(getTrustStoreLocation(), null);
- return TSSLTransportFactory.getClientSocket(HOST, PORT, 0/*timeout*/, params);
+ return TSSLTransportFactory.getClientSocket(HOST, PORT, 0 /*timeout*/, params);
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryStreamedStore.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryStreamedStore.java
index cc3cb68ca..55b965f75 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryStreamedStore.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTSSLTransportFactoryStreamedStore.java
@@ -25,23 +25,23 @@ import java.net.InetAddress;
public class TestTSSLTransportFactoryStreamedStore extends TestTSSLTransportFactory {
@Override
- public TTransport getClientTransport(TTransport underlyingTransport)
- throws Exception {
- TSSLTransportFactory.TSSLTransportParameters params = new
- TSSLTransportFactory.TSSLTransportParameters();
+ public TTransport getClientTransport(TTransport underlyingTransport) throws Exception {
+ TSSLTransportFactory.TSSLTransportParameters params =
+ new TSSLTransportFactory.TSSLTransportParameters();
params.setTrustStore(new FileInputStream(getTrustStoreLocation()), getTrustStorePassword());
- return TSSLTransportFactory.getClientSocket(HOST, PORT, 0/*timeout*/, params);
+ return TSSLTransportFactory.getClientSocket(HOST, PORT, 0 /*timeout*/, params);
}
@Override
protected TServerSocket getServerTransport() throws Exception {
- TSSLTransportFactory.TSSLTransportParameters params = new
- TSSLTransportFactory.TSSLTransportParameters();
+ TSSLTransportFactory.TSSLTransportParameters params =
+ new TSSLTransportFactory.TSSLTransportParameters();
params.setKeyStore(new FileInputStream(getKeyStoreLocation()), getKeyStorePassword());
- return TSSLTransportFactory.getServerSocket(PORT, 0/*timeout*/, InetAddress.getByName(HOST), params);
+ return TSSLTransportFactory.getServerSocket(
+ PORT, 0 /*timeout*/, InetAddress.getByName(HOST), params);
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java
index 7cc5ca6c6..224da216d 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java
@@ -19,17 +19,17 @@
package org.apache.thrift.transport;
-import org.apache.thrift.TConfiguration;
-import org.apache.thrift.TProcessor;
-import org.apache.thrift.protocol.TProtocolFactory;
-import org.apache.thrift.server.ServerTestBase;
-import org.apache.thrift.server.TServer;
-import org.apache.thrift.server.TServer.Args;
-import org.apache.thrift.server.TSimpleServer;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
@@ -43,19 +43,18 @@ import javax.security.sasl.SaslClientFactory;
import javax.security.sasl.SaslException;
import javax.security.sasl.SaslServer;
import javax.security.sasl.SaslServerFactory;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
+import org.apache.thrift.TConfiguration;
+import org.apache.thrift.TProcessor;
+import org.apache.thrift.protocol.TProtocolFactory;
+import org.apache.thrift.server.ServerTestBase;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TServer.Args;
+import org.apache.thrift.server.TSimpleServer;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class TestTSaslTransports {
+public class TestTSaslTransports {
private static final Logger LOGGER = LoggerFactory.getLogger(TestTSaslTransports.class);
@@ -76,15 +75,16 @@ public class TestTSaslTransports {
WRAPPED_PROPS.put("com.sun.security.sasl.digest.realm", REALM);
}
- private static final String testMessage1 = "Hello, world! Also, four "
- + "score and seven years ago our fathers brought forth on this "
- + "continent a new nation, conceived in liberty, and dedicated to the "
- + "proposition that all men are created equal.";
-
- private static final String testMessage2 = "I have a dream that one day "
- + "this nation will rise up and live out the true meaning of its creed: "
- + "'We hold these truths to be self-evident, that all men are created equal.'";
+ private static final String testMessage1 =
+ "Hello, world! Also, four "
+ + "score and seven years ago our fathers brought forth on this "
+ + "continent a new nation, conceived in liberty, and dedicated to the "
+ + "proposition that all men are created equal.";
+ private static final String testMessage2 =
+ "I have a dream that one day "
+ + "this nation will rise up and live out the true meaning of its creed: "
+ + "'We hold these truths to be self-evident, that all men are created equal.'";
public static class TestSaslCallbackHandler implements CallbackHandler {
private final String password;
@@ -130,19 +130,23 @@ public class TestTSaslTransports {
}
private void internalRun() throws Exception {
- try (TServerSocket serverSocket = new TServerSocket(
- new TServerSocket.ServerSocketTransportArgs().
- port(ServerTestBase.PORT))) {
+ try (TServerSocket serverSocket =
+ new TServerSocket(
+ new TServerSocket.ServerSocketTransportArgs().port(ServerTestBase.PORT))) {
acceptAndWrite(serverSocket);
}
}
- private void acceptAndWrite(TServerSocket serverSocket)
- throws Exception {
+ private void acceptAndWrite(TServerSocket serverSocket) throws Exception {
TTransport serverTransport = serverSocket.accept();
- TTransport saslServerTransport = new TSaslServerTransport(
- mechanism, SERVICE, HOST,
- props, new TestSaslCallbackHandler(PASSWORD), serverTransport);
+ TTransport saslServerTransport =
+ new TSaslServerTransport(
+ mechanism,
+ SERVICE,
+ HOST,
+ props,
+ new TestSaslCallbackHandler(PASSWORD),
+ serverTransport);
saslServerTransport.open();
@@ -177,8 +181,15 @@ public class TestTSaslTransports {
try {
TSocket clientSocket = new TSocket(HOST, ServerTestBase.PORT);
- TTransport saslClientTransport = new TSaslClientTransport(mechanism,
- PRINCIPAL, SERVICE, HOST, props, new TestSaslCallbackHandler(PASSWORD), clientSocket);
+ TTransport saslClientTransport =
+ new TSaslClientTransport(
+ mechanism,
+ PRINCIPAL,
+ SERVICE,
+ HOST,
+ props,
+ new TestSaslCallbackHandler(PASSWORD),
+ clientSocket);
saslClientTransport.open();
LOGGER.debug("client writing: {}", testMessage1);
saslClientTransport.write(testMessage1.getBytes());
@@ -228,8 +239,8 @@ public class TestTSaslTransports {
}
/**
- * Test that we get the proper exceptions thrown back the server when
- * the client provides invalid password.
+ * Test that we get the proper exceptions thrown back the server when the client provides invalid
+ * password.
*/
@Test
public void testBadPassword() throws Exception {
@@ -242,13 +253,23 @@ public class TestTSaslTransports {
// Ah well.
}
- TTransportException tte = assertThrows(TTransportException.class, () -> {
- TSocket clientSocket = new TSocket(HOST, ServerTestBase.PORT);
- TTransport saslClientTransport = new TSaslClientTransport(
- UNWRAPPED_MECHANISM, PRINCIPAL, SERVICE, HOST, UNWRAPPED_PROPS,
- new TestSaslCallbackHandler("NOT THE PASSWORD"), clientSocket);
- saslClientTransport.open();
- }, "Was able to open transport with bad password");
+ TTransportException tte =
+ assertThrows(
+ TTransportException.class,
+ () -> {
+ TSocket clientSocket = new TSocket(HOST, ServerTestBase.PORT);
+ TTransport saslClientTransport =
+ new TSaslClientTransport(
+ UNWRAPPED_MECHANISM,
+ PRINCIPAL,
+ SERVICE,
+ HOST,
+ UNWRAPPED_PROPS,
+ new TestSaslCallbackHandler("NOT THE PASSWORD"),
+ clientSocket);
+ saslClientTransport.open();
+ },
+ "Was able to open transport with bad password");
LOGGER.error("Exception for bad password", tte);
assertNotNull(tte.getMessage());
assertTrue(tte.getMessage().contains("Invalid response"));
@@ -271,32 +292,52 @@ public class TestTSaslTransports {
@Override
public TTransport getClientTransport(TTransport underlyingTransport) throws Exception {
return new TSaslClientTransport(
- WRAPPED_MECHANISM, PRINCIPAL, SERVICE, HOST, WRAPPED_PROPS,
- new TestSaslCallbackHandler(PASSWORD), underlyingTransport);
+ WRAPPED_MECHANISM,
+ PRINCIPAL,
+ SERVICE,
+ HOST,
+ WRAPPED_PROPS,
+ new TestSaslCallbackHandler(PASSWORD),
+ underlyingTransport);
}
@Override
- public void startServer(final TProcessor processor, final TProtocolFactory protoFactory, final TTransportFactory factory) throws Exception {
- serverThread = new Thread() {
- public void run() {
- try {
- // Transport
- TServerSocket socket = new TServerSocket(new TServerSocket.ServerSocketTransportArgs().port(PORT));
-
- TTransportFactory factory = new TSaslServerTransport.Factory(
- WRAPPED_MECHANISM, SERVICE, HOST, WRAPPED_PROPS,
- new TestSaslCallbackHandler(PASSWORD));
- server = new TSimpleServer(new Args(socket).processor(processor).transportFactory(factory).protocolFactory(protoFactory));
-
- // Run it
- LOGGER.debug("Starting the server on port {}", PORT);
- server.serve();
- } catch (Exception e) {
- e.printStackTrace();
- fail(e);
- }
- }
- };
+ public void startServer(
+ final TProcessor processor,
+ final TProtocolFactory protoFactory,
+ final TTransportFactory factory)
+ throws Exception {
+ serverThread =
+ new Thread() {
+ public void run() {
+ try {
+ // Transport
+ TServerSocket socket =
+ new TServerSocket(new TServerSocket.ServerSocketTransportArgs().port(PORT));
+
+ TTransportFactory factory =
+ new TSaslServerTransport.Factory(
+ WRAPPED_MECHANISM,
+ SERVICE,
+ HOST,
+ WRAPPED_PROPS,
+ new TestSaslCallbackHandler(PASSWORD));
+ server =
+ new TSimpleServer(
+ new Args(socket)
+ .processor(processor)
+ .transportFactory(factory)
+ .protocolFactory(protoFactory));
+
+ // Run it
+ LOGGER.debug("Starting the server on port {}", PORT);
+ server.serve();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e);
+ }
+ }
+ };
serverThread.start();
Thread.sleep(1000);
}
@@ -310,14 +351,9 @@ public class TestTSaslTransports {
LOGGER.debug("interrupted during sleep", e);
}
}
-
}
-
- /**
- * Implementation of SASL ANONYMOUS, used for testing client-side
- * initial responses.
- */
+ /** Implementation of SASL ANONYMOUS, used for testing client-side initial responses. */
private static class AnonymousClient implements SaslClient {
private final String username;
private boolean hasProvidedInitialResponse;
@@ -327,9 +363,15 @@ public class TestTSaslTransports {
}
@Override
- public String getMechanismName() { return "ANONYMOUS"; }
+ public String getMechanismName() {
+ return "ANONYMOUS";
+ }
+
@Override
- public boolean hasInitialResponse() { return true; }
+ public boolean hasInitialResponse() {
+ return true;
+ }
+
@Override
public byte[] evaluateChallenge(byte[] challenge) throws SaslException {
if (hasProvidedInitialResponse) {
@@ -339,58 +381,84 @@ public class TestTSaslTransports {
hasProvidedInitialResponse = true;
return username.getBytes(StandardCharsets.UTF_8);
}
+
@Override
- public boolean isComplete() { return hasProvidedInitialResponse; }
+ public boolean isComplete() {
+ return hasProvidedInitialResponse;
+ }
+
@Override
public byte[] unwrap(byte[] incoming, int offset, int len) {
throw new UnsupportedOperationException();
}
+
@Override
public byte[] wrap(byte[] outgoing, int offset, int len) {
throw new UnsupportedOperationException();
}
+
@Override
- public Object getNegotiatedProperty(String propName) { return null; }
+ public Object getNegotiatedProperty(String propName) {
+ return null;
+ }
+
@Override
public void dispose() {}
}
private static class AnonymousServer implements SaslServer {
private String user;
+
@Override
- public String getMechanismName() { return "ANONYMOUS"; }
+ public String getMechanismName() {
+ return "ANONYMOUS";
+ }
+
@Override
public byte[] evaluateResponse(byte[] response) throws SaslException {
this.user = new String(response, StandardCharsets.UTF_8);
return null;
}
+
@Override
- public boolean isComplete() { return user != null; }
+ public boolean isComplete() {
+ return user != null;
+ }
+
@Override
- public String getAuthorizationID() { return user; }
+ public String getAuthorizationID() {
+ return user;
+ }
+
@Override
public byte[] unwrap(byte[] incoming, int offset, int len) {
throw new UnsupportedOperationException();
}
+
@Override
public byte[] wrap(byte[] outgoing, int offset, int len) {
throw new UnsupportedOperationException();
}
+
@Override
- public Object getNegotiatedProperty(String propName) { return null; }
+ public Object getNegotiatedProperty(String propName) {
+ return null;
+ }
+
@Override
public void dispose() {}
-
}
- public static class SaslAnonymousFactory
- implements SaslClientFactory, SaslServerFactory {
+ public static class SaslAnonymousFactory implements SaslClientFactory, SaslServerFactory {
@Override
public SaslClient createSaslClient(
- String[] mechanisms, String authorizationId, String protocol,
- String serverName, Map<String,?> props, CallbackHandler cbh)
- {
+ String[] mechanisms,
+ String authorizationId,
+ String protocol,
+ String serverName,
+ Map<String, ?> props,
+ CallbackHandler cbh) {
for (String mech : mechanisms) {
if ("ANONYMOUS".equals(mech)) {
return new AnonymousClient(authorizationId);
@@ -401,22 +469,27 @@ public class TestTSaslTransports {
@Override
public SaslServer createSaslServer(
- String mechanism, String protocol, String serverName, Map<String,?> props, CallbackHandler cbh)
- {
+ String mechanism,
+ String protocol,
+ String serverName,
+ Map<String, ?> props,
+ CallbackHandler cbh) {
if ("ANONYMOUS".equals(mechanism)) {
return new AnonymousServer();
}
return null;
}
+
@Override
public String[] getMechanismNames(Map<String, ?> props) {
- return new String[] { "ANONYMOUS" };
+ return new String[] {"ANONYMOUS"};
}
}
static {
java.security.Security.addProvider(new SaslAnonymousProvider());
}
+
public static class SaslAnonymousProvider extends java.security.Provider {
public SaslAnonymousProvider() {
super("ThriftSaslAnonymous", 1.0, "Thrift Anonymous SASL provider");
@@ -432,15 +505,15 @@ public class TestTSaslTransports {
public MockTTransport(int mode) throws TTransportException {
readBuffer = new TMemoryInputTransport();
- if (mode==1) {
+ if (mode == 1) {
// Invalid status byte
- badHeader = new byte[] { (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x05 };
+ badHeader = new byte[] {(byte) 0xFF, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x05};
} else if (mode == 2) {
// Valid status byte, negative payload length
- badHeader = new byte[] { (byte)0x01, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF };
+ badHeader = new byte[] {(byte) 0x01, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
} else if (mode == 3) {
// Valid status byte, excessively large, bogus payload length
- badHeader = new byte[] { (byte)0x01, (byte)0x64, (byte)0x00, (byte)0x00, (byte)0x00 };
+ badHeader = new byte[] {(byte) 0x01, (byte) 0x64, (byte) 0x00, (byte) 0x00, (byte) 0x00};
}
readBuffer.reset(badHeader);
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTSimpleFileTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTSimpleFileTransport.java
index 926b78220..94c1f3296 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTSimpleFileTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTSimpleFileTransport.java
@@ -18,41 +18,41 @@
*/
package org.apache.thrift.transport;
-import org.junit.jupiter.api.Test;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
-public class TestTSimpleFileTransport {
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.junit.jupiter.api.Test;
+
+public class TestTSimpleFileTransport {
@Test
public void testFresh() throws Exception {
- //Test write side
+ // Test write side
Path tempFilePathName = Files.createTempFile("TSimpleFileTransportTest", null);
Files.delete(tempFilePathName);
- byte[] input_buf = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- TSimpleFileTransport trans_write = new TSimpleFileTransport(tempFilePathName.toString(),false, true, false);
+ byte[] input_buf = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ TSimpleFileTransport trans_write =
+ new TSimpleFileTransport(tempFilePathName.toString(), false, true, false);
assert (!trans_write.isOpen());
trans_write.open();
- assert(trans_write.isOpen());
+ assert (trans_write.isOpen());
trans_write.write(input_buf);
- trans_write.write(input_buf,2,2);
+ trans_write.write(input_buf, 2, 2);
trans_write.flush();
trans_write.close();
- //Test read side
- TSimpleFileTransport trans = new TSimpleFileTransport(tempFilePathName.toString(),true, false);
- assert(trans.isOpen());
+ // Test read side
+ TSimpleFileTransport trans = new TSimpleFileTransport(tempFilePathName.toString(), true, false);
+ assert (trans.isOpen());
- //Simple file trans provides no buffer access
+ // Simple file trans provides no buffer access
assertEquals(0, trans.getBufferPosition());
assertNull(trans.getBuffer());
assertEquals(-1, trans.getBytesRemainingInBuffer());
- //Test file pointer operations
+ // Test file pointer operations
assertEquals(0, trans.getFilePointer());
assertEquals(12, trans.length());
@@ -60,10 +60,10 @@ public class TestTSimpleFileTransport {
byte[] buf1 = new byte[BUFSIZ];
trans.readAll(buf1, 0, BUFSIZ);
assertEquals(BUFSIZ, trans.getFilePointer());
- assertArrayEquals(new byte[]{1, 2, 3, 4}, buf1);
+ assertArrayEquals(new byte[] {1, 2, 3, 4}, buf1);
int bytesRead = trans.read(buf1, 0, BUFSIZ);
- assert(bytesRead > 0);
+ assert (bytesRead > 0);
for (int i = 0; i < bytesRead; ++i) {
assertEquals(buf1[i], i + 5);
}
@@ -71,7 +71,7 @@ public class TestTSimpleFileTransport {
trans.seek(0);
assertEquals(0, trans.getFilePointer());
trans.readAll(buf1, 0, BUFSIZ);
- assertArrayEquals(new byte[]{1, 2, 3, 4}, buf1);
+ assertArrayEquals(new byte[] {1, 2, 3, 4}, buf1);
assertEquals(BUFSIZ, trans.getFilePointer());
trans.close();
Files.delete(tempFilePathName);
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTZlibTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTZlibTransport.java
index 75e917f6a..345a4d708 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/TestTZlibTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTZlibTransport.java
@@ -18,7 +18,8 @@
*/
package org.apache.thrift.transport;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -29,20 +30,18 @@ import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
+import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class TestTZlibTransport {
+public class TestTZlibTransport {
protected TTransport getTransport(TTransport underlying) throws TTransportException {
return new TZlibTransport(underlying);
}
public static byte[] byteSequence(int start, int end) {
- byte[] result = new byte[end-start+1];
- for (int i = 0; i <= (end-start); i++) {
- result[i] = (byte)(start+i);
+ byte[] result = new byte[end - start + 1];
+ for (int i = 0; i <= (end - start); i++) {
+ result[i] = (byte) (start + i);
}
return result;
}
@@ -50,8 +49,8 @@ public class TestTZlibTransport {
@Test
public void testClose() throws TTransportException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- WriteCountingTransport countingTrans = new WriteCountingTransport(new TIOStreamTransport(new BufferedOutputStream
- (baos)));
+ WriteCountingTransport countingTrans =
+ new WriteCountingTransport(new TIOStreamTransport(new BufferedOutputStream(baos)));
TTransport trans = getTransport(countingTrans);
trans.write(byteSequence(0, 245));
countingTrans.close();
@@ -68,7 +67,8 @@ public class TestTZlibTransport {
final byte[] compressed = baos.toByteArray();
final byte[] buf = new byte[255];
- TTransport transRead = getTransport(new TIOStreamTransport(new ByteArrayInputStream(compressed)));
+ TTransport transRead =
+ getTransport(new TIOStreamTransport(new ByteArrayInputStream(compressed)));
int readBytes = transRead.read(buf, 0, buf.length);
assertEquals(uncompressed.length, readBytes);
transRead.close();
@@ -111,7 +111,8 @@ public class TestTZlibTransport {
@Test
public void testWrite() throws TTransportException, IOException, DataFormatException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- WriteCountingTransport countingTrans = new WriteCountingTransport(new TIOStreamTransport(new BufferedOutputStream(baos)));
+ WriteCountingTransport countingTrans =
+ new WriteCountingTransport(new TIOStreamTransport(new BufferedOutputStream(baos)));
TTransport trans = getTransport(countingTrans);
trans.write(byteSequence(0, 100));
@@ -127,7 +128,8 @@ public class TestTZlibTransport {
trans.flush();
assertEquals(3, countingTrans.writeCount);
- DataInputStream din = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(baos.toByteArray())));
+ DataInputStream din =
+ new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(baos.toByteArray())));
byte[] buf = new byte[256];
int n = din.read(buf, 0, 256);
assertEquals(n, 256);
@@ -136,11 +138,10 @@ public class TestTZlibTransport {
buf = new byte[246];
n = din.read(buf, 0, 246);
assertEquals(n, 246);
- for (int i = 0; i<buf.length; i++) {
- assertEquals(byteSequence(0,245)[i], buf[i], "for "+i);
+ for (int i = 0; i < buf.length; i++) {
+ assertEquals(byteSequence(0, 245)[i], buf[i], "for " + i);
}
assertArrayEquals(byteSequence(0, 245), buf);
}
-
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/WriteCountingTransport.java b/lib/java/src/test/java/org/apache/thrift/transport/WriteCountingTransport.java
index 50b778b89..cb05a928b 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/WriteCountingTransport.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/WriteCountingTransport.java
@@ -18,7 +18,6 @@
*/
package org.apache.thrift.transport;
-
import org.apache.thrift.TConfiguration;
public class WriteCountingTransport extends TTransport {
@@ -33,7 +32,9 @@ public class WriteCountingTransport extends TTransport {
public void close() {}
@Override
- public boolean isOpen() {return true;}
+ public boolean isOpen() {
+ return true;
+ }
@Override
public void open() throws TTransportException {}
@@ -45,7 +46,7 @@ public class WriteCountingTransport extends TTransport {
@Override
public void write(byte[] buf, int off, int len) throws TTransportException {
- writeCount ++;
+ writeCount++;
trans.write(buf, off, len);
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameReader.java b/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameReader.java
index 4b90cceca..4288d4a65 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameReader.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameReader.java
@@ -19,23 +19,23 @@
package org.apache.thrift.transport.sasl;
-import org.apache.thrift.transport.TMemoryInputTransport;
-import org.apache.thrift.transport.TTransportException;
-import org.junit.jupiter.api.Test;
-
-import java.nio.ByteBuffer;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.nio.ByteBuffer;
+import org.apache.thrift.transport.TMemoryInputTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.junit.jupiter.api.Test;
+
public class TestDataFrameReader {
@Test
public void testRead() throws TTransportException {
// Prepare data
int payloadSize = 23;
- ByteBuffer buffer = ByteBuffer.allocate(DataFrameHeaderReader.PAYLOAD_LENGTH_BYTES + payloadSize);
+ ByteBuffer buffer =
+ ByteBuffer.allocate(DataFrameHeaderReader.PAYLOAD_LENGTH_BYTES + payloadSize);
buffer.putInt(payloadSize);
for (int i = 0; i < payloadSize; i++) {
buffer.put((byte) i);
@@ -53,12 +53,18 @@ public class TestDataFrameReader {
dataFrameReader.read(transport);
assertFalse(dataFrameReader.isComplete(), "Only header is complete");
assertTrue(dataFrameReader.getHeader().isComplete(), "Header should be complete");
- assertEquals(payloadSize, dataFrameReader.getHeader().payloadSize(), "Payload size should be " + payloadSize);
+ assertEquals(
+ payloadSize,
+ dataFrameReader.getHeader().payloadSize(),
+ "Payload size should be " + payloadSize);
// Read the rest of payload.
transport.reset(buffer.array(), 6, 21);
dataFrameReader.read(transport);
assertTrue(dataFrameReader.isComplete(), "Reader should be complete");
buffer.position(DataFrameHeaderReader.PAYLOAD_LENGTH_BYTES);
- assertEquals(buffer, ByteBuffer.wrap(dataFrameReader.getPayload()), "Payload should be the same as from the transport");
+ assertEquals(
+ buffer,
+ ByteBuffer.wrap(dataFrameReader.getPayload()),
+ "Payload should be the same as from the transport");
}
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameWriter.java b/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameWriter.java
index b6f4529e7..741a5f78f 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameWriter.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestDataFrameWriter.java
@@ -19,6 +19,13 @@
package org.apache.thrift.transport.sasl;
+import static org.apache.thrift.transport.sasl.DataFrameHeaderReader.PAYLOAD_LENGTH_BYTES;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.nio.ByteBuffer;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.transport.TNonblockingTransport;
import org.junit.jupiter.api.Test;
@@ -26,80 +33,76 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import java.nio.ByteBuffer;
-
-import static org.apache.thrift.transport.sasl.DataFrameHeaderReader.PAYLOAD_LENGTH_BYTES;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class TestDataFrameWriter {
- private static final byte[] BYTES = new byte[]{0x32, 0x2A, (byte) 0xE1, 0x18, (byte) 0x90, 0x75};
+ private static final byte[] BYTES = new byte[] {0x32, 0x2A, (byte) 0xE1, 0x18, (byte) 0x90, 0x75};
- @Test
- public void testProvideEntireByteArrayAsPayload() {
- DataFrameWriter frameWriter = new DataFrameWriter();
- frameWriter.withOnlyPayload(BYTES);
- byte[] expectedBytes = new byte[BYTES.length + PAYLOAD_LENGTH_BYTES];
- EncodingUtils.encodeBigEndian(BYTES.length, expectedBytes);
- System.arraycopy(BYTES, 0, expectedBytes, PAYLOAD_LENGTH_BYTES, BYTES.length);
- assertEquals(ByteBuffer.wrap(expectedBytes), frameWriter.frameBytes);
- }
+ @Test
+ public void testProvideEntireByteArrayAsPayload() {
+ DataFrameWriter frameWriter = new DataFrameWriter();
+ frameWriter.withOnlyPayload(BYTES);
+ byte[] expectedBytes = new byte[BYTES.length + PAYLOAD_LENGTH_BYTES];
+ EncodingUtils.encodeBigEndian(BYTES.length, expectedBytes);
+ System.arraycopy(BYTES, 0, expectedBytes, PAYLOAD_LENGTH_BYTES, BYTES.length);
+ assertEquals(ByteBuffer.wrap(expectedBytes), frameWriter.frameBytes);
+ }
- @Test
- public void testProvideByteArrayPortionAsPayload() {
- DataFrameWriter frameWriter = new DataFrameWriter();
- int portionOffset = 2;
- int portionLength = 3;
- frameWriter.withOnlyPayload(BYTES, portionOffset, portionLength);
- byte[] expectedBytes = new byte[portionLength + PAYLOAD_LENGTH_BYTES];
- EncodingUtils.encodeBigEndian(portionLength, expectedBytes);
- System.arraycopy(BYTES, portionOffset, expectedBytes, PAYLOAD_LENGTH_BYTES, portionLength);
- assertEquals(ByteBuffer.wrap(expectedBytes), frameWriter.frameBytes);
- }
+ @Test
+ public void testProvideByteArrayPortionAsPayload() {
+ DataFrameWriter frameWriter = new DataFrameWriter();
+ int portionOffset = 2;
+ int portionLength = 3;
+ frameWriter.withOnlyPayload(BYTES, portionOffset, portionLength);
+ byte[] expectedBytes = new byte[portionLength + PAYLOAD_LENGTH_BYTES];
+ EncodingUtils.encodeBigEndian(portionLength, expectedBytes);
+ System.arraycopy(BYTES, portionOffset, expectedBytes, PAYLOAD_LENGTH_BYTES, portionLength);
+ assertEquals(ByteBuffer.wrap(expectedBytes), frameWriter.frameBytes);
+ }
- @Test
- public void testProvideHeaderAndPayload() {
- DataFrameWriter frameWriter = new DataFrameWriter();
- assertThrows(IllegalArgumentException.class, () -> frameWriter.withHeaderAndPayload(new byte[1], new byte[1]));
- }
+ @Test
+ public void testProvideHeaderAndPayload() {
+ DataFrameWriter frameWriter = new DataFrameWriter();
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> frameWriter.withHeaderAndPayload(new byte[1], new byte[1]));
+ }
- @Test
- public void testProvidePayloadToIncompleteFrame() {
- DataFrameWriter frameWriter = new DataFrameWriter();
- assertThrows(IllegalStateException.class, () -> {
- frameWriter.withOnlyPayload(BYTES);
- frameWriter.withOnlyPayload(new byte[1]);
+ @Test
+ public void testProvidePayloadToIncompleteFrame() {
+ DataFrameWriter frameWriter = new DataFrameWriter();
+ assertThrows(
+ IllegalStateException.class,
+ () -> {
+ frameWriter.withOnlyPayload(BYTES);
+ frameWriter.withOnlyPayload(new byte[1]);
});
- }
+ }
- @Test
- public void testWrite() throws Exception {
- DataFrameWriter frameWriter = new DataFrameWriter();
- frameWriter.withOnlyPayload(BYTES);
- // Slow socket which writes one byte per call.
- TNonblockingTransport transport = Mockito.mock(TNonblockingTransport.class);
- SlowWriting slowWriting = new SlowWriting();
- Mockito.when(transport.write(frameWriter.frameBytes)).thenAnswer(slowWriting);
- frameWriter.write(transport);
- while (slowWriting.written < frameWriter.frameBytes.limit()) {
- assertFalse(frameWriter.isComplete(), "Frame writer should not be complete");
- frameWriter.write(transport);
- }
- assertTrue(frameWriter.isComplete(), "Frame writer should be complete");
+ @Test
+ public void testWrite() throws Exception {
+ DataFrameWriter frameWriter = new DataFrameWriter();
+ frameWriter.withOnlyPayload(BYTES);
+ // Slow socket which writes one byte per call.
+ TNonblockingTransport transport = Mockito.mock(TNonblockingTransport.class);
+ SlowWriting slowWriting = new SlowWriting();
+ Mockito.when(transport.write(frameWriter.frameBytes)).thenAnswer(slowWriting);
+ frameWriter.write(transport);
+ while (slowWriting.written < frameWriter.frameBytes.limit()) {
+ assertFalse(frameWriter.isComplete(), "Frame writer should not be complete");
+ frameWriter.write(transport);
}
+ assertTrue(frameWriter.isComplete(), "Frame writer should be complete");
+ }
- private static class SlowWriting implements Answer<Integer> {
- int written = 0;
+ private static class SlowWriting implements Answer<Integer> {
+ int written = 0;
- @Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
- ByteBuffer bytes = (ByteBuffer) invocation.getArguments()[0];
- bytes.get();
- written++;
- return 1;
- }
+ @Override
+ public Integer answer(InvocationOnMock invocation) throws Throwable {
+ ByteBuffer bytes = (ByteBuffer) invocation.getArguments()[0];
+ bytes.get();
+ written++;
+ return 1;
}
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameReader.java b/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameReader.java
index 7c4556a6c..fef88835e 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameReader.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameReader.java
@@ -19,52 +19,53 @@
package org.apache.thrift.transport.sasl;
-import org.apache.thrift.transport.TMemoryInputTransport;
-import org.apache.thrift.transport.TTransportException;
-import org.junit.jupiter.api.Test;
-
-import java.nio.ByteBuffer;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.nio.ByteBuffer;
+import org.apache.thrift.transport.TMemoryInputTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.junit.jupiter.api.Test;
+
public class TestSaslNegotiationFrameReader {
- @Test
- public void testRead() throws TTransportException {
- TMemoryInputTransport transport = new TMemoryInputTransport();
- SaslNegotiationFrameReader negotiationReader = new SaslNegotiationFrameReader();
- // No bytes received
- negotiationReader.read(transport);
- assertFalse(negotiationReader.isComplete(), "No bytes received");
- assertFalse(negotiationReader.getHeader().isComplete(), "No bytes received");
- // Read header
- ByteBuffer buffer = ByteBuffer.allocate(5);
- buffer.put(0, NegotiationStatus.OK.getValue());
- buffer.putInt(1, 10);
- transport.reset(buffer.array());
- negotiationReader.read(transport);
- assertFalse(negotiationReader.isComplete(), "Only header is complete");
- assertTrue(negotiationReader.getHeader().isComplete(), "Header should be complete");
- assertEquals(10, negotiationReader.getHeader().payloadSize(), "Payload size should be 10");
- // Read payload
- transport.reset(new byte[20]);
- negotiationReader.read(transport);
- assertTrue(negotiationReader.isComplete(), "Reader should be complete");
- assertEquals(10, negotiationReader.getPayload().length, "Payload length should be 10");
- }
+ @Test
+ public void testRead() throws TTransportException {
+ TMemoryInputTransport transport = new TMemoryInputTransport();
+ SaslNegotiationFrameReader negotiationReader = new SaslNegotiationFrameReader();
+ // No bytes received
+ negotiationReader.read(transport);
+ assertFalse(negotiationReader.isComplete(), "No bytes received");
+ assertFalse(negotiationReader.getHeader().isComplete(), "No bytes received");
+ // Read header
+ ByteBuffer buffer = ByteBuffer.allocate(5);
+ buffer.put(0, NegotiationStatus.OK.getValue());
+ buffer.putInt(1, 10);
+ transport.reset(buffer.array());
+ negotiationReader.read(transport);
+ assertFalse(negotiationReader.isComplete(), "Only header is complete");
+ assertTrue(negotiationReader.getHeader().isComplete(), "Header should be complete");
+ assertEquals(10, negotiationReader.getHeader().payloadSize(), "Payload size should be 10");
+ // Read payload
+ transport.reset(new byte[20]);
+ negotiationReader.read(transport);
+ assertTrue(negotiationReader.isComplete(), "Reader should be complete");
+ assertEquals(10, negotiationReader.getPayload().length, "Payload length should be 10");
+ }
- @Test
- public void testReadInvalidNegotiationStatus() throws TTransportException {
- byte[] bytes = new byte[5];
- // Invalid status byte.
- bytes[0] = -1;
- TMemoryInputTransport transport = new TMemoryInputTransport(bytes);
- SaslNegotiationFrameReader negotiationReader = new SaslNegotiationFrameReader();
- assertThrows(TSaslNegotiationException.class, () -> {
- negotiationReader.read(transport);
+ @Test
+ public void testReadInvalidNegotiationStatus() throws TTransportException {
+ byte[] bytes = new byte[5];
+ // Invalid status byte.
+ bytes[0] = -1;
+ TMemoryInputTransport transport = new TMemoryInputTransport(bytes);
+ SaslNegotiationFrameReader negotiationReader = new SaslNegotiationFrameReader();
+ assertThrows(
+ TSaslNegotiationException.class,
+ () -> {
+ negotiationReader.read(transport);
});
- }
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameWriter.java b/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameWriter.java
index 49110e473..6e08a9fe6 100644
--- a/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameWriter.java
+++ b/lib/java/src/test/java/org/apache/thrift/transport/sasl/TestSaslNegotiationFrameWriter.java
@@ -19,39 +19,41 @@
package org.apache.thrift.transport.sasl;
-import org.apache.thrift.EncodingUtils;
-import org.junit.jupiter.api.Test;
-
-import java.nio.ByteBuffer;
-
import static org.apache.thrift.transport.sasl.SaslNegotiationFrameWriter.HEADER_BYTES;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import java.nio.ByteBuffer;
+import org.apache.thrift.EncodingUtils;
+import org.junit.jupiter.api.Test;
+
public class TestSaslNegotiationFrameWriter {
- private static final byte[] PAYLOAD = {0x11, 0x08, 0x3F, 0x58, 0x73, 0x22, 0x00, (byte) 0xFF};
-
- @Test
- public void testWithHeaderAndPayload() {
- SaslNegotiationFrameWriter frameWriter = new SaslNegotiationFrameWriter();
- frameWriter.withHeaderAndPayload(new byte[]{NegotiationStatus.OK.getValue()}, PAYLOAD);
- byte[] expectedBytes = new byte[HEADER_BYTES + PAYLOAD.length];
- expectedBytes[0] = NegotiationStatus.OK.getValue();
- EncodingUtils.encodeBigEndian(PAYLOAD.length, expectedBytes, 1);
- System.arraycopy(PAYLOAD, 0, expectedBytes, HEADER_BYTES, PAYLOAD.length);
- assertEquals(ByteBuffer.wrap(expectedBytes), frameWriter.frameBytes);
- }
-
- @Test
- public void testWithInvalidHeaderLength() {
- SaslNegotiationFrameWriter frameWriter = new SaslNegotiationFrameWriter();
- assertThrows(IllegalArgumentException.class, () -> frameWriter.withHeaderAndPayload(new byte[5], 0, 2, PAYLOAD, 0, 1));
- }
-
- @Test
- public void testWithOnlyPayload() {
- SaslNegotiationFrameWriter frameWriter = new SaslNegotiationFrameWriter();
- assertThrows(UnsupportedOperationException.class, () -> frameWriter.withOnlyPayload(new byte[0]));
- }
+ private static final byte[] PAYLOAD = {0x11, 0x08, 0x3F, 0x58, 0x73, 0x22, 0x00, (byte) 0xFF};
+
+ @Test
+ public void testWithHeaderAndPayload() {
+ SaslNegotiationFrameWriter frameWriter = new SaslNegotiationFrameWriter();
+ frameWriter.withHeaderAndPayload(new byte[] {NegotiationStatus.OK.getValue()}, PAYLOAD);
+ byte[] expectedBytes = new byte[HEADER_BYTES + PAYLOAD.length];
+ expectedBytes[0] = NegotiationStatus.OK.getValue();
+ EncodingUtils.encodeBigEndian(PAYLOAD.length, expectedBytes, 1);
+ System.arraycopy(PAYLOAD, 0, expectedBytes, HEADER_BYTES, PAYLOAD.length);
+ assertEquals(ByteBuffer.wrap(expectedBytes), frameWriter.frameBytes);
+ }
+
+ @Test
+ public void testWithInvalidHeaderLength() {
+ SaslNegotiationFrameWriter frameWriter = new SaslNegotiationFrameWriter();
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> frameWriter.withHeaderAndPayload(new byte[5], 0, 2, PAYLOAD, 0, 1));
+ }
+
+ @Test
+ public void testWithOnlyPayload() {
+ SaslNegotiationFrameWriter frameWriter = new SaslNegotiationFrameWriter();
+ assertThrows(
+ UnsupportedOperationException.class, () -> frameWriter.withOnlyPayload(new byte[0]));
+ }
}
diff --git a/lib/java/src/test/java/org/apache/thrift/utils/TestStringUtils.java b/lib/java/src/test/java/org/apache/thrift/utils/TestStringUtils.java
index 272815765..6fcea1e80 100644
--- a/lib/java/src/test/java/org/apache/thrift/utils/TestStringUtils.java
+++ b/lib/java/src/test/java/org/apache/thrift/utils/TestStringUtils.java
@@ -19,44 +19,42 @@
package org.apache.thrift.utils;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
-public class TestStringUtils {
-
- @Test
- public void testToHexString() {
- byte[] bytes = {0x00, 0x1A, (byte) 0xEF, (byte) 0xAB, (byte) 0x92};
- assertEquals("001AEFAB92", StringUtils.bytesToHexString(bytes));
- assertEquals("EFAB92", StringUtils.bytesToHexString(bytes, 2, 3));
- assertNull(StringUtils.bytesToHexString(null));
- }
-
-
- private byte[] bytes;
-
- @BeforeEach
- public void setUp() throws Exception {
- bytes = new byte[]{1, 2, 3, 4, 5};
- }
-
- @Test
- public void testNegativeLength() {
- assertThrows(IllegalArgumentException.class, () -> StringUtils.bytesToHexString(bytes, 0, -1));
- }
-
- @Test
- public void testNegativeStartOffset() {
- assertThrows(IndexOutOfBoundsException.class, () -> StringUtils.bytesToHexString(bytes, -1, 1));
- }
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
- @Test
- public void testInvalidRange() {
- assertThrows(IndexOutOfBoundsException.class, () -> StringUtils.bytesToHexString(bytes, 5, 1));
- }
+public class TestStringUtils {
+ @Test
+ public void testToHexString() {
+ byte[] bytes = {0x00, 0x1A, (byte) 0xEF, (byte) 0xAB, (byte) 0x92};
+ assertEquals("001AEFAB92", StringUtils.bytesToHexString(bytes));
+ assertEquals("EFAB92", StringUtils.bytesToHexString(bytes, 2, 3));
+ assertNull(StringUtils.bytesToHexString(null));
+ }
+
+ private byte[] bytes;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ bytes = new byte[] {1, 2, 3, 4, 5};
+ }
+
+ @Test
+ public void testNegativeLength() {
+ assertThrows(IllegalArgumentException.class, () -> StringUtils.bytesToHexString(bytes, 0, -1));
+ }
+
+ @Test
+ public void testNegativeStartOffset() {
+ assertThrows(IndexOutOfBoundsException.class, () -> StringUtils.bytesToHexString(bytes, -1, 1));
+ }
+
+ @Test
+ public void testInvalidRange() {
+ assertThrows(IndexOutOfBoundsException.class, () -> StringUtils.bytesToHexString(bytes, 5, 1));
+ }
}