All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lyncode.testy.http.TestyHttpWithContentRequestBuilder Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package com.lyncode.testy.http;

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.StringEntity;

import java.io.UnsupportedEncodingException;

public abstract class TestyHttpWithContentRequestBuilder extends TestyHttpRequestBuilder {
    private String content;

    @Override
    protected HttpRequestBase build(String url) {
        HttpEntityEnclosingRequestBase requestBase = buildEnclosable(url);
        try {
            requestBase.setEntity(new StringEntity(content));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        return requestBase;
    }

    abstract HttpEntityEnclosingRequestBase buildEnclosable (String url);

    public TestyHttpRequestBuilder with(BodyContentBuilder content) {
        this.content = content.build();
        return self();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy