com.consol.citrus.http.client.HttpClient Java Examples

The following examples show how to use com.consol.citrus.http.client.HttpClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpClientSteps.java    From yaks with Apache License 2.0 6 votes vote down vote up
@Before
public void before(Scenario scenario) {
    if (httpClient == null && citrus.getCitrusContext().getReferenceResolver().resolveAll(HttpClient.class).size() == 1L) {
        httpClient = citrus.getCitrusContext().getReferenceResolver().resolve(HttpClient.class);
    } else {
        httpClient = new HttpClientBuilder().build();
    }

    timeout = httpClient.getEndpointConfiguration().getTimeout();

    requestHeaders = new HashMap<>();
    responseHeaders = new HashMap<>();
    requestParams = new HashMap<>();
    requestMessageType = CitrusSettings.DEFAULT_MESSAGE_TYPE;
    responseMessageType = CitrusSettings.DEFAULT_MESSAGE_TYPE;
    requestBody = null;
    responseBody = null;
    bodyValidationExpressions = new HashMap<>();
    outboundDictionary = null;
    inboundDictionary = null;
}
 
Example #2
Source File: HttpClientSteps.java    From yaks with Apache License 2.0 6 votes vote down vote up
/**
 * Get secure http client implementation with trust all strategy and noop host name verifier.
 * @return
 */
private org.apache.http.client.HttpClient sslClient() {
    try {
        SSLContext sslcontext = SSLContexts
                .custom()
                .loadTrustMaterial(TrustAllStrategy.INSTANCE)
                .build();

        SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
                sslcontext, NoopHostnameVerifier.INSTANCE);

        return HttpClients
                .custom()
                .setSSLSocketFactory(sslSocketFactory)
                .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                .build();
    } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
        throw new CitrusRuntimeException("Failed to create http client for ssl connection", e);
    }
}
 
Example #3
Source File: EndpointModelConverterTest.java    From citrus-admin with Apache License 2.0 6 votes vote down vote up
@DataProvider
public Object[][] converterData() {
    return new Object[][] {
        new Object[] {new JmsEndpointModelConverter(), new JmsEndpointModel(), new JmsEndpoint(), "jms().asynchronous()"},
        new Object[] {new ChannelEndpointModelConverter(), new ChannelEndpointModel(), new ChannelEndpoint(), "channel()"},
        new Object[] {new CamelEndpointModelConverter(), new CamelEndpointModel(), new CamelEndpoint(), "camel()"},
        new Object[] {new VertxEndpointModelConverter(), new VertxEndpointModel(), new VertxEndpoint(), "vertx()"},
        new Object[] {new HttpClientModelConverter(), new HttpClientModel(), new HttpClient(), "http().client()"},
        new Object[] {new HttpServerModelConverter(), new HttpServerModel(), new HttpServer(), "http().server()"},
        new Object[] {new WebServiceClientModelConverter(), new WebServiceClientModel(), new WebServiceClient(), "soap().client()"},
        new Object[] {new WebServiceServerModelConverter(), new WebServiceServerModel(), new WebServiceServer(), "soap().server()"},
        new Object[] {new WebSocketClientModelConverter(), new WebSocketClientModel(), new WebServiceClient(), "websocket().client()"},
        new Object[] {new WebSocketServerModelConverter(), new WebSocketServerModel(), new WebSocketServer(), "websocket().server()"},
        new Object[] {new FtpClientModelConverter(), new FtpClientModel(), new FtpClient(), "ftp().client()"},
        new Object[] {new FtpServerModelConverter(), new FtpServerModel(), new FtpServer(), "ftp().server()"},
        new Object[] {new JdbcServerModelConverter(), new JdbcServerModel(), new JdbcServer(), "jdbc().server()"},
        new Object[] {new SshClientModelConverter(), new SshClientModel(), new SshClient(), "ssh().client()"},
        new Object[] {new SshServerModelConverter(), new SshServerModel(), new SshServer(), "ssh().server()"},
        new Object[] {new RmiClientModelConverter(), new RmiClientModel(), new RmiClient(), "rmi().client()"},
        new Object[] {new RmiServerModelConverter(), new RmiServerModel(), new RmiServer(), "rmi().server()"},
        new Object[] {new JmxClientModelConverter(), new JmxClientModel(), new JmxClient(), "jmx().client()"},
        new Object[] {new JmxServerModelConverter(), new JmxServerModel(), new JmxServer(), "jmx().server()"},
        new Object[] {new MailClientModelConverter(), new MailClientModel(), new MailClient(), "mail().client()"},
        new Object[] {new MailServerModelConverter(), new MailServerModel(), new MailServer(), "mail().server()"}
    };
}
 
Example #4
Source File: HttpClientSteps.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Given("^HTTP client \"([^\"\\s]+)\"$")
public void setClient(String id) {
    if (!citrus.getCitrusContext().getReferenceResolver().isResolvable(id)) {
        throw new CitrusRuntimeException("Unable to find http client for id: " + id);
    }

    httpClient = citrus.getCitrusContext().getReferenceResolver().resolve(id, HttpClient.class);
}
 
