org.assertj.core.api.AbstractCharSequenceAssert.endsWith()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中org.assertj.core.api.AbstractCharSequenceAssert.endsWith()方法的一些代码示例,展示了AbstractCharSequenceAssert.endsWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractCharSequenceAssert.endsWith()方法的具体详情如下:
包路径:org.assertj.core.api.AbstractCharSequenceAssert
类名称:AbstractCharSequenceAssert
方法名:endsWith

AbstractCharSequenceAssert.endsWith介绍

[英]Verifies that the actual CharSequence ends with the given suffix.

Example :

// assertion will pass 
assertThat("Frodo").endsWith("do"); 
// assertion will fail 
assertThat("Frodo").endsWith("Fro");

[中]验证实际字符序列是否以给定后缀结尾。
例子:

// assertion will pass 
assertThat("Frodo").endsWith("do"); 
// assertion will fail 
assertThat("Frodo").endsWith("Fro");

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Test
public void get_file_by_absolute_path() throws IOException {
 PathResolver resolver = new PathResolver();
 File rootDir = temp.newFolder();
 File file = resolver.relativeFile(rootDir, new File(rootDir, "org/foo/Bar.java").getAbsolutePath());
 assertThat(file.getName()).isEqualTo("Bar.java");
 assertThat(FilenameUtils.separatorsToUnix(file.getCanonicalPath())).endsWith("org/foo/Bar.java");
 assertThat(file.getParentFile().getParentFile().getParentFile().getCanonicalPath()).isEqualTo(rootDir.getCanonicalPath());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void testCustomAppender() throws UnsupportedEncodingException {
 conf.setLogOutput(listener);
 LoggingConfigurator.apply(conf);
 Logger logger = LoggerFactory.getLogger(this.getClass());
 logger.info(TEST_STR);
 assertThat(listener.msg).endsWith(TEST_STR);
 assertThat(listener.level).isEqualTo(LogOutput.Level.INFO);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void get_file_by_relative_path() throws IOException {
 PathResolver resolver = new PathResolver();
 File rootDir = temp.newFolder();
 File file = resolver.relativeFile(rootDir, "org/foo/Bar.java");
 assertThat(file.getName()).isEqualTo("Bar.java");
 assertThat(FilenameUtils.separatorsToUnix(file.getCanonicalPath())).endsWith("org/foo/Bar.java");
 assertThat(file.getParentFile().getParentFile().getParentFile().getCanonicalPath()).isEqualTo(rootDir.getCanonicalPath());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void non_existing_file_should_throw_exception() {
 try {
  createInputFileWithMetadata(Paths.get(""), "non_existing");
  Assert.fail();
 } catch (IllegalStateException e) {
  assertThat(e.getMessage()).endsWith("Unable to read file " + Paths.get("").resolve("non_existing").toAbsolutePath());
  assertThat(e.getCause()).isInstanceOf(IllegalStateException.class);
 }
}

代码示例来源:origin: springside/springside4

@Test
  public void getJarPath() {
    System.out.println("the jar file contains Files.class" + FilePathUtil.getJarPath(Files.class));
    assertThat(FilePathUtil.getJarPath(Files.class)).endsWith("guava-20.0.jar");
  }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void reformatParam_truncates_if_too_long() {
 String param = repeat("a", SqlLogFormatter.PARAM_MAX_WIDTH + 10);
 String formattedParam = SqlLogFormatter.reformatParam(param);
 assertThat(formattedParam)
  .hasSize(SqlLogFormatter.PARAM_MAX_WIDTH)
  .endsWith("...")
  .startsWith(repeat("a", SqlLogFormatter.PARAM_MAX_WIDTH - 3));
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test() throws Exception {
 File baseDir = temp.newFolder();
 DefaultInputDir inputDir = new DefaultInputDir("ABCDE", "src")
  .setModuleBaseDir(baseDir.toPath());
 assertThat(inputDir.key()).isEqualTo("ABCDE:src");
 assertThat(inputDir.file().getAbsolutePath()).isEqualTo(new File(baseDir, "src").getAbsolutePath());
 assertThat(inputDir.relativePath()).isEqualTo("src");
 assertThat(new File(inputDir.relativePath())).isRelative();
 assertThat(inputDir.absolutePath()).endsWith("src");
 assertThat(new File(inputDir.absolutePath())).isAbsolute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void aggregate_plugin_classloaders() {
 URLClassLoader checkstyle = newCheckstyleClassloader();
 I18nClassloader i18nClassloader = new I18nClassloader(Lists.newArrayList(checkstyle));
 assertThat(i18nClassloader.getResource("org/sonar/l10n/checkstyle.properties")).isNotNull();
 assertThat(i18nClassloader.getResource("org/sonar/l10n/checkstyle.properties").getFile()).endsWith("checkstyle.properties");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void stopError_adds_context_after_time_by_default() {
 addSomeContext(underTest);
 underTest.start().stopError("Rules registered");
 assertThat(tester.logs()).hasSize(1);
 assertThat(tester.logs(LoggerLevel.ERROR).get(0))
  .startsWith("Rules registered | time=")
  .endsWith("ms | a_string=bar | an_int=42 | after_start=true");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void builds_adds_hardcoded_collation_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())
  .endsWith(" ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin");
}

代码示例来源: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 support_base_url_ending_with_slash() throws Exception {
 assertThat(serverUrl).endsWith("/");
 underTest = HttpConnector.newBuilder().url(StringUtils.removeEnd(serverUrl, "/")).build();
 GetRequest request = new GetRequest("api/issues/search");
 answerHelloWorld();
 WsResponse response = underTest.call(request);
 assertThat(response.hasContent()).isTrue();
}

代码示例来源: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 empty_message() {
 underTest.addContext("foo", "bar");
 underTest.startInfo("");
 assertThat(tester.logs()).containsOnly("foo=bar");
 underTest.addContext("after_start", true);
 underTest.stopInfo("");
 assertThat(tester.logs()).hasSize(2);
 assertThat(tester.logs().get(1))
  .startsWith("time=")
  .endsWith("ms | foo=bar | after_start=true");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void empty_message() {
 underTest.addContext("foo", "bar");
 underTest.startInfo("");
 assertThat(tester.logs()).containsOnly("foo=bar");
 underTest.addContext("after_start", true);
 underTest.stopInfo("");
 assertThat(tester.logs()).hasSize(2);
 assertThat(tester.logs().get(1))
  .startsWith("time=")
  .endsWith("ms | foo=bar | 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: json-path/JsonPath

@Test
public void object_can_be_mapped(){
  TypeRef<List<String>> typeRef = new TypeRef<List<String>>() {};
  MapFunction mapFunction = new ToStringMapFunction();
  DocumentContext documentContext = JsonPath.using(JACKSON_CONFIGURATION).parse(JSON_DOCUMENT);
  Object list = documentContext.read("$..book");
  assertThat(list).isInstanceOf(List.class);
  String result = documentContext.map("$..book", mapFunction).read("$..book", typeRef).get(0);
  assertThat(result).isInstanceOf(String.class);
  assertThat(result).endsWith("converted");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void createRollingPolicy_time() {
 props.set("sonar.log.rollingPolicy", "time:yyyy-MM");
 props.set("sonar.log.maxFiles", "20");
 LoggerContext ctx = underTest.getRootContext();
 LogbackHelper.RollingPolicy policy = underTest.createRollingPolicy(ctx, props, "sonar");
 RollingFileAppender appender = (RollingFileAppender) policy.createAppender("SONAR_FILE");
 // max 5 monthly files
 TimeBasedRollingPolicy triggeringPolicy = (TimeBasedRollingPolicy) appender.getTriggeringPolicy();
 assertThat(triggeringPolicy.getMaxHistory()).isEqualTo(20);
 assertThat(triggeringPolicy.getFileNamePattern()).endsWith("sonar.%d{yyyy-MM}.log");
}

代码示例来源: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("}");
}

相关文章

微信公众号

最新文章

更多