本文整理了Java中org.apache.commons.lang3.Validate.notBlank()
方法的一些代码示例,展示了Validate.notBlank()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate.notBlank()
方法的具体详情如下:
包路径:org.apache.commons.lang3.Validate
类名称:Validate
方法名:notBlank
[英]Validate that the specified argument character sequence is neither null, a length of zero (no characters), empty nor whitespace; otherwise throwing an exception.
Validate.notBlank(myString);
The message in the exception is "The validated character sequence is blank".
[中]验证指定的参数字符序列既不是空的、长度为零(无字符)、空的,也不是空白;否则将引发异常。
Validate.notBlank(myString);
异常中的消息是“已验证的字符序列为空”。
代码示例来源:origin: rest-assured/rest-assured
private EncoderConfig(String defaultContentCharset, String defaultQueryParameterCharset,
boolean shouldAppendDefaultContentCharsetToContentTypeIfUndefined,
Map<String, ContentType> encoders, Map<String, String> contentTypeToDefaultCharset,
boolean isUserDefined) {
Validate.notBlank(defaultContentCharset, "Default encoder content charset to cannot be blank. See \"appendDefaultContentCharsetToContentTypeIfMissing\" method if you like to disable automatically appending the charset to the content-type.");
Validate.notBlank(defaultQueryParameterCharset, "Default protocol charset to cannot be blank.");
this.contentTypeToDefaultCharset = new HashMap<String, String>(contentTypeToDefaultCharset);
this.defaultContentCharset = defaultContentCharset;
this.defaultQueryParameterCharset = defaultQueryParameterCharset;
this.shouldAppendDefaultContentCharsetToContentTypeIfUndefined = shouldAppendDefaultContentCharsetToContentTypeIfUndefined;
this.contentEncoders = encoders;
this.isUserDefined = isUserDefined;
}
代码示例来源:origin: rest-assured/rest-assured
private DecoderConfig(String defaultContentCharset, boolean useNoWrapForInflateDecoding, boolean isUserConfigured, List<ContentDecoder> contentDecoders, Map<String, String> contentTypeToDefaultCharset) {
Validate.notBlank(defaultContentCharset, "Default decoder content charset to cannot be blank");
this.contentTypeToDefaultCharset = new HashMap<String, String>(contentTypeToDefaultCharset);
this.defaultContentCharset = defaultContentCharset;
this.contentDecoders = Collections.unmodifiableList(contentDecoders == null ? Collections.<ContentDecoder>emptyList() : contentDecoders);
this.useNoWrapForInflateDecoding = useNoWrapForInflateDecoding;
this.isUserConfigured = isUserConfigured;
}
代码示例来源:origin: springside/springside4
/**
* 获取File的BufferedWriter.
*
* @see {@link Files#newBufferedWriter}
*/
public static BufferedWriter asBufferedWriter(String fileName) throws IOException {
Validate.notBlank(fileName, "filename is blank");
return Files.newBufferedWriter(getPath(fileName), Charsets.UTF_8);
}
代码示例来源:origin: springside/springside4
/**
* 获取File的BufferedReader.
*
* @see {@link Files#newBufferedReader}
*/
public static BufferedReader asBufferedReader(String fileName) throws IOException {
Validate.notBlank(fileName, "filename is blank");
return asBufferedReader(getPath(fileName));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankMsgNotBlankStringShouldNotThrow() {
//given
final String string = "abc";
//when
Validate.notBlank(string, "Message");
//then should not throw
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankMsgNotBlankStringWithNewlinesShouldNotThrow() {
//given
final String string = " \n \t abc \r \n ";
//when
Validate.notBlank(string, "Message");
//then should not throw
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankMsgNotBlankStringWithWhitespacesShouldNotThrow() {
//given
final String string = " abc ";
//when
Validate.notBlank(string, "Message");
//then should not throw
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankNotBlankStringWithWhitespacesShouldNotThrow() {
//given
final String string = " abc ";
//when
Validate.notBlank(string);
//then should not throw
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankNotBlankStringWithNewlinesShouldNotThrow() {
//given
final String string = " \n \t abc \r \n ";
//when
Validate.notBlank(string);
//then should not throw
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankNotBlankStringShouldNotThrow() {
//given
final String string = "abc";
//when
Validate.notBlank(string);
//then should not throw
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankReturnValues2() {
final String str = "Hi";
final String test = Validate.notBlank(str, "Message");
assertSame(str, test);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankReturnValues1() {
final String str = "Hi";
final String test = Validate.notBlank(str);
assertSame(str, test);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankNullStringShouldThrow() {
//given
final String string = null;
try {
//when
Validate.notBlank(string);
fail("Expecting NullPointerException");
} catch (final NullPointerException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankMsgEmptyStringShouldThrow() {
//given
final String string = "";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
} catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankBlankStringWithNewlinesShouldThrow() {
//given
final String string = " \n \t \r \n ";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
} catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankMsgBlankStringShouldThrow() {
//given
final String string = " \n \t \r \n ";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
} catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankEmptyStringShouldThrow() {
//given
final String string = "";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
} catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankMsgBlankStringWithWhitespacesShouldThrow() {
//given
final String string = " ";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
} catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankMsgNullStringShouldThrow() {
//given
final String string = null;
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting NullPointerException");
} catch (final NullPointerException e) {
//then
assertEquals("Message", e.getMessage());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testNotBlankBlankStringWithWhitespacesShouldThrow() {
//given
final String string = " ";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
} catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!