### Question:
StringEncoderComparator implements Comparator { @Override public int compare(final Object o1, final Object o2) { int compareCode = 0; try { @SuppressWarnings("unchecked") final Comparable<Comparable<?>> s1 = (Comparable<Comparable<?>>) this.stringEncoder.encode(o1); final Comparable<?> s2 = (Comparable<?>) this.stringEncoder.encode(o2); compareCode = s1.compareTo(s2); } catch (final EncoderException ee) { compareCode = 0; } return compareCode; } @Deprecated  StringEncoderComparator();  StringEncoderComparator(final StringEncoder stringEncoder); @Override int compare(final Object o1, final Object o2);  }### Answer:
@Test public void testComparatorWithSoundex() throws Exception { final StringEncoderComparator sCompare = new StringEncoderComparator( new Soundex() ); assertTrue( "O'Brien and O'Brian didn't come out with " + "the same Soundex, something must be wrong here", 0 == sCompare.compare( "O'Brien", "O'Brian" ) ); }
@Test public void testComparatorWithDoubleMetaphoneAndInvalidInput() throws Exception { final StringEncoderComparator sCompare = new StringEncoderComparator( new DoubleMetaphone() ); final int compare = sCompare.compare(new Double(3.0), Long.valueOf(3)); assertEquals( "Trying to compare objects that make no sense to the underlying encoder should return a zero compare code", 0, compare); }