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


Java HttpMethod.PUT属性代码示例

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


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

示例1: setTicketFieldValue

private void setTicketFieldValue(final GepardTestClass tc, final String ticket, final String fieldName, final String value) throws IOException {
    String jiraSetFieldPage = getIssueFieldSetValueUrl(ticket);
    WebRequest requestSettings = new WebRequest(new URL(jiraSetFieldPage), HttpMethod.PUT);
    requestSettings.setAdditionalHeader("Content-type", "application/json");
    requestSettings.setRequestBody("{ \"fields\": {\"" + fieldName + "\": \"" + value + "\"} }");
    try {
        UnexpectedPage infoPage = webClient.getPage(requestSettings);
        if (infoPage.getWebResponse().getStatusCode() == HTTP_RESPONSE_OK) {
            tc.logComment("Field: '" + fieldName + "' of Ticket: " + ticket + " was updated to value: '" + value + "' successfully.");
        } else {
            throw new SimpleGepardException("Ticket: " + ticket + " field: " + fieldName + " update failed, status code: " + infoPage.getWebResponse().getStatusCode());
        }
    } catch (FailingHttpStatusCodeException e) {
        throw new SimpleGepardException("Ticket: " + ticket + " field: " + fieldName + " update failed.", e);
    }
}
 
开发者ID:epam,项目名称:Gepard,代码行数:16,代码来源:JiraSiteHandler.java

示例2: putCustomListsTest

@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 2)
@OperateOnDeployment("ear")
@RunAsClient
public void putCustomListsTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/lists/2"), HttpMethod.PUT);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    requestSettings.setRequestBody(
            "[{\"dns_client\":\"10.10.10.10/32\"," +
                    "\"lists\":{\"seznam.cz\":\"W\"," +
                    "\"google.com\":\"B\"," +
                    "\"example.com\":\"L\"}" +
                    "}," +
                    "{\"dns_client\":\"fe80::3ea9:f4ff:fe81:c450/64\"," +
                    "\"lists\":{\"seznam.cz\":\"L\"," +
                    "\"google.com\":\"W\"," +
                    "\"example.com\":\"W\"}" +
                    "}]");
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("putCustomListsTest Response:" + responseBody);
    String expected = "6 CUSTOM LISTS ELEMENTS PROCESSED, 6 PRESENT";
    assertTrue(responseBody.contains(expected), "Expected: " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:26,代码来源:ApiIntegrationTest.java

示例3: PutMethodWebRequest

public PutMethodWebRequest( String url, InputStream inputStream, String contentType )
    throws Exception
{
    super( new URL( url ), HttpMethod.PUT );
    this.url = url;
    this.inputStream = inputStream;
    this.contentType = contentType;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:8,代码来源:AbstractRepositoryServletTestCase.java

示例4: putHashPrefixTest

@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 201)
@OperateOnDeployment("ear")
@RunAsClient
public void putHashPrefixTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/gsb/aabbccdd"), HttpMethod.PUT);
    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("hashPrefixTest Response:" + responseBody);
    String expected = "true";
    assertTrue(responseBody.contains(expected), "Should have contained " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:15,代码来源:GSBTest.java

示例5: getWebResponse

protected WebResponse getWebResponse( WebRequest webRequest ) //, boolean followRedirect )
    throws Exception
{

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI( webRequest.getUrl().getPath() );
    request.addHeader( "User-Agent", "Apache Archiva unit test" );

    request.setMethod( webRequest.getHttpMethod().name() );

    if ( webRequest.getHttpMethod() == HttpMethod.PUT )
    {
        PutMethodWebRequest putRequest = PutMethodWebRequest.class.cast( webRequest );
        request.setContentType( putRequest.contentType );
        request.setContent( IOUtils.toByteArray( putRequest.inputStream ) );
    }

    if ( webRequest instanceof MkColMethodWebRequest )
    {
        request.setMethod( "MKCOL" );
    }

    final MockHttpServletResponse response = execute( request );

    if ( response.getStatus() == HttpServletResponse.SC_MOVED_PERMANENTLY
        || response.getStatus() == HttpServletResponse.SC_MOVED_TEMPORARILY )
    {
        String location = response.getHeader( "Location" );
        log.debug( "follow redirect to {}", location );
        return getWebResponse( new GetMethodWebRequest( location ) );
    }

    return new WebResponse( null, null, 1 )
    {
        @Override
        public String getContentAsString()
        {
            try
            {
                return response.getContentAsString();
            }
            catch ( UnsupportedEncodingException e )
            {
                throw new RuntimeException( e.getMessage(), e );
            }
        }

        @Override
        public int getStatusCode()
        {
            return response.getStatus();
        }

        @Override
        public String getResponseHeaderValue( String headerName )
        {
            return response.getHeader( headerName );
        }
    };
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:60,代码来源:AbstractRepositoryServletTestCase.java

示例6: put

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


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