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


Java ClientResponse.getEntity方法代码示例

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


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

示例1: getServiceProviderCatalog

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
public static ServiceProviderCatalog getServiceProviderCatalog() throws Exception {
    OslcClient client = new OslcClient();
    ClientResponse response = null;
    ServiceProviderCatalog catalog = null;

    // Start of user code getServiceProviderCatalog_init
    // End of user code

    response = client.getResource(serviceProviderCatalogURI,OSLCConstants.CT_RDF);
    if (response != null) {
        catalog = response.getEntity(ServiceProviderCatalog.class);
    }
    // Start of user code getServiceProviderCatalog_final
    // End of user code
    return catalog;
}
 
开发者ID:EricssonResearch,项目名称:scott-eu,代码行数:17,代码来源:GenericRequiredAdaptorClient.java

示例2: getMission

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
public static Mission getMission(String resourceURI) throws Exception {
    OslcClient client = new OslcClient();
    ClientResponse response = null;
    Mission resource = null;

    // Start of user code getMission_init
    // End of user code

    response = client.getResource(resourceURI, OSLCConstants.CT_RDF);
    if (response != null) {
        resource = response.getEntity(Mission.class);
    }
    // Start of user code getMission_final
    // End of user code
    return resource;
}
 
开发者ID:EricssonResearch,项目名称:scott-eu,代码行数:17,代码来源:GenericRequiredAdaptorClient.java

示例3: getPlan

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
public static Plan getPlan(String resourceURI) throws Exception {
    OslcClient client = new OslcClient();
    ClientResponse response = null;
    Plan resource = null;

    // Start of user code getPlan_init
    // End of user code

    response = client.getResource(resourceURI, OSLCConstants.CT_RDF);
    if (response != null) {
        resource = response.getEntity(Plan.class);
    }
    // Start of user code getPlan_final
    // End of user code
    return resource;
}
 
开发者ID:EricssonResearch,项目名称:scott-eu,代码行数:17,代码来源:GenericRequiredAdaptorClient.java

示例4: testCreateMessage

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test
@InSequence(1)
public void testCreateMessage(){
	
	final String testUrl = String.format("http://localhost:9080/%s/messages", contextRoot);
	
	RestClient client = new RestClient();
	Message message = new Message();
	message.setValue(testMessage);
	
	ClientResponse response = client.resource(testUrl)
								.accept(MediaType.APPLICATION_JSON)
								.contentType(MediaType.APPLICATION_JSON)
								.post(message);	
	
	assertEquals("The status code of the response is not the expected value.", Status.CREATED.getStatusCode(), response.getStatusCode());

	Message respMsg = response.getEntity(Message.class);
	
	assertNotNull("The message id was not set by the service.", respMsg.getId());
	
	messageId = respMsg.getId();
	
	assertNotNull("The message modified date was not set by the service.", respMsg.getLastUpdated());
	assertEquals("The value of the message does not match what was provided.",  message.getValue(), respMsg.getValue());
}
 
开发者ID:tglawless,项目名称:jee,代码行数:27,代码来源:MessageResourceTest.java

示例5: testFindMessageById

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test
@InSequence(2)
public void testFindMessageById(){
	
	final String testUrl = String.format("http://localhost:9080/%s/messages/%d", contextRoot, messageId);
	
	RestClient client = new RestClient();
	ClientResponse response = client.resource(testUrl)
								.accept(MediaType.APPLICATION_JSON)
								.get();	
	
	assertEquals("The status code of the response is not the expected value.", Status.OK.getStatusCode(), response.getStatusCode());

	Message respMsg = response.getEntity(Message.class);
	assertNotNull("The message id was not set by the service.", respMsg.getId());
	assertNotNull("The message modified date was not set by the service.", respMsg.getLastUpdated());
	assertEquals("The value of the message does not match what was provided.",  testMessage, respMsg.getValue());
}
 
