blob: 28669a21f126a2cd455418c03847ee374d914e9e [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -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 */
Thomas Vachuskabf916ea2015-05-20 18:24:34 -070016package org.onosproject.incubator.net.tunnel;
jcc4a20a5f2015-04-30 15:43:39 +080017
18import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.is;
20import static org.hamcrest.Matchers.notNullValue;
21import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
22
23import org.junit.Test;
24import org.onlab.packet.IpAddress;
25import org.onosproject.core.DefaultGroupId;
26import org.onosproject.net.provider.ProviderId;
27
28/**
29 * Test of a tunnel event.
30 */
31public 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));
49 DefaultGroupId groupId = new DefaultGroupId(92034);
50 TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
51 TunnelId tunnelId = TunnelId.valueOf(41654654);
52 ProviderId producerName1 = new ProviderId("producer1", "13");
53 Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
54 Tunnel.State.ACTIVE, groupId, tunnelId,
samuel7a5691a2015-05-23 00:36:32 +080055 tunnelName, null);
jcc4a20a5f2015-04-30 15:43:39 +080056 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}