Examples of SocketFactory


Examples of javax.net.SocketFactory

    ) throws IOException, UnknownHostException, ConnectTimeoutException {
        if (params == null) {
            throw new IllegalArgumentException("Parameters may not be null");
        }
        int timeout = params.getConnectionTimeout();
        SocketFactory socketfactory = getSSLContext().getSocketFactory();
        if (timeout == 0) {
            return socketfactory.createSocket(host, port, localAddress, localPort);
        } else {
            Socket socket = socketfactory.createSocket();
            SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
            SocketAddress remoteaddr = new InetSocketAddress(host, port);
            socket.bind(localaddr);
            socket.connect(remoteaddr, timeout);
            return socket;
View Full Code Here

Examples of javax.net.SocketFactory

    ) throws IOException, UnknownHostException, ConnectTimeoutException {
        if (params == null) {
            throw new IllegalArgumentException("Parameters may not be null");
        }
        int timeout = params.getConnectionTimeout();
        SocketFactory socketfactory = getSSLContext().getSocketFactory();
        if (timeout == 0) {
            return socketfactory.createSocket(host, port, localAddress, localPort);
        } else {
            Socket socket = socketfactory.createSocket();
            SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
            SocketAddress remoteaddr = new InetSocketAddress(host, port);
            socket.bind(localaddr);
            socket.connect(remoteaddr, timeout);
            return socket;
View Full Code Here

Examples of javax.net.SocketFactory

            throw new IllegalArgumentException("Parameters may not be null");
        }
        int timeout = params.getConnectionTimeout();
        Socket socket = null;
       
        SocketFactory socketfactory = SSLSocketFactory.getDefault();
        if (timeout == 0) {
            socket = socketfactory.createSocket(host, port, localAddress, localPort);
        } else {
            socket = socketfactory.createSocket();
            SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
            SocketAddress remoteaddr = new InetSocketAddress(host, port);
            socket.bind(localaddr);
            socket.connect(remoteaddr, timeout);
        }
View Full Code Here

Examples of javax.net.SocketFactory

    public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
        if (params == null) {
            throw new IllegalArgumentException("Parameters may not be null");
        }
        int timeout = params.getConnectionTimeout();
        SocketFactory socketfactory = getSSLContext().getSocketFactory();
        if (timeout == 0) {
            return socketfactory.createSocket(host, port, localAddress, localPort);
        }
        else {
            Socket socket = socketfactory.createSocket();
            SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
            SocketAddress remoteaddr = new InetSocketAddress(host, port);
            socket.bind(localaddr);
            socket.connect(remoteaddr, timeout);
            return socket;
View Full Code Here

Examples of javax.net.SocketFactory

        try {
            Socket socket = mock(Socket.class);
            when(socket.getOutputStream()).thenReturn(out);
            when(socket.getInputStream()).thenReturn(in);

            SocketFactory factory = mock(SocketFactory.class);
            when(factory.createSocket()).thenReturn(socket);
            when(factory.createSocket(anyString(), anyInt())).thenReturn(socket);

            return factory;
        } catch (Exception e) {
            e.printStackTrace();
            throw new AssertionError("Cannot be here!");
View Full Code Here

Examples of javax.net.SocketFactory

            when(socket.getOutputStream()).thenReturn(out);
            when(socket.getInputStream()).thenReturn(in);
            when(socket.isConnected()).thenReturn(true);
            socketMocks.add(socket);

            SocketFactory factory = mock(SocketFactory.class);
            OngoingStubbing<Socket> stubbing = when(factory.createSocket(anyString(), anyInt()));
            for (Socket t : socketMocks)
                stubbing = stubbing.thenReturn(t);

            return factory;
        } catch (Exception e) {
View Full Code Here

Examples of javax.net.SocketFactory

    }

    /** With Connection **/
    @Test
    public void connectionParsedOne() {
        SocketFactory sf = MockingUtils.mockSocketFactory(null, simpleStream);
        ApnsFeedbackConnection connection = new ApnsFeedbackConnection(sf, "localhost", 80);
        checkParsedSimple(connection.getInactiveDevices());
    }
View Full Code Here

Examples of javax.net.SocketFactory

        checkParsedSimple(connection.getInactiveDevices());
    }

    @Test
    public void connectionParsedThree() {
        SocketFactory sf = MockingUtils.mockSocketFactory(null, threeStream);
        ApnsFeedbackConnection connection = new ApnsFeedbackConnection(sf, "localhost", 80);
        checkParsedThree(connection.getInactiveDevices());
    }
View Full Code Here

Examples of javax.net.SocketFactory

    }

    /** Check error recover **/
    @Test
    public void feedbackWithClosedSocket() {
        SocketFactory sf = mockClosedThenOpenSocket(null, simpleStream, true, 1);
        ApnsFeedbackConnection connection = new ApnsFeedbackConnection(sf, "localhost", 80);
        connection.DELAY_IN_MS = 0;
        checkParsedSimple(connection.getInactiveDevices());
    }
View Full Code Here

Examples of javax.net.SocketFactory

        checkParsedSimple(connection.getInactiveDevices());
    }

    @Test
    public void feedbackWithErrorOnce() {
        SocketFactory sf = mockClosedThenOpenSocket(null, simpleStream, true, 2);
        ApnsFeedbackConnection connection = new ApnsFeedbackConnection(sf, "localhost", 80);
        connection.DELAY_IN_MS = 0;
        checkParsedSimple(connection.getInactiveDevices());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.