本文整理了Java中org.springframework.util.Assert.doesNotContain()
方法的一些代码示例,展示了Assert.doesNotContain()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.doesNotContain()
方法的具体详情如下:
包路径:org.springframework.util.Assert
类名称:Assert
方法名:doesNotContain
[英]Assert that the given text does not contain the given substring.
Assert.doesNotContain(name, "rod");
[中]断言给定的文本不包含给定的子字符串
Assert.doesNotContain(name, "rod");
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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 + "]");
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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 : "");
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: org.springframework/spring-web
/**
* 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;
}
代码示例来源:origin: org.springframework/spring-core
/**
* 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 + "]");
}
代码示例来源:origin: org.springframework/spring-web
/**
* 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 : "");
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: spring-projects/spring-batch
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;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithEmptySubstring() {
Assert.doesNotContain("A cool chick's name is Brod.", "", "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithMessageSupplier() {
Assert.doesNotContain("foo", "bar", () -> "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithNullSearchStringAndMessageSupplier() {
Assert.doesNotContain(null, "bar", () -> "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithNullSearchString() {
Assert.doesNotContain(null, "rod", "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithNullSubstring() {
Assert.doesNotContain("A cool chick's name is Brod.", null, "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithNullSubstringAndMessageSupplier() {
Assert.doesNotContain("foo", null, () -> "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithNullSearchStringAndNullSubstringAndMessageSupplier() {
Assert.doesNotContain(null, null, () -> "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithNullSearchStringAndNullSubstring() {
Assert.doesNotContain(null, null, "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithNullMessageSupplier() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(equalTo(null));
Assert.doesNotContain("1234", "23", (Supplier<String>) null);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void doesNotContainWithSubstringPresentInSearchStringAndMessageSupplier() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("enigma");
Assert.doesNotContain("1234", "23", () -> "enigma");
}
内容来源于网络,如有侵权,请联系作者删除!