Skip to content

Commit

Permalink
Implement toString
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Sep 5, 2024
1 parent 324432a commit 56abeb3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/scalasbt/ipcsocket/UnixDomainSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public UnixDomainSocket(int fd) {
this(fd, false);
}

public String toString() {
return "UnixDomainSocket(path = " + this.path + ")";
}

public InputStream getInputStream() {
return is;
}
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/org/scalasbt/ipcsocket/SocketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,20 @@ public void shortReadWrite() throws IOException, InterruptedException {
});
}
*/

@Test
public void testToString() throws IOException, InterruptedException {
withSocket(
sock -> {
System.out.println("SocketTest#testToString(" + Boolean.toString(useJNI()) + ")");
ServerSocket serverSocket = newServerSocket(sock);
Socket client = newClientSocket(sock);
try {
assertTrue(client.toString().startsWith("UnixDomainSocket(path ="));
} finally {
client.close();
serverSocket.close();
}
});
}
}

0 comments on commit 56abeb3

Please sign in to comment.