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 | |
| 3 | import static org.junit.Assert.*; |
Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame^] | 4 | import net.onrc.onos.core.intent.ShortestPathIntent; |
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 { |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 18 | @Before |
| 19 | public void setUp() throws Exception { |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | @After |
| 23 | public void tearDown() throws Exception { |
| 24 | } |
| 25 | |
| 26 | @Test |
| 27 | public void test() { |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 28 | Kryo kryo = new Kryo(); |
| 29 | Output output = new Output(1024); |
| 30 | |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 31 | ShortestPathIntent intent1 = |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 32 | new ShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 33 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 34 | kryo.writeObject(output, intent1); |
| 35 | output.close(); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 36 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 37 | Input input = new Input(output.toBytes()); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 38 | ShortestPathIntent intent2 = |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 39 | kryo.readObject(input, ShortestPathIntent.class); |
| 40 | input.close(); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 41 | |
| 42 | assertEquals("1", intent2.getId()); |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 43 | assertEquals(2L, intent2.getSrcSwitchDpid()); |
| 44 | assertEquals(3L, intent2.getSrcPortNumber()); |
| 45 | assertEquals(4L, intent2.getSrcMac()); |
| 46 | assertEquals(5L, intent2.getDstSwitchDpid()); |
| 47 | assertEquals(6L, intent2.getDstPortNumber()); |
| 48 | assertEquals(7L, intent2.getDstMac()); |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 49 | } |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 50 | } |