FetchPartPathDecoder { public SectionType decode(CharSequence sectionSpecification) throws DecodingException { init(); sectionType = decode(0, sectionSpecification); prunePath(); return sectionType; } FetchPartPathDecoder(); SectionType decode(CharSequence sectionSpecification); final int[] getPath(); final SectionType getSpecifier(); final List<String> getNames();  }
@Test public void testShouldDetectText() throws Exception { assertThat(decoder.decode("TEXT")).isEqualTo(SectionType.TEXT); assertThat(decoder.decode("3.TEXT")).isEqualTo(SectionType.TEXT); assertThat(decoder.decode("3.1.TEXT")).isEqualTo(SectionType.TEXT); assertThat(decoder .decode("3.2.5.7.8.TEXT")).isEqualTo(SectionType.TEXT); }
@Test public void testShouldDetectHeader() throws Exception { assertThat(decoder.decode("HEADER")).isEqualTo(SectionType.HEADER); assertThat(decoder.decode("4.HEADER")).isEqualTo(SectionType.HEADER); assertThat(decoder.decode("10.1.HEADER")).isEqualTo(SectionType.HEADER); assertThat(decoder .decode("8.3.5.11.HEADER")).isEqualTo(SectionType.HEADER); }
@Test public void testShouldDetectHeaderFields() throws Exception { assertThat(decoder .decode("HEADER.FIELDS ()")).isEqualTo(SectionType.HEADER_FIELDS); assertThat(decoder .decode("4.HEADER.FIELDS ()")).isEqualTo(SectionType.HEADER_FIELDS); assertThat(decoder .decode("10.1.HEADER.FIELDS ()")).isEqualTo(SectionType.HEADER_FIELDS); assertThat(decoder .decode("8.3.5.11.HEADER.FIELDS ()")).isEqualTo(SectionType.HEADER_FIELDS); }
@Test public void testShouldDetectHeaderFieldsNot() throws Exception { assertThat(decoder .decode("HEADER.FIELDS.NOT ()")).isEqualTo(SectionType.HEADER_NOT_FIELDS); assertThat(decoder .decode("4.HEADER.FIELDS.NOT ()")).isEqualTo(SectionType.HEADER_NOT_FIELDS); assertThat(decoder .decode("10.1.HEADER.FIELDS.NOT ()")).isEqualTo(SectionType.HEADER_NOT_FIELDS); assertThat(decoder .decode("8.3.5.11.HEADER.FIELDS.NOT ()")).isEqualTo(SectionType.HEADER_NOT_FIELDS); }
@Test public void testShouldDetectMime() throws Exception { assertThat(decoder.decode("MIME")).isEqualTo(SectionType.MIME); assertThat(decoder.decode("6.MIME")).isEqualTo(SectionType.MIME); assertThat(decoder.decode("2.88.MIME")).isEqualTo(SectionType.MIME); assertThat(decoder .decode("32.3.15.11.MIME")).isEqualTo(SectionType.MIME); }
@Test public void testShouldDetectContent() throws Exception { assertThat(decoder.decode("34")).isEqualTo(SectionType.CONTENT); assertThat(decoder.decode("6")).isEqualTo(SectionType.CONTENT); assertThat(decoder.decode("9.88")).isEqualTo(SectionType.CONTENT); assertThat(decoder.decode("17.3.15.11")).isEqualTo(SectionType.CONTENT); }
@Test public void testShouldIgnoreCase() throws Exception { assertThat(decoder.decode("6.MIME")).isEqualTo(SectionType.MIME); assertThat(decoder.decode("6.mime")).isEqualTo(SectionType.MIME); assertThat(decoder.decode("6.miME")).isEqualTo(SectionType.MIME); assertThat(decoder.decode("6.MIme")).isEqualTo(SectionType.MIME); assertThat(decoder.decode("6.HEADER")).isEqualTo(SectionType.HEADER); assertThat(decoder.decode("6.header")).isEqualTo(SectionType.HEADER); assertThat(decoder.decode("6.HEadER")).isEqualTo(SectionType.HEADER); assertThat(decoder.decode("6.heADEr")).isEqualTo(SectionType.HEADER); assertThat(decoder.decode("6.TEXT")).isEqualTo(SectionType.TEXT); assertThat(decoder.decode("6.text")).isEqualTo(SectionType.TEXT); assertThat(decoder.decode("6.TExt")).isEqualTo(SectionType.TEXT); assertThat(decoder.decode("6.teXT")).isEqualTo(SectionType.TEXT); }
@Test public void testShouldThrowProtocolExceptionWhenSpecifierBogus() { try { decoder.decode("1.34.BOGUS"); fail("Expected protocol exception to be thrown"); } catch (DecodingException e) { } }
@Test public void testShouldThrowProtocolExceptionWhenPathBogus() { try { decoder.decode("1.34.BOGUS.44.34234.324"); fail("Expected protocol exception to be thrown"); } catch (DecodingException e) { } }