Package org.apache.http.nio.reactor

Examples of org.apache.http.nio.reactor.SessionRequest


    @Test
    public void testRemove() throws Exception {
        LocalRoutePool pool = new LocalRoutePool();
        IOSession session1 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest1.getSession()).thenReturn(session1);
        BasicFuture<LocalPoolEntry> future1 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest1, future1);
        IOSession session2 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest2.getSession()).thenReturn(session2);
        BasicFuture<LocalPoolEntry> future2 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest2, future2);
        IOSession session3 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest3 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest3.getSession()).thenReturn(session3);
        BasicFuture<LocalPoolEntry> future3 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest3, future3);

        Assert.assertEquals(3, pool.getAllocatedCount());
        Assert.assertEquals(0, pool.getAvailableCount());
View Full Code Here


    @Test
    public void testShutdown() throws Exception {
        LocalRoutePool pool = new LocalRoutePool();
        IOSession session1 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest1.getSession()).thenReturn(session1);
        BasicFuture<LocalPoolEntry> future1 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest1, future1);
        IOSession session2 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest2.getSession()).thenReturn(session2);
        BasicFuture<LocalPoolEntry> future2 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest2, future2);
        IOSession session3 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest3 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest3.getSession()).thenReturn(session3);
        BasicFuture<LocalPoolEntry> future3 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest3, future3);

        LocalPoolEntry entry1 = pool.completed(sessionRequest1, session1);
        Assert.assertNotNull(entry1);
View Full Code Here

        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());

        Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
        for (int i = 0; i < connNo; i++) {
            SessionRequest sessionRequest = this.client.openConnection(
                    new InetSocketAddress("localhost", serverAddress.getPort()),
                    queue);
            connRequests.add(sessionRequest);
        }

        while (!connRequests.isEmpty()) {
            SessionRequest sessionRequest = connRequests.remove();
            sessionRequest.waitFor();
            if (sessionRequest.getException() != null) {
                throw sessionRequest.getException();
            }
            Assert.assertNotNull(sessionRequest.getSession());
        }

        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());

        for (int i = 0; i < jobs.length; i++) {
View Full Code Here

        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());

        Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
        for (int i = 0; i < connNo; i++) {
            SessionRequest sessionRequest = this.client.openConnection(
                    new InetSocketAddress("localhost", serverAddress.getPort()),
                    queue);
            connRequests.add(sessionRequest);
        }

        while (!connRequests.isEmpty()) {
            SessionRequest sessionRequest = connRequests.remove();
            sessionRequest.waitFor();
            if (sessionRequest.getException() != null) {
                throw sessionRequest.getException();
            }
            Assert.assertNotNull(sessionRequest.getSession());
        }

        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());

        for (int i = 0; i < jobs.length; i++) {
View Full Code Here

    @Test
    public void testSuccessfulConnect() throws Exception {
        LocalRoutePool pool = new LocalRoutePool();
        IOSession session = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest.getSession()).thenReturn(session);
        BasicFuture<LocalPoolEntry> future = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest, future);
        Assert.assertEquals(1, pool.getAllocatedCount());
        Assert.assertEquals(0, pool.getAvailableCount());
        Assert.assertEquals(0, pool.getLeasedCount());
View Full Code Here

    }

    @Test
    public void testFailedConnect() throws Exception {
        LocalRoutePool pool = new LocalRoutePool();
        SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest.getException()).thenReturn(new IOException());
        BasicFuture<LocalPoolEntry> future = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest, future);
        Assert.assertEquals(1, pool.getAllocatedCount());
        Assert.assertEquals(0, pool.getAvailableCount());
        Assert.assertEquals(0, pool.getLeasedCount());
View Full Code Here

    }

    @Test
    public void testCancelledConnect() throws Exception {
        LocalRoutePool pool = new LocalRoutePool();
        SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
        BasicFuture<LocalPoolEntry> future = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest, future);
        Assert.assertEquals(1, pool.getAllocatedCount());
        Assert.assertEquals(0, pool.getAvailableCount());
        Assert.assertEquals(0, pool.getLeasedCount());
View Full Code Here

    }

    @Test
    public void testConnectTimeout() throws Exception {
        LocalRoutePool pool = new LocalRoutePool();
        SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
        BasicFuture<LocalPoolEntry> future = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest, future);
        Assert.assertEquals(1, pool.getAllocatedCount());
        Assert.assertEquals(0, pool.getAvailableCount());
        Assert.assertEquals(0, pool.getLeasedCount());
View Full Code Here

    @Test
    public void testLeaseRelease() throws Exception {
        LocalRoutePool pool = new LocalRoutePool();
        IOSession session1 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest1.getSession()).thenReturn(session1);
        BasicFuture<LocalPoolEntry> future1 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest1, future1);
        IOSession session2 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest2.getSession()).thenReturn(session2);
        BasicFuture<LocalPoolEntry> future2 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest2, future2);
        IOSession session3 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest3 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest3.getSession()).thenReturn(session3);
        BasicFuture<LocalPoolEntry> future3 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest3, future3);

        Assert.assertEquals(3, pool.getAllocatedCount());
        Assert.assertEquals(0, pool.getAvailableCount());
View Full Code Here

    @Test
    public void testLeaseReleaseStateful() throws Exception {
        LocalRoutePool pool = new LocalRoutePool();

        IOSession session1 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest1.getSession()).thenReturn(session1);
        BasicFuture<LocalPoolEntry> future1 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest1, future1);
        IOSession session2 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest2.getSession()).thenReturn(session2);
        BasicFuture<LocalPoolEntry> future2 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest2, future2);
        IOSession session3 = Mockito.mock(IOSession.class);
        SessionRequest sessionRequest3 = Mockito.mock(SessionRequest.class);
        Mockito.when(sessionRequest3.getSession()).thenReturn(session3);
        BasicFuture<LocalPoolEntry> future3 = new BasicFuture<LocalPoolEntry>(null);
        pool.addPending(sessionRequest3, future3);

        LocalPoolEntry entry1 = pool.completed(sessionRequest1, session1);
        Assert.assertNotNull(entry1);
View Full Code Here

TOP

Related Classes of org.apache.http.nio.reactor.SessionRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.