当前位置: 首页>>代码示例>>Java>>正文


Java StringStartsWith类代码示例

本文整理汇总了Java中org.hamcrest.core.StringStartsWith的典型用法代码示例。如果您正苦于以下问题:Java StringStartsWith类的具体用法?Java StringStartsWith怎么用?Java StringStartsWith使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringStartsWith类属于org.hamcrest.core包,在下文中一共展示了StringStartsWith类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPOJOWithNestedArrayNoHashCodeKeyRejection

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:DataStreamTest.java

示例2: testTupleNestedArrayKeyRejection

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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;
		}
	});
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:DataStreamTest.java

示例3: verifyJwtToken

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
private void verifyJwtToken(Response response) throws NoSuchAlgorithmException, InvalidKeyException, IOException, SignatureException, JWTVerifyException {
    String cookieContent = response.getCookies().get(HttpHeaders.AUTHORIZATION).getValue();
    assertThat(cookieContent, StringStartsWith.startsWith("Bearer "));
    String jwt = cookieContent.substring(7);

    JWTVerifier jwtVerifier = new JWTVerifier("myJWT4Gr4v1t33_S3cr3t");

    Map<String, Object> mapJwt = jwtVerifier.verify(jwt);

    assertEquals(mapJwt.get("sub"),"[email protected]");

    assertEquals(mapJwt.get("firstname"),"Jane");
    assertEquals(mapJwt.get("iss"),"gravitee-management-auth");
    assertEquals(mapJwt.get("sub"),"[email protected]");
    assertEquals(mapJwt.get("email"),"[email protected]");
    assertEquals(mapJwt.get("lastname"),"Doe");
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:18,代码来源:OAuth2AuthenticationResourceTest.java

示例4: testNotJsonResponse

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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();
}
 
开发者ID:arteam,项目名称:simple-json-rpc,代码行数:19,代码来源:BatchRequestBuilderErrors.java

示例5: testNoVersion

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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();
}
 
开发者ID:arteam,项目名称:simple-json-rpc,代码行数:19,代码来源:BatchRequestBuilderErrors.java

示例6: testUnexpectedResult

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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();
}
 
开发者ID:arteam,项目名称:simple-json-rpc,代码行数:22,代码来源:BatchRequestBuilderErrors.java

示例7: assertCallFailure

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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");
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:8,代码来源:RestfulServerTest.java

示例8: testUnsuccessfulResponseCode

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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);
}
 
开发者ID:hortonworks,项目名称:nifi-android-s2s,代码行数:10,代码来源:PeerTrackerTest.java

示例9: checkLookupSetMissing

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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));
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:9,代码来源:TestErrorHandling.java

示例10: checkLookupMissing

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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));
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:9,代码来源:TestErrorHandling.java

示例11: checkFixedStringLookupMissing

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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));
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:9,代码来源:TestErrorHandling.java

示例12: checkFixedStringLookupMissingvalue

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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));
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:9,代码来源:TestErrorHandling.java

示例13: checkSyntaxErrorRequire

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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));
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:9,代码来源:TestErrorHandling.java

示例14: checkSyntaxErrorExpect

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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));
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:9,代码来源:TestErrorHandling.java

示例15: checkSyntaxErrorVariableBackReference

import org.hamcrest.core.StringStartsWith; //导入依赖的package包/类
@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));
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:9,代码来源:TestErrorHandling.java


注:本文中的org.hamcrest.core.StringStartsWith类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。