Search in sources :

Example 16 with Executor

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

the class RedissonSessionManagerTest method testUpdate.

@Test
public void testUpdate() 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");
    read(8080, executor, "test", "1");
    write(8080, 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 17 with Executor

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

the class RedissonSessionManagerTest method testHttpSessionListener.

@Test
public void testHttpSessionListener() throws Exception {
    TomcatServer server1 = new TomcatServer("myapp", 8080, "src/test/");
    server1.start();
    TomcatServer server2 = new TomcatServer("myapp", 8081, "src/test/");
    server2.start();
    Executor executor = Executor.newInstance();
    BasicCookieStore cookieStore = new BasicCookieStore();
    executor.use(cookieStore);
    TestHttpSessionListener.CREATED_INVOCATION_COUNTER = 0;
    TestHttpSessionListener.DESTROYED_INVOCATION_COUNTER = 0;
    write(8080, executor, "test", "1234");
    TomcatServer server3 = new TomcatServer("myapp", 8082, "src/test/");
    server3.start();
    invalidate(executor);
    Thread.sleep(500);
    Assert.assertEquals(2, TestHttpSessionListener.CREATED_INVOCATION_COUNTER);
    Assert.assertEquals(3, TestHttpSessionListener.DESTROYED_INVOCATION_COUNTER);
    Executor.closeIdleConnections();
    server1.stop();
    server2.stop();
    server3.stop();
}
Also used : BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Example 18 with Executor

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

the class RedissonSessionManagerTest method testSwitchServer.

@Test
public void testSwitchServer() throws Exception {
    // start the server at http://localhost:8080/myapp
    TomcatServer server = new TomcatServer("myapp", 8080, "src/test/");
    server.start();
    Executor executor = Executor.newInstance();
    BasicCookieStore cookieStore = new BasicCookieStore();
    executor.use(cookieStore);
    write(8080, executor, "test", "1234");
    System.out.println("done1");
    Cookie cookie = cookieStore.getCookies().get(0);
    Executor.closeIdleConnections();
    server.stop();
    server = new TomcatServer("myapp", 8080, "src/test/");
    server.start();
    executor = Executor.newInstance();
    cookieStore = new BasicCookieStore();
    cookieStore.addCookie(cookie);
    executor.use(cookieStore);
    read(8080, executor, "test", "1234");
    remove(executor, "test", "null");
    Executor.closeIdleConnections();
    server.stop();
}
Also used : Cookie(org.apache.http.cookie.Cookie) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Example 19 with Executor

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

the class RedissonSessionManagerTest method testUpdate.

@Test
public void testUpdate() 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(executor, "test", "1");
    read(executor, "test", "1");
    write(executor, "test", "2");
    read(executor, "test", "2");
    Executor.closeIdleConnections();
    server.stop();
}
Also used : Executor(org.apache.http.client.fluent.Executor) Test(org.junit.jupiter.api.Test)

Example 20 with Executor

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

the class RedissonSessionManagerTest method testSwitchServer.

@Test
public void testSwitchServer() throws Exception {
    // start the server at http://localhost:8080/myapp
    TomcatServer server = new TomcatServer("myapp", 8080, "src/test/");
    server.start();
    Executor executor = Executor.newInstance();
    BasicCookieStore cookieStore = new BasicCookieStore();
    executor.use(cookieStore);
    write(executor, "test", "1234");
    Cookie cookie = cookieStore.getCookies().get(0);
    Executor.closeIdleConnections();
    server.stop();
    server = new TomcatServer("myapp", 8080, "src/test/");
    server.start();
    executor = Executor.newInstance();
    cookieStore = new BasicCookieStore();
    cookieStore.addCookie(cookie);
    executor.use(cookieStore);
    read(executor, "test", "1234");
    remove(executor, "test", "null");
    Executor.closeIdleConnections();
    server.stop();
}
Also used : Cookie(org.apache.http.cookie.Cookie) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) Executor(org.apache.http.client.fluent.Executor) Test(org.junit.jupiter.api.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