blob: 5fc4452f5f5483ab3e6a7897591da70f2ba6fdcd [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent;
Toshio Koideebdbb622014-02-12 20:28:38 -08002
Jonathan Harta88fd242014-04-03 11:24:54 -07003import static org.junit.Assert.assertEquals;
Toshio Koide0e4d8d22014-02-14 10:56:10 -08004
Toshio Koideebdbb622014-02-12 20:28:38 -08005import org.junit.After;
6import org.junit.Before;
7import org.junit.Test;
8
Toshio Koide0e4d8d22014-02-14 10:56:10 -08009import com.esotericsoftware.kryo.Kryo;
10import com.esotericsoftware.kryo.io.Input;
11import com.esotericsoftware.kryo.io.Output;
12
Toshio Koide066506e2014-02-20 19:52:09 -080013/**
Yuta HIGUCHId4acc802014-06-19 22:30:31 -070014 * Unit tests for ShortestPathIntent.
Toshio Koide066506e2014-02-20 19:52:09 -080015 */
Toshio Koideebdbb622014-02-12 20:28:38 -080016public class ShortestPathIntentTest {
Ray Milkey269ffb92014-04-03 14:43:30 -070017 @Before
18 public void setUp() throws Exception {
19 }
Toshio Koideebdbb622014-02-12 20:28:38 -080020
Ray Milkey269ffb92014-04-03 14:43:30 -070021 @After
22 public void tearDown() throws Exception {
23 }
Toshio Koideebdbb622014-02-12 20:28:38 -080024
Ray Milkey269ffb92014-04-03 14:43:30 -070025 @Test
26 public void test() {
27 Kryo kryo = new Kryo();
28 Output output = new Output(1024);
Toshio Koide0e4d8d22014-02-14 10:56:10 -080029
Ray Milkey269ffb92014-04-03 14:43:30 -070030 ShortestPathIntent intent1 =
31 new ShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L);
Toshio Koideebdbb622014-02-12 20:28:38 -080032
Ray Milkey269ffb92014-04-03 14:43:30 -070033 kryo.writeObject(output, intent1);
34 output.close();
Toshio Koideebdbb622014-02-12 20:28:38 -080035
Ray Milkey269ffb92014-04-03 14:43:30 -070036 Input input = new Input(output.toBytes());
37 ShortestPathIntent intent2 =
38 kryo.readObject(input, ShortestPathIntent.class);
39 input.close();
Toshio Koideebdbb622014-02-12 20:28:38 -080040
Ray Milkey269ffb92014-04-03 14:43:30 -070041 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 Koideebdbb622014-02-12 20:28:38 -080049}