Debian Codegraph @

src/test/java/jnr/netdb/FileProtocolDBTest.java

raw
1
2 package jnr.netdb;
3
4 import org.junit.After;
5 import org.junit.AfterClass;
6 import org.junit.Before;
7 import org.junit.BeforeClass;
8 import org.junit.Test;
9 import static org.junit.Assert.*;
10
11 /**
12 *
13 */
14 public class FileProtocolDBTest {
15
16 public FileProtocolDBTest() {
17 }
18
19 @BeforeClass
20 public static void setUpClass() throws Exception {
21 }
22
23 @AfterClass
24 public static void tearDownClass() throws Exception {
25 }
26
27 @Before
28 public void setUp() {
29 }
30
31 @After
32 public void tearDown() {
33 }
34
35 @Test public void canLookupIpProtocolByName() {
36 ProtocolsDB db = FileProtocolsDB.getInstance();
37 // we try ip first and then ipv4 due to jnr/jnr-netdb#4
38 Protocol p = Protocol.getProtocolByName("ip");
39 if (p != null) {
40 assertEquals("incorrect proto number", 0, p.getProto());
41 assertEquals("incorrect name", "ip", p.getName());
42 } else {
43 p = Protocol.getProtocolByName("ipv4");
44 assertNotNull("could not lookup ipv4 protocol", p);
45 assertEquals("incorrect proto number", 4, p.getProto());
46 assertEquals("incorrect name", "ipv4", p.getName());
47 }
48 }
49
50 @Test public void canLookupIpProtocolByNumber() {
51 ProtocolsDB db = FileProtocolsDB.getInstance();
52 // we try ip first and then ipv4 due to jnr/jnr-netdb#4
53 Protocol p = Protocol.getProtocolByName("ip");
54 if (p != null) {
55 p = Protocol.getProtocolByNumber(0);
56 assertEquals("incorrect proto number", 0, p.getProto());
57 assertEquals("incorrect name", "ip", p.getName());
58 } else {
59 p = Protocol.getProtocolByNumber(4);
60 assertNotNull("could not lookup ip protocol", p);
61 assertEquals("incorrect proto number", 4, p.getProto());
62 assertEquals("incorrect name", "ipv4", p.getName());
63 }
64 }
65 }