@Test
    public void findByMediaType() {
        // The 'protocol' parameter has to be case-insensitive.
        assertThat(find(parse("application/x-thrift; protocol=tbinary"))).isSameAs(BINARY);
        assertThat(find(parse("application/x-thrift;protocol=TCompact"))).isSameAs(COMPACT);
        assertThat(find(parse("application/x-thrift ; protocol=\"TjSoN\""))).isSameAs(JSON);

        // An unknown parameter ('version' in this case) should not be accepted.
        assertThat(find(parse("application/x-thrift ; version=3;protocol=ttext"))).isNull();

        // 'charset=utf-8' parameter should be accepted for TJSON and TTEXT.
        assertThat(find(parse("application/x-thrift; protocol=tjson; charset=utf-8"))).isSameAs(JSON);
        assertThat(find(parse("application/vnd.apache.thrift.json; charset=utf-8"))).isSameAs(JSON);
        assertThat(find(parse("application/x-thrift; protocol=ttext; charset=utf-8"))).isSameAs(TEXT);
        assertThat(find(parse("application/vnd.apache.thrift.text; charset=utf-8"))).isSameAs(TEXT);
        assertThat(find(parse("application/x-thrift; protocol=ttext_named_enum; charset=utf-8")))
                .isSameAs(TEXT_NAMED_ENUM);
        assertThat(find(parse("application/vnd.apache.thrift.text_named_enum; charset=utf-8")))
                .isSameAs(TEXT_NAMED_ENUM);

        // .. but neither non-UTF-8 charsets:
        assertThat(find(parse("application/x-thrift; protocol=tjson; charset=us-ascii"))).isNull();
        assertThat(find(parse("application/vnd.apache.thrift.json; charset=us-ascii"))).isNull();
        assertThat(find(parse("application/x-thrift; protocol=ttext; charset=us-ascii"))).isNull();
        assertThat(find(parse("application/vnd.apache.thrift.text; charset=us-ascii"))).isNull();
        assertThat(find(parse("application/x-thrift; protocol=ttext_named_enum; charset=us-ascii"))).isNull();
        assertThat(find(parse("application/vnd.apache.thrift.text_named_enum; charset=us-ascii"))).isNull();

        // .. nor binary/compact formats:
        assertThat(find(parse("application/x-thrift; protocol=tbinary; charset=utf-8"))).isNull();
        assertThat(find(parse("application/vnd.apache.thrift.binary; charset=utf-8"))).isNull();
        assertThat(find(parse("application/x-thrift; protocol=tcompact; charset=utf-8"))).isNull();
        assertThat(find(parse("application/vnd.apache.thrift.compact; charset=utf-8"))).isNull();
    }
Test of serialization format validation / detection based on HTTP headers.
thrift/thrift0.13/src/test/java/com/linecorp/armeria/server/thrift/ThriftSerializationFormatsTest.java