blob: 6f330a7120277c15901cd17dfb9a162b32a4695d [file] [log] [blame]
Thomas Vachuskabf916ea2015-05-20 18:24:34 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16
17package org.onosproject.incubator.net.tunnel;
jcc4a20a5f2015-04-30 15:43:39 +080018
19import static org.hamcrest.MatcherAssert.assertThat;
20import static org.hamcrest.Matchers.is;
21import static org.hamcrest.Matchers.notNullValue;
22import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
23
24import org.junit.Test;
25import org.onlab.packet.IpAddress;
26import org.onosproject.core.DefaultGroupId;
27import org.onosproject.net.provider.ProviderId;
28
29/**
30 * Test of a tunnel event.
31 */
32public class TunnelEventTest {
33 /**
34 * Checks that the Order class is immutable.
35 */
36 @Test
37 public void testImmutability() {
38 assertThatClassIsImmutable(TunnelEvent.class);
39 }
40
41 /**
42 * Checks the operation of equals(), hashCode() and toString() methods.
43 */
44 @Test
45 public void testConstructor() {
46 TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress
47 .valueOf(23423));
48 TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
49 .valueOf(32421));
50 DefaultGroupId groupId = new DefaultGroupId(92034);
51 TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
52 TunnelId tunnelId = TunnelId.valueOf(41654654);
53 ProviderId producerName1 = new ProviderId("producer1", "13");
54 Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
55 Tunnel.State.ACTIVE, groupId, tunnelId,
56 tunnelName);
57 TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1);
58 assertThat(e1, is(notNullValue()));
59 assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED));
60 assertThat(e1.subject(), is(p1));
61 }
62}