Skip to content

Commit

Permalink
Use more standard "ipv4" proto instead of "ip".
Browse files Browse the repository at this point in the history
Arch linux does not by default define the "ip" protocol. Other
platforms may have the same situation.

See #4.
  • Loading branch information
headius committed Jan 6, 2017
1 parent d0e6f73 commit 4697814
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions src/test/java/jnr/netdb/FileProtocolDBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ public void tearDown() {

@Test public void canLookupIpProtocolByName() {
ProtocolsDB db = FileProtocolsDB.getInstance();
Protocol p = db.getProtocolByName("ip");
assertNotNull("could not lookup ip protocol", p);
assertEquals("incorrect proto number", 0, p.getProto());
assertEquals("incorrect name", "ip", p.getName());
Protocol p = db.getProtocolByName("ipv4");
assertNotNull("could not lookup ipv4 protocol", p);
assertEquals("incorrect proto number", 4, p.getProto());
assertEquals("incorrect name", "ipv4", p.getName());
}

@Test public void canLookupIpProtocolByNumber() {
ProtocolsDB db = FileProtocolsDB.getInstance();
Protocol p = db.getProtocolByNumber(0);
assertNotNull("could not lookup ip protocol", p);
assertEquals("incorrect proto number", 0, p.getProto());
assertEquals("incorrect name", "ip", p.getName());
Protocol p = db.getProtocolByNumber(4);
assertNotNull("could not lookup ipv4 protocol", p);
assertEquals("incorrect proto number", 4, p.getProto());
assertEquals("incorrect name", "ipv4", p.getName());
}
}
16 changes: 8 additions & 8 deletions src/test/java/jnr/netdb/NativeProtocolsDBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ public void tearDown() {

@Test public void canLookupIpProtocolByName() {
ProtocolsDB db = NativeProtocolsDB.getInstance();
Protocol p = db.getProtocolByName("ip");
assertNotNull("could not lookup ip protocol", p);
assertEquals("incorrect proto number", 0, p.getProto());
assertEquals("incorrect name", "ip", p.getName());
Protocol p = db.getProtocolByName("ipv4");
assertNotNull("could not lookup ipv4 protocol", p);
assertEquals("incorrect proto number", 4, p.getProto());
assertEquals("incorrect name", "ipv4", p.getName());
}

@Test public void canLookupIpProtocolByNumber() {
ProtocolsDB db = NativeProtocolsDB.getInstance();
Protocol p = db.getProtocolByNumber(0);
assertNotNull("could not lookup ip protocol", p);
assertEquals("incorrect proto number", 0, p.getProto());
assertEquals("incorrect name", "ip", p.getName());
Protocol p = db.getProtocolByNumber(4);
assertNotNull("could not lookup ipv4 protocol", p);
assertEquals("incorrect proto number", 4, p.getProto());
assertEquals("incorrect name", "ipv4", p.getName());
}

@Test public void canLookupTcpProtocolByName() {
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/jnr/netdb/ProtocolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public void tearDown() {
}

@Test public void canLookupIpProtocolByName() {
Protocol p = Protocol.getProtocolByName("ip");
assertNotNull("could not lookup ip protocol", p);
assertEquals("incorrect proto number", 0, p.getProto());
assertEquals("incorrect name", "ip", p.getName());
Protocol p = Protocol.getProtocolByName("ipv4");
assertNotNull("could not lookup ipv4 protocol", p);
assertEquals("incorrect proto number", 4, p.getProto());
assertEquals("incorrect name", "ipv4", p.getName());
}

@Test public void returnsNullOnUnknownProtocol() {
Expand All @@ -45,10 +45,10 @@ public void tearDown() {
}

@Test public void canLookupIpProtocolByNumber() {
Protocol p = Protocol.getProtocolByNumber(0);
Protocol p = Protocol.getProtocolByNumber(4);
assertNotNull("could not lookup ip protocol", p);
assertEquals("incorrect proto number", 0, p.getProto());
assertEquals("incorrect name", "ip", p.getName());
assertEquals("incorrect proto number", 4, p.getProto());
assertEquals("incorrect name", "ipv4", p.getName());
}

@Test public void returnsNullOnInvalidNumber() {
Expand Down

0 comments on commit 4697814

Please sign in to comment.