### Question:
BouncyCastleUtils { public static boolean x500NameCompare(final String nameValue1, final String nameValue2) { if (nameValue1 == null || nameValue2 == null) { throw new IllegalArgumentException("Provided DN string is null."); } boolean result = false; X500Name x500Name1; X500Name x500Name2; try { x500Name1 = new X500Name(nameValue1.replace(SEPARATOR_PLUS, SEPARATOR_COMMA)); x500Name2 = new X500Name(nameValue2.replace(SEPARATOR_PLUS, SEPARATOR_COMMA)); result = x500Name1.equals(x500Name2); } catch (IllegalArgumentException iaEx) { LOGGER.error(iaEx.toString()); } return result; } private  BouncyCastleUtils(); static boolean x500NameCompare(final String nameValue1, final String nameValue2);  }### Answer:
@Test public void testX500NameCompareTrue() { Assert.assertTrue(BouncyCastleUtils.x500NameCompare( VALID_RDN_STRING, VALID_RDN_STRING_SWITCHED)); Assert.assertTrue(BouncyCastleUtils.x500NameCompare( VALID_RDN_STRING, VALID_RDN_STRING_UPPERCASE)); Assert.assertTrue(BouncyCastleUtils.x500NameCompare( VALID_RDN_STRING, VALID_RDN_STRING_PLUS)); }
@Test public void testX500NameCompareFalse() { Assert.assertFalse(BouncyCastleUtils.x500NameCompare( VALID_RDN_STRING, UNEQUAL_RDN_STRING)); Assert.assertFalse(BouncyCastleUtils.x500NameCompare(VALID_RDN_STRING, Strings.EMPTY)); Assert.assertFalse(BouncyCastleUtils.x500NameCompare(Strings.EMPTY, VALID_RDN_STRING)); Assert.assertFalse(BouncyCastleUtils.x500NameCompare(Strings.EMPTY, Strings.EMPTY)); Assert.assertFalse(BouncyCastleUtils.x500NameCompare( VALID_RDN_STRING, MALFORMED_RDN_STRING)); Assert.assertFalse(BouncyCastleUtils.x500NameCompare( MALFORMED_RDN_STRING, VALID_RDN_STRING)); Assert.assertFalse(BouncyCastleUtils.x500NameCompare( MALFORMED_RDN_STRING, MALFORMED_RDN_STRING)); }
@Test public void testX500NameCompareNullError() { try { BouncyCastleUtils.x500NameCompare(VALID_RDN_STRING, null); Assert.fail("No IllegalArgumentException thrown."); } catch (Exception ex) { Assert.assertEquals(ex.getMessage(), "Provided DN string is null."); } try { BouncyCastleUtils.x500NameCompare(null, VALID_RDN_STRING); Assert.fail("No IllegalArgumentException thrown."); } catch (Exception ex) { Assert.assertEquals(ex.getMessage(), "Provided DN string is null."); } try { BouncyCastleUtils.x500NameCompare(null, null); Assert.fail("No IllegalArgumentException thrown."); } catch (Exception ex) { Assert.assertEquals(ex.getMessage(), "Provided DN string is null."); } }