blob: 8160ca875b6b442a6f2f49775ae53ff7afb5c6a2 [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 ConstrainedShortestPathIntentTest {
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 ConstrainedShortestPathIntent intent1 =
26 new ConstrainedShortestPathIntent(g, "1", 1L, 20L, 1L, 4L, 20L, 4L, 1000.0);
27
28 byte b[] = intent1.toBytes();
29
30 ConstrainedShortestPathIntent intent2 =
31 ConstrainedShortestPathIntent.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 assertEquals(Double.valueOf(1000.0), intent2.getBandwidth());
41 }
42}