Package org.jpos.iso.channel

Examples of org.jpos.iso.channel.RawChannel


    }

    @Test
    public void testCreateMsg() throws Throwable {
        ISOPackager p = new ISO87APackagerBBitmap();
        BaseChannel rawChannel = new RawChannel();
        rawChannel.setPackager(p);
        ISOMsg result = rawChannel.createMsg();
        assertEquals("result.getDirection()", 0, result.getDirection());
        assertSame("(RawChannel) rawChannel.packager", p, ((RawChannel) rawChannel).packager);
    }
View Full Code Here


        }
    }

    @Test
    public void testDisconnect() throws Throwable {
        BaseChannel rawChannel = new RawChannel();
        rawChannel.disconnect();
        assertNull("(RawChannel) rawChannel.getSocket()", rawChannel.getSocket());
        assertFalse("(RawChannel) rawChannel.usable", ((RawChannel) rawChannel).usable);
    }
View Full Code Here

    @Test
    public void testDisconnectWithDefaultSoLingerOption() throws Exception {
        Socket socket = mockSocket();
        when(socketFactory.createSocket(anyString(), anyInt())).thenReturn(socket);

        BaseChannel rawChannel = new RawChannel();
        rawChannel.setSocketFactory(socketFactory);

        rawChannel.connect();
        rawChannel.disconnect();

        verify(socket).setSoLinger(true, 5);
        verify(socket).shutdownOutput();
        verify(socket).close();

        assertTrue(rawChannel.isSoLingerOn());
        assertEquals(5, rawChannel.getSoLingerSeconds());
    }
View Full Code Here

    @Test
    public void testDisconnectWithCustomSoLingerOption() throws Exception {
        Socket socket = mockSocket();
        when(socketFactory.createSocket(anyString(), anyInt())).thenReturn(socket);

        BaseChannel rawChannel = new RawChannel();
        rawChannel.setSocketFactory(socketFactory);
        rawChannel.setSoLinger(true, 0);

        rawChannel.connect();
        rawChannel.disconnect();

        verify(socket).setSoLinger(true, 0);
        verify(socket).close();
        verify(socket, never()).shutdownOutput()// this does not make sense when sending a TCP RST down the socket

        assertTrue(rawChannel.isSoLingerOn());
        assertEquals(0, rawChannel.getSoLingerSeconds());
    }
View Full Code Here

        return socket;
    }

    @Test
    public void testGetBytesThrowsNullPointerException() throws Throwable {
        BaseChannel rawChannel = new RawChannel(new ISO87APackagerBBitmap(), "".getBytes());
        byte[] b = new byte[1];
        try {
            rawChannel.getBytes(b);
            fail("Expected NullPointerException to be thrown");
        } catch (NullPointerException ex) {
            assertNull("ex.getMessage()", ex.getMessage());
            assertNull("(RawChannel) rawChannel.serverIn", ((RawChannel) rawChannel).serverIn);
        }
View Full Code Here

        assertEquals("result[0]", 0, result[0]);
    }

    @Test
    public void testGetDynamicHeader() throws Throwable {
        BaseChannel rawChannel = new RawChannel();
        byte[] image = new byte[2];
        BaseHeader result = (BaseHeader) rawChannel.getDynamicHeader(image);
        assertEquals("result.getLength()", 2, result.getLength());
    }
View Full Code Here

        assertEquals("result", 12, result);
    }

    @Test
    public void testGetHeaderLength3() throws Throwable {
        BaseChannel rawChannel = new RawChannel();
        int result = rawChannel.getHeaderLength();
        assertEquals("result", 0, result);
    }
View Full Code Here

        assertEquals("result.size()", 0, result.size());
    }

    @Test
    public void testGetMessageThrowsNullPointerException() throws Throwable {
        BaseChannel rawChannel = new RawChannel();
        byte[] b = new byte[3];
        try {
            rawChannel.getMessage(b, 100, 1000);
            fail("Expected NullPointerException to be thrown");
        } catch (NullPointerException ex) {
            assertNull("ex.getMessage()", ex.getMessage());
            assertNull("(RawChannel) rawChannel.serverIn", ((RawChannel) rawChannel).serverIn);
        }
View Full Code Here

        }
    }

    @Test
    public void testGetOriginalRealm() throws Throwable {
        BaseChannel rawChannel = new RawChannel(new ISO87APackagerBBitmap(), "".getBytes());
        rawChannel.setLogger(null, "testBaseChannelRealm");
        String result = rawChannel.getOriginalRealm();
        assertEquals("result", "testBaseChannelRealm", result);
    }
View Full Code Here

    }

    @Test
    public void testGetServerSocket() throws Throwable {
        ServerSocket sock = new ServerSocket();
        BaseChannel rawChannel = new RawChannel();
        rawChannel.setServerSocket(sock);
        ServerSocket result = rawChannel.getServerSocket();
        assertSame("result", sock, result);
    }
View Full Code Here

TOP

Related Classes of org.jpos.iso.channel.RawChannel

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.