开发者ID:tglawless,项目名称:jee,代码行数:19,代码来源:MessageResourceTest.java

示例6: testUpdateMessage

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test
@InSequence(3)
public void testUpdateMessage(){
	
	final String testUrl = String.format("http://localhost:9080/%s/messages/%d", contextRoot, messageId);
	
	RestClient client = new RestClient();
	Message message = new Message();
	message.setValue(testMessage + " - updated: " + new Date());
	
	ClientResponse response = client.resource(testUrl)
								.accept(MediaType.APPLICATION_JSON)
								.contentType(MediaType.APPLICATION_JSON)
								.put(message);	
	
	assertEquals("The status code of the response is not the expected value.", Status.OK.getStatusCode(), response.getStatusCode());

	Message respMsg = response.getEntity(Message.class);
	assertNotNull("The message id was not set by the service.", respMsg.getId());
	assertNotNull("The message modified date was not set by the service.", respMsg.getLastUpdated());
	assertEquals("The value of the message does not match what was provided.",  message.getValue(), respMsg.getValue());
}
 
开发者ID:tglawless,项目名称:jee,代码行数:23,代码来源:MessageResourceTest.java

示例7: testFindAllMessages

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test
@InSequence(4)
public void testFindAllMessages(){
	
	final String testUrl = String.format("http://localhost:9080/%s/messages", contextRoot);
	
	RestClient client = new RestClient();
	ClientResponse response = client.resource(testUrl)
							.accept(MediaType.APPLICATION_JSON)
							.get();
	
	Message[] messages = response.getEntity(Message[].class);
	
	assertNotNull("The list of messages returned by the service was null.", messages);
	assertTrue("Test expected at least 1 message to be contained within the list.", messages.length > 0);
}
 
开发者ID:tglawless,项目名称:jee,代码行数:17,代码来源:MessageResourceTest.java

示例8: addReplyToNoteNote

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test(groups = {"wso2.greg", "wso2.greg.es"}, dependsOnMethods = "addNoteToAsset", description = "Add Reply to note added for a Asset test")
public void addReplyToNoteNote() throws JSONException, IOException {
    queryParamMap.put("type", "note");
    //  https://localhost:9443/publisher/apis/assets?type=note
    String dataBody = String.format(readFile(resourcePath + "publisherNoteReplyRestResource.json")
            , noteOverviewHash,"replyNote123",noteOverviewHash);
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/assets",
                                                     MediaType.APPLICATION_JSON,
                                                     MediaType.APPLICATION_JSON, dataBody
                    , queryParamMap, headerMap, cookieHeaderPublisher);
    Assert.assertTrue((response.getStatusCode() == 201),
                      "Wrong status code ,Expected 200 OK ,Received " +
                      response.getStatusCode());

    JSONObject responseObj = new JSONObject(response.getEntity(String.class));
    Assert.assertTrue(responseObj.getJSONObject("attributes").get("overview_note").toString().contains("replyNote123"), "Does not create a note");
    Assert.assertTrue(responseObj.getJSONObject("attributes").get("overview_resourcepath").toString().contains(noteOverviewHash),"Fault resource path for note");
    replyOverviewHash= responseObj.getJSONObject("attributes").get("overview_hash").toString();
    Assert.assertNotNull(replyOverviewHash);
    replyAssetId =responseObj.get("id").toString();
}
 
开发者ID:wso2,项目名称:product-es,代码行数:23,代码来源:AssertNotesESTestCase.java

示例9: checkOptionFieldValues

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "Check Option Field Values in Publisher")
public void checkOptionFieldValues() throws IOException, JSONException {
    ClientResponse response = getAssetCreatePage("evlc");
    assertTrue((response.getStatusCode() == 200),
            "Wrong status code ,Expected 200 OK ,Received " +
                    response.getStatusCode()
    );
    String createPage = response.getEntity(String.class);
    String [] formGroup = createPage.split("<div class=\"form-group\">");
    for (String form: formGroup) {
        if (form.contains("rules_gender")) {
            assertTrue(form.contains("male"));
            assertTrue(form.contains("female"));
            break;
        }
    }
}
 
