Package com.taobao.gecko.service

Examples of com.taobao.gecko.service.Connection


        this.fileMessageSet.flush();
        assertEquals(2L * str.length(), this.fileMessageSet.highWaterMark());
        final FileMessageSet subSet = (FileMessageSet) this.fileMessageSet.slice(0, 100);

        assertEquals(2L * str.length(), subSet.highWaterMark());
        final Connection conn = EasyMock.createMock(Connection.class);
        EasyMock.expect(conn.getRemoteSocketAddress()).andReturn(new InetSocketAddress(8181)).anyTimes();

        final int opaque = 99;
        final IoBuffer head = IoBuffer.wrap(("value " + 2 * str.length() + " " + opaque + "\r\n").getBytes());
        conn.transferFrom(head, null, this.fileMessageSet.channel(), 0, 2 * str.length());
        EasyMock.expectLastCall();
        EasyMock.replay(conn);

        subSet.write(new GetCommand("test", "boyan-test", -1, 0, 1024 * 1024, opaque), new SessionContextImpl(null,
            conn));
View Full Code Here


public class SessionContextHolderUnitTest {

    @Test
    public void testGetOrCreateSessionContext_LocalTransactionId() {
        final Connection conn = EasyMock.createMock(Connection.class);
        final LocalTransactionId xid = new LocalTransactionId("test", 1);
        EasyMock.expect(conn.getAttribute("test")).andReturn(null);
        EasyMock.expect(conn.setAttributeIfAbsent("test", new SessionContextImpl("test", conn))).andReturn(null);
        EasyMock.replay(conn);

        final SessionContext ctx = SessionContextHolder.getOrCreateSessionContext(conn, xid);
        assertNotNull(ctx);
        assertEquals("test", ctx.getSessionId());
View Full Code Here

    }


    @Test
    public void testGetOrCreateSessionContext_XATransactionId() {
        final Connection conn = EasyMock.createMock(Connection.class);
        final XATransactionId xid = XIDGenerator.createXID(0);
        EasyMock.expect(conn.getAttribute(SessionContextHolder.GLOBAL_SESSION_KEY)).andReturn(null);
        EasyMock.expect(
            conn.setAttributeIfAbsent(SessionContextHolder.GLOBAL_SESSION_KEY, new SessionContextImpl(null, conn)))
            .andReturn(null);
        EasyMock.replay(conn);

        final SessionContext ctx = SessionContextHolder.getOrCreateSessionContext(conn, xid);
        assertNotNull(ctx);
View Full Code Here

    /**
     * Get the session's tasks queue.
     */
    private TasksQueue getConnectionTasksQueue(final IoCatalog ioCatalog) {
        final Connection connection = ioCatalog.connection;
        final String catalog = this.getCatalog(ioCatalog);
        TasksQueue queue = (TasksQueue) connection.getAttribute(catalog);
        if (queue == null) {
            queue = new TasksQueue();
            final TasksQueue oldQueue = (TasksQueue) connection.setAttributeIfAbsent(catalog, queue);
            if (oldQueue != null) {
                queue = oldQueue;
            }
        }

View Full Code Here

TOP

Related Classes of com.taobao.gecko.service.Connection

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.