Search in sources :

Example 36 with SocketFactory

use of javax.net.SocketFactory in project java-apns by notnoop.

the class ApnsConnectionTest method errorTwice.

@Test
public void errorTwice() {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SocketFactory factory = mockClosedThenOpenSocket(baos, null, false, 2);
    packetSentRegardless(factory, baos);
}
Also used : SocketFactory(javax.net.SocketFactory) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 37 with SocketFactory

use of javax.net.SocketFactory in project java-apns by notnoop.

the class ApnsConnectionTest method closedSocket.

@Test
@Ignore
public void closedSocket() {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SocketFactory factory = mockClosedThenOpenSocket(baos, null, true, 1);
    packetSentRegardless(factory, baos);
}
Also used : SocketFactory(javax.net.SocketFactory) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 38 with SocketFactory

use of javax.net.SocketFactory in project java-apns by notnoop.

the class ApnsConnectionTest method errorThrice.

/**
     * Connection fails after three retries
     */
@Test(expected = Exception.class)
public void errorThrice() {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SocketFactory factory = mockClosedThenOpenSocket(baos, null, false, 3);
    packetSentRegardless(factory, baos);
}
Also used : SocketFactory(javax.net.SocketFactory) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 39 with SocketFactory

use of javax.net.SocketFactory in project java-apns by notnoop.

the class ApnsFeedbackConnectionTest method feedbackWithErrorOnce.

@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());
}
Also used : SocketFactory(javax.net.SocketFactory) Test(org.junit.Test)

Example 40 with SocketFactory

use of javax.net.SocketFactory in project java-apns by notnoop.

the class ApnsFeedbackConnectionTest method connectionParsedOne.

/** With Connection **/
@Test
public void connectionParsedOne() {
    SocketFactory sf = MockingUtils.mockSocketFactory(null, simpleStream);
    ApnsFeedbackConnection connection = new ApnsFeedbackConnection(sf, "localhost", 80);
    checkParsedSimple(connection.getInactiveDevices());
}
Also used : SocketFactory(javax.net.SocketFactory) Test(org.junit.Test)

Aggregations

SocketFactory (javax.net.SocketFactory)66 Socket (java.net.Socket)25 Test (org.junit.Test)25 IOException (java.io.IOException)18 InetSocketAddress (java.net.InetSocketAddress)14 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 SSLSocket (javax.net.ssl.SSLSocket)10 OutputStream (java.io.OutputStream)9 ServerSocket (java.net.ServerSocket)9 SocketAddress (java.net.SocketAddress)6 Configuration (org.apache.hadoop.conf.Configuration)5 ServerSocketFactory (javax.net.ServerSocketFactory)4 InputStream (java.io.InputStream)3 InetAddress (java.net.InetAddress)3 UnknownHostException (java.net.UnknownHostException)3 ProtocolSocketFactory (org.apache.commons.httpclient.protocol.ProtocolSocketFactory)3 StandardSocketFactory (org.apache.hadoop.net.StandardSocketFactory)3 ByteChunk (org.apache.tomcat.util.buf.ByteChunk)3 SocketException (java.net.SocketException)2