本文整理了Java中org.jclouds.io.Payload.getRawContent()
方法的一些代码示例,展示了Payload.getRawContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Payload.getRawContent()
方法的具体详情如下:
包路径:org.jclouds.io.Payload
类名称:Payload
方法名:getRawContent
[英]Payload in its original form.
[中]原始形式的有效载荷。
代码示例来源:origin: jclouds/legacy-jclouds
public HttpRequest filter(HttpRequest request) {
checkNotNull(request.getPayload(), "request is not ready to wrap; payload not present");
Credentials current = creds.get();
String body = request.getPayload().getRawContent().toString();
Payload wrappedPayload = Payloads.newStringPayload(new StringBuilder()
.append(format(SOAP_PREFIX, current.identity, current.credential)).append(body).append(SOAP_SUFFIX)
.toString());
wrappedPayload.getContentMetadata().setContentType("application/xml");
return request.toBuilder().payload(wrappedPayload).build();
}
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
void testBuildCanonicalizedStringSetsVersion() {
HttpRequest filtered = staticCredentialsFilter.filter(request);
assertEquals(filtered.getPayload().getRawContent(),
"Action=DescribeImages&ImageId.1=ami-2bb65342&Signature=ugnt4m2eHE7Ka/vXTr9EhKZq7bhxOfvW0y4pAEqF97w%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=apiVersion&AWSAccessKeyId=identity");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testDefault() throws Exception {
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml"));
GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
Builder<String, Object> map = ImmutableMap.builder();
map.put("name", "my-vapp");
map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/4181");
assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testAlarmNamesBinder() throws Exception {
HttpRequest request = binder.bindToRequest(request(), ImmutableSet.of("TestAlarmName1", "TestAlarmName2"));
Assert.assertEquals(request.getPayload().getRawContent(),
"AlarmNames.member.1=TestAlarmName1&AlarmNames.member.2=TestAlarmName2");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testDefault() throws IOException {
String expected = toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate-default.xml"));
GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
BindCloneVAppTemplateParamsToXmlPayload binder = injector
.getInstance(BindCloneVAppTemplateParamsToXmlPayload.class);
Builder<String, Object> map = ImmutableMap.builder();
map.put("name", "my-vapptemplate");
map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181");
assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
}
}
代码示例来源:origin: org.apache.jclouds.provider/ultradns-ws
public HttpRequest filter(HttpRequest request) {
checkNotNull(request.getPayload(), "request is not ready to wrap; payload not present");
Credentials current = creds.get();
String body = request.getPayload().getRawContent().toString();
Payload wrappedPayload = Payloads.newStringPayload(new StringBuilder()
.append(format(SOAP_PREFIX, current.identity, current.credential)).append(body).append(SOAP_SUFFIX)
.toString());
wrappedPayload.getContentMetadata().setContentType("application/xml");
return request.toBuilder().payload(wrappedPayload).build();
}
}
代码示例来源:origin: apache/jclouds
public void testAlarmNamesBinder() throws Exception {
HttpRequest request = binder.bindToRequest(request(), ImmutableSet.of("TestAlarmName1", "TestAlarmName2"));
Assert.assertEquals(request.getPayload().getRawContent(),
"AlarmNames.member.1=TestAlarmName1&AlarmNames.member.2=TestAlarmName2");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testSaveStateTrue() throws IOException {
String expected = "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" saveState=\"true\"/>";
GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
BindUndeployVAppParamsToXmlPayload binder = injector.getInstance(BindUndeployVAppParamsToXmlPayload.class);
Map<String, Object> map = Maps.newHashMap();
map.put("saveState", "true");
assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
}
代码示例来源:origin: io.cloudsoft.jclouds.provider/ultradns-ws
public HttpRequest filter(HttpRequest request) {
checkNotNull(request.getPayload(), "request is not ready to wrap; payload not present");
Credentials current = creds.get();
String body = request.getPayload().getRawContent().toString();
Payload wrappedPayload = Payloads.newStringPayload(new StringBuilder()
.append(format(SOAP_PREFIX, current.identity, current.credential)).append(body).append(SOAP_SUFFIX)
.toString());
wrappedPayload.getContentMetadata().setContentType("application/xml");
return request.toBuilder().payload(wrappedPayload).build();
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testApplyInputStream() throws IOException {
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/CreateNodeService-test.xml"));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build();
BindAddNodeServiceToXmlPayload binder = injector.getInstance(BindAddNodeServiceToXmlPayload.class);
Map<String, Object> map = Maps.newHashMap();
map.put("name", "Node for Jim");
map.put("ipAddress", "172.16.20.3");
map.put("port", "80");
map.put("enabled", "false");
map.put("description", "Some test node");
assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testPowerOnTrue() throws IOException {
String expected = "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" powerOn=\"true\"/>";
GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
BindDeployVAppParamsToXmlPayload binder = injector.getInstance(BindDeployVAppParamsToXmlPayload.class);
Map<String, Object> map = Maps.newHashMap();
map.put("powerOn", "true");
assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
}
代码示例来源:origin: apache/jclouds
private HttpRequest createSoapRequest(HttpRequest request) {
Payload oldPayload = request.getPayload();
ContentMetadata oldMetadata = oldPayload.getContentMetadata();
String body = SOAP_PREFIX.concat(oldPayload.getRawContent().toString()).concat(SOAP_SUFFIX);
Payload newPayload = Payloads.newStringPayload(body);
HttpUtils.copy(oldMetadata, newPayload.getContentMetadata());
newPayload.getContentMetadata().setContentLength(Long.valueOf(body.getBytes().length)); // resize, add prefix/suffix length
return request.toBuilder().payload(newPayload).build();
}
代码示例来源:origin: jclouds/legacy-jclouds
public void test() {
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
request = binder.bindToRequest(request, ImmutableList.builder().add("alpha").add("omega").build());
assertEquals(request.getPayload().getRawContent(), "ResourceId.1=alpha&ResourceId.2=omega");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testDefault() throws Exception {
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml"));
GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
Map<String, Object> map = Maps.newHashMap();
map.put("newName", "my-vapp");
map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/4181");
assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public HttpRequest filter(HttpRequest request) throws HttpException {
checkNotNull(request.getFirstHeaderOrNull(HttpHeaders.HOST), "request is not ready to sign; host not present");
Multimap<String, String> decodedParams = queryParser().apply(request.getPayload().getRawContent().toString());
decodedParams.replaceValues(VERSION, ImmutableSet.of(apiVersion));
addSigningParams(decodedParams);
validateParams(decodedParams);
String stringToSign = createStringToSign(request, decodedParams);
String signature = sign(stringToSign);
addSignature(decodedParams, signature);
request = setPayload(request, decodedParams);
utils.logRequest(signatureLog, request, "<<");
return request;
}
代码示例来源:origin: apache/jclouds
public void test() {
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
request = binder.bindToRequest(request, ImmutableMap.<String, String>builder().put("one", "alpha").put("two", "beta").build());
assertEquals(request.getPayload().getRawContent(), "Tag.1.Key=one&Tag.1.Value=alpha&Tag.2.Key=two&Tag.2.Value=beta");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testDefault() throws IOException {
String expected = "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>";
GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
BindUndeployVAppParamsToXmlPayload binder = injector.getInstance(BindUndeployVAppParamsToXmlPayload.class);
Map<String, Object> map = Maps.newHashMap();
assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AMIAsyncClient.class, "getLaunchPermissionForImageInRegion", String.class, String.class);
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, getLaunchPermissionForImage.getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, PermissionHandler.class);
assertFallbackClassEquals(method, null);
checkFilters(request);
}
代码示例来源:origin: jclouds/legacy-jclouds
public void test() {
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
request = binder.bindToRequest(request, ImmutableMultimap.<String, String> builder()
.put("resource-type", "instance")
.put("key", "stack")
.putAll("value", "Test", "Production")
.build());
assertEquals(
request.getPayload().getRawContent(),
"Filter.1.Name=resource-type&Filter.1.Value.1=instance&Filter.2.Name=key&Filter.2.Value.1=stack&Filter.3.Name=value&Filter.3.Value.1=Test&Filter.3.Value.2=Production");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testDefault() throws IOException {
String expected = "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>";
GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
BindDeployVAppParamsToXmlPayload binder = injector.getInstance(BindDeployVAppParamsToXmlPayload.class);
Map<String, Object> map = Maps.newHashMap();
assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
}
}
内容来源于网络,如有侵权,请联系作者删除!