Example #5
Source File: SimulatorWebServiceClientIT.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
@Bean
public HttpClient simulatorRestEndpoint() {
    return CitrusEndpoints.http().client()
            .requestUrl(String.format("http://localhost:%s", 8080))
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .build();
}
 
Example #6
Source File: SimulatorJmsIT.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
@Bean
public HttpClient simulatorRestEndpoint() {
    return CitrusEndpoints.http().client()
            .requestUrl(String.format("http://localhost:%s", 8080))
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .build();
}
 
Example #7
Source File: HttpClientConfig.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
@Bean
public HttpClient simulatorHttpClientEndpoint() {
    return CitrusEndpoints.http()
            .client()
            .timeout(defaultTimeout)
            .requestUrl(String.format("https://localhost:%s/", port))
            .requestFactory(sslRequestFactory())
            .build();
}
 
Example #8
Source File: EndpointConfig.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
/**
 * Citrus Http client
 * do a sync request/reply over HTTP on localhost:8080/order with a GET call and timeout for 60 seconds
 */
@Bean
public HttpClient statusHttpClient() {
    return CitrusEndpoints.http()
            .client()
            .requestUrl("http://localhost:8080/order")
            .requestMethod(HttpMethod.GET)
            .contentType("text/xml")
            .timeout(60000L)
            .build();
}
 
Example #9
Source File: AddBeanJavaConfig.java    From citrus-admin with Apache License 2.0 5 votes vote down vote up
@Bean
public HttpClient httpClient() {
    return CitrusEndpoints
            .http()
            .client()
            .requestUrl("http://localhost:8080/foo")
            .build();
}
 
Example #10
Source File: GetBeanDefinitionConfig.java    From citrus-admin with Apache License 2.0 5 votes vote down vote up
@Bean("httpClient")
public HttpClient client() {
    return CitrusEndpoints
            .http()
            .client()
            .requestUrl("http://localhost:8080/foo")
            .build();
}
 
Example #11
Source File: TodoListApi_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient todoListApiClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s", integrationContainer.getServerPort()))
            .build();
}
 
Example #12
Source File: TodoApi_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient todoApiClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s", integrationContainer.getServerPort()))
            .build();
}
 
Example #13
Source File: HttpClientModelConverter.java    From citrus-admin with Apache License 2.0 4 votes vote down vote up
@Override
public HttpClientModel convert(String id, HttpClient model) {
    HttpClientModel converted = convert(model);
    converted.setId(id);
    return converted;
}
 
Example #14
Source File: TodoOpenApiV3_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient todoApiClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s", integrationContainer.getServerPort()))
            .build();
}
 
Example #15
Source File: ConditionalFlows_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient webHookClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s/webhook/test-webhook", integrationContainer.getServerPort()))
            .build();
}
 
Example #16
Source File: WebHookSplitToDB_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient webHookClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s/webhook/test-webhook", integrationContainer.getServerPort()))
            .build();
}
 
Example #17
Source File: WebHookToDB_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient webHookClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s/webhook/test-webhook", integrationContainer.getServerPort()))
            .build();
}
 
Example #18
Source File: ValidateStarter.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
public ValidateStarter(@Qualifier("simulatorHttpClientEndpoint") HttpClient client) {
    this.client = client;
}
 
Example #19
Source File: CalculateStarter.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
public CalculateStarter(@Qualifier("simulatorHttpClientEndpoint") HttpClient client) {
    this.client = client;
}
 
Example #20
Source File: SendMail_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient webHookClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s/webhook/test-webhook", integrationContainer.getServerPort()))
            .build();
}
 
Example #21
Source File: SimulatorRestIT.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient petstoreClient() {
    return CitrusEndpoints.http().client()
            .requestUrl(String.format("http://localhost:%s/petstore/v2", 8080))
            .build();
}
 
Example #22
Source File: SimulatorRestIT.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient simulatorUiClient() {
    return CitrusEndpoints.http().client()
            .requestUrl(String.format("http://localhost:%s", 8080))
            .build();
}
 
Example #23
Source File: WebHookToFtp_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient webHookClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s/webhook/contact", integrationContainer.getServerPort()))
            .build();
}
 
Example #24
Source File: SimulatorRestIT.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient simulatorClient() {
    return CitrusEndpoints.http().client()
            .requestUrl(String.format("http://localhost:%s/services/rest/simulator", 8080))
            .build();
}
 
Example #25
Source File: Webhook2DB_IT.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient webHookClient() {
    return new HttpClientBuilder()
            .requestUrl(String.format("http://localhost:%s/webhook/quickstart", integrationContainer.getServerPort()))
            .build();
}
 
Example #26
Source File: EndpointConfig.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpClient simulatorClient() {
    return CitrusEndpoints.http().client()
            .requestUrl(String.format("http://localhost:%s/services/rest/simulator", 8080))
            .build();
}