Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.intent; |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 2 | |
Jonathan Hart | a88fd24 | 2014-04-03 11:24:54 -0700 | [diff] [blame] | 3 | import static org.junit.Assert.assertEquals; |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 4 | |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 5 | import org.junit.After; |
| 6 | import org.junit.Before; |
| 7 | import org.junit.Test; |
| 8 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 9 | import com.esotericsoftware.kryo.Kryo; |
| 10 | import com.esotericsoftware.kryo.io.Input; |
| 11 | import com.esotericsoftware.kryo.io.Output; |
| 12 | |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 13 | /** |
Yuta HIGUCHI | d4acc80 | 2014-06-19 22:30:31 -0700 | [diff] [blame] | 14 | * Unit tests for ShortestPathIntent. |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 15 | */ |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 16 | public class ShortestPathIntentTest { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 17 | @Before |
| 18 | public void setUp() throws Exception { |
| 19 | } |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 20 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 21 | @After |
| 22 | public void tearDown() throws Exception { |
| 23 | } |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 24 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 25 | @Test |
| 26 | public void test() { |
| 27 | Kryo kryo = new Kryo(); |
| 28 | Output output = new Output(1024); |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 29 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 30 | ShortestPathIntent intent1 = |
| 31 | new ShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 32 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 33 | kryo.writeObject(output, intent1); |
| 34 | output.close(); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 35 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 36 | Input input = new Input(output.toBytes()); |
| 37 | ShortestPathIntent intent2 = |
| 38 | kryo.readObject(input, ShortestPathIntent.class); |
| 39 | input.close(); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 40 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 41 | assertEquals("1", intent2.getId()); |
| 42 | assertEquals(2L, intent2.getSrcSwitchDpid()); |
| 43 | assertEquals(3L, intent2.getSrcPortNumber()); |
| 44 | assertEquals(4L, intent2.getSrcMac()); |
| 45 | assertEquals(5L, intent2.getDstSwitchDpid()); |
| 46 | assertEquals(6L, intent2.getDstPortNumber()); |
| 47 | assertEquals(7L, intent2.getDstMac()); |
| 48 | } |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 49 | } |