@Test
    void tTextNamedEnumProtocolReadWriteTest() throws Exception {
        // Deserialize the file contents into a thrift message.
        final ByteArrayInputStream bais1 = new ByteArrayInputStream(testData.getBytes());
        final TTextProtocolTestMsg msg1 = new TTextProtocolTestMsg();
        msg1.read(new TTextProtocol(new TIOStreamTransport(bais1), true));

        assertThat(msg1).isEqualTo(testMsg());

        // Serialize that thrift message out to a byte array
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        msg1.write(new TTextProtocol(new TIOStreamTransport(baos), true));
        final byte[] bytes = baos.toByteArray();

        // y can be serialized to either 1 (<0.19) or ALPHA (>=0.19)
        assertThatJson(CR_PATTERN.matcher(baos.toString()).replaceAll(""))
                .when(IGNORING_ARRAY_ORDER)
                .whenIgnoringPaths("y")
                .isEqualTo(namedEnumSerialized);
        if (ThriftVersionDetector.majorVersion() == 0 && ThriftVersionDetector.minorVersion() < 19) {
            assertThatJson(CR_PATTERN.matcher(baos.toString()).replaceAll(""))
                    .node("y").isEqualTo("1");
        } else {
            assertThatJson(CR_PATTERN.matcher(baos.toString()).replaceAll(""))
                    .node("y").isEqualTo("ALPHA");
        }

        // Deserialize that string back to a thrift message.
        final ByteArrayInputStream bais2 = new ByteArrayInputStream(bytes);
        final TTextProtocolTestMsg msg2 = new TTextProtocolTestMsg();
        msg2.read(new TTextProtocol(new TIOStreamTransport(bais2), true));

        assertThat(msg2).isEqualTo(msg1);
    }
Read in (deserialize) a thrift message in TTextProtocol format
from a file on disk, then serialize it back out to a string.
Finally, deserialize that string and compare to the original
message.
thrift/thrift0.13/src/test/java/com/linecorp/armeria/common/thrift/text/TTextProtocolTest.java