### Question:
OSGIResourceNameComparator implements Comparator<String> { @Override public int compare( String o1, String o2 ) { Matcher o1Matcher = OSGIResourceNamingConvention.getResourceNameMatcher( o1 ); Matcher o2Matcher = OSGIResourceNamingConvention.getResourceNameMatcher( o2 ); String name1 = o1Matcher.group( 1 ) + o1Matcher.group( 2 ); String name2 = o2Matcher.group( 1 ) + o2Matcher.group( 2 ); if ( name1.compareTo( name2 ) == 0 ) { int priority1 = OSGIResourceNamingConvention.getPropertyPriority( o1 ); int priority2 = OSGIResourceNamingConvention.getPropertyPriority( o2 ); return priority1 - priority2; } else { return name1.compareTo( name2 ); } }  @Override int compare( String o1, String o2 );  }### Answer:
@Test( expected = NullPointerException.class ) public void testNullName() { String first = null; String second = "bundle/messages.properties"; comparator.compare( first, second ); }
@Test( expected = IllegalArgumentException.class ) public void testEmptyName() { String first = ""; String second = "bundle/messages.properties"; comparator.compare( first, second ); }
@Test public void testNoPriority() { String first = "bundle/messages_en.properties"; String second = "bundle/messages.properties"; Assert.assertTrue( comparator.compare( first, second ) > 0 ); }
@Test public void testWithPriority() { String first = "bundle/messages.properties.3"; String second = "bundle/messages.properties.2"; Assert.assertTrue( comparator.compare( first, second ) > 0 ); }
@Test public void testMixed() { String first = "bundle/messages.properties.2"; String second = "bundle/messages.properties"; Assert.assertTrue( comparator.compare( first, second ) > 0 ); }