RegexpMimeRulesSource implements MimeRulesSource { public void addRule(final String pattern, final String mimeType) { addRule(Pattern.compile(pattern), mimeType); }  void addRule(final String pattern, final String mimeType); void addRule(final Pattern pattern, final String mimeType); @Override MimeRule getRuleForName(final String name);  }
@Test public void testRegectMimeRulesSourceTest() { final RegexpMimeRulesSource underTest = new RegexpMimeRulesSource(); underTest.addRule(".*\\.foo\\z", "foo/bar"); underTest.addRule(".*\\.pom\\z", "application/x-pom"); underTest.addRule("(.*/maven-metadata.xml\\z)|(maven-metadata.xml\\z)", "application/x-maven-metadata"); underTest.addRule("\\A/atom-service/.*\\.xml\\z", "application/atom+xml"); underTest.addRule(".*\\.xml\\z", "application/xml"); assertValues(underTest, "/some/repo/path/content.foo", equalTo("foo/bar")); assertValues(underTest, "/some/repo/path/content.foo.bar", nullValue()); assertValues(underTest, "/log4j/log4j/1.2.12/log4j-1.2.12.pom", equalTo("application/x-pom")); assertValues(underTest, "maven-metadata.xml", equalTo("application/x-maven-metadata")); assertValues(underTest, "/maven-metadata.xml", equalTo("application/x-maven-metadata")); assertValues(underTest, "/org/sonatype/nexus/maven-metadata.xml", equalTo("application/x-maven-metadata")); assertValues(underTest, "/org/sonatype/nexus/maven-metadata.xml.bar", nullValue()); assertValues(underTest, "/org/sonatype/nexus/maven-metadata.xml/tricky/path.pom", equalTo("application/x-pom")); assertValues(underTest, "/org/sonatype/nexus/maven-metadata1.xml", equalTo("application/xml")); assertValues(underTest, "/atom-service }