/** Test that giving a null 'safeChars' string causes a {@link NullPointerException}. */ public void testBadArguments_null() { try { new PercentEscaper(null, false); fail("Expected null pointer exception for null parameter"); } catch (NullPointerException expected) { // pass } }
/** * Tests that if space is a safe character you cannot also specify 'plusForSpace' (throws {@link * IllegalArgumentException}). */ public void testBadArguments_plusforspace() { try { new PercentEscaper(" ", false); } catch (IllegalArgumentException e) { fail("Space can be a 'safe' character if plusForSpace is false"); } String msg = "plusForSpace cannot be specified when space is a 'safe' character"; try { new PercentEscaper(" ", true); fail(msg); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessageThat().isEqualTo(msg); } }
/** * Tests that specifying any alphanumeric characters as 'safe' causes an {@link * IllegalArgumentException}. */ public void testBadArguments_badchars() { String msg = "Alphanumeric characters are always 'safe' " + "and should not be explicitly specified"; try { new PercentEscaper("-+#abc.!", false); fail(msg); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessageThat().isEqualTo(msg); } }
/** * Test that giving a null 'safeChars' string causes a * {@link NullPointerException}. */ public void testBadArguments_null() { try { new PercentEscaper(null, false); fail("Expected null pointer exception for null parameter"); } catch (NullPointerException expected) { // pass } }
/** * Tests that if space is a safe character you cannot also specify * 'plusForSpace' (throws {@link IllegalArgumentException}). */ public void testBadArguments_plusforspace() { try { new PercentEscaper(" ", false); } catch (IllegalArgumentException e) { fail("Space can be a 'safe' character if plusForSpace is false"); } String msg = "plusForSpace cannot be specified when space is a 'safe' character"; try { new PercentEscaper(" ", true); fail(msg); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage(msg); } }
/** * Tests that specifying any alphanumeric characters as 'safe' causes an * {@link IllegalArgumentException}. */ public void testBadArguments_badchars() { String msg = "Alphanumeric characters are always 'safe' " + "and should not be explicitly specified"; try { new PercentEscaper("-+#abc.!", false); fail(msg); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage(msg); } }