Search in sources :

Example 1 with RemoteConnectionEndpoint

use of org.jivesoftware.smack.util.rce.RemoteConnectionEndpoint in project Smack by igniterealtime.

the class RemoteXmppTcpConnectionEndpointsTest method testConnectionException.

@Test
public void testConnectionException() {
    List<RemoteConnectionException<? extends RemoteConnectionEndpoint>> connectionExceptions = new ArrayList<>();
    {
        A aRr = new A("1.2.3.4");
        UInt16 port = UInt16.from(1234);
        String host = "example.org";
        IpTcpRemoteConnectionEndpoint<A> remoteConnectionEndpoint = new IpTcpRemoteConnectionEndpoint<>(host, port, aRr);
        Exception exception = new Exception("Failed for some reason");
        RemoteConnectionException<IpTcpRemoteConnectionEndpoint<A>> remoteConnectionException = RemoteConnectionException.from(remoteConnectionEndpoint, exception);
        connectionExceptions.add(remoteConnectionException);
    }
    {
        A aRr = new A("1.3.3.7");
        UInt16 port = UInt16.from(5678);
        String host = "other.example.org";
        IpTcpRemoteConnectionEndpoint<A> remoteConnectionEndpoint = new IpTcpRemoteConnectionEndpoint<>(host, port, aRr);
        Exception exception = new Exception("Failed for some other reason");
        RemoteConnectionException<IpTcpRemoteConnectionEndpoint<A>> remoteConnectionException = RemoteConnectionException.from(remoteConnectionEndpoint, exception);
        connectionExceptions.add(remoteConnectionException);
    }
    List<RemoteConnectionEndpointLookupFailure> lookupFailures = Collections.emptyList();
    SmackException.EndpointConnectionException endpointConnectionException = SmackException.EndpointConnectionException.from(lookupFailures, connectionExceptions);
    String message = endpointConnectionException.getMessage();
    assertEquals("The following addresses failed: " + "'RFC 6120 A/AAAA Endpoint + [example.org:1234] (/1.2.3.4:1234)' failed because: java.lang.Exception: Failed for some reason, " + "'RFC 6120 A/AAAA Endpoint + [other.example.org:5678] (/1.3.3.7:5678)' failed because: java.lang.Exception: Failed for some other reason", message);
}
Also used : A(org.minidns.record.A) RemoteConnectionException(org.jivesoftware.smack.util.rce.RemoteConnectionException) RemoteConnectionEndpointLookupFailure(org.jivesoftware.smack.util.rce.RemoteConnectionEndpointLookupFailure) SmackException(org.jivesoftware.smack.SmackException) ArrayList(java.util.ArrayList) SmackException(org.jivesoftware.smack.SmackException) RemoteConnectionException(org.jivesoftware.smack.util.rce.RemoteConnectionException) UInt16(org.jivesoftware.smack.datatypes.UInt16) RemoteConnectionEndpoint(org.jivesoftware.smack.util.rce.RemoteConnectionEndpoint) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayList (java.util.ArrayList)1 SmackException (org.jivesoftware.smack.SmackException)1 UInt16 (org.jivesoftware.smack.datatypes.UInt16)1 RemoteConnectionEndpoint (org.jivesoftware.smack.util.rce.RemoteConnectionEndpoint)1 RemoteConnectionEndpointLookupFailure (org.jivesoftware.smack.util.rce.RemoteConnectionEndpointLookupFailure)1 RemoteConnectionException (org.jivesoftware.smack.util.rce.RemoteConnectionException)1 Test (org.junit.jupiter.api.Test)1 A (org.minidns.record.A)1