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


Java WebClient.type方法代码示例

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


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

示例1: testHomeJSON

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

    WebClient client = WebClient.create(ENDPOINT_ADDRESS);

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

    client.path("home");

    String response = readReource("json/response-home.json");

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

示例2: 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);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:TestService.java

示例3: 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

示例4: 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

示例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 );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:27,代码来源:PeerWebClient.java

示例6: 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

示例7: getResourceHostMetrics

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

        client = WebClientBuilder.buildPeerWebClient( peerInfo, path, provider );
        client.type( MediaType.APPLICATION_JSON );
        client.accept( MediaType.APPLICATION_JSON );
        response = client.get();
    }
    catch ( Exception e )
    {
        LOG.error( e.getMessage(), e );
        throw new PeerException( String.format( "Error getting rh metrics: %s", e.getMessage() ) );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

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

示例8: 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 );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:27,代码来源:PeerWebClient.java

示例9: uploadSmallSQLFile

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test ()
public void uploadSmallSQLFile() throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/databases/main_2812_2811.sql", "dataFile");
	client = getClient(false);
	client.type("multipart/form-data");
	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);

}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:19,代码来源:DatabaseTest.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: uploadSmallMalformedCSVFile

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

	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(500, response.getStatus());
	
	logout();
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:15,代码来源:DatabaseTest.java

示例12: 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

示例13: 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

示例14: configureHostsInEnvironment

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public void configureHostsInEnvironment( final EnvironmentId environmentId, final HostAddresses hostAddresses )
        throws PeerException
{
    WebClient client = null;
    Response response;
    try
    {
        String path = String.format( "/%s/containers/hosts", environmentId.getId() );

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

        client.type( MediaType.APPLICATION_JSON );

        response = client.post( hostAddresses );
    }
    catch ( Exception e )
    {
        LOG.error( e.getMessage(), e );
        throw new PeerException( "Error configuring hosts in environment: " + e.getMessage() );
    }
    finally
    {
        WebClientBuilder.close( client );
    }

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

示例15: 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 );
}
 
开发者ID:subutai-io,项目名称:base,代码行数:28,代码来源:EnvironmentWebClient.java


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