aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport')
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java76
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java142
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java72
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java66
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java66
5 files changed, 422 insertions, 0 deletions
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java
new file mode 100644
index 00000000..dabe5896
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.vtnrsc.virtualport;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onosproject.vtnrsc.AllowedAddressPair;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Unit tests for AllowedAddressPair class.
+ */
+public class AllowedAddressPairTest {
+
+ final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
+ final IpAddress ip2 = IpAddress.valueOf("192.168.0.2");
+ final MacAddress mac1 = MacAddress.valueOf("fa:16:3e:76:83:88");
+ final MacAddress mac2 = MacAddress.valueOf("aa:16:3e:76:83:88");
+
+ /**
+ * Checks that the AllowedAddressPair class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(AllowedAddressPair.class);
+ }
+
+ /**
+ * Checks the operation of equals().
+ */
+ @Test
+ public void testEquals() {
+ AllowedAddressPair p1 = AllowedAddressPair
+ .allowedAddressPair(ip1, mac1);
+ AllowedAddressPair p2 = AllowedAddressPair
+ .allowedAddressPair(ip1, mac1);
+ AllowedAddressPair p3 = AllowedAddressPair
+ .allowedAddressPair(ip2, mac2);
+ new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
+ .testEquals();
+ }
+
+ /**
+ * Checks the construction of a AllowedAddressPair object.
+ */
+ @Test
+ public void testConstruction() {
+ AllowedAddressPair allowedAddressPair = AllowedAddressPair
+ .allowedAddressPair(ip1, mac1);
+ assertThat(ip1, is(notNullValue()));
+ assertThat(ip1, is(allowedAddressPair.ip()));
+ assertThat(mac1, is(notNullValue()));
+ assertThat(mac1, is(allowedAddressPair.mac()));
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java
new file mode 100644
index 00000000..8a0c8004
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.vtnrsc.virtualport;
+
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.vtnrsc.AllowedAddressPair;
+import org.onosproject.vtnrsc.BindingHostId;
+import org.onosproject.vtnrsc.DefaultVirtualPort;
+import org.onosproject.vtnrsc.FixedIp;
+import org.onosproject.vtnrsc.SecurityGroup;
+import org.onosproject.vtnrsc.SubnetId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.VirtualPort;
+import org.onosproject.vtnrsc.VirtualPortId;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Unit tests for DefaultVirtualPort class.
+ */
+public class DefaultVirtualPortTest {
+
+ private Set<FixedIp> fixedIps;
+ private Map<String, String> propertyMap;
+ private Set<AllowedAddressPair> allowedAddressPairs;
+ private Set<SecurityGroup> securityGroups;
+ private VirtualPortId id1;
+ private VirtualPortId id2;
+ private String macAddressStr = "fa:12:3e:56:ee:a2";
+ private String ipAddress = "10.1.1.1";
+ private String deviceStr = "of:000000000000001";
+ private String tenantIdStr = "123";
+ private String portId1 = "1241";
+ private String portId2 = "1242";
+ private String tenantNetworkId = "1234567";
+ private String subnet = "1212";
+ private String hostIdStr = "fa:e2:3e:56:ee:a2";
+
+ private void initVirtualPortId() {
+ id1 = VirtualPortId.portId(portId1);
+ id2 = VirtualPortId.portId(portId2);
+ }
+
+ private void initFixedIpSet() {
+ FixedIp fixedIp = FixedIp.fixedIp(SubnetId.subnetId(subnet),
+ IpAddress.valueOf(ipAddress));
+ fixedIps = Sets.newHashSet();
+ fixedIps.add(fixedIp);
+ }
+
+ private void initPropertyMap() {
+ String deviceOwner = "james";
+ propertyMap = Maps.newHashMap();
+ propertyMap.putIfAbsent("deviceOwner", deviceOwner);
+ }
+
+ private void initAddressPairSet() {
+ allowedAddressPairs = Sets.newHashSet();
+ AllowedAddressPair allowedAddressPair = AllowedAddressPair
+ .allowedAddressPair(IpAddress.valueOf(ipAddress),
+ MacAddress.valueOf(macAddressStr));
+ allowedAddressPairs.add(allowedAddressPair);
+ }
+
+ private void initSecurityGroupSet() {
+ securityGroups = Sets.newHashSet();
+ }
+
+ /**
+ * Checks that the DefaultVirtualPort class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(SecurityGroup.class);
+ }
+
+ /**
+ * Checks the operation of equals().
+ */
+ @Test
+ public void testEquals() {
+ initVirtualPortId();
+ initFixedIpSet();
+ initPropertyMap();
+ initAddressPairSet();
+ initSecurityGroupSet();
+ TenantNetworkId networkId = TenantNetworkId.networkId(tenantNetworkId);
+ MacAddress macAddress = MacAddress.valueOf(macAddressStr);
+ TenantId tenantId = TenantId.tenantId(tenantIdStr);
+ DeviceId deviceId = DeviceId.deviceId(deviceStr);
+ BindingHostId bindingHostId = BindingHostId.bindingHostId(hostIdStr);
+
+ VirtualPort d1 = new DefaultVirtualPort(id1, networkId, true,
+ propertyMap,
+ VirtualPort.State.ACTIVE,
+ macAddress, tenantId, deviceId,
+ fixedIps, bindingHostId,
+ allowedAddressPairs,
+ securityGroups);
+ VirtualPort d2 = new DefaultVirtualPort(id1, networkId, true,
+ propertyMap,
+ VirtualPort.State.ACTIVE,
+ macAddress, tenantId, deviceId,
+ fixedIps, bindingHostId,
+ allowedAddressPairs,
+ securityGroups);
+ VirtualPort d3 = new DefaultVirtualPort(id2, networkId, true,
+ propertyMap,
+ VirtualPort.State.ACTIVE,
+ macAddress, tenantId, deviceId,
+ fixedIps, bindingHostId,
+ allowedAddressPairs,
+ securityGroups);
+ new EqualsTester().addEqualityGroup(d1, d2).addEqualityGroup(d3)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java
new file mode 100644
index 00000000..1e33da09
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.vtnrsc.virtualport;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onosproject.vtnrsc.FixedIp;
+import org.onosproject.vtnrsc.SubnetId;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Unit tests for FixedIp class.
+ */
+public class FixedIpTest {
+
+ final SubnetId subnetId1 = SubnetId.subnetId("lef11-95w-4er-9c9c");
+ final SubnetId subnetId2 = SubnetId.subnetId("lefaa-95w-4er-9c9c");
+ final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
+ final IpAddress ip2 = IpAddress.valueOf("192.168.1.1");
+
+ /**
+ * Checks that the FixedIp class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(FixedIp.class);
+ }
+
+ /**
+ * Checks the operation of equals().
+ */
+ @Test
+ public void testEquals() {
+ FixedIp fixedIp1 = FixedIp.fixedIp(subnetId1, ip1);
+ FixedIp fixedIp2 = FixedIp.fixedIp(subnetId1, ip1);
+ FixedIp fixedIp3 = FixedIp.fixedIp(subnetId2, ip2);
+ new EqualsTester().addEqualityGroup(fixedIp1, fixedIp2)
+ .addEqualityGroup(fixedIp3).testEquals();
+ }
+
+ /**
+ * Checks the construction of a FixedIp object.
+ */
+ @Test
+ public void testConstruction() {
+ FixedIp fixedIp = FixedIp.fixedIp(subnetId1, ip1);
+ assertThat(ip1, is(notNullValue()));
+ assertThat(ip1, is(fixedIp.ip()));
+ assertThat(subnetId1, is(notNullValue()));
+ assertThat(subnetId1, is(fixedIp.subnetId()));
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java
new file mode 100644
index 00000000..8c04e499
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.vtnrsc.virtualport;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+import org.junit.Test;
+import org.onosproject.vtnrsc.SecurityGroup;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Unit tests for SecurityGroup class.
+ */
+public class SecurityGroupTest {
+
+ final SecurityGroup securityGroup1 = SecurityGroup.securityGroup("1");
+ final SecurityGroup sameAssecurityGroup = SecurityGroup.securityGroup("1");
+ final SecurityGroup securityGroup2 = SecurityGroup.securityGroup("2");
+
+ /**
+ * Checks that the SecurityGroup class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(SecurityGroup.class);
+ }
+
+ /**
+ * Checks the operation of equals().
+ */
+ @Test
+ public void testEquals() {
+ new EqualsTester().addEqualityGroup(securityGroup1, sameAssecurityGroup)
+ .addEqualityGroup(securityGroup2).testEquals();
+ }
+
+ /**
+ * Checks the construction of a SecurityGroup object.
+ */
+ @Test
+ public void testConstruction() {
+ final String securityGroupValue = "1";
+ final SecurityGroup securityGroup = SecurityGroup.securityGroup(securityGroupValue);
+ assertThat(securityGroup, is(notNullValue()));
+ assertThat(securityGroup.securityGroup(), is(securityGroupValue));
+
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java
new file mode 100644
index 00000000..2d63e91c
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.vtnrsc.virtualport;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+import org.junit.Test;
+import org.onosproject.vtnrsc.VirtualPortId;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Unit tests for VirtualPortId class.
+ */
+public class VirtualPortIdTest {
+
+ final VirtualPortId virtualPortId1 = VirtualPortId.portId("1");
+ final VirtualPortId sameAsVirtualPortId1 = VirtualPortId.portId("1");
+ final VirtualPortId virtualPortId2 = VirtualPortId.portId("2");
+
+ /**
+ * Checks that the VirtualPortId class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(VirtualPortId.class);
+ }
+
+ /**
+ * Checks the operation of equals().
+ */
+ @Test
+ public void testEquals() {
+ new EqualsTester().addEqualityGroup(virtualPortId1, sameAsVirtualPortId1)
+ .addEqualityGroup(virtualPortId2).testEquals();
+ }
+
+ /**
+ * Checks the construction of a VirtualPortId object.
+ */
+ @Test
+ public void testConstruction() {
+ final String vPortIdValue = "aaa";
+ final VirtualPortId virtualPortId = VirtualPortId.portId(vPortIdValue);
+ assertThat(virtualPortId, is(notNullValue()));
+ assertThat(virtualPortId.portId(), is(vPortIdValue));
+
+ }
+}