本文整理汇总了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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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 );
}
};
}
示例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();
}