/** * Create a new interceptor which adds Basic Authentication for the * given username and password, encoded using the specified charset. * @param username the username to use * @param password the password to use * @param charset the charset to use * @see HttpHeaders#setBasicAuth(String, String, Charset) */ public BasicAuthenticationInterceptor(String username, String password, @Nullable Charset charset) { Assert.doesNotContain(username, ":", "Username must not contain a colon"); this.username = username; this.password = password; this.charset = charset; }
/** * Assert that the given text does not contain the given substring. * @deprecated as of 4.3.7, in favor of {@link #doesNotContain(String, String, String)} */ @Deprecated public static void doesNotContain(@Nullable String textToSearch, String substring) { doesNotContain(textToSearch, substring, () -> "[Assertion failed] - this String argument must not contain the substring [" + substring + "]"); }
/** * Create a new interceptor which adds a BASIC authorization header * for the given username and password. * @param username the username to use * @param password the password to use */ public BasicAuthorizationInterceptor(@Nullable String username, @Nullable String password) { Assert.doesNotContain(username, ":", "Username must not contain a colon"); this.username = (username != null ? username : ""); this.password = (password != null ? password : ""); }
/** * Set the template used for method entry log messages. * This template can contain any of the following placeholders: * <ul> * <li>{@code $[targetClassName]}</li> * <li>{@code $[targetClassShortName]}</li> * <li>{@code $[argumentTypes]}</li> * <li>{@code $[arguments]}</li> * </ul> */ public void setEnterMessage(String enterMessage) throws IllegalArgumentException { Assert.hasText(enterMessage, "enterMessage must not be empty"); checkForInvalidPlaceholders(enterMessage); Assert.doesNotContain(enterMessage, PLACEHOLDER_RETURN_VALUE, "enterMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE); Assert.doesNotContain(enterMessage, PLACEHOLDER_EXCEPTION, "enterMessage cannot contain placeholder " + PLACEHOLDER_EXCEPTION); Assert.doesNotContain(enterMessage, PLACEHOLDER_INVOCATION_TIME, "enterMessage cannot contain placeholder " + PLACEHOLDER_INVOCATION_TIME); this.enterMessage = enterMessage; }
/** * Create a new interceptor which adds Basic Authentication for the * given username and password, encoded using the specified charset. * @param username the username to use * @param password the password to use * @param charset the charset to use * @see HttpHeaders#setBasicAuth(String, String, Charset) */ public BasicAuthenticationInterceptor(String username, String password, @Nullable Charset charset) { Assert.doesNotContain(username, ":", "Username must not contain a colon"); this.username = username; this.password = password; this.charset = charset; }
/** * Assert that the given text does not contain the given substring. * @deprecated as of 4.3.7, in favor of {@link #doesNotContain(String, String, String)} */ @Deprecated public static void doesNotContain(@Nullable String textToSearch, String substring) { doesNotContain(textToSearch, substring, () -> "[Assertion failed] - this String argument must not contain the substring [" + substring + "]"); }
/** * Create a new interceptor which adds a BASIC authorization header * for the given username and password. * @param username the username to use * @param password the password to use */ public BasicAuthorizationInterceptor(@Nullable String username, @Nullable String password) { Assert.doesNotContain(username, ":", "Username must not contain a colon"); this.username = (username != null ? username : ""); this.password = (password != null ? password : ""); }
/** * Set the template used for method exception log messages. * This template can contain any of the following placeholders: * <ul> * <li>{@code $[targetClassName]}</li> * <li>{@code $[targetClassShortName]}</li> * <li>{@code $[argumentTypes]}</li> * <li>{@code $[arguments]}</li> * <li>{@code $[exception]}</li> * </ul> */ public void setExceptionMessage(String exceptionMessage) { Assert.hasText(exceptionMessage, "exceptionMessage must not be empty"); checkForInvalidPlaceholders(exceptionMessage); Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE, "exceptionMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE); this.exceptionMessage = exceptionMessage; }
/** * Set the template used for method exit log messages. * This template can contain any of the following placeholders: * <ul> * <li>{@code $[targetClassName]}</li> * <li>{@code $[targetClassShortName]}</li> * <li>{@code $[argumentTypes]}</li> * <li>{@code $[arguments]}</li> * <li>{@code $[returnValue]}</li> * <li>{@code $[invocationTime]}</li> * </ul> */ public void setExitMessage(String exitMessage) { Assert.hasText(exitMessage, "exitMessage must not be empty"); checkForInvalidPlaceholders(exitMessage); Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION, "exitMessage cannot contain placeholder" + PLACEHOLDER_EXCEPTION); this.exitMessage = exitMessage; }
public void setSortKey(String key) { Assert.doesNotContain(key, ",", "String setter is valid for a single ASC key only"); Map<String, Order> keys = new LinkedHashMap<>(); keys.put(key, Order.ASCENDING); this.sortKeys = keys; }
@Test public void doesNotContainWithEmptySubstring() { Assert.doesNotContain("A cool chick's name is Brod.", "", "enigma"); }
@Test public void doesNotContainWithMessageSupplier() { Assert.doesNotContain("foo", "bar", () -> "enigma"); }
@Test public void doesNotContainWithNullSearchStringAndMessageSupplier() { Assert.doesNotContain(null, "bar", () -> "enigma"); }
@Test public void doesNotContainWithNullSearchString() { Assert.doesNotContain(null, "rod", "enigma"); }
@Test public void doesNotContainWithNullSubstring() { Assert.doesNotContain("A cool chick's name is Brod.", null, "enigma"); }
@Test public void doesNotContainWithNullSubstringAndMessageSupplier() { Assert.doesNotContain("foo", null, () -> "enigma"); }
@Test public void doesNotContainWithNullSearchStringAndNullSubstringAndMessageSupplier() { Assert.doesNotContain(null, null, () -> "enigma"); }
@Test public void doesNotContainWithNullSearchStringAndNullSubstring() { Assert.doesNotContain(null, null, "enigma"); }
@Test public void doesNotContainWithNullMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage(equalTo(null)); Assert.doesNotContain("1234", "23", (Supplier<String>) null); }
@Test public void doesNotContainWithSubstringPresentInSearchStringAndMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma"); Assert.doesNotContain("1234", "23", () -> "enigma"); }