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

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

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

AbstractStringAssert.containsPattern介绍

暂无

代码示例

代码示例来源:origin: apache/geode

@Test
public void outputDisplaysResultsFromComplexRegion() throws Exception {
 String result = gfsh.execute("query --query='select c.name, c.address from /complexRegion c'");
 String[] resultLines = splitOnLineBreaks(result);
 assertThat(resultLines[0]).containsPattern("Result\\s+:\\s+true");
 assertThat(resultLines[1]).containsPattern("Limit\\s+:\\s+100");
 assertThat(resultLines[2]).containsPattern("Rows\\s+:\\s+100");
 assertThat(resultLines[3]).containsPattern("name\\s+\\|\\s+address");
 Arrays.asList(resultLines).subList(5, resultLines.length)
   .forEach(line -> assertThat(line).matches("name\\d+.*\"city\":\"Hometown\".*"));
}

代码示例来源:origin: apache/geode

/**
 * Verifies that the gfsh output contains the given key, value pair.
 *
 * For example, given the following gfsh output:
 *
 * <pre>
 * {@code
 * Result : true
 * Key Class : java.lang.String
 * Key : key92
 * Locations Found : 2
 * }
 * </pre>
 *
 * We might assert that:
 *
 * <pre>
 * <code> containsKeyValuePair("Key Class", "java.lang.String"); </code>
 * </pre>
 */
public CommandResultAssert containsKeyValuePair(String key, String value) {
 assertThat(actual.getOutput()).containsPattern(key + "\\s+: " + value);
 return this;
}

代码示例来源:origin: apache/geode

@Test
public void canOutputComplexRegionToFile() throws Exception {
 File outputFile = temporaryFolder.newFile("queryOutput.txt");
 FileUtils.deleteQuietly(outputFile);
 gfsh.executeAndAssertThat(
   "query --query='select c.name, c.address from /complexRegion c' --file="
     + outputFile.getAbsolutePath())
   .statusIsSuccess().containsOutput(outputFile.getAbsolutePath());
 assertThat(outputFile).exists();
 List<String> lines = Files.readLines(outputFile, StandardCharsets.UTF_8);
 assertThat(lines.get(7)).containsPattern("name\\s+\\|\\s+address");
 lines.subList(9, lines.size())
   .forEach(line -> assertThat(line).matches("name\\d+.*\"city\":\"Hometown\".*"));
}

代码示例来源:origin: apache/geode

private void assertLowMemoryException(LowMemoryException exception) {
 assertThat(exception).isExactlyInstanceOf(LowMemoryException.class);
 assertThat(exception.getMessage()).containsPattern(LOW_MEMORY_REGEX);
}

代码示例来源:origin: apache/geode

@Test
public void execute_nonexistentAeqId_returnsError() throws Throwable {
 when(cache.getAsyncEventQueue(TEST_AEQ_ID)).thenReturn(null);
 function.execute(mockContext);
 verify(resultSender).lastResult(resultCaptor.capture());
 CliFunctionResult result = resultCaptor.getValue();
 assertThat(result.isSuccessful()).isFalse();
 assertThat(result.getMessage()).containsPattern(TEST_AEQ_ID + ".*not found");
}

代码示例来源:origin: apache/geode

@Test
 public void execute_nonexistentAeqIdIfExists_returnsSuccess() throws Throwable {
  when(cache.getAsyncEventQueue(TEST_AEQ_ID)).thenReturn(null);
  when(mockArgs.isIfExists()).thenReturn(true);

  function.execute(mockContext);
  verify(resultSender).lastResult(resultCaptor.capture());
  CliFunctionResult result = resultCaptor.getValue();

  assertThat(result.isSuccessful()).isTrue();
  assertThat(result.getMessage()).containsPattern("Skipping:.*" + TEST_AEQ_ID + ".*not found");
 }
}

代码示例来源:origin: apache/geode

@Test
public void testMixMarshall() throws Exception {
 CacheConfig cache = new CacheConfig();
 setBasicValues(cache);
 cache.getCustomCacheElements().add(new ElementOne("testOne"));
 xml = service.marshall(cache);
 System.out.println(xml);
 assertThat(xml).contains("custom-one>");
 unmarshalled = service2.unMarshall(xml);
 unmarshalled.getCustomCacheElements().add(new ElementTwo("testTwo"));
 // xml generated wtih CacheConfigTwo has both elements in there.
 xml = service.marshall(unmarshalled);
 System.out.println(xml);
 assertThat(xml).contains("custom-one>");
 assertThat(xml).contains("custom-two>");
 assertThat(xml).containsPattern("xmlns=\"http://geode.apache.org/schema/cache\"");
 assertThat(xml).containsPattern("xmlns:ns\\d=\"http://geode.apache.org/schema/CustomOne\"");
 assertThat(xml).containsPattern("xmlns:ns\\d=\"http://geode.apache.org/schema/CustomTwo\"");
}

代码示例来源:origin: line/armeria

assertThat(content).containsPattern(
    multilinePattern("server_request_duration_seconds_count",
             "{handler=\"Bar\",hostnamePattern=\"*\",httpStatus=\"200\",",
             "method=\"hello\",pathMapping=\"exact:/bar\",} 1.0"));
