本文整理了Java中org.assertj.core.api.AbstractCharSequenceAssert.contains()
方法的一些代码示例,展示了AbstractCharSequenceAssert.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractCharSequenceAssert.contains()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractCharSequenceAssert
类名称:AbstractCharSequenceAssert
方法名:contains
[英]Verifies that the actual CharSequence contains all the CharSequences of the given Iterable.
Examples:
assertThat("Gandalf the grey").contains(Arrays.asList("alf"));
assertThat("Gandalf the grey").contains(Arrays.asList("alf", "grey"));
[中]验证实际CharSequence是否包含给定Iterable的所有CharSequence。
示例:
assertThat("Gandalf the grey").contains(Arrays.asList("alf"));
assertThat("Gandalf the grey").contains(Arrays.asList("alf", "grey"));
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testComplexCommandUsage() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
itf.execute("complex", "-h");
assertThat(baos.toString())
.contains("-o1 <opt>", " [-o2] ")
.contains("arg1", "[arg2]")
.contains("A command with options and arguments.") // Summary
.contains("This is a complex command.") // Description
.contains("-o1,--option1 <opt>") // Option
.contains("-o2,--option2"); // Option
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapUserInChildGroup()
throws IOException
{
ldapUserName = CHILD_GROUP_USER.getAttributes().get("cn");
launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName)));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testCommandUsageForHello() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
itf.execute("hello", "--help");
assertThat(baos.toString())
.contains("Usage: ")
.contains("A command saying hello.") // Summary
.contains("A simple command to wish you a good day.") // Description
.contains("-n,--name <name>") // Option
.contains("your name"); // Option description
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapUserInParentGroup()
throws IOException
{
ldapUserName = PARENT_GROUP_USER.getAttributes().get("cn");
launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName)));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testCommandUsageForGoodbye() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
itf.execute("bye", "--help");
assertThat(baos.toString())
.contains("A command saying goodbye.") // Summary
.contains("-n <value>"); // Option
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForOrphanLdapUser()
throws IOException
{
ldapUserName = ORPHAN_USER.getAttributes().get("cn");
launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName)));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testUsage() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
itf.execute("--help");
assertThat(baos.toString()).contains("hello").contains("bye")
.doesNotContain("hidden").contains("A command saying hello");
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForEmptyUser()
throws IOException
{
ldapUserName = "";
launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains("Malformed decoded credentials"));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testMissingValue() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
itf.execute("hello", "-n");
assertThat(baos.toString())
.contains("The option 'name' requires a value");
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForWrongLdapPassword()
throws IOException
{
ldapUserPassword = "wrong_password";
launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains("Invalid credentials"));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testMissingOption() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
itf.execute("hello");
assertThat(baos.toString())
.contains("The option", "name", "is required");
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForWrongLdapUser()
throws IOException
{
ldapUserName = "invalid_user";
launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains("Invalid credentials"));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testInvalidValue() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
itf.execute("hidden", "-n", "vert.x", "-c", "hello");
assertThat(baos.toString())
.contains("The value 'hello' is not accepted by 'count'");
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapWithoutPassword()
throws IOException
{
launchPrestoCli("--server", ldapServerAddress,
"--truststore-path", ldapTruststorePath,
"--truststore-password", ldapTruststorePassword,
"--user", ldapUserName,
"--execute", "select * from hive.default.nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains("Authentication failed: Unauthorized"));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testCommandNotFound() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
itf.execute("missing");
assertThat(baos.toString()).contains("The command", "missing", "See", "--help");
baos.reset();
itf.execute("missing", "--help");
assertThat(baos.toString()).contains("The command", "missing", "See", "--help");
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapWithoutHttps()
throws IOException
{
ldapServerAddress = format("http://%s:8443", serverHost);
launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains("Authentication using username/password requires HTTPS to be enabled"));
skipAfterTestWithContext();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void check_paths() {
doInit();
when(platform.status()).thenReturn(UP);
assertThat(underTest.getContent("/foo")).contains(TEST_CONTEXT).contains("default");
assertThat(underTest.getContent("/foo.html")).contains(TEST_CONTEXT).contains("default");
assertThat(underTest.getContent("/index")).contains(TEST_CONTEXT).contains("default");
assertThat(underTest.getContent("/index.html")).contains(TEST_CONTEXT).contains("default");
assertThat(underTest.getContent("/integration/vsts/index.html")).contains(TEST_CONTEXT).contains("vsts");
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailForIncorrectTrustStore()
throws IOException
{
ldapTruststorePassword = "wrong_password";
launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains("Keystore was tampered with, or password was incorrect"));
skipAfterTestWithContext();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testUsageOnDifferentStream() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
itf = new VertxCommandLauncher() {
/**
* @return the printer used to write the messages. Defaults to {@link System#out}.
*/
@Override
public PrintStream getPrintStream() {
return stream;
}
};
itf.execute("--help");
assertThat(baos.toString()).contains("hello").contains("bye")
.doesNotContain("hidden").contains("A command saying hello");
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailForUserWithColon()
throws IOException
{
ldapUserName = "UserWith:Colon";
launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
assertThat(line).contains("Illegal character ':' found in username"));
skipAfterTestWithContext();
}
内容来源于网络,如有侵权,请联系作者删除!