本文整理了Java中org.assertj.core.api.AbstractCharSequenceAssert.startsWith()
方法的一些代码示例,展示了AbstractCharSequenceAssert.startsWith()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractCharSequenceAssert.startsWith()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractCharSequenceAssert
类名称:AbstractCharSequenceAssert
方法名:startsWith
[英]Verifies that the actual CharSequence starts with the given prefix.
Example :
// assertions will pass
assertThat("Frodo").startsWith("Fro");
assertThat("Gandalf the grey").startsWith("Gandalf");
// assertions will fail
assertThat("Frodo").startsWith("fro");
assertThat("Gandalf the grey").startsWith("grey");
[中]验证实际字符序列是否以给定前缀开头。
例子:
// assertions will pass
assertThat("Frodo").startsWith("Fro");
assertThat("Gandalf the grey").startsWith("Gandalf");
// assertions will fail
assertThat("Frodo").startsWith("fro");
assertThat("Gandalf the grey").startsWith("grey");
代码示例来源:origin: SonarSource/sonarqube
@Test
public void format_date_time() {
TimeZone initialTz = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("GMT+1"));
assertThat(underTest.formatDateTime(Locale.ENGLISH, DateUtils.parseDateTime("2014-01-22T19:10:03+0100"))).startsWith("Jan 22, 2014");
TimeZone.setDefault(initialTz);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void dotWorkingDir() throws IOException {
File sonarHome = temp.getRoot();
String globalWorkDir = ".";
ScannerProperties globalProperties = new ScannerProperties(ImmutableMap.of("sonar.userHome", sonarHome.getAbsolutePath(),
CoreProperties.GLOBAL_WORKING_DIRECTORY, globalWorkDir));
TempFolder tempFolder = tempFolderProvider.provide(globalProperties);
File newFile = tempFolder.newFile();
assertThat(newFile.getParentFile().getParentFile().getAbsolutePath()).isEqualTo(sonarHome.getAbsolutePath());
assertThat(newFile.getParentFile().getName()).startsWith(".sonartmp_");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldFormatDateTime_with_long() {
assertThat(DateUtils.formatDateTime(System.currentTimeMillis())).startsWith("20");
assertThat(DateUtils.formatDateTime(System.currentTimeMillis()).length()).isGreaterThan(20);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void loadPropsFromCommandLineArgs_missing_argument() {
try {
ConfigurationUtils.loadPropsFromCommandLineArgs(new String[0]);
fail();
} catch (IllegalArgumentException e) {
assertThat(e.getMessage()).startsWith("Only a single command-line argument is accepted");
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldFormatDate() {
assertThat(DateUtils.formatDate(new Date())).startsWith("20");
assertThat(DateUtils.formatDate(new Date())).hasSize(10);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void format_date_time_null_safe() {
assertThat(DateUtils.formatDateTimeNullSafe(new Date())).startsWith("20");
assertThat(DateUtils.formatDateTimeNullSafe(new Date()).length()).isGreaterThan(20);
assertThat(DateUtils.formatDateTimeNullSafe(null)).isEmpty();
}
代码示例来源:origin: SonarSource/sonarqube
private void checkSvg(TestResponse response, String expectedLabel, String expectedValue, Color expectedColorValue) {
assertThat(response.getHeader("ETag")).startsWith("W/");
assertThat(response.getHeader("Cache-Control")).contains("no-cache");
assertThat(response.getHeader("Expires")).isNull();
assertThat(response.getInput()).contains(
"<text", expectedLabel + "</text>",
"<text", expectedValue + "</text>",
"rect fill=\"" + expectedColorValue.getValue() + "\"");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void start_publishes_URL_in_IPC() {
try (DefaultProcessCommands commands = DefaultProcessCommands.secondary(this.sharedDir, 1)) {
assertThat(commands.getHttpUrl()).startsWith("http://127.0.0.1:");
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testWithOneLongOption() throws CLIException {
Option[] options = new Option[]{
new Option().setShortName("f").setLongName("file").setSingleValued(true)
};
cli.addOptions(Arrays.asList(options));
CommandLine evaluated = cli.parse(Collections.singletonList("--file=hello.txt"));
assertThat(evaluated.cli().getOptions()).hasSize(1);
assertThat((String) evaluated.getOptionValue("file")).isEqualTo("hello.txt");
assertThat(evaluated.getOptionValues("f")).containsExactly("hello.txt");
StringBuilder usage = new StringBuilder();
cli.usage(usage);
assertThat(usage.toString()).startsWith("Usage: test [-f <value>]");
assertThat(usage.toString()).contains("-f,--file <value>");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void get_index() throws Exception {
writeStringToFile(new File(batchDir, "sonar-batch.jar"), "something");
batchIndex.start();
String index = tester.newRequest().execute().getInput();
assertThat(index).startsWith("sonar-batch.jar|");
}
代码示例来源:origin: SonarSource/sonarqube
private static void assertEqual(QProfileDto p1, QProfileDto p2) {
assertThat(p2.getOrganizationUuid()).isEqualTo(p1.getOrganizationUuid());
assertThat(p2.getName()).isEqualTo(p1.getName());
assertThat(p2.getKee()).startsWith(p1.getKee());
assertThat(p2.getLanguage()).isEqualTo(p1.getLanguage());
assertThat(p2.getId()).isEqualTo(p1.getId());
assertThat(p2.getParentKee()).isEqualTo(p1.getParentKee());
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void build_adds_AUTO_INCREMENT_clause_on_MySql() {
List<String> stmts = new CreateTableBuilder(MY_SQL, TABLE_NAME)
.addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT)
.build();
assertThat(stmts).hasSize(1);
assertThat(stmts.iterator().next())
.startsWith("CREATE TABLE table_42 (id INTEGER NOT NULL AUTO_INCREMENT, CONSTRAINT pk_table_42 PRIMARY KEY (id))");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void stopInfo_adds_context_after_time_by_default() {
addSomeContext(underTest);
underTest.start().stopInfo("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs(LoggerLevel.INFO).get(0))
.startsWith("Rules registered | time=")
.endsWith("ms | a_string=bar | an_int=42 | after_start=true");
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testWithOneLongOptionUsingSpace() throws CLIException {
Option[] options = new Option[]{
new Option().setShortName("f").setLongName("file")
.setSingleValued(true)
};
cli.addOptions(Arrays.asList(options));
CommandLine evaluated = cli.parse(Arrays.asList("--file", "hello.txt"));
assertThat(evaluated.cli().getOptions()).hasSize(1);
assertThat((String) evaluated.getOptionValue("file")).isEqualTo("hello.txt");
assertThat(evaluated.getOptionValues("f")).containsExactly("hello.txt");
StringBuilder usage = new StringBuilder();
cli.usage(usage);
assertThat(usage.toString()).startsWith("Usage: test [-f <value>]");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void stopError_adds_context_before_time_if_logTimeLast_is_true() {
addSomeContext(underTest);
underTest.logTimeLast(true);
underTest.start().stopError("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs(LoggerLevel.ERROR).get(0))
.startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
.endsWith("ms");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void stopInfo_adds_context_before_time_if_logTimeLast_is_true() {
addSomeContext(underTest);
underTest.logTimeLast(true);
underTest.start().stopInfo("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs(LoggerLevel.INFO).get(0))
.startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
.endsWith("ms");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void stopTrace_adds_context_after_time_by_default() {
tester.setLevel(LoggerLevel.TRACE);
addSomeContext(underTest);
underTest.start().stopTrace("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs(LoggerLevel.TRACE).get(0))
.startsWith("Rules registered | time=")
.endsWith("ms | a_string=bar | an_int=42 | after_start=true");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void stopTrace_adds_context_before_time_if_logTimeLast_is_true() {
tester.setLevel(LoggerLevel.TRACE);
addSomeContext(underTest);
underTest.logTimeLast(true);
underTest.start().stopTrace("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs(LoggerLevel.TRACE).get(0))
.startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
.endsWith("ms");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void write_json_by_default() {
TestRequest request = new TestRequest();
DumbResponse response = new DumbResponse();
Issues.Issue msg = Issues.Issue.newBuilder().setKey("I1").build();
WsUtils.writeProtobuf(msg, request, response);
assertThat(response.stream().mediaType()).isEqualTo(MediaTypes.JSON);
assertThat(response.outputAsString())
.startsWith("{")
.contains("\"key\":\"I1\"")
.endsWith("}");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void create_user_generates_unique_login_no_login_provided() {
createDefaultGroup();
UserDto user = underTest.createAndCommit(db.getSession(), NewUser.builder()
.setName("John Doe")
.build(), u -> {
});
UserDto dto = dbClient.userDao().selectByLogin(session, user.getLogin());
assertThat(dto.getLogin()).startsWith("john-doe");
assertThat(dto.getName()).isEqualTo("John Doe");
}
内容来源于网络,如有侵权,请联系作者删除!