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; |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 5 | |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 6 | import org.junit.After; |
| 7 | import org.junit.Before; |
| 8 | import org.junit.Test; |
| 9 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 10 | import com.esotericsoftware.kryo.Kryo; |
| 11 | import com.esotericsoftware.kryo.io.Input; |
| 12 | import com.esotericsoftware.kryo.io.Output; |
| 13 | |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 14 | public class ConstrainedShortestPathIntentTest { |
| 15 | NetworkGraph g; |
| 16 | |
| 17 | @Before |
| 18 | public void setUp() throws Exception { |
| 19 | MockNetworkGraph graph = new MockNetworkGraph(); |
| 20 | graph.createSampleTopology(); |
| 21 | g = graph; |
| 22 | } |
| 23 | |
| 24 | @After |
| 25 | public void tearDown() throws Exception { |
| 26 | } |
| 27 | |
| 28 | @Test |
| 29 | public void test() { |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 30 | Kryo kryo = new Kryo(); |
| 31 | Output output = new Output(1024); |
| 32 | |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 33 | ConstrainedShortestPathIntent intent1 = |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 34 | new ConstrainedShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L, 1000.0); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 35 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 36 | kryo.writeObject(output, intent1); |
| 37 | output.close(); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 38 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 39 | Input input = new Input(output.toBytes()); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 40 | ConstrainedShortestPathIntent intent2 = |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 41 | kryo.readObject(input, ConstrainedShortestPathIntent.class); |
| 42 | input.close(); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 43 | |
| 44 | assertEquals("1", intent2.getId()); |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 45 | assertEquals(2L, intent2.getSrcSwitchDpid()); |
| 46 | assertEquals(3L, intent2.getSrcPortNumber()); |
| 47 | assertEquals(4L, intent2.getSrcMac()); |
| 48 | assertEquals(5L, intent2.getDstSwitchDpid()); |
| 49 | assertEquals(6L, intent2.getDstPortNumber()); |
| 50 | assertEquals(7L, intent2.getDstMac()); |
| 51 | assertEquals(1000.0, intent2.getBandwidth(), 0.0); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 52 | } |
| 53 | } |