return Optional.empty();
}
+ @Override
+ public String toString() {
+ return String.format("→ %s:%d", hostname, port);
+ }
+
/** Handles input and output for the connection. */
private class ConnectionHandler implements Closeable {
--- /dev/null
+package net.pterodactylus.irc;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+
+import org.junit.Test;
+
+/**
+ * Unit test for {@link DefaultConnection}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class DefaultConnectionTest {
+
+ private static final String HOSTNAME = "some.host.name";
+ private static final int PORT = 12345;
+
+ @Test
+ public void toStringContainsHostnameAndPort() {
+ DefaultConnection defaultConnection = new DefaultConnection(null, null, HOSTNAME, PORT);
+ assertThat(defaultConnection.toString(), containsString(HOSTNAME));
+ assertThat(defaultConnection.toString(), containsString(String.valueOf(PORT)));
+ }
+
+}