本文整理汇总了Java中javax.json.JsonReader类的典型用法代码示例。如果您正苦于以下问题:Java JsonReader类的具体用法?Java JsonReader怎么用?Java JsonReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JsonReader类属于javax.json包,在下文中一共展示了JsonReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyInjectedJTI2
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
description = "Verify that the injected jti claim is as expected")
public void verifyInjectedJTI2() throws Exception {
Reporter.log("Begin verifyInjectedJTI\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedJTI";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.jti.name(), "a-123")
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例2: verifyInjectedRawTokenStandard
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI,
description = "Verify that the injected raw token claim using @Claim(standard) is as expected")
public void verifyInjectedRawTokenStandard() throws Exception {
Reporter.log("Begin verifyInjectedRawTokenStandard\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedRawTokenStandard";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.raw_token.name(), token)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例3: isStatusOk
import javax.json.JsonReader; //导入依赖的package包/类
/**
* Says if status is OK
* @return true if status is OK
*/
public boolean isStatusOk() {
if (jsonResult == null || jsonResult.isEmpty()) {
return false;
}
try {
JsonReader reader = Json.createReader(new StringReader(jsonResult));
JsonStructure jsonst = reader.read();
JsonObject object = (JsonObject) jsonst;
JsonString status = (JsonString) object.get("status");
if (status != null && status.getString().equals("OK")) {
return true;
} else {
return false;
}
} catch (Exception e) {
this.parseException = e;
invalidJsonStream = true;
return false;
}
}
示例4: testLogin
import javax.json.JsonReader; //导入依赖的package包/类
@Test
public void testLogin() {
try {
String authUrl = String.format(AUTH_URL_BASE, port);
JsonObject request = Json.createObjectBuilder()
.add("id", DEFAULT_ID)
.add("key", DEFAULT_KEY)
.build();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<>(request.toString(), headers);
RestTemplate rest = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
ResponseEntity<String> response = rest.exchange(authUrl, HttpMethod.POST, entity, String.class);
assertEquals(200, response.getStatusCodeValue());
JsonReader reader = Json.createReader(new StringReader(response.getBody()));
JsonObject o = reader.readObject();
String token = o.getString("token");
assertTrue(!StringUtils.isEmpty(token));
logger.info(token);
} catch (Exception e) {
logger.error(e.getMessage(), e);
fail(e.getMessage());
}
}
示例5: loadMetadata
import javax.json.JsonReader; //导入依赖的package包/类
private void loadMetadata() {
String requestUrl = "http://archive.org/metadata/" + identifier;
try {
// get the metadata for the item as a json stream
InputStream jsonStream = Request.Get(requestUrl).execute().returnContent().asStream();
BufferedReader streamReader = new BufferedReader(new InputStreamReader(jsonStream));
StringBuilder result = new StringBuilder();
String line;
// read each line of the stream
while ((line = streamReader.readLine()) != null) {
result.append(line);
}
streamReader.close();
JsonReader jsonReader = Json.createReader(new StringReader(result.toString()));
metadata = jsonReader.readObject();
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: verifyIssuerClaim
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected token issuer claim is as expected")
public void verifyIssuerClaim() throws Exception {
Reporter.log("Begin verifyIssuerClaim");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedIssuer";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.iss.name(), TCKConstants.TEST_ISSUER)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例7: verifyInjectedRawToken
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected raw token claim is as expected")
public void verifyInjectedRawToken() throws Exception {
Reporter.log("Begin verifyInjectedRawToken\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedRawToken";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.raw_token.name(), token)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例8: verifyInjectedAudience
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected aud claim is as expected")
public void verifyInjectedAudience() throws Exception {
Reporter.log("Begin verifyInjectedAudience\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedAudience";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.aud.name(), "s6BhdRkqt3")
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例9: verifyInjectedAuthTime
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected raw token claim is as expected")
public void verifyInjectedAuthTime() throws Exception {
Reporter.log("Begin verifyInjectedAuthTime\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedAuthTime";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例10: verifyInjectedIssuedAt
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected iat claim is as expected")
public void verifyInjectedIssuedAt() throws Exception {
Reporter.log("Begin verifyInjectedIssuedAt\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedIssuedAt";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.iat.name(), iatClaim)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例11: verifyInjectedCustomString
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected customString claim is as expected")
public void verifyInjectedCustomString() throws Exception {
Reporter.log("Begin verifyInjectedCustomString\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedCustomString";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam("value", "customStringValue")
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例12: verifyInjectedCustomInteger
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected customInteger claim is as expected")
public void verifyInjectedCustomInteger() throws Exception {
Reporter.log("Begin verifyInjectedCustomInteger\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedCustomInteger";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam("value", 123456789)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例13: verifyInjectedCustomDouble
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected customDouble claim is as expected")
public void verifyInjectedCustomDouble() throws Exception {
Reporter.log("Begin verifyInjectedCustomDouble\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedCustomDouble";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam("value", 3.141592653589793)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例14: verifyInjectedCustomStringArray
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected customStringArray claim is as expected")
public void verifyInjectedCustomStringArray() throws Exception {
Reporter.log("Begin verifyInjectedCustomStringArray\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedCustomStringArray";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam("value", "value0", "value1", "value2")
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
示例15: verifyInjectedCustomIntegerArray
import javax.json.JsonReader; //导入依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected customIntegerArray claim is as expected")
public void verifyInjectedCustomIntegerArray() throws Exception {
Reporter.log("Begin verifyInjectedCustomIntegerArray\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedCustomIntegerArray";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam("value", 0, 1, 2, 3)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}