Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 16 | package org.onosproject.incubator.net.tunnel; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 17 | |
| 18 | import static org.hamcrest.MatcherAssert.assertThat; |
| 19 | import static org.hamcrest.Matchers.is; |
| 20 | import static org.hamcrest.Matchers.notNullValue; |
| 21 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 22 | |
| 23 | import org.junit.Test; |
| 24 | import org.onlab.packet.IpAddress; |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 25 | import org.onosproject.core.GroupId; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 26 | import org.onosproject.net.provider.ProviderId; |
| 27 | |
| 28 | /** |
| 29 | * Test of a tunnel event. |
| 30 | */ |
| 31 | public class TunnelEventTest { |
| 32 | /** |
| 33 | * Checks that the Order class is immutable. |
| 34 | */ |
| 35 | @Test |
| 36 | public void testImmutability() { |
| 37 | assertThatClassIsImmutable(TunnelEvent.class); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Checks the operation of equals(), hashCode() and toString() methods. |
| 42 | */ |
| 43 | @Test |
| 44 | public void testConstructor() { |
| 45 | TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
| 46 | .valueOf(23423)); |
| 47 | TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
| 48 | .valueOf(32421)); |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 49 | GroupId groupId = new GroupId(92034); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 50 | TunnelName tunnelName = TunnelName.tunnelName("TunnelName"); |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 51 | TunnelId tunnelId = TunnelId.valueOf("41654654"); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 52 | ProviderId producerName1 = new ProviderId("producer1", "13"); |
| 53 | Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, |
| 54 | Tunnel.State.ACTIVE, groupId, tunnelId, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 55 | tunnelName, null); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 56 | TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1); |
| 57 | assertThat(e1, is(notNullValue())); |
| 58 | assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED)); |
| 59 | assertThat(e1.subject(), is(p1)); |
| 60 | } |
| 61 | } |