assertThat(content).containsPattern(
    multilinePattern("server_request_length_count",
             "{handler=\"Bar\",hostnamePattern=\"*\",httpStatus=\"200\",",
             "method=\"hello\",pathMapping=\"exact:/bar\",} 1.0"));
assertThat(content).containsPattern(
    multilinePattern("server_response_length_count",
             "{handler=\"Bar\",hostnamePattern=\"*\",httpStatus=\"200\",",
             "method=\"hello\",pathMapping=\"exact:/bar\",} 1.0"));
assertThat(content).containsPattern(
    multilinePattern("client_request_duration_seconds_count",
             "{handler=\"Bar\",httpStatus=\"200\",method=\"hello\",} 1.0"));
assertThat(content).containsPattern(
    multilinePattern("client_request_length_count",
             "{handler=\"Bar\",httpStatus=\"200\",method=\"hello\",} 1.0"));
assertThat(content).containsPattern(
    multilinePattern("client_response_length_count",
             "{handler=\"Bar\",httpStatus=\"200\",method=\"hello\",} 1.0"));
assertThat(content).containsPattern(
    multilinePattern("server_requests_total",
             "{handler=\"Bar\",hostnamePattern=\"*\",httpStatus=\"200\",",
             "method=\"hello\",pathMapping=\"exact:/bar\",",
             "result=\"success\",} 1.0"));
assertThat(content).containsPattern(

代码示例来源:origin: line/armeria

assertThat(content).containsPattern(
    multilinePattern("server_request_duration_seconds_count",
             "{handler=\"Foo\",hostnamePattern=\"*\",httpStatus=\"200\",",
             "method=\"hello\",pathMapping=\"exact:/foo\",} 7.0"));
assertThat(content).containsPattern(
    multilinePattern("server_request_length_count",
             "{handler=\"Foo\",hostnamePattern=\"*\",httpStatus=\"200\",",
             "method=\"hello\",pathMapping=\"exact:/foo\",} 7.0"));
assertThat(content).containsPattern(
    multilinePattern("server_response_length_count",
             "{handler=\"Foo\",hostnamePattern=\"*\",httpStatus=\"200\",",
             "method=\"hello\",pathMapping=\"exact:/foo\",} 7.0"));
assertThat(content).containsPattern(
    multilinePattern("client_request_duration_seconds_count",
             "{handler=\"Foo\",httpStatus=\"200\",method=\"hello\",} 7.0"));
assertThat(content).containsPattern(
    multilinePattern("client_request_length_count",
             "{handler=\"Foo\",httpStatus=\"200\",method=\"hello\",} 7.0"));
assertThat(content).containsPattern(
    multilinePattern("client_response_length_count",
             "{handler=\"Foo\",httpStatus=\"200\",method=\"hello\",} 7.0"));
assertThat(content).containsPattern(
    multilinePattern("server_requests_total",
             "{handler=\"Foo\",hostnamePattern=\"*\",httpStatus=\"200\",",
             "method=\"hello\",pathMapping=\"exact:/foo\",",
             "result=\"failure\",} 3.0"));
assertThat(content).containsPattern(

代码示例来源:origin: jdbi/jdbi

@Test
public void testNeitherHasToString() {
  handle.registerArgument(new FooArgumentFactory());
  handle.createUpdate(INSERT_POSITIONAL).bind(0, new Foo()).execute();
  assertThat(positional).containsPattern("@[0-9a-f]{1,8}$");
}

代码示例来源:origin: otto-de/edison-microservice

@Test
public void shouldTriggerJob() {
  final ResponseEntity<String> postResponse = restTemplate.postForEntity("/internal/jobs/Foo", "", String.class);
  assertThat(postResponse.getStatusCodeValue()).isEqualTo(204);
  final ResponseEntity<String> jobResponse = restTemplate.getForEntity(postResponse.getHeaders().getLocation(), String.class);
  assertThat(jobResponse.getStatusCodeValue()).isEqualTo(200);
  assertThat(jobResponse.getBody()).containsPattern(("\"state\"( )*:( )*\"Running\"")); // contains ignoring whitespaces
  assertThat(jobResponse.getBody()).containsPattern("\"jobType\"( )*:( )*\"Foo\""); // contains ignoring whitespaces
}

代码示例来源:origin: SpectoLabs/hoverfly-java

@Test
public void shouldLogToStdOut() {
  final Appender<ILoggingEvent> appender = Mockito.mock(Appender.class);
  final Logger logger = (Logger) LoggerFactory.getLogger("hoverfly");
  logger.addAppender(appender);
  logger.setLevel(Level.INFO);
  systemOut.enableLog();
  hoverfly = new Hoverfly(localConfigs().logToStdOut(), SIMULATE);
  hoverfly.start();
  verify(appender, never()).doAppend(any());
  assertThat(systemOut.getLogWithNormalizedLineSeparator()).containsPattern("Default proxy port has been overwritten       [^\n]*port[^\n]*=");
}

代码示例来源:origin: SpectoLabs/hoverfly-java

@Test
public void shouldAllowTLSVerificationToBeDisabled() {
  systemOut.enableLog();
  hoverfly = new Hoverfly(localConfigs().logToStdOut().disableTlsVerification(), SIMULATE);
  hoverfly.start();
  assertThat(systemOut.getLogWithNormalizedLineSeparator())
      .containsPattern("TLS certificate verification has been disabled");
}

相关文章

微信公众号

最新文章

更多