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


Java Json.createReader方法代码示例

本文整理汇总了Java中javax.json.Json.createReader方法的典型用法代码示例。如果您正苦于以下问题:Java Json.createReader方法的具体用法?Java Json.createReader怎么用?Java Json.createReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.json.Json的用法示例。


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

示例1: verifyInjectedCustomInteger2

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected customInteger claim is as expected")
public void verifyInjectedCustomInteger2() 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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:ProviderInjectionTest.java

示例2: verifyOptionalAudience

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_JWT,
        description = "Verify that the aud claim is as expected")
public void verifyOptionalAudience() throws Exception {
    Reporter.log("Begin verifyOptionalAudience\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyOptionalAudience";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
            .target(uri)
            .queryParam(Claims.aud.name(), null)
            .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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:RequiredClaimsTest.java

示例3: verifyInjectedOptionalCustomMissing

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected custom claim is missing as expected")
public void verifyInjectedOptionalCustomMissing() throws Exception {
    Reporter.log("Begin verifyInjectedOptionalCustomMissing\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedOptionalCustomMissing";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        ;
    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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:18,代码来源:ProviderInjectionTest.java

示例4: verifyInjectedSUB

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected sub claim is as expected")
public void verifyInjectedSUB() throws Exception {
    Reporter.log("Begin verifyInjectedSUB\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedSUB";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.sub.name(), "24400320")
        .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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:PrimitiveInjectionTest.java

示例5: verifyIssuerStandardClaim

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI,
    description = "Verify that the injected token issuer claim using @Claim(standard) is as expected")
public void verifyIssuerStandardClaim() throws Exception {
    Reporter.log("Begin verifyIssuerClaim");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedIssuerStandard";
    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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:ClaimValueInjectionTest.java

示例6: verifyInjectedJTI

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI,
    description = "Verify that the injected jti claim is as expected")
public void verifyInjectedJTI() 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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:ClaimValueInjectionTest.java

示例7: verifyInjectedCustomStringArray

import javax.json.Json; //导入方法依赖的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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:JsonValueInjectionTest.java

示例8: verifyInjectedCustomInteger

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:ProviderInjectionTest.java

示例9: verifyInjectedJTI2

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
    description = "Verify that the injected jti claim is as expected from Token2")
public void verifyInjectedJTI2() throws Exception {
    Reporter.log("Begin verifyInjectedJTI2\n");
    String token2 = TokenUtils.generateTokenString("/Token2.json");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedJTI";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.jti.name(), "a-123.2")
        .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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:20,代码来源:JsonValueInjectionTest.java

示例10: verifyInjectedCustomString

import javax.json.Json; //导入方法依赖的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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:ProviderInjectionTest.java

示例11: act

import javax.json.Json; //导入方法依赖的package包/类
@Override
public Response act(Request req) throws IOException {
    try {
        long number = Long.parseLong(((RqRegex) req).matcher().group("number"));
        Product product = base.products().product(number);

        JsonReader reader = Json.createReader(req.body());
        JsonObject json = reader.readObject();
        String name = json.getString("name");
        String desc = json.getString("desc");
        FastMoney price = FastMoney.of(new BigDecimal(json.getString("price")), "CZK");

        Product result = product.update(name, desc, price);
        return new RsJson(result);
    } catch (IOException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:yaroska,项目名称:true_oop,代码行数:19,代码来源:TkProductUpdate.java

示例12: verifyIssuerClaim

import javax.json.Json; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:ProviderInjectionTest.java

示例13: verifyInjectedAudience2

import javax.json.Json; //导入方法依赖的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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:ProviderInjectionTest.java

示例14: verifyInjectedAuthTime

import javax.json.Json; //导入方法依赖的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"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:18,代码来源:JsonValueInjectionTest.java

示例15: postJson

import javax.json.Json; //导入方法依赖的package包/类
/**
 *
 * @param content
 * @return
 */
@POST
@Consumes(javax.ws.rs.core.MediaType.APPLICATION_JSON)
@Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON)
public String postJson(String content) {
    JsonObject announcement;
    try (JsonReader reader = Json.createReader(new StringReader(content))) {
        announcement = reader.readObject();
    }
    // Simple check for parts
        Logger.getLogger(Message.class.getName()).log(Level.INFO, announcement.toString());
    // ERRORS
    if (announcement.containsKey("@id")) {
        // There should not be one already; these are new annoucements.
        Response.status(HttpURLConnection.HTTP_BAD_REQUEST).entity("POST is for new annoucements only.").build();
        return "{\"error\":\"Property '@id' indicates this is not a new annoucement.\"}";
    }
    if (!announcement.containsKey("motivation")) {
        // This should always exist.
        Response.status(HttpURLConnection.HTTP_BAD_REQUEST).entity("Missing 'motivation' property.").build();
        return "{\"error\":\"Annoucements without 'motivation' are not allowed on this server.\"}";
    }

    //NORMALIZATIONS       
    if (!announcement.containsKey("@context")) {
        // Put in a default, please.
        announcement = new Message().generate(announcement, "@context", CONTEXT);
    }
    
    // add timestamp
    Date time = new Date();
        announcement = new Message().generate(announcement, "published", time.toString());

    try {
        announcement = postMessage(announcement);
    } catch (Exception ex) {
        Logger.getLogger(Message.class.getName()).log(Level.SEVERE, null, ex);
    }
    return announcement.toString();
}
 
开发者ID:CenterForDigitalHumanities,项目名称:inbox,代码行数:45,代码来源:MessagesResource.java


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