本文整理汇总了Java中javax.json.JsonReader.readObject方法的典型用法代码示例。如果您正苦于以下问题:Java JsonReader.readObject方法的具体用法?Java JsonReader.readObject怎么用?Java JsonReader.readObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.json.JsonReader
的用法示例。
在下文中一共展示了JsonReader.readObject方法的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: 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());
}
}
示例3: verifyInjectedIssuedAt
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI,
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"));
}
示例4: verifyExpiration
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_JWT,
description = "Verify that the exp claim is as expected")
public void verifyExpiration() throws Exception {
Reporter.log("Begin verifyExpiration\n");
String uri = baseURL.toExternalForm() + "/endp/verifyExpiration";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.exp.name(), expClaim)
.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"));
}
示例5: verifyInjectedAuthTime2
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected auth_time is as expected from Token2")
public void verifyInjectedAuthTime2() throws Exception {
Reporter.log("Begin verifyInjectedAuthTime2\n");
HashMap<String, Long> timeClaims = new HashMap<>();
String token2 = TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
Long authTimeClaim = timeClaims.get(Claims.auth_time.name());
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 " + token2).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"));
}
示例6: verifyInjectedRawToken2
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected raw token claim is as expected from Token2")
public void verifyInjectedRawToken2() throws Exception {
Reporter.log("Begin verifyInjectedRawToken2\n");
String token2 = TokenUtils.generateTokenString("/Token2.json");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedRawToken";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.raw_token.name(), token2)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token2).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: verifyInjectedOptionalAuthTime
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
description = "Verify that the injected raw token claim is as expected")
public void verifyInjectedOptionalAuthTime() throws Exception {
Reporter.log("Begin verifyInjectedOptionalAuthTime\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedOptionalAuthTime";
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"));
}
示例8: 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"));
}
示例9: verifyInjectedAudience2
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
description = "Verify that the injected aud claim is as expected")
public void verifyInjectedAudience2() 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"));
}
示例10: verifyInjectedIssuedAt2
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
description = "Verify that the injected iat claim is as expected from Token2")
public void verifyInjectedIssuedAt2() throws Exception {
Reporter.log("Begin verifyInjectedIssuedAt2\n");
HashMap<String, Long> timeClaims = new HashMap<>();
String token2 = TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
Long iatClaim = timeClaims.get(Claims.auth_time.name());
Long authTimeClaim = timeClaims.get(Claims.auth_time.name());
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 " + token2).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: verifyInjectedGroups
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
description = "Verify that the injected groups claim is as expected")
public void verifyInjectedGroups() throws Exception {
Reporter.log("Begin verifyInjectedGroups\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedGroups";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.groups.name(), new String[]{
"Echoer", "Tester", "group1", "group2"})
.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: verifyInjectedCustomString
import javax.json.JsonReader; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
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"));
}
示例13: processData
import javax.json.JsonReader; //导入方法依赖的package包/类
@Override
public void processData(List<String> jsonData) {
for (Iterator<String> iterator = jsonData.iterator(); iterator.hasNext();) {
String jsonStr = iterator.next();
JsonReader jsonReader = Json.createReader(new StringReader(jsonStr));
try {
JsonObject jsonObject = jsonReader.readObject();
String topicName = jsonObject.getString("topic", null);
if (topicName != null) {
if (topicName.equals("http")) {
JsonObject payload = jsonObject.getJsonObject("payload");
long requestTime = payload.getJsonNumber("time").longValue();
long requestDuration = payload.getJsonNumber("duration").longValue();
String requestUrl = payload.getString("url", "");
synchronized (aggregateHttpData) {
aggregateHttpData.aggregate(requestTime, requestDuration, requestUrl);
}
} else {
emit(jsonObject.toString());
}
}
} catch (JsonException je) {
// Skip this object, log the exception and keep trying with
// the rest of the list
je.printStackTrace();
}
}
emitHttp();
}
示例14: parseSuccessfulAnalysisResults
import javax.json.JsonReader; //导入方法依赖的package包/类
private DeltaAnalysisResult parseSuccessfulAnalysisResults(HttpResponse rawResponse, Commits commits) throws IOException {
final HttpEntity responseBody = rawResponse.getEntity();
if (responseBody == null) {
throw new RuntimeException("Internal error: The delta analysis was a success but failed to parse the returned results");
}
final JsonReader reader = Json.createReader(responseBody.getContent());
final JsonObject delta = reader.readObject();
return new DeltaAnalysisResult(commits, delta);
}
示例15: read
import javax.json.JsonReader; //导入方法依赖的package包/类
public void read(String data) {
JsonReader reader = Json.createReader(new StringReader(data));
JsonObject nets = reader.readObject();
networks = new HashMap<String, NetworkModel>();
Iterator<?> iter = nets.keySet().iterator();
while (iter.hasNext()) {
String key = (String) iter.next();
NetworkModel net = new NetworkModel(key);
NetworkData netData = new NetworkData(key);
netData.read(nets.getJsonObject(key));
net.setData(netData);
networks.put(key, net);
}
}