blob: 85ea36efe8038d4a8ee9b2b28028c2397f5b2f70 [file] [log] [blame]
Carmelo Cascone58136812018-07-19 03:40:16 +02001/*
2 * Copyright 2018-present Open Networking Foundation
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.net.pi.runtime;
18
19import com.google.common.testing.EqualsTester;
20import org.junit.Test;
21import org.onosproject.net.PortNumber;
22
23import static org.hamcrest.MatcherAssert.assertThat;
24import static org.hamcrest.Matchers.is;
25
26/**
27 * Tests for {@link PiPreReplica}.
28 */
29public class PiPreReplicaTest {
30
31 private final long instanceId1 = 1;
32 private final long instanceId2 = 2;
33 private final PortNumber port1 = PortNumber.portNumber(1);
34 private final PortNumber port2 = PortNumber.portNumber(2);
35
36 private final PiPreReplica replica1of1 = new PiPreReplica(port1, instanceId1);
37 private final PiPreReplica sameAsReplica1of1 = new PiPreReplica(port1, instanceId1);
38
39 private final PiPreReplica replica1of2 = new PiPreReplica(port2, instanceId1);
40 private final PiPreReplica sameAsReplica1of2 = new PiPreReplica(port2, instanceId1);
41
42 private final PiPreReplica replica2of2 = new PiPreReplica(port2, instanceId2);
43 private final PiPreReplica sameAsReplica2of2 = new PiPreReplica(port2, instanceId2);
44
45 @Test
46 public void testPiPreReplica() {
47 assertThat("Invalid port", replica1of1.egressPort(), is(port1));
48 assertThat("Invalid instance ID", replica1of1.instanceId(), is(instanceId1));
49 assertThat("Invalid port", replica1of2.egressPort(), is(port2));
50 assertThat("Invalid instance ID", replica1of2.instanceId(), is(instanceId1));
51 }
52
53 @Test
54 public void testEquality() {
55 new EqualsTester()
56 .addEqualityGroup(replica1of1, sameAsReplica1of1)
57 .addEqualityGroup(replica1of2, sameAsReplica1of2)
58 .addEqualityGroup(replica2of2, sameAsReplica2of2)
59 .testEquals();
60 }
61}