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);
}
Aggregations