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 | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame^] | 14 | /** |
| 15 | * @author Toshio Koide (t-koide@onlab.us) |
| 16 | */ |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 17 | public class ShortestPathIntentTest { |
| 18 | NetworkGraph g; |
| 19 | |
| 20 | @Before |
| 21 | public void setUp() throws Exception { |
| 22 | MockNetworkGraph graph = new MockNetworkGraph(); |
| 23 | graph.createSampleTopology(); |
| 24 | g = graph; |
| 25 | } |
| 26 | |
| 27 | @After |
| 28 | public void tearDown() throws Exception { |
| 29 | } |
| 30 | |
| 31 | @Test |
| 32 | public void test() { |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 33 | Kryo kryo = new Kryo(); |
| 34 | Output output = new Output(1024); |
| 35 | |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 36 | ShortestPathIntent intent1 = |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 37 | new ShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L); |
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 | kryo.writeObject(output, intent1); |
| 40 | output.close(); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 41 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 42 | Input input = new Input(output.toBytes()); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 43 | ShortestPathIntent intent2 = |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 44 | kryo.readObject(input, ShortestPathIntent.class); |
| 45 | input.close(); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 46 | |
| 47 | assertEquals("1", intent2.getId()); |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 48 | assertEquals(2L, intent2.getSrcSwitchDpid()); |
| 49 | assertEquals(3L, intent2.getSrcPortNumber()); |
| 50 | assertEquals(4L, intent2.getSrcMac()); |
| 51 | assertEquals(5L, intent2.getDstSwitchDpid()); |
| 52 | assertEquals(6L, intent2.getDstPortNumber()); |
| 53 | assertEquals(7L, intent2.getDstMac()); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 54 | } |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 55 | } |