Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame^] | 1 | package net.onrc.onos.intent; |
| 2 | |
| 3 | import static org.junit.Assert.*; |
| 4 | import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph; |
| 5 | import org.junit.After; |
| 6 | import org.junit.Before; |
| 7 | import org.junit.Test; |
| 8 | |
| 9 | public class ShortestPathIntentTest { |
| 10 | NetworkGraph g; |
| 11 | |
| 12 | @Before |
| 13 | public void setUp() throws Exception { |
| 14 | MockNetworkGraph graph = new MockNetworkGraph(); |
| 15 | graph.createSampleTopology(); |
| 16 | g = graph; |
| 17 | } |
| 18 | |
| 19 | @After |
| 20 | public void tearDown() throws Exception { |
| 21 | } |
| 22 | |
| 23 | @Test |
| 24 | public void test() { |
| 25 | ShortestPathIntent intent1 = |
| 26 | new ShortestPathIntent(g, "1", 1L, 20L, 1L, 4L, 20L, 4L); |
| 27 | |
| 28 | byte b[] = intent1.toBytes(); |
| 29 | |
| 30 | ShortestPathIntent intent2 = |
| 31 | ShortestPathIntent.fromBytes(g, b); |
| 32 | |
| 33 | assertEquals("1", intent2.getId()); |
| 34 | assertEquals(Long.valueOf(1), intent2.getSourcePort().getSwitch().getDpid()); |
| 35 | assertEquals(Long.valueOf(20), intent2.getSourcePort().getNumber()); |
| 36 | assertEquals(1L, intent2.getSourceMac().toLong()); |
| 37 | assertEquals(Long.valueOf(4), intent2.getDestinationPort().getSwitch().getDpid()); |
| 38 | assertEquals(Long.valueOf(20), intent2.getDestinationPort().getNumber()); |
| 39 | assertEquals(4L, intent2.getDestinationMac().toLong()); |
| 40 | } |
| 41 | |
| 42 | } |