开发者ID:wso2,项目名称:product-es,代码行数:18,代码来源:GenericCRUDTestCase.java

示例10: createSpaceRestServices

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "Create Space Rest Service",
        dependsOnMethods = {"createTestRestServices"})
public void createSpaceRestServices() throws JSONException, IOException {
    queryParamMap.put("type", "restservice");
    String dataBody = readFile(resourcePath + "json" + File.separator + "publisherPublishRestSpaceResource.json");
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/assets",
                    MediaType.APPLICATION_JSON,
                    MediaType.APPLICATION_JSON, dataBody
                    , queryParamMap, headerMap, cookieHeader);
    JSONObject obj = new JSONObject(response.getEntity(String.class));
    assertTrue((response.getStatusCode() == Response.Status.CREATED.getStatusCode()),
            "Wrong status code ,Expected 201 Created ,Received " +
                    response.getStatusCode()
    );
    spaceAssetId = obj.get("id").toString();
    assertNotNull(spaceAssetId, "Empty asset resource id available" +
            response.getEntity(String.class));
}
 
开发者ID:wso2,项目名称:product-es,代码行数:20,代码来源:GregRestResourceAssociationTestCase.java

示例11: deleteAllAssociationsById

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
/**
 * Delete all associations by ID
 *
 * @param publisherUrl      publisher url
 * @param genericRestClient generic rest client object
 * @param cookieHeader      session cookies header
 * @param id                asset ID
 * @param queryParamMap     query ParamMap
 * @return response
 * @throws JSONException
 */
public boolean deleteAllAssociationsById(String publisherUrl,
                                         GenericRestClient genericRestClient,
                                         String cookieHeader, String id,
                                         Map<String, String> queryParamMap)
        throws JSONException {
    boolean result = false;
    if (id != null) {
        ClientResponse clientResponse = this.getAssociationsById(publisherUrl, genericRestClient, cookieHeader, id, queryParamMap);
        JSONObject jsonObject = new JSONObject(clientResponse.getEntity(String.class));
        JSONArray assocArray = jsonObject.getJSONArray("results");
        for (int i = 0; i < assocArray.length(); i++) {
            String assocId = (String) assocArray.getJSONObject(i).get("uuid");
            String assocShortName = (String) assocArray.getJSONObject(i).get("shortName");
            Map<String, String> assocQueryMap = new HashMap<>();
            assocQueryMap.put("type", assocShortName);
            this.deleteAssetById(publisherUrl, genericRestClient, cookieHeader, assocId, assocQueryMap);
            this.deleteAllAssociationsById(publisherUrl, genericRestClient, cookieHeader, assocId, assocQueryMap);
        }
        result = true;
    }
    return result;
}
 
开发者ID:wso2,项目名称:product-es,代码行数:34,代码来源:ESTestBaseTest.java

示例12: createTestRestServices

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "Create Test Rest Service",
        dependsOnMethods = {"authenticatePublisher"})
public void createTestRestServices() throws JSONException, IOException {
    queryParamMap.put("type", "restservice");
    String dataBody = readFile(resourcePath + "json" + File.separator + "publisherPublishRestResource.json");
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/assets",
                    MediaType.APPLICATION_JSON,
                    MediaType.APPLICATION_JSON, dataBody
                    , queryParamMap, headerMap, cookieHeader);
    JSONObject obj = new JSONObject(response.getEntity(String.class));
    assertTrue((response.getStatusCode() == Response.Status.CREATED.getStatusCode()),
            "Wrong status code ,Expected 201 Created ,Received " +
                    response.getStatusCode()
    );
    testAssetId = obj.get("id").toString();
    assertNotNull(testAssetId, "Empty asset resource id available" +
            response.getEntity(String.class));
}
 
