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


Java HttpMethod.GET属性代码示例

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


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

示例1: collectIssues

/**
 * Get a Jira query result in a map form.
 *
 * @param query is the jira query
 * @return with the map of JIRA_ID - ticketInfo in JSONObject pairs as result of a Jira query.
 * @throws IOException   in case of problem
 * @throws JSONException in case of problem
 */
public ConcurrentHashMap<String, JSONObject> collectIssues(final String query) throws IOException, JSONException {
    String jqlURL = getListOfIssuesByQueryUrl(query);
    WebRequest requestSettings = new WebRequest(new URL(jqlURL), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-type", "application/json");
    UnexpectedPage infoPage = webClient.getPage(requestSettings);
    if (infoPage.getWebResponse().getStatusCode() == HTTP_RESPONSE_OK) {
        String ticketList = infoPage.getWebResponse().getContentAsString();
        JSONObject obj = new JSONObject(ticketList);
        String maxResults = obj.getString("maxResults");
        String total = obj.getString("total");
        if (Integer.valueOf(maxResults) < Integer.valueOf(total)) {
            throw new SimpleGepardException("ERROR: Too many issues belong to given query (" + total + "), please change the query to shorten the result list.");
        }
        JSONArray array = obj.getJSONArray("issues");
        ConcurrentHashMap<String, JSONObject> map = new ConcurrentHashMap<>();
        for (int i = 0; i < array.length(); i++) {
            JSONObject o = (JSONObject) array.get(i);
            map.put(o.getString("key"), o);
        }
        return map;
    }
    throw new SimpleGepardException("ERROR: Cannot fetch Issue list from JIRA, status code:" + infoPage.getWebResponse().getStatusCode());
}
 
开发者ID:epam,项目名称:Gepard,代码行数:31,代码来源:JiraSiteHandler.java

示例2: getIoCTest

@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 6)
@OperateOnDeployment("ear")
@RunAsClient
public void getIoCTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/blacklist/record/seznam.cz"), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("getIoCTest Response:" + responseBody);
    String expected = "\"black_listed_domain_or_i_p\":\"aed14ad7ed6c543f818a4cfe89cb8f20\""; // md5 of seznam.cz
    assertTrue(responseBody.contains(expected), "IoC response should have contained " + expected + ", but got:" + responseBody);
    expected = "\"sources\":{\"feed2\":{\"a\":\"blacklist\",\"b\":\"myDocumentId\"}}";
    assertTrue(responseBody.contains(expected), "IoC should have contained " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:17,代码来源:ApiIntegrationTest.java

示例3: iocInCacheTest

@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 11)
@OperateOnDeployment("ear")
@RunAsClient
public void iocInCacheTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/blacklist/record/phishing.ru"), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("iocInCacheTest Response:" + responseBody);
    String expected = "\"black_listed_domain_or_i_p\":\"926dab5157943daed27851a34f30b701\"";  // md5 of phishing.ru
    assertTrue(responseBody.contains(expected), "IoC response should have contained " + expected + ", but got:" + responseBody);
    expected = "\"sources\":{\"integrationTest\":{\"a\":\"phishing\",\"b\":\"";
    assertTrue(responseBody.contains(expected), "IoC should have contained " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:17,代码来源:ApiIntegrationTest.java

示例4: testAuthenticatedRequest

@Test
public void testAuthenticatedRequest() throws IOException, SAXException {
	logger.info("start authenticated request");
	WebRequest request = new WebRequest(new URL(base + "LoginServlet?user=u1&password=p1"), HttpMethod.GET);
	WebResponse response = webClient.getWebConnection().getResponse(request);
	String responseText = response.getContentAsString();
	logger.info(responseText);

	assertTrue("Is user in Role", responseText.contains("isUserInRole?true"));
	assertTrue("Get Remote User", responseText.contains("getRemoteUser?u1"));
	assertTrue("Get User Principal", responseText.contains("getUserPrincipal?u1"));
	assertTrue("Get Auth Type", responseText.contains("getAuthType?BASIC"));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:13,代码来源:SecureServletTestCase.java

示例5: detectWorkflow

/**
 * Detect the actual workflow possibilities of the ticket, from its actual status.
 *
 * @param ticket is the id
 * @return with String representation of the list of possibilities, in form of statusTransferId;newStatusName strings
 * @throws IOException   in case of problem
 * @throws JSONException in case of problem
 */
public String detectWorkflow(final String ticket) throws IOException, JSONException {
    String jqlURL;

    //first detect status
    String ticketFields = getTicketFields(ticket);
    JSONObject fieldObj = new JSONObject(ticketFields);
    fieldObj = fieldObj.getJSONObject("fields");
    fieldObj = fieldObj.getJSONObject("status");
    String status = "@" + fieldObj.get("name").toString();

    //then collect possible transactions
    jqlURL = getIssueTransitionsUrl(ticket);
    WebRequest requestSettings = new WebRequest(new URL(jqlURL), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-type", "application/json");
    UnexpectedPage infoPage = webClient.getPage(requestSettings);
    if (infoPage.getWebResponse().getStatusCode() == HTTP_RESPONSE_OK) {
        String ticketList = infoPage.getWebResponse().getContentAsString();
        JSONObject obj = new JSONObject(ticketList);
        JSONArray array = obj.getJSONArray("transitions");
        List<String> toList = new ArrayList<>();
        toList.add(status);
        for (int i = 0; i < array.length(); i++) {
            JSONObject o = (JSONObject) array.get(i);
            JSONObject o2 = o.getJSONObject("to");
            String toPossibility = o2.get("name").toString();
            String toPossibilityID = o.get("id").toString(); //it is the transition id not the status id
            toList.add(toPossibilityID + ";" + toPossibility);
        }
        return toList.toString();
    }
    throw new SimpleGepardException("ERROR: Cannot fetch Issue transition possibilities from JIRA, for ticket: "
            + ticket + ", Status code:" + infoPage.getWebResponse().getStatusCode());
}
 
开发者ID:epam,项目名称:Gepard,代码行数:41,代码来源:JiraSiteHandler.java

示例6: getStatsTest

@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 4)
@OperateOnDeployment("ear")
@RunAsClient
public void getStatsTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/stats"), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("getStatsTest Response:" + responseBody);
    String expected = "{\"rule\":4,\"ioc\":1}";
    assertTrue(responseBody.contains(expected), "Expected: " + expected + ". got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:15,代码来源:ApiIntegrationTest.java

示例7: getIoCsTest

@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 5)
@OperateOnDeployment("ear")
@RunAsClient
public void getIoCsTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/blacklist/records"), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("getIoCsTest Response:" + responseBody);
    String expected = "[\"aed14ad7ed6c543f818a4cfe89cb8f20\"]"; // md5 of seznam.cz
    assertTrue(responseBody.contains(expected), "Expected " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:15,代码来源:ApiIntegrationTest.java

示例8: getSinkHoleTest

@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 7)
@OperateOnDeployment("ear")
@RunAsClient
public void getSinkHoleTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/blacklist/dns/10.11.12.22/seznam.cz/seznam.cz"), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("getSinkHoleTest Response:" + responseBody);
    String expected = "{\"sinkhole\":\"" + System.getenv("SINKIT_SINKHOLE_IP") + "\"}";
    assertTrue(responseBody.contains(expected), "Should have contained " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:15,代码来源:ApiIntegrationTest.java

示例9: getStatsTest

@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 202)
@OperateOnDeployment("ear")
@RunAsClient
public void getStatsTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/gsb/stats"), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("getStatsTest Response:" + responseBody);
    String expected = "{\"gsbRecords\":1}";
    assertTrue(responseBody.contains(expected), "Should have contained " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:15,代码来源:GSBTest.java

示例10: get

/**
 * This method is similar to {@link #process()}. It overrides the setting for the HTTP method with GET and performs
 * the call.
 *
 * @return The updated RESTCall instance.
 *
 * @throws Throwable
 *         Thrown if an error occurs during processing of the REST call.
 */
public RESTCall get() throws Throwable
{
    this.httpMethod = HttpMethod.GET;
    return process();
}
 
开发者ID:Xceptance,项目名称:XRT-Xceptance-REST-Test,代码行数:14,代码来源:RESTCall.java


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