Java 类org.hamcrest.core.StringStartsWith 实例源码

项目:flink    文件:DataStreamTest.java   
@Test
public void testPOJOWithNestedArrayNoHashCodeKeyRejection() {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    DataStream<POJOWithHashCode> input = env.fromElements(
            new POJOWithHashCode(new int[] {1, 2}));

    TypeInformation<?> expectedTypeInfo = new TupleTypeInfo<Tuple1<int[]>>(
            PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO);

    // adjust the rule
    expectedException.expect(InvalidProgramException.class);
    expectedException.expectMessage(new StringStartsWith("Type " + expectedTypeInfo + " cannot be used as key."));

    input.keyBy("id");
}
项目:flink    文件:DataStreamTest.java   
@Test
public void testTupleNestedArrayKeyRejection() {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    DataStream<Tuple2<Integer[], String>> input = env.fromElements(
            new Tuple2<>(new Integer[] {1, 2}, "test-test"));

    TypeInformation<?> expectedTypeInfo = new TupleTypeInfo<Tuple2<Integer[], String>>(
            BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);

    // adjust the rule
    expectedException.expect(InvalidProgramException.class);
    expectedException.expectMessage(new StringStartsWith("Type " + expectedTypeInfo + " cannot be used as key."));

    input.keyBy(new KeySelector<Tuple2<Integer[], String>, Tuple2<Integer[], String>>() {
        @Override
        public Tuple2<Integer[], String> getKey(Tuple2<Integer[], String> value) throws Exception {
            return value;
        }
    });
}
项目:simple-json-rpc    文件:BatchRequestBuilderErrors.java   
@Test
public void testNotJsonResponse() {
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage(new StringStartsWith("Unable parse a JSON response"));

    JsonRpcClient client = new JsonRpcClient(new Transport() {
        @NotNull
        @Override
        public String pass(@NotNull String request) throws IOException {
            return "test data";
        }
    });
    client.createBatchRequest()
            .add(1L, "findPlayer", "Steven", "Stamkos")
            .add(2L, "findPlayer", "Vladimir", "Sobotka")
            .returnType(Player.class)
            .execute();
}
项目:simple-json-rpc    文件:BatchRequestBuilderErrors.java   
@Test
public void testNoVersion() {
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage(new StringStartsWith("Not a JSON-RPC response"));

    JsonRpcClient client = new JsonRpcClient(new Transport() {
        @NotNull
        @Override
        public String pass(@NotNull String request) throws IOException {
            return "[{\"test\":\"data\"}]";
        }
    });
    client.createBatchRequest()
            .add(1L, "findPlayer", "Steven", "Stamkos")
            .add(2L, "findPlayer", "Vladimir", "Sobotka")
            .returnType(Player.class)
            .execute();
}
项目:simple-json-rpc    文件:BatchRequestBuilderErrors.java   
@Test
public void testUnexpectedResult() {
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage(new StringStartsWith("Neither result or error is set in response"));

    JsonRpcClient client = new JsonRpcClient(new Transport() {
        @NotNull
        @Override
        public String pass(@NotNull String request) throws IOException {
            return "[{\n" +
                    "    \"jsonrpc\": \"2.0\",\n" +
                    "    \"id\": 1\n" +
                    "}]";
        }
    });
    client.createBatchRequest()
            .add(1L, "findPlayer", "Steven", "Stamkos")
            .add(2L, "findPlayer", "Vladimir", "Sobotka")
            .returnType(Player.class)
            .execute();
}
项目:elastic-job-cloud    文件:RestfulServerTest.java   
@Test
public void assertCallFailure() throws Exception {
    ContentExchange actual = sentRequest("{\"string\":\"test\",\"integer\":\"invalid_number\"}");
    Assert.assertThat(actual.getResponseStatus(), Is.is(500));
    Assert.assertThat(actual.getResponseContent(), StringStartsWith.startsWith("java.lang.NumberFormatException"));
    Mockito.verify(caller).call("test");
}
项目:nifi-android-s2s    文件:PeerTrackerTest.java   
@Test
public void testUnsuccessfulResponseCode() throws IOException {
    expectedException.expect(IOException.class);
    expectedException.expectMessage(new StringStartsWith(RECEIVED_RESPONSE_CODE));

    mockNiFiS2SServer.getMockWebServer().enqueue(new MockResponse().setResponseCode(400));

    new HttpSiteToSiteClient(siteToSiteClientConfig, siteToSiteRemoteCluster);
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkLookupSetMissing() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Missing lookupSet"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/LookupSetMissing.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkLookupMissing() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Missing lookup"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/LookupMissing.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkFixedStringLookupMissing() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Missing lookup"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/FixedStringLookupMissing.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkFixedStringLookupMissingvalue() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Fixed value"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/FixedStringLookupMissingValue.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkSyntaxErrorRequire() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Syntax error"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/SyntaxErrorRequire.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkSyntaxErrorExpect() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Syntax error"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/SyntaxErrorExtract.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkSyntaxErrorVariableBackReference() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Syntax error"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/Variable-BackReference.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkSyntaxErrorVariableBadDefinition() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Invalid variable config line:"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/Variable-BadDefinition.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:yauaa    文件:TestErrorHandling.java   
@Test
public void checkSyntaxErrorVariableFixedString() {
    expectedEx.expect(InvalidParserConfigurationException.class);
    expectedEx.expectMessage(new StringStartsWith("Syntax error"));

    UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester("classpath*:BadDefinitions/Variable-FixedString.yaml");
    Assert.assertTrue(uaa.runTests(false, false));
}
项目:TomboloDigitalConnector    文件:RowCellExtractorTest.java   
@Test
public void extractSillyValue() throws Exception {

    RowCellExtractor extractor = new RowCellExtractor(3, CellType.NUMERIC);

    extractor.setRow(workbook.getSheet("sheet").getRow(0));
    thrown.expect(BlankCellException.class);
    thrown.expectMessage(new StringStartsWith("Could not extract value"));
    extractor.extract();

    extractor.setRow(workbook.getSheet("sheet").getRow(1));
    assertEquals("7.0", extractor.extract());

}
项目:TomboloDigitalConnector    文件:RowCellExtractorTest.java   
@Test
public void extractUnhandledCellType() throws Exception {

    RowCellExtractor extractor = new RowCellExtractor(4, CellType.FORMULA);

    extractor.setRow(workbook.getSheet("sheet").getRow(0));
    thrown.expect(ExtractorException.class);
    thrown.expectMessage(new StringStartsWith("Unhandled cell type"));
    extractor.extract();
}
项目:TomboloDigitalConnector    文件:RowCellExtractorTest.java   
@Test
public void extractNonExistingColumn() throws Exception {

    RowCellExtractor extractor = new RowCellExtractor(4, CellType.FORMULA);

    extractor.setRow(workbook.getSheet("sheet").getRow(1));
    thrown.expect(ExtractorException.class);
    thrown.expectMessage(new StringStartsWith("Column with index 4 does not exit"));
    extractor.extract();
}
项目:flink    文件:DataStreamTest.java   
private <K> void testKeyRejection(KeySelector<Tuple2<Integer[], String>, K> keySelector, TypeInformation<K> expectedKeyType) {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    DataStream<Tuple2<Integer[], String>> input = env.fromElements(
            new Tuple2<>(new Integer[] {1, 2}, "barfoo")
    );

    Assert.assertEquals(expectedKeyType, TypeExtractor.getKeySelectorTypes(keySelector, input.getType()));

    // adjust the rule
    expectedException.expect(InvalidProgramException.class);
    expectedException.expectMessage(new StringStartsWith("Type " + expectedKeyType + " cannot be used as key."));

    input.keyBy(keySelector);
}
项目:fake-jedis    文件:FakeJedisTest.java   
@Test public void call_a_method_that_is_not_implemented() {
    // GIVEN

    // THEN
    this.expectedException.expect(FakeJedisNotImplementedException.class);
    this.expectedException.expectMessage(StringStartsWith.startsWith("The method "));
    this.expectedException.expectMessage(StringContains.containsString("FakeJedis.mget"));
    this.expectedException.expectMessage(StringEndsWith.endsWith(" is not implemented in your version of FakeJedis. Contribute on github! https://github.com/vdurmont/fake-jedis"));

    // WHEN
    this.jedis.mget(KEY);
}
项目:hapi-fhir    文件:PlainProviderTest.java   
@Test
public void testGlobalHistory() throws Exception {
    GlobalHistoryProvider provider = new GlobalHistoryProvider();
    myRestfulServer.setProviders(provider);
    myServer.start();

    String baseUri = "http://localhost:" + myPort + "/fhir/context";
    HttpResponse status = myClient.execute(new HttpGet(baseUri + "/_history?_since=2012-01-02T00%3A01%3A02&_count=12"));

    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    ourLog.info("Response was:\n{}", responseContent);
    assertEquals(200, status.getStatusLine().getStatusCode());
    Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(3, bundle.getEntries().size());

    assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
    assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));

    status = myClient.execute(new HttpGet(baseUri + "/_history?&_count=12"));
    responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    assertEquals(200, status.getStatusLine().getStatusCode());
    bundle = ourCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(3, bundle.getEntries().size());
    assertNull(provider.myLastSince);
    assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));

    status =myClient.execute(new HttpGet(baseUri + "/_history?_since=2012-01-02T00%3A01%3A02"));
    responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    assertEquals(200, status.getStatusLine().getStatusCode());
    bundle = ourCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(3, bundle.getEntries().size());
    assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
    assertNull(provider.myLastCount);
}
项目:hapi-fhir    文件:PlainProviderR4Test.java   
@Test
public void testGlobalHistory() throws Exception {
    GlobalHistoryProvider provider = new GlobalHistoryProvider();
    myRestfulServer.setProviders(provider);
    myServer.start();

    String baseUri = "http://localhost:" + myPort + "/fhir/context";
    HttpResponse status = myClient.execute(new HttpGet(baseUri + "/_history?_since=2012-01-02T00%3A01%3A02&_count=12"));

    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    ourLog.info("Response was:\n{}", responseContent);
    assertEquals(200, status.getStatusLine().getStatusCode());
    Bundle bundle = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
    assertEquals(3, bundle.getEntry().size());

    assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
    assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));

    status = myClient.execute(new HttpGet(baseUri + "/_history?&_count=12"));
    responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    assertEquals(200, status.getStatusLine().getStatusCode());
    bundle = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
    assertEquals(3, bundle.getEntry().size());
    assertNull(provider.myLastSince);
    assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));

    status =myClient.execute(new HttpGet(baseUri + "/_history?_since=2012-01-02T00%3A01%3A02"));
    responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    assertEquals(200, status.getStatusLine().getStatusCode());
    bundle = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
    assertEquals(3, bundle.getEntry().size());
    assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
    assertNull(provider.myLastCount);
}
项目:hbase    文件:TestLockProcedure.java   
private void validateLockRequestException(LockRequest lockRequest, String message)
    throws Exception {
  exception.expect(ServiceException.class);
  exception.expectCause(IsInstanceOf.instanceOf(DoNotRetryIOException.class));
  exception.expectMessage(
      StringStartsWith.startsWith("org.apache.hadoop.hbase.DoNotRetryIOException: "
          + "java.lang.IllegalArgumentException: " + message));
  masterRpcService.requestLock(null, lockRequest);
}
项目:simple-json-rpc    文件:BatchRequestBuilderErrors.java   
@Test
public void testFailFastOnNotJsonData() {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage(new StringStartsWith("No serializer found"));

    client.createBatchRequest()
            .add(1L, "findPlayer", new Name("Steven"), new Name("Stamkos"))
            .add(2L, "findPlayer", new Name("Vladimir"), new Name("Sobotka"))
            .keysType(Long.class)
            .returnType(Player.class)
            .execute();
}
项目:simple-json-rpc    文件:BatchRequestBuilderErrors.java   
@Test
public void testBadVersion() {
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage(new StringStartsWith("Bad protocol version"));

    JsonRpcClient client = new JsonRpcClient(new Transport() {
        @NotNull
        @Override
        public String pass(@NotNull String request) throws IOException {
            return "[{\n" +
                    "    \"jsonrpc\": \"1.0\",\n" +
                    "    \"id\": 1,\n" +
                    "    \"result\": {\n" +
                    "        \"firstName\": \"Steven\",\n" +
                    "        \"lastName\": \"Stamkos\",\n" +
                    "        \"team\": {\n" +
                    "            \"name\": \"Tampa Bay Lightning\",\n" +
                    "            \"league\": \"NHL\"\n" +
                    "        },\n" +
                    "        \"number\": 91,\n" +
                    "        \"position\": \"C\",\n" +
                    "        \"birthDate\": \"1990-02-07T00:00:00.000+0000\",\n" +
                    "        \"capHit\": 7.5\n" +
                    "    }\n" +
                    "}]";
        }
    });
    client.createBatchRequest()
            .add(1L, "findPlayer", "Steven", "Stamkos")
            .add(2L, "findPlayer", "Vladimir", "Sobotka")
            .returnType(Player.class)
            .execute();
}
项目:cdi-interceptors    文件:LoggingInterceptorTest.java   
@Test
public void testDefaultRuntimeException() throws Throwable {
    try {
        def.runAndThrow("foo", new RuntimeException("re message"));
        fail();
    } catch (RuntimeException e) {
        assertThat(
                LogbackTestAppender.getMessage(),
                StringStartsWith
                        .startsWith("ERROR call runAndThrow(objectParam=foo, throwable=java.lang.RuntimeException: re message) caused java.lang.RuntimeException: re message"
                                + "\njava.lang.RuntimeException: re message"
                                + "\n\tat com.github.sfleiter.cdi_interceptors.LoggingInterceptorTest.testDefaultRuntimeException(LoggingInterceptorTest.java"));
    }
}
项目:cdi-interceptors    文件:LoggingInterceptorTest.java   
@Test
public void testConfiguredRuntimeException() throws Throwable {
    try {
        conf.runAndThrow("foo", new RuntimeException("re message"));
        fail();
    } catch (RuntimeException e) {
        assertThat(
                LogbackTestAppender.getMessage(),
                StringStartsWith
                        .startsWith("WARN call runAndThrow(objectParam=foo, throwable=java.lang.RuntimeException: re message) caused java.lang.RuntimeException: re message"
                                + "\njava.lang.RuntimeException: re message"
                                + "\n\tat com.github.sfleiter.cdi_interceptors.LoggingInterceptorTest.testConfiguredRuntimeException(LoggingInterceptorTest.java"));
    }
}
项目:cdi-interceptors    文件:LoggingInterceptorTest.java   
@Test
public void testDefaultCheckedException() throws Throwable {
    try {
        def.runAndThrow("foo", new Exception("e message"));
        fail();
    } catch (Exception e) {
        assertThat(
                LogbackTestAppender.getMessage(),
                StringStartsWith
                        .startsWith("INFO call runAndThrow(objectParam=foo, throwable=java.lang.Exception: e message) caused java.lang.Exception: e message"
                                + "\njava.lang.Exception: e message"
                                + "\n\tat com.github.sfleiter.cdi_interceptors.LoggingInterceptorTest.testDefaultCheckedException(LoggingInterceptorTest.java"));
    }
}
项目:fullsync    文件:ChangeLogTest.java   
@Test
public void testChangeLogEntryFormatting() throws Exception {
    ChangeLogEntry changelog = new ChangeLogLoader().load(versionsDirectory, "^0\\.9\\.1\\.html$").get(0);
    StringWriter sw = new StringWriter();
    String entryPattern = "### ENTRY ### ";
    changelog.write("### HEADER ### %s %s", entryPattern + "%s", sw, DateTimeFormatter.BASIC_ISO_DATE);
    String entry = sw.toString();
    String[] lines = entry.split("\r?\n");
    assertEquals("first line is the header", "### HEADER ### 0.9.1 20050308", lines[0].trim());
    assertEquals("entry has three lines ", 3, lines.length);
    for (int i = 1; i < lines.length; ++i) {
        assertThat("Line " + i, lines[i], StringStartsWith.startsWith(entryPattern));
    }
}
项目:assertj-vavr    文件:ExpectedException.java   
private void expectMessageStartingWith(String start) {
    delegate.expectMessage(StringStartsWith.startsWith(format(start)));
}
项目:cito    文件:ConnectionTest.java   
@Test
public void toString_() {
    assertThat(this.connection.toString(), new StringStartsWith(Connection.class.getName() + "@"));
    assertThat(this.connection.toString(), new StringEndsWith("[sessionId=ABC123]"));
}
项目:cito    文件:SessionTest.java   
@Test
public void toString_() {
    assertThat(this.session.toString(), new StringStartsWith(Session.class.getName() + "@"));
    assertThat(this.session.toString(), new StringEndsWith("[connection=conn,session=delegate]"));
}
项目:TomboloDigitalConnector    文件:TrafficCountImporterTest.java   
@Test
public void testImportDatasourceUnknown() throws Exception{
    thrown.expect(ConfigurationException.class);
    thrown.expectMessage(new StringStartsWith("Unknown DatasourceId:"));
    importer.importDatasource("xyz", null, null, null);
}
项目:TomboloDigitalConnector    文件:TrafficCountImporterTest.java   
@Test
public void testImportDatasourceNowhere() throws Exception {
    thrown.expect(ConfigurationException.class);
    thrown.expectMessage(new StringStartsWith("Missing geography scope"));
    importer.importDatasource("trafficCounts", null, null, null);
}
项目:TomboloDigitalConnector    文件:TrafficCountImporterTest.java   
@Test
public void testImportDatasourceNorthPole() throws Exception {
    thrown.expect(ConfigurationException.class);
    thrown.expectMessage(new StringStartsWith("Unknown Geography Scope:"));
    importer.importDatasource("trafficCounts", Arrays.asList("North Pole"), null, null);
}
项目:FHIR-Server    文件:PlainProviderTest.java   
@Test
public void testGlobalHistory() throws Exception {
    GlobalHistoryProvider provider = new GlobalHistoryProvider();
    myRestfulServer.setProviders(provider);
    myServer.start();

    String baseUri = "http://localhost:" + myPort + "/fhir/context";
    HttpResponse status = myClient.execute(new HttpGet(baseUri + "/_history?_since=2012-01-02T00%3A01%3A02&_count=12"));

    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    ourLog.info("Response was:\n{}", responseContent);
    assertEquals(200, status.getStatusLine().getStatusCode());
    Bundle bundle = myCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(3, bundle.getEntries().size());

    assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
    assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));

    status = myClient.execute(new HttpGet(baseUri + "/_history?&_count=12"));
    responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    assertEquals(200, status.getStatusLine().getStatusCode());
    bundle = myCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(3, bundle.getEntries().size());
    assertNull(provider.myLastSince.getValueAsString());
    assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));

    status =myClient.execute(new HttpGet(baseUri + "/_history?_since=2012-01-02T00%3A01%3A02"));
    responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    assertEquals(200, status.getStatusLine().getStatusCode());
    bundle = myCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(3, bundle.getEntries().size());
    assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
    assertNull(provider.myLastCount.getValueAsString());

    status =myClient.execute(new HttpGet(baseUri + "/_history"));
    responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    assertEquals(200, status.getStatusLine().getStatusCode());
    bundle = myCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(3, bundle.getEntries().size());
    assertNull(provider.myLastSince.getValueAsString());
    assertNull(provider.myLastCount.getValueAsString());

}
项目:paymenthighway-java-lib    文件:FormAPIConnectionTest.java   
static String postCardFormAndReturnLastQueryString(
    String serviceUrl,
    String formUri,
    String cardNumber,
    String expirationMonth,
    String expirationYear,
    String cvc
) {
  HttpPost httpPost = new HttpPost(serviceUrl + formUri);
  List<NameValuePair> submitParameters = new ArrayList<>();
  submitParameters.add(new BasicNameValuePair("card_number", cardNumber));
  submitParameters.add(new BasicNameValuePair("expiration_month", expirationMonth));
  submitParameters.add(new BasicNameValuePair("expiration_year", expirationYear));
  submitParameters.add(new BasicNameValuePair("cvv", cvc));

  httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
  httpPost.addHeader("User-Agent", "PaymentHighway Java Lib");

  String submitResponse = null;
  HttpClientContext context = null;

  try {
    httpPost.setEntity(new UrlEncodedFormEntity(submitParameters));
    CloseableHttpClient httpclient = HttpClients.createDefault();
    context = HttpClientContext.create();

    submitResponse = httpclient.execute(httpPost, FormAPIConnection.bodyResponseHandler(), context);
    httpclient.close();
  } catch (IOException e) {
    e.printStackTrace();
  }
  // test that response is from success url
  assertNotNull(submitResponse);
  assertTrue(submitResponse.contains("paymenthighway"));

  List<URI> redirectURIs = context.getRedirectLocations();
  assertEquals(2, redirectURIs.size());

  String query = redirectURIs.get(1).getQuery();
  assertThat(query, StringStartsWith.startsWith("success"));
  return query;
}
项目:assertj-core    文件:ExpectedException.java   
private void expectMessageStartingWith(String start) {
  delegate.expectMessage(StringStartsWith.startsWith(format(start)));
}