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


Java WebClient.accept方法代码示例

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


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

示例1: testGetDecisionByAttributesJSON

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void testGetDecisionByAttributesJSON() {
    if (!waitForWADL()) {
        return;
    }

    WebClient client = WebClient.create(ENDPOINT_ADDRESS);

    client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
    client.type("application/json");
    client.accept("application/xml");

    client.path("by-attrib");

    String request = readReource("json/request-by-attrib-1.json");
    String response = readReource("json/response-by-attrib-1.xml");

    String webRespose = client.post(request, String.class);

    assertEquals(response, webRespose);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:TestService.java

示例2: testGetDecisionByAttributesBooleanXML

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void testGetDecisionByAttributesBooleanXML() {
    if (!waitForWADL()) {
        return;
    }

    WebClient client = WebClient.create(ENDPOINT_ADDRESS);

    client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
    client.type("application/xml");
    client.accept("application/xml");

    client.path("by-attrib-boolean");

    String request = readReource("xml/request-by-attrib-bool-1.xml");
    String response = readReource("xml/response-by-attrib-bool-1.xml");

    String webRespose = client.post(request, String.class);

    assertEquals(response, webRespose);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:TestService.java

示例3: testEntitledAttributesXML

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void testEntitledAttributesXML() {
    if (!waitForWADL()) {
        return;
    }

    WebClient client = WebClient.create(ENDPOINT_ADDRESS);

    client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
    client.type("application/xml");
    client.accept("application/xml");

    client.path("entitled-attribs");

    String request = readReource("xml/request-entitled-attribs-1.xml");
    String response = readReource("xml/response-entitled-attribs-1.xml");

    String webRespose = client.post(request, String.class);
    assertEquals(response, webRespose);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:TestService.java

示例4: exportUnauth

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void exportUnauth ( ) throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/small_test.csv", "dataFile");

	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
	
	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);	
	
	logout();
	
	client = getClient(true);
	client.accept("application/sql");
	String exportPath = "/"+id+"/export/sql";
	response = client.path(exportPath).get();
	assertEquals(403, response.getStatus());

}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:26,代码来源:DatabaseTest.java

示例5: getEndpoints

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
@RunAsClient
public void getEndpoints() throws Exception {

    final WebClient webClient = WebClient.create(this.url.toURI());
    webClient.accept(MediaType.APPLICATION_JSON);

    final String reset = webClient.path("/service/endpoints/").get(String.class);
    Assert.assertNotNull("Failed to reset", reset);

    final Endpoints eps = webClient.path("conference")
            .get(Endpoints.class);

    Assert.assertNotNull("Failed to get Endpoints", eps);
    Assert.assertFalse("Endpoints is empty", eps.getEndpoints().isEmpty());
}
 
开发者ID:eclipse,项目名称:microprofile-conference,代码行数:17,代码来源:EndpointServiceTest.java

示例6: getPeerInfo

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Override
public PeerInfo getPeerInfo( final String destinationHost ) throws PeerException
{

    WebClient client = null;
    Response response;

    try
    {
        client = restUtil.getTrustedWebClient( buildUrl( destinationHost, "info" ), provider );
        client.type( MediaType.APPLICATION_JSON );
        client.accept( MediaType.APPLICATION_JSON );

        response = client.get();
    }
    catch ( Exception e )
    {
        throw new PeerException( String.format( "Can not connect to '%s'.", destinationHost ) );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    return WebClientBuilder.checkResponse( response, PeerInfo.class );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:27,代码来源:RegistrationClientImpl.java

示例7: getUsedNetResources

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public UsedNetworkResources getUsedNetResources() throws PeerException
{
    WebClient client = null;
    Response response;
    try
    {
        remotePeer.checkRelation();
        String path = "/netresources";
        client = WebClientBuilder.buildPeerWebClient( peerInfo, path, provider );

        client.accept( MediaType.APPLICATION_JSON );

        response = client.get();
    }
    catch ( Exception e )
    {
        LOG.error( e.getMessage(), e );
        throw new PeerException(
                String.format( "Error obtaining reserved network resources: %s", e.getMessage() ) );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    return WebClientBuilder.checkResponse( response, UsedNetworkResources.class );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:28,代码来源:PeerWebClient.java

示例8: addCustomProxy

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void addCustomProxy( final CustomProxyConfig proxyConfig ) throws PeerException
{
    WebClient client = null;

    Response response;

    try
    {
        String path = String.format( "/%s/container/%s/customProxy/add", proxyConfig.getEnvironmentId(),
                proxyConfig.getContainerId() );

        client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider );

        client.accept( MediaType.APPLICATION_JSON );
        client.type( MediaType.APPLICATION_JSON );

        response = client.post( path );
    }
    catch ( Exception e )
    {
        LOG.error( e.getMessage(), e );
        throw new PeerException( String.format( "Error on adding custom proxy: %s", e.getMessage() ) );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    WebClientBuilder.checkResponse( response );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:31,代码来源:EnvironmentWebClient.java

示例9: excludeContainerFromEnvironment

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void excludeContainerFromEnvironment( final String environmentId, final String containerId )
        throws PeerException
{
    WebClient client = null;
    Response response;
    try
    {
        remotePeer.checkRelation();
        String path = String.format( "/%s/containers/%s/exclude", environmentId, containerId );
        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 container from environment: " + e.getMessage() );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    WebClientBuilder.checkResponse( response );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:28,代码来源:EnvironmentWebClient.java

示例10: getQuota

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public ContainerQuota getQuota( final ContainerId containerId ) throws PeerException
{
    WebClient client = null;
    Response response;
    try
    {
        remotePeer.checkRelation();
        String path = String.format( "/%s/container/%s/quota", containerId.getEnvironmentId().getId(),
                containerId.getId() );

        client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider, 5000L, 15000L, 1 );

        client.type( MediaType.APPLICATION_JSON );
        client.accept( MediaType.APPLICATION_JSON );
        response = client.get();
    }
    catch ( Exception e )
    {
        LOG.error( e.getMessage(), e );
        throw new PeerException( "Error on obtaining available quota: " + e.getMessage() );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    return WebClientBuilder.checkResponse( response, ContainerQuota.class );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:29,代码来源:EnvironmentWebClient.java

示例11: buildEnvironmentWebClient

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public static WebClient buildEnvironmentWebClient( final PeerInfo peerInfo, final String path,
                                                   final Object provider )
{
    String effectiveUrl = String.format( ENVIRONMENT_URL_TEMPLATE, peerInfo.getIp(), peerInfo.getPublicSecurePort(),
            path.startsWith( "/" ) ? path : "/" + path );
    WebClient client = WebClient.create( effectiveUrl, Arrays.asList( provider ) );
    client.type( MediaType.APPLICATION_JSON );
    client.accept( MediaType.APPLICATION_JSON );
    HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit();

    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout( DEFAULT_CONNECTION_TIMEOUT );
    httpClientPolicy.setReceiveTimeout( DEFAULT_RECEIVE_TIMEOUT );
    httpClientPolicy.setMaxRetransmits( DEFAULT_MAX_RETRANSMITS );

    httpConduit.setClient( httpClientPolicy );

    KeyStoreTool keyStoreManager = new KeyStoreTool();
    KeyStoreData keyStoreData = new KeyStoreData();
    keyStoreData.setupKeyStorePx2();
    keyStoreData.setAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS );
    KeyStore keyStore = keyStoreManager.load( keyStoreData );

    LOG.debug( String.format( "Getting key with alias: %s for url: %s", SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS,
            effectiveUrl ) );

    KeyStoreData trustStoreData = new KeyStoreData();
    trustStoreData.setupTrustStorePx2();
    KeyStore trustStore = keyStoreManager.load( trustStoreData );

    SSLManager sslManager = new SSLManager( keyStore, keyStoreData, trustStore, trustStoreData );

    TLSClientParameters tlsClientParameters = new TLSClientParameters();
    tlsClientParameters.setDisableCNCheck( true );
    tlsClientParameters.setTrustManagers( sslManager.getClientTrustManagers() );
    tlsClientParameters.setKeyManagers( sslManager.getClientKeyManagers() );
    tlsClientParameters.setCertAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS );
    httpConduit.setTlsClientParameters( tlsClientParameters );
    return client;
}
 
开发者ID:subutai-io,项目名称:base,代码行数:41,代码来源:WebClientBuilder.java

示例12: sendCancelRequest

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Override
public void sendCancelRequest( String destinationHost, final RegistrationData registrationData )
        throws PeerException
{
    WebClient client = null;
    Response response;

    try
    {
        client = restUtil.getTrustedWebClient( buildUrl( destinationHost, "cancel" ), provider );
        client.type( MediaType.APPLICATION_JSON );
        client.accept( MediaType.APPLICATION_JSON );

        response = client.post( registrationData );
    }
    catch ( Exception e )
    {
        throw new PeerException(
                String.format( "Error requesting remote peer '%s': %s.", destinationHost, e.getMessage() ) );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    WebClientBuilder.checkResponse( response, Response.Status.OK );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:28,代码来源:RegistrationClientImpl.java

示例13: createEnvironmentKeyPair

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public PublicKeyContainer createEnvironmentKeyPair( final RelationLinkDto envLink ) throws PeerException
{
    WebClient client = null;
    Response response;
    try
    {
        remotePeer.checkRelation();
        String path = "/pek";

        client = WebClientBuilder.buildPeerWebClient( peerInfo, path, provider );

        client.type( MediaType.APPLICATION_JSON );
        client.accept( MediaType.APPLICATION_JSON );

        response = client.post( envLink );
    }
    catch ( Exception e )
    {
        LOG.error( e.getMessage(), e );
        throw new PeerException( String.format( "Error creating peer environment key: %s", e.getMessage() ) );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    return WebClientBuilder.checkResponse( response, PublicKeyContainer.class );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:29,代码来源:PeerWebClient.java

示例14: getState

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public ContainerHostState getState( ContainerId containerId ) throws PeerException
{
    WebClient client = null;
    Response response;
    try
    {
        remotePeer.checkRelation();
        String path = String.format( "/%s/container/%s/state", containerId.getEnvironmentId().getId(),
                containerId.getId() );
        client = WebClientBuilder.buildEnvironmentWebClient( peerInfo, path, provider, 5000L, 15000L, 1 );

        client.type( MediaType.APPLICATION_JSON );
        client.accept( MediaType.APPLICATION_JSON );
        response = client.get();
    }
    catch ( Exception e )
    {
        LOG.warn( e.getMessage() );
        throw new PeerException( "Error on reading container state: " + e.getMessage() );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    return WebClientBuilder.checkResponse( response, ContainerHostState.class );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:28,代码来源:EnvironmentWebClient.java

示例15: destroyContainer

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void destroyContainer( ContainerId containerId ) throws PeerException
{
    WebClient client = null;
    Response response;
    try
    {
        remotePeer.checkRelation();
        String path = String.format( "/%s/container/%s/destroy", containerId.getEnvironmentId().getId(),
                containerId.getId() );
        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 destroying container: " + e.getMessage() );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

    WebClientBuilder.checkResponse( response );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:28,代码来源:EnvironmentWebClient.java


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