Search in sources :

Example 36 with Executor

use of org.apache.http.client.fluent.Executor in project substitution-schedule-parser by vertretungsplanme.

the class LoginHandlerTest method testBasicAuthFailUrl.

@Test(expected = CredentialInvalidException.class)
public void testBasicAuthFailUrl() throws JSONException, IOException, CredentialInvalidException {
    stubBasicAuth();
    Executor exec = newExecutor();
    LoginHandler handler = new LoginHandler(dataBasicUrl, wrong, null);
    handler.handleLogin(exec, null);
}
Also used : Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Example 37 with Executor

use of org.apache.http.client.fluent.Executor in project acs-aem-commons by Adobe-Consulting-Services.

the class HttpClientFactoryImplTest method testJsonGet.

@Test
public void testJsonGet() throws Exception {
    impl.activate(config);
    Request get = impl.get("/anonJson");
    Executor exec = impl.getExecutor();
    JSONObject jsonObject = exec.execute(get).handleResponse(new JsonObjectResponseHandler());
    assertThat(jsonObject.has("foo"), is(true));
    assertThat(jsonObject.getString("foo"), is("bar"));
}
Also used : Executor(org.apache.http.client.fluent.Executor) JSONObject(org.apache.sling.commons.json.JSONObject) HttpRequest(org.mockserver.model.HttpRequest) Request(org.apache.http.client.fluent.Request) JsonObjectResponseHandler(com.adobe.acs.commons.http.JsonObjectResponseHandler) Test(org.junit.Test)

Example 38 with Executor

use of org.apache.http.client.fluent.Executor in project redisson by redisson.

the class RedissonSessionManagerTest method testUpdateTwoServers_readValue.

@Test
public void testUpdateTwoServers_readValue() throws Exception {
    TomcatServer server1 = new TomcatServer("myapp", 8080, "src/test/");
    TomcatServer server2 = new TomcatServer("myapp", 8081, "src/test/");
    try {
        server1.start();
        server2.start();
        Executor executor = Executor.newInstance();
        BasicCookieStore cookieStore = new BasicCookieStore();
        executor.use(cookieStore);
        write(8080, executor, "test", "from_server1");
        write(8081, executor, "test", "from_server2");
        read(8080, executor, "test", "from_server2");
        read(8080, executor, "test", "from_server2");
    } finally {
        Executor.closeIdleConnections();
        server1.stop();
        server2.stop();
    }
}
Also used : BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Example 39 with Executor

use of org.apache.http.client.fluent.Executor in project redisson by redisson.

the class RedissonSessionManagerTest method testRecreate.

@Test
public void testRecreate() throws Exception {
    // start the server at http://localhost:8080/myapp
    TomcatServer server = new TomcatServer("myapp", 8080, "src/test/");
    server.start();
    Executor executor = Executor.newInstance();
    write(8080, executor, "test", "1");
    recreate(executor, "test", "2");
    read(8080, executor, "test", "2");
    Executor.closeIdleConnections();
    server.stop();
}
Also used : Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Example 40 with Executor

use of org.apache.http.client.fluent.Executor in project redisson by redisson.

the class RedissonSessionManagerTest method testUpdateTwoServers_twoValues.

@Test
public void testUpdateTwoServers_twoValues() throws Exception {
    TomcatServer server1 = new TomcatServer("myapp", 8080, "src/test/");
    TomcatServer server2 = new TomcatServer("myapp", 8081, "src/test/");
    try {
        server1.start();
        server2.start();
        Executor executor = Executor.newInstance();
        BasicCookieStore cookieStore = new BasicCookieStore();
        executor.use(cookieStore);
        write(8080, executor, "key1", "value1");
        write(8080, executor, "key2", "value1");
        write(8081, executor, "key1", "value2");
        write(8081, executor, "key2", "value2");
        read(8080, executor, "key1", "value2");
        read(8080, executor, "key2", "value2");
    } finally {
        Executor.closeIdleConnections();
        server1.stop();
        server2.stop();
    }
}
Also used : BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Aggregations

Executor (org.apache.http.client.fluent.Executor)46 Test (org.junit.Test)26 Request (org.apache.http.client.fluent.Request)12 BasicCookieStore (org.apache.http.impl.client.BasicCookieStore)11 HttpResponse (org.apache.http.HttpResponse)6 Response (org.apache.http.client.fluent.Response)6 URI (java.net.URI)5 Cookie (org.apache.http.cookie.Cookie)5 Test (org.junit.jupiter.api.Test)5 JsonObject (com.google.gson.JsonObject)4 InputStream (java.io.InputStream)4 DistributionTransportSecret (org.apache.sling.distribution.transport.DistributionTransportSecret)4 StreamsConnection (com.ibm.streamsx.rest.StreamsConnection)3 HashMap (java.util.HashMap)3 DistributionRequest (org.apache.sling.distribution.DistributionRequest)3 JsonParser (com.google.gson.JsonParser)2 Instance (com.ibm.streamsx.rest.Instance)2 ICP4DAuthenticator (com.ibm.streamsx.rest.internal.ICP4DAuthenticator)2 StandaloneAuthenticator (com.ibm.streamsx.rest.internal.StandaloneAuthenticator)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2