本文整理汇总了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");
}
示例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;
}
});
}
示例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();
}
示例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();
}
示例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();
}
示例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");
}
示例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);
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}