开发者ID:wso2,项目名称:product-es,代码行数:20,代码来源:GregRestResourceAssociationTestCase.java

示例13: createRestServiceAssetWithLC

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "Authenticate Publisher test",
        dependsOnMethods = {"addLifecycleForRestServiceResources", "authenticatePublisher"})
public void createRestServiceAssetWithLC()
        throws JSONException, InterruptedException,
               IOException, ResourceAdminServiceResourceServiceExceptionException {
    queryParamMap.put("type", "restservice");
    String dataBody = readFile(resourcePath + "json" + File.separator
                               + "publisherPublishRestResource.json");
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/assets",
                                                     MediaType.APPLICATION_JSON,
                                                     MediaType.APPLICATION_JSON, dataBody
                    , queryParamMap, headerMap, cookieHeader);
    JSONObject obj = new JSONObject(response.getEntity(String.class));
    Assert.assertTrue((response.getStatusCode() == 201),
                      "Wrong status code ,Expected 201 Created ,Received " +
                      response.getStatusCode());
    assetId = obj.get("id").toString();
    Assert.assertNotNull(assetId, "Empty asset resource id available" +
                                  response.getEntity(String.class));
    Assert.assertTrue(this.getAsset(assetId, "restservice").get("lifecycle")
                              .equals(lifeCycleName), "LifeCycle not assigned to given assert");

    resourceAdminServiceClient.addResourcePermission(restServiceResourcePath, "manager", "3", "1");
}
 
开发者ID:wso2,项目名称:product-es,代码行数:26,代码来源:RestResourceLifeCycleManagementTestCase.java

示例14: createSoapServiceAsset

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "Create Soap Service in Publisher")
public void createSoapServiceAsset() throws JSONException, IOException {

    String soapTemplate = readFile(resourcePath + "json" + File.separator + "soapservice-sample.json");
    assetName = "soapserviceLC";
    String dataBody = String.format(soapTemplate, assetName, "soapserviceLC", "1.0.0",null);
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/assets",
                                                     MediaType.APPLICATION_JSON,
                                                     MediaType.APPLICATION_JSON, dataBody
                    , queryParamMap, headerMap, cookieHeader);
    JSONObject obj = new JSONObject(response.getEntity(String.class));
    Assert.assertTrue((response.getStatusCode() == 201),
                      "Wrong status code ,Expected 201 Created ,Received " +
                      response.getStatusCode());
    assetId = (String)obj.get("id");
    Assert.assertNotNull(assetId, "Empty asset resource id available" +
                                  response.getEntity(String.class));
}
 
开发者ID:wso2,项目名称:product-es,代码行数:20,代码来源:SoapServiceLCPromotionTestCase.java

示例15: updateRestServiceAsset

import org.apache.wink.client.ClientResponse; //导入方法依赖的package包/类
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "Authenticate Publisher test",
        dependsOnMethods = {"authenticatePublisher", "createRestServiceAsset"})
public void updateRestServiceAsset() throws JSONException, IOException {
    queryParamMap.put("type", "restservice");
    String dataBody = readFile(resourcePath + "json" + File.separator + "PublisherRestResourceUpdate.json");
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/assets/" + assetId,
                                                     MediaType.APPLICATION_JSON,
                                                     MediaType.APPLICATION_JSON, dataBody
                    , queryParamMap, headerMap, cookieHeader);
    JSONObject obj = new JSONObject(response.getEntity(String.class));
    Assert.assertTrue((response.getStatusCode() == 202),
                      "Wrong status code ,Expected 202 Created ,Received " +
                      response.getStatusCode());
    Assert.assertTrue(obj.getJSONObject("attributes").get("overview_context")
                              .equals("/changed/Context"));
}
 
开发者ID:wso2,项目名称:product-es,代码行数:18,代码来源:RestResourcePublisherESTestCase.java


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