blob: a0da341d45eb3aa31505435d1d013f5616225acf [file] [log] [blame]
Toshio Koideebdbb622014-02-12 20:28:38 -08001package net.onrc.onos.intent;
2
3import static org.junit.Assert.*;
4import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph;
5import org.junit.After;
6import org.junit.Before;
7import org.junit.Test;
8
9public 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}