Skip to content

Commit

Permalink
Merge pull request #707 from daveyarwood/improve-sad-path-address-res…
Browse files Browse the repository at this point in the history
…olution-tests

Improve sad path address resolution tests
  • Loading branch information
trevorbernard committed Apr 3, 2019
2 parents 46b2042 + 877fc08 commit 0fdcb58
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/java/zmq/io/net/TestAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.zeromq.ZMQException;

public class TestAddress
{
Expand All @@ -24,4 +25,10 @@ public void testResolvedToString()
String resolved = addr.toString();
assertTrue(resolved.matches("tcp://\\d+\\.\\d+\\.\\d+\\.\\d+:90"));
}

@Test(expected = ZMQException.class)
public void testInvalid()
{
new Address("tcp", "ggglocalhostxxx.google.com:80").resolve(false);
}
}
15 changes: 15 additions & 0 deletions src/test/java/zmq/io/net/tcp/TcpAddressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ public void testGoodIP46Google()
Assert.assertEquals(80, sa.getPort());
}

@Test
public void testBad()
{
try {
Address addr = new Address(NetProtocol.tcp.name(), "ggglocalhostxxx.google.com:80");
addr.resolve(true);
addr.resolved();
Assert.fail();
}
catch (ZMQException e) {
Assert.assertEquals(ZError.EADDRNOTAVAIL, e.getErrorCode());
Assert.assertEquals(e.getCause().getMessage(), e.getMessage());
}
}

@Test
public void testUnspecifiedIPv6DoubleColon() throws IOException
{
Expand Down

0 comments on commit 0fdcb58

Please sign in to comment.