2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.vtnrsc.router;
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;
23 import java.util.HashSet;
26 import org.junit.Test;
27 import org.onosproject.vtnrsc.RouterGateway;
28 import org.onosproject.vtnrsc.TenantNetworkId;
29 import org.onosproject.vtnrsc.FixedIp;
31 import com.google.common.testing.EqualsTester;
34 * Unit tests for RouterGateway class.
36 public class RouterGatewayTest {
37 final TenantNetworkId networkId1 = TenantNetworkId.networkId("1");
38 final TenantNetworkId networkId2 = TenantNetworkId.networkId("2");
39 final Set<FixedIp> fixedIpSet1 = new HashSet<>();
40 final Set<FixedIp> fixedIpSet2 = new HashSet<>();
43 * Checks that the RouterGateway class is immutable.
46 public void testImmutability() {
47 assertThatClassIsImmutable(RouterGateway.class);
51 * Checks the operation of equals().
54 public void testEquals() {
55 RouterGateway routerGateway1 = RouterGateway.routerGateway(networkId1,
58 RouterGateway routerGateway2 = RouterGateway.routerGateway(networkId1,
61 RouterGateway routerGateway3 = RouterGateway.routerGateway(networkId2,
64 new EqualsTester().addEqualityGroup(routerGateway1, routerGateway2)
65 .addEqualityGroup(routerGateway3).testEquals();
69 * Checks the construction of a RouterGateway object.
72 public void testConstruction() {
73 RouterGateway routerGateway = RouterGateway.routerGateway(networkId1,
76 assertThat(fixedIpSet1, is(notNullValue()));
77 assertThat(fixedIpSet1, is(routerGateway.externalFixedIps()));
78 assertThat(networkId1, is(notNullValue()));
79 assertThat(networkId1, is(routerGateway.networkId()));
80 assertThat(routerGateway.enableSnat(), is(true));