本文整理汇总了Java中org.apache.cxf.jaxrs.client.WebClient.post方法的典型用法代码示例。如果您正苦于以下问题:Java WebClient.post方法的具体用法?Java WebClient.post怎么用?Java WebClient.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.jaxrs.client.WebClient
的用法示例。
在下文中一共展示了WebClient.post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test200searchAllUsers
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void test200searchAllUsers() {
final String TEST_NAME = "test200searchAllUsers";
displayTestTile(this, TEST_NAME);
WebClient client = prepareClient();
client.path("/users/search");
getDummyAuditService().clear();
TestUtil.displayWhen(TEST_NAME);
Response response = client.post(new QueryType());
TestUtil.displayThen(TEST_NAME);
displayResponse(response);
assertStatus(response, 200);
IntegrationTestTools.display("Audit", getDummyAuditService());
getDummyAuditService().assertRecords(2);
getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
}
示例2: getAccessToken
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
private ClientAccessToken getAccessToken() {
JwsHeaders headers = new JwsHeaders(JoseType.JWT, SignatureAlgorithm.RS256);
JwtClaims claims = new JwtClaims();
claims.setIssuer(config.getServiceAccountClientId());
claims.setAudience("https://accounts.google.com/o/oauth2/token");
claims.setSubject(config.getServiceAccountSubject());
long issuedAt = OAuthUtils.getIssuedAt();
long tokenTimeout = config.getServiceAccountTokenLifetime();
claims.setIssuedAt(issuedAt);
claims.setExpiryTime(issuedAt + tokenTimeout);
claims.setProperty("scope", "https://www.googleapis.com/auth/admin.directory.group.readonly https://www.googleapis.com/auth/admin.directory.user");
JwtToken token = new JwtToken(headers, claims);
JwsJwtCompactProducer p = new JwsJwtCompactProducer(token);
String base64UrlAssertion = p.signWith(privateKey);
JwtBearerGrant grant = new JwtBearerGrant(base64UrlAssertion);
WebClient accessTokenService = WebClient.create("https://accounts.google.com/o/oauth2/token",
Arrays.asList(new OAuthJSONProvider(), new AccessTokenGrantWriter()));
accessTokenService.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_JSON);
return accessTokenService.post(grant, ClientAccessToken.class);
}
示例3: removeSshKey
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void removeSshKey( final EnvironmentId environmentId, final String sshPublicKey ) throws PeerException
{
WebClient client = null;
Response response;
try
{
String path = String.format( "/%s/containers/sshkey/remove", environmentId.getId() );
client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider );
response = client.post( sshPublicKey );
}
catch ( Exception e )
{
LOG.error( e.getMessage(), e );
throw new PeerException( "Error removing ssh key in environment: " + e.getMessage() );
}
finally
{
WebClientBuilder.close( client );
}
WebClientBuilder.checkResponse( response );
}
示例4: testPdpJSON
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void testPdpJSON() {
if (!waitForWADL()) {
return;
}
WebClient client = WebClient.create(ENDPOINT_ADDRESS);
client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
client.type("application/json");
client.accept("application/json");
client.path("pdp");
String request = readReource("json/request-pdp-1.json");
String response = readReource("json/response-pdp-1.json");
String webRespose = client.post(request, String.class);
assertEquals(response, webRespose);
}
示例5: reserveNetworkResource
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public Integer reserveNetworkResource( final NetworkResourceImpl networkResource ) throws PeerException
{
WebClient client = null;
Response response;
try
{
String path = "/netresources";
client = WebClientBuilder.buildPeerWebClient( peerInfo, path, provider );
client.type( MediaType.APPLICATION_JSON );
response = client.post( networkResource );
}
catch ( Exception e )
{
LOG.error( e.getMessage(), e );
throw new PeerException( String.format( "Error reserving network resources: %s", e.getMessage() ) );
}
finally
{
WebClientBuilder.close( client );
}
return WebClientBuilder.checkResponse( response, Integer.class );
}
示例6: excludePeerFromEnvironment
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void excludePeerFromEnvironment( final String environmentId, final String peerId ) throws PeerException
{
WebClient client = null;
Response response;
try
{
remotePeer.checkRelation();
String path = String.format( "/%s/peers/%s/exclude", environmentId, peerId );
client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider );
client.type( MediaType.APPLICATION_JSON );
client.accept( MediaType.APPLICATION_JSON );
response = client.post( null );
}
catch ( Exception e )
{
LOG.error( e.getMessage(), e );
throw new PeerException( "Error excluding peer from environment: " + e.getMessage() );
}
finally
{
WebClientBuilder.close( client );
}
WebClientBuilder.checkResponse( response );
}
示例7: addPeerEnvironmentPubKey
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void addPeerEnvironmentPubKey( final String keyId, final String pubKeyRing ) throws PeerException
{
WebClient client = null;
Response response;
try
{
remotePeer.checkRelation();
String path = String.format( "/pek/add/%s", keyId );
client = WebClientBuilder.buildPeerWebClient( peerInfo, path, provider, 3000, 15000, 1 );
client.type( MediaType.APPLICATION_JSON );
client.accept( MediaType.APPLICATION_JSON );
response = client.post( pubKeyRing );
}
catch ( Exception e )
{
LOG.error( e.getMessage(), e );
throw new PeerException( String.format( "Error adding PEK: %s", e.getMessage() ) );
}
finally
{
WebClientBuilder.close( client );
}
WebClientBuilder.checkResponse( response );
}
示例8: test132DarthAdderEnableByAdministrator
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void test132DarthAdderEnableByAdministrator() throws Exception {
final String TEST_NAME = "test132DarthAdderEnableByAdministrator";
displayTestTile(this, TEST_NAME);
WebClient client = prepareClient();
client.path("/users/"+USER_DARTHADDER_OID);
getDummyAuditService().clear();
TestUtil.displayWhen(TEST_NAME);
Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ENABLE)));
TestUtil.displayThen(TEST_NAME);
displayResponse(response);
assertStatus(response, 204);
IntegrationTestTools.display("Audit", getDummyAuditService());
getDummyAuditService().assertRecords(4);
getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class);
OperationResult result = new OperationResult("test");
PrismObject<UserType> user = getRepositoryService().getObject(UserType.class, USER_DARTHADDER_OID, null, result);
assertEquals("Wrong administrativeStatus", ActivationStatusType.ENABLED, user.asObjectable().getActivation().getAdministrativeStatus());
}
示例9: configureSshInEnvironment
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void configureSshInEnvironment( final EnvironmentId environmentId, final SshKeys sshKeys )
throws PeerException
{
WebClient client = null;
Response response;
try
{
String path = String.format( "/%s/containers/sshkeys", environmentId.getId() );
client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider );
client.type( MediaType.APPLICATION_JSON );
response = client.post( sshKeys );
}
catch ( Exception e )
{
LOG.error( e.getMessage(), e );
throw new PeerException( "Error configuring ssh in environment: " + e.getMessage() );
}
finally
{
WebClientBuilder.close( client );
}
WebClientBuilder.checkResponse( response );
}
示例10: test401AddUserTemplateOverwrite
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void test401AddUserTemplateOverwrite() throws Exception {
final String TEST_NAME = "test401AddUserTemplateOverwrite";
displayTestTile(this, TEST_NAME);
WebClient client = prepareClient();
client.path("/objectTemplates");
client.query("options", "overwrite");
getDummyAuditService().clear();
TestUtil.displayWhen(TEST_NAME);
Response response = client.post(getRepoFile(USER_TEMPLATE_FILE));
TestUtil.displayThen(TEST_NAME);
displayResponse(response);
assertEquals("Expected 201 but got " + response.getStatus(), 201, response.getStatus());
String location = response.getHeaderString("Location");
String expected = ENDPOINT_ADDRESS + "/objectTemplates/" + USER_TEMPLATE_OID;
assertEquals("Unexpected location, expected: " + expected + " but was " + location,
expected,
location);
IntegrationTestTools.display("Audit", getDummyAuditService());
getDummyAuditService().assertRecords(4);
getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
getDummyAuditService().assertHasDelta(1, ChangeType.ADD, ObjectTemplateType.class);
}
示例11: updateContainerHostname
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void updateContainerHostname( final String environmentId, final String containerId, final String hostname )
throws PeerException
{
WebClient client = null;
Response response;
try
{
remotePeer.checkRelation();
String path = String.format( "/%s/containers/%s/hostname/%s", environmentId, containerId, hostname );
client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider );
client.type( MediaType.APPLICATION_JSON );
client.accept( MediaType.APPLICATION_JSON );
response = client.post( null );
}
catch ( Exception e )
{
LOG.error( e.getMessage(), e );
throw new PeerException( "Error updating container hostname: " + e.getMessage() );
}
finally
{
WebClientBuilder.close( client );
}
WebClientBuilder.checkResponse( response );
}
示例12: test503generateValueExecute
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void test503generateValueExecute() throws Exception {
final String TEST_NAME = "test503generateValueExecute";
displayTestTile(this, TEST_NAME);
WebClient client = prepareClient();
client.path("/users/" + USER_DARTHADDER_OID + "/generate");
getDummyAuditService().clear();
TestUtil.displayWhen(TEST_NAME);
Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_EXECUTE));
TestUtil.displayThen(TEST_NAME);
displayResponse(response);
traceResponse(response);
assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus());
IntegrationTestTools.display("Audit", getDummyAuditService());
getDummyAuditService().assertRecords(4);
getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class);
//UserType user = loadObject(UserType.class, USER_DARTHADDER_OID);
//TODO assert changed items
}
示例13: placeEnvironmentInfoByContainerId
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void placeEnvironmentInfoByContainerId( final String environmentId, final String containerId )
throws PeerException
{
WebClient client = null;
Response response;
try
{
remotePeer.checkRelation();
String path = String.format( "/%s/info/%s", environmentId, containerId );
client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider, 5000L, 15000L, 1 );
client.type( MediaType.APPLICATION_JSON );
client.accept( MediaType.APPLICATION_JSON );
response = client.post( null );
}
catch ( Exception e )
{
LOG.error( e.getMessage(), e );
throw new PeerException( "Error requesting environment info: " + e.getMessage() );
}
finally
{
WebClientBuilder.close( client );
}
WebClientBuilder.checkResponse( response );
}
示例14: exportTemplate
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public String exportTemplate( final ContainerId containerId, final String templateName,
final boolean isPrivateTemplate, final String token ) throws PeerException
{
WebClient client = null;
Response response;
try
{
remotePeer.checkRelation();
String path =
String.format( "/%s/containers/%s/template/%s/export/%s/token/%s", containerId.getEnvironmentId(),
containerId.getId(), templateName, isPrivateTemplate, token );
client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider, 5000L,
Common.TEMPLATE_EXPORT_TIMEOUT_SEC * 1000L, 1 );
client.type( MediaType.APPLICATION_JSON );
client.accept( MediaType.APPLICATION_JSON );
response = client.post( null );
}
catch ( Exception e )
{
LOG.error( e.getMessage(), e );
throw new PeerException( "Error exporting template: " + e.getMessage() );
}
finally
{
WebClientBuilder.close( client );
}
return WebClientBuilder.checkResponse( response, String.class );
}
示例15: test104AddAccountRawResourceDoesNotExist
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void test104AddAccountRawResourceDoesNotExist() throws Exception {
final String TEST_NAME = "test104AddAccountRaw";
displayTestTile(this, TEST_NAME);
WebClient client = prepareClient();
client.path("/shadows");
client.query("options", "raw");
getDummyAuditService().clear();
TestUtil.displayWhen(TEST_NAME);
Response response = client.post(getRepoFile(ACCOUT_CHUCK_FILE));
TestUtil.displayThen(TEST_NAME);
displayResponse(response);
// expecting hadnled error because resource doesn't exist.. it is OK, but let's say admin about that
assertStatus(response, 240);
OperationResult addResult = traceResponse(response);
assertNotNull("Expected operation result in the response, but nothing in the body", addResult);
assertEquals("Unexpected status of the operation result. Expected "+ OperationResultStatus.HANDLED_ERROR + ", but was " + addResult.getStatus(), addResult.getStatus(), OperationResultStatus.HANDLED_ERROR);
OperationResult parentResult = new OperationResult("get");
try {
getProvisioning().getObject(ShadowType.class, ACCOUT_CHUCK_OID,
SelectorOptions.createCollection(GetOperationOptions.createDoNotDiscovery()), null,
parentResult);
fail("expected object not found exception but haven't got one.");
} catch (ObjectNotFoundException ex) {
// this is OK..we expect objet not found, because accout was added
// with the raw options which indicates, that it was created only in
// the repository
}
IntegrationTestTools.display("Audit", getDummyAuditService());
getDummyAuditService().assertRecords(4);
getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
getDummyAuditService().assertHasDelta(1, ChangeType.ADD, ShadowType.class);
}