Open Kilda Java Documentation
IPortImplTest.java
Go to the documentation of this file.
1 package org.openkilda.simulator.classes;
2 
3 import org.junit.After;
4 import org.junit.Before;
5 import org.junit.Rule;
6 import org.junit.Test;
7 import org.junit.rules.ExpectedException;
9 
10 import static org.junit.Assert.*;
11 
12 public class IPortImplTest {
13  IPortImpl port;
14  ISwitchImpl sw;
15  int portNum = 1;
16 
17  @Rule
18  public ExpectedException thrown = ExpectedException.none();
19 
20 
21  @Before
22  public void setUp() throws Exception {
23  sw = new ISwitchImpl();
24  port = new IPortImpl(sw, PortStateType.DOWN, portNum);
25  }
26 
27  @After
28  public void tearDown() throws Exception {
29  }
30 
31  @Test
32  public void testInit() throws Exception {
33  int portNum = 5;
34  IPortImpl port = new IPortImpl(sw, PortStateType.DOWN, portNum);
35  assertFalse(port.isActive());
36  assertEquals(portNum, port.getNumber());
37 
38  port = new IPortImpl(sw, PortStateType.UP, portNum);
39  assertTrue(port.isActive());
40  }
41 
42  @Test
43  public void testEnableDisable() throws Exception {
44  port.enable();
45  assertTrue(port.isActive());
46 
47  port.disable();
48  assertFalse(port.isActive());
49  }
50 
51  @Test
52  public void testBlockUnblock() throws Exception {
53  port.block();
54  assertFalse(port.isForwarding());
55 
56  port.unblock();
57  assertTrue(port.isForwarding());
58  }
59 
60  @Test
61  public void isActiveIsl() throws Exception {
62  port.enable();
63  port.setPeerSwitch("00:00:00:00:00:01");
64  port.setPeerPortNum(10);
65  assertTrue(port.isActiveIsl());
66 
67  port.disable();
68  assertFalse(port.isActiveIsl());
69 
70  port.enable();
71  port.block();
72  assertFalse(port.isActiveIsl());
73 
74  port.unblock();
75  assertTrue(port.isActiveIsl());
76 
77  port.disable();
78  port.unblock();
79  assertFalse(port.isActiveIsl());
80  }
81 
82  @Test
83  public void getStats() throws Exception {
84  }
85 
86 }