diff options
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnrsc')
24 files changed, 4 insertions, 1889 deletions
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java index 39df2cff..7915ce08 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java @@ -43,6 +43,8 @@ public final class DefaultFlowClassifier implements FlowClassifier { private static final int NULL_PORT = 0; private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "FlowClassifier id can not be null."; private static final String TENANT_ID_NOT_NULL = "Tenant id can not be null."; + private static final String NAME_NOT_NULL = "Name can not be null."; + private static final String ETHER_TYPE_NOT_NULL = "Ether Type can not be null."; /** * Constructor to create default flow classifier. @@ -160,11 +162,9 @@ public final class DefaultFlowClassifier implements FlowClassifier { private FlowClassifierId flowClassifierId; private TenantId tenantId; private String name; - private boolean isFlowClassifierNameSet = false; private String description; private boolean isFlowClassifierDescriptionSet = false; private String etherType; - private boolean isEtherTypeSet = false; private String protocol; private boolean isProtocolSet = false; private int minSrcPortRange; @@ -189,9 +189,9 @@ public final class DefaultFlowClassifier implements FlowClassifier { checkNotNull(flowClassifierId, FLOW_CLASSIFIER_ID_NOT_NULL); checkNotNull(tenantId, TENANT_ID_NOT_NULL); - String name = null; + checkNotNull(name, NAME_NOT_NULL); + checkNotNull(etherType, ETHER_TYPE_NOT_NULL); String description = null; - String etherType = null; String protocol = null; int minSrcPortRange = NULL_PORT; int maxSrcPortRange = NULL_PORT; @@ -202,15 +202,9 @@ public final class DefaultFlowClassifier implements FlowClassifier { VirtualPortId srcPort = null; VirtualPortId dstPort = null; - if (isFlowClassifierNameSet) { - name = this.name; - } if (isFlowClassifierDescriptionSet) { description = this.description; } - if (isEtherTypeSet) { - etherType = this.etherType; - } if (isProtocolSet) { protocol = this.protocol; } @@ -259,7 +253,6 @@ public final class DefaultFlowClassifier implements FlowClassifier { @Override public Builder setName(String name) { this.name = name; - this.isFlowClassifierNameSet = true; return this; } @@ -273,7 +266,6 @@ public final class DefaultFlowClassifier implements FlowClassifier { @Override public Builder setEtherType(String etherType) { this.etherType = etherType; - this.isEtherTypeSet = true; return this; } diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java deleted file mode 100644 index 6b0d9a64..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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.flowclassifier; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -import org.junit.Test; -import org.onlab.packet.IpPrefix; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.DefaultFlowClassifier; -import org.onosproject.vtnrsc.FlowClassifierId; -import org.onosproject.vtnrsc.VirtualPortId; -import org.onosproject.vtnrsc.FlowClassifier; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for DefaultFlowClassifier class. - */ -public class DefaultFlowClassifierTest { - /** - * Checks that the DefaultFlowClassifier class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultFlowClassifier.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - // Create same two flow classifier objects. - final String name = "FlowClassifier1"; - final String description = "FlowClassifier1"; - final String ethType = "IPv4"; - final String protocol = "tcp"; - final int minSrcPortRange = 5; - final int maxSrcPortRange = 10; - final int minDstPortRange = 5; - final int maxDstPortRange = 10; - final FlowClassifierId flowClassifierId = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId = TenantId.tenantId("1"); - final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0"); - final IpPrefix dstIpPrefix = IpPrefix.valueOf("10.10.10.10/0"); - final VirtualPortId virtualSrcPort = VirtualPortId.portId("1"); - final VirtualPortId virtualDstPort = VirtualPortId.portId("2"); - - DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder(); - final FlowClassifier flowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) - .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) - .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) - .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) - .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); - - flowClassifierBuilder = new DefaultFlowClassifier.Builder(); - final FlowClassifier sameAsFlowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) - .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) - .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) - .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) - .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); - - // Create different classifier object. - final String name2 = "FlowClassifier2"; - final String description2 = "FlowClassifier2"; - final String ethType2 = "IPv6"; - final String protocol2 = "udp"; - final int minSrcPortRange2 = 5; - final int maxSrcPortRange2 = 10; - final int minDstPortRange2 = 5; - final int maxDstPortRange2 = 10; - final FlowClassifierId flowClassifierId2 = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId2 = TenantId.tenantId("2"); - final IpPrefix srcIpPrefix2 = IpPrefix.valueOf("0.0.0.0/0"); - final IpPrefix dstIpPrefix2 = IpPrefix.valueOf("10.10.10.10/0"); - final VirtualPortId virtualSrcPort2 = VirtualPortId.portId("3"); - final VirtualPortId virtualDstPort2 = VirtualPortId.portId("4"); - - DefaultFlowClassifier.Builder flowClassifierBuilder3 = new DefaultFlowClassifier.Builder(); - final FlowClassifier flowClassifier2 = flowClassifierBuilder3.setFlowClassifierId(flowClassifierId2) - .setTenantId(tenantId2).setName(name2).setDescription(description2).setEtherType(ethType2) - .setProtocol(protocol2).setMinSrcPortRange(minSrcPortRange2).setMaxSrcPortRange(maxSrcPortRange2) - .setMinDstPortRange(minDstPortRange2).setMaxDstPortRange(maxDstPortRange2).setSrcIpPrefix(srcIpPrefix2) - .setDstIpPrefix(dstIpPrefix2).setSrcPort(virtualSrcPort2).setDstPort(virtualDstPort2).build(); - - new EqualsTester().addEqualityGroup(flowClassifier1, sameAsFlowClassifier1).addEqualityGroup(flowClassifier2) - .testEquals(); - } - - /** - * Checks the construction of a DefaultFlowClassifier object. - */ - @Test - public void testConstruction() { - final String name = "FlowClassifier"; - final String description = "FlowClassifier"; - final String ethType = "IPv4"; - final String protocol = "tcp"; - final int minSrcPortRange = 5; - final int maxSrcPortRange = 10; - final int minDstPortRange = 5; - final int maxDstPortRange = 10; - final FlowClassifierId flowClassifierId = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId = TenantId.tenantId("1"); - final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0"); - final IpPrefix dstIpPrefix = IpPrefix.valueOf("10.10.10.10/0"); - final VirtualPortId virtualSrcPort = VirtualPortId.portId("1"); - final VirtualPortId virtualDstPort = VirtualPortId.portId("2"); - - DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder(); - final FlowClassifier flowClassifier = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) - .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) - .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) - .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) - .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); - - assertThat(flowClassifierId, is(flowClassifier.flowClassifierId())); - assertThat(tenantId, is(flowClassifier.tenantId())); - assertThat(name, is(flowClassifier.name())); - assertThat(description, is(flowClassifier.description())); - assertThat(ethType, is(flowClassifier.etherType())); - assertThat(protocol, is(flowClassifier.protocol())); - assertThat(minSrcPortRange, is(flowClassifier.minSrcPortRange())); - assertThat(maxSrcPortRange, is(flowClassifier.maxSrcPortRange())); - assertThat(minDstPortRange, is(flowClassifier.minDstPortRange())); - assertThat(maxDstPortRange, is(flowClassifier.maxDstPortRange())); - assertThat(srcIpPrefix, is(flowClassifier.srcIpPrefix())); - assertThat(dstIpPrefix, is(flowClassifier.dstIpPrefix())); - assertThat(virtualSrcPort, is(flowClassifier.srcPort())); - assertThat(virtualDstPort, is(flowClassifier.dstPort())); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java deleted file mode 100644 index 4f521836..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.flowclassifier; - -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.FlowClassifierId; - -import com.google.common.testing.EqualsTester; -import java.util.UUID; - -/** - * Unit tests for FlowClassifierId class. - */ -public class FlowClassifierIdTest { - - final FlowClassifierId flowClassifierId1 = FlowClassifierId - .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final FlowClassifierId sameAsFlowClassifierId1 = FlowClassifierId - .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final FlowClassifierId flowClassifierId2 = FlowClassifierId - .of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); - - /** - * Checks that the FlowClassifierId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(FlowClassifierId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(flowClassifierId1, sameAsFlowClassifierId1) - .addEqualityGroup(flowClassifierId2).testEquals(); - } - - /** - * Checks the construction of a FlowClassifierId object. - */ - @Test - public void testConstruction() { - final String flowClassifierIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; - final FlowClassifierId flowClassifierId = FlowClassifierId.of(flowClassifierIdValue); - assertThat(flowClassifierId, is(notNullValue())); - assertThat(flowClassifierId.value(), is(UUID.fromString(flowClassifierIdValue))); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java deleted file mode 100644 index b9ce73d8..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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.flowclassifier; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -import org.junit.Test; -import java.util.List; -import java.util.LinkedList; - -import org.onosproject.vtnrsc.PortChainId; -import org.onosproject.vtnrsc.PortPairGroupId; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.FlowClassifierId; -import org.onosproject.vtnrsc.PortChain; -import org.onosproject.vtnrsc.DefaultPortChain; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for DefaultPortChain class. - */ -public class DefaultPortChainTest { - /** - * Checks that the DefaultPortChain class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultPortChain.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - // Create same two port chain objects. - final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId = TenantId.tenantId("1"); - final String name = "PortChain1"; - final String description = "PortChain1"; - // create list of Port Pair Groups. - final List<PortPairGroupId> portPairGroups = new LinkedList<PortPairGroupId>(); - PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairGroups.add(portPairGroupId); - portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af"); - portPairGroups.add(portPairGroupId); - // create list of Flow classifiers. - final List<FlowClassifierId> flowClassifiers = new LinkedList<FlowClassifierId>(); - FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae"); - flowClassifiers.add(flowClassifierId); - flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af"); - flowClassifiers.add(flowClassifierId); - - DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder(); - final PortChain portChain1 = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name) - .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers) - .build(); - - portChainBuilder = new DefaultPortChain.Builder(); - final PortChain samePortChain1 = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name) - .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers) - .build(); - - // Create different port chain object. - final PortChainId portChainId2 = PortChainId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId2 = TenantId.tenantId("2"); - final String name2 = "PortChain2"; - final String description2 = "PortChain2"; - // create list of Port Pair Groups. - final List<PortPairGroupId> portPairGroups2 = new LinkedList<PortPairGroupId>(); - portPairGroupId = PortPairGroupId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairGroups2.add(portPairGroupId); - portPairGroupId = PortPairGroupId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3af"); - portPairGroups2.add(portPairGroupId); - // create list of Flow classifiers. - final List<FlowClassifierId> flowClassifiers2 = new LinkedList<FlowClassifierId>(); - flowClassifierId = FlowClassifierId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3ae"); - flowClassifiers2.add(flowClassifierId); - flowClassifierId = FlowClassifierId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3af"); - flowClassifiers2.add(flowClassifierId); - - portChainBuilder = new DefaultPortChain.Builder(); - final PortChain portChain2 = portChainBuilder.setId(portChainId2).setTenantId(tenantId2).setName(name2) - .setDescription(description2).setPortPairGroups(portPairGroups2).setFlowClassifiers(flowClassifiers2) - .build(); - - new EqualsTester().addEqualityGroup(portChain1, samePortChain1).addEqualityGroup(portChain2).testEquals(); - } - - /** - * Checks the construction of a DefaultPortChain object. - */ - @Test - public void testConstruction() { - final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId = TenantId.tenantId("1"); - final String name = "PortChain"; - final String description = "PortChain"; - // create list of Port Pair Groups. - final List<PortPairGroupId> portPairGroups = new LinkedList<PortPairGroupId>(); - PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairGroups.add(portPairGroupId); - portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af"); - portPairGroups.add(portPairGroupId); - // create list of Flow classifiers. - final List<FlowClassifierId> flowClassifiers = new LinkedList<FlowClassifierId>(); - FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae"); - flowClassifiers.add(flowClassifierId); - flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af"); - flowClassifiers.add(flowClassifierId); - - DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder(); - final PortChain portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name) - .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers) - .build(); - - assertThat(portChainId, is(portChain.portChainId())); - assertThat(tenantId, is(portChain.tenantId())); - assertThat(name, is(portChain.name())); - assertThat(description, is(portChain.description())); - assertThat(portPairGroups, is(portChain.portPairGroups())); - assertThat(flowClassifiers, is(portChain.flowClassifiers())); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java deleted file mode 100644 index a87bdb99..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.portchain; - -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.PortChainId; - -import com.google.common.testing.EqualsTester; -import java.util.UUID; - -/** - * Unit tests for PortChainId class. - */ -public class PortChainIdTest { - - final PortChainId portChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final PortChainId sameAsPortChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final PortChainId portChainId2 = PortChainId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); - - /** - * Checks that the PortChainId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(PortChainId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(portChainId1, sameAsPortChainId1).addEqualityGroup(portChainId2) - .testEquals(); - } - - /** - * Checks the construction of a PortChainId object. - */ - @Test - public void testConstruction() { - final String portChainIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; - final PortChainId portChainId = PortChainId.of(portChainIdValue); - assertThat(portChainId, is(notNullValue())); - assertThat(portChainId.value(), is(UUID.fromString(portChainIdValue))); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java deleted file mode 100644 index 91e7ab37..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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.flowclassifier; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -import org.junit.Test; - -import org.onosproject.vtnrsc.PortPairId; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.PortPair; -import org.onosproject.vtnrsc.DefaultPortPair; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for DefaultPortPair class. - */ -public class DefaultPortPairTest { - /** - * Checks that the DefaultPortPair class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultPortPair.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - // Create same two port pair objects. - final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId = TenantId.tenantId("1"); - final String name = "PortPair1"; - final String description = "PortPair1"; - final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1"; - final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345"; - - DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder(); - final PortPair portPair1 = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name) - .setDescription(description).setIngress(ingress).setEgress(egress).build(); - - portPairBuilder = new DefaultPortPair.Builder(); - final PortPair samePortPair1 = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name) - .setDescription(description).setIngress(ingress).setEgress(egress).build(); - - // Create different port pair object. - final PortPairId portPairId2 = PortPairId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId2 = TenantId.tenantId("2"); - final String name2 = "PortPair2"; - final String description2 = "PortPair2"; - final String ingress2 = "d5555555-24fc-4fae-af4b-321c5e2eb3d1"; - final String egress2 = "a6666666-4a56-2a6e-cd3a-9dee4e2ec345"; - - portPairBuilder = new DefaultPortPair.Builder(); - final PortPair portPair2 = portPairBuilder.setId(portPairId2).setTenantId(tenantId2).setName(name2) - .setDescription(description2).setIngress(ingress2).setEgress(egress2).build(); - - new EqualsTester().addEqualityGroup(portPair1, samePortPair1).addEqualityGroup(portPair2).testEquals(); - } - - /** - * Checks the construction of a DefaultPortPair object. - */ - @Test - public void testConstruction() { - final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId = TenantId.tenantId("1"); - final String name = "PortPair"; - final String description = "PortPair"; - final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1"; - final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345"; - - DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder(); - final PortPair portPair = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name) - .setDescription(description).setIngress(ingress).setEgress(egress).build(); - - assertThat(portPairId, is(portPair.portPairId())); - assertThat(tenantId, is(portPair.tenantId())); - assertThat(name, is(portPair.name())); - assertThat(description, is(portPair.description())); - assertThat(ingress, is(portPair.ingress())); - assertThat(egress, is(portPair.egress())); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java deleted file mode 100644 index f176089e..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.portpair; - -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.PortPairId; - -import com.google.common.testing.EqualsTester; -import java.util.UUID; - -/** - * Unit tests for PortPairId class. - */ -public class PortPairIdTest { - - final PortPairId portPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final PortPairId sameAsPortPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final PortPairId portPairId2 = PortPairId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); - - /** - * Checks that the PortPairId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(PortPairId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(portPairId1, sameAsPortPairId1).addEqualityGroup(portPairId2).testEquals(); - } - - /** - * Checks the construction of a PortPairId object. - */ - @Test - public void testConstruction() { - final String portPairIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; - final PortPairId portPairId = PortPairId.of(portPairIdValue); - assertThat(portPairId, is(notNullValue())); - assertThat(portPairId.value(), is(UUID.fromString(portPairIdValue))); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java deleted file mode 100644 index 2528fb29..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.flowclassifier; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -import org.junit.Test; -import java.util.List; -import java.util.LinkedList; - -import org.onosproject.vtnrsc.PortPairGroupId; -import org.onosproject.vtnrsc.PortPairId; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.PortPairGroup; -import org.onosproject.vtnrsc.DefaultPortPairGroup; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for DefaultPortPairGroup class. - */ -public class DefaultPortPairGroupTest { - /** - * Checks that the DefaultPortPairGroup class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultPortPairGroup.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - // Create same two port-pair-group objects. - final PortPairGroupId portPairGroupId = PortPairGroupId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId = TenantId.tenantId("1"); - final String name = "PortPairGroup1"; - final String description = "PortPairGroup1"; - // create port-pair-id list - final List<PortPairId> portPairList = new LinkedList<PortPairId>(); - PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairList.add(portPairId); - portPairId = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairList.add(portPairId); - - DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder(); - final PortPairGroup portPairGroup1 = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId) - .setName(name).setDescription(description).setPortPairs(portPairList).build(); - - portPairGroupBuilder = new DefaultPortPairGroup.Builder(); - final PortPairGroup samePortPairGroup1 = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId) - .setName(name).setDescription(description).setPortPairs(portPairList).build(); - - // Create different port-pair-group object. - final PortPairGroupId portPairGroupId2 = PortPairGroupId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId2 = TenantId.tenantId("2"); - final String name2 = "PortPairGroup2"; - final String description2 = "PortPairGroup2"; - // create port-pair-id list - final List<PortPairId> portPairList2 = new LinkedList<PortPairId>(); - portPairId = PortPairId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairList2.add(portPairId); - portPairId = PortPairId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairList2.add(portPairId); - - portPairGroupBuilder = new DefaultPortPairGroup.Builder(); - final PortPairGroup portPairGroup2 = portPairGroupBuilder.setId(portPairGroupId2).setTenantId(tenantId2) - .setName(name2).setDescription(description2).setPortPairs(portPairList2).build(); - - new EqualsTester().addEqualityGroup(portPairGroup1, samePortPairGroup1).addEqualityGroup(portPairGroup2) - .testEquals(); - } - - /** - * Checks the construction of a DefaultPortPairGroup object. - */ - @Test - public void testConstruction() { - final PortPairGroupId portPairGroupId = PortPairGroupId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); - final TenantId tenantId = TenantId.tenantId("1"); - final String name = "PortPairGroup"; - final String description = "PortPairGroup"; - // create port-pair-id list - final List<PortPairId> portPairList = new LinkedList<PortPairId>(); - PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairList.add(portPairId); - portPairId = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae"); - portPairList.add(portPairId); - - DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder(); - final PortPairGroup portPairGroup = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId) - .setName(name).setDescription(description).setPortPairs(portPairList).build(); - - assertThat(portPairGroupId, is(portPairGroup.portPairGroupId())); - assertThat(tenantId, is(portPairGroup.tenantId())); - assertThat(name, is(portPairGroup.name())); - assertThat(description, is(portPairGroup.description())); - assertThat(portPairList, is(portPairGroup.portPairs())); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java deleted file mode 100644 index 25db9d2e..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.portpairgroup; - -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.PortPairGroupId; - -import com.google.common.testing.EqualsTester; -import java.util.UUID; - -/** - * Unit tests for PortPairGroupId class. - */ -public class PortPairGroupIdTest { - - final PortPairGroupId portPairGroupId1 = PortPairGroupId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final PortPairGroupId sameAsPortPairGroupId1 = PortPairGroupId - .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); - final PortPairGroupId portPairGroupId2 = PortPairGroupId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); - - /** - * Checks that the PortPairGroupId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(PortPairGroupId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(portPairGroupId1, sameAsPortPairGroupId1) - .addEqualityGroup(portPairGroupId2).testEquals(); - } - - /** - * Checks the construction of a PortPairGroupId object. - */ - @Test - public void testConstruction() { - final String portPairGroupIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; - final PortPairGroupId portPairGroupId = PortPairGroupId.of(portPairGroupIdValue); - assertThat(portPairGroupId, is(notNullValue())); - assertThat(portPairGroupId.value(), is(UUID.fromString(portPairGroupIdValue))); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java deleted file mode 100644 index ce6b6c00..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.router; - -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 java.util.HashSet; -import java.util.Set; - -import org.junit.Test; -import org.onosproject.vtnrsc.RouterGateway; -import org.onosproject.vtnrsc.TenantNetworkId; -import org.onosproject.vtnrsc.FixedIp; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for RouterGateway class. - */ -public class RouterGatewayTest { - final TenantNetworkId networkId1 = TenantNetworkId.networkId("1"); - final TenantNetworkId networkId2 = TenantNetworkId.networkId("2"); - final Set<FixedIp> fixedIpSet1 = new HashSet<>(); - final Set<FixedIp> fixedIpSet2 = new HashSet<>(); - - /** - * Checks that the RouterGateway class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(RouterGateway.class); - } - - /** - * Checks the operation of equals(). - */ - @Test - public void testEquals() { - RouterGateway routerGateway1 = RouterGateway.routerGateway(networkId1, - true, - fixedIpSet1); - RouterGateway routerGateway2 = RouterGateway.routerGateway(networkId1, - true, - fixedIpSet1); - RouterGateway routerGateway3 = RouterGateway.routerGateway(networkId2, - true, - fixedIpSet2); - new EqualsTester().addEqualityGroup(routerGateway1, routerGateway2) - .addEqualityGroup(routerGateway3).testEquals(); - } - - /** - * Checks the construction of a RouterGateway object. - */ - @Test - public void testConstruction() { - RouterGateway routerGateway = RouterGateway.routerGateway(networkId1, - true, - fixedIpSet1); - assertThat(fixedIpSet1, is(notNullValue())); - assertThat(fixedIpSet1, is(routerGateway.externalFixedIps())); - assertThat(networkId1, is(notNullValue())); - assertThat(networkId1, is(routerGateway.networkId())); - assertThat(routerGateway.enableSnat(), is(true)); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java deleted file mode 100644 index 3751c11a..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.router; - -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.RouterId; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for RouterId class. - */ -public class RouterIdTest { - final RouterId routerId1 = RouterId.valueOf("1"); - final RouterId sameAsRouterId1 = RouterId.valueOf("1"); - final RouterId routerId2 = RouterId.valueOf("2"); - - /** - * Checks that the RouterId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(RouterId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(routerId1, sameAsRouterId1).addEqualityGroup(routerId2) - .testEquals(); - } - - /** - * Checks the construction of a RouterId object. - */ - @Test - public void testConstruction() { - final String routerIdValue = "s"; - final RouterId routerId = RouterId.valueOf(routerIdValue); - assertThat(routerId, is(notNullValue())); - assertThat(routerId.routerId(), is(routerIdValue)); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultAllocationPoolTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultAllocationPoolTest.java deleted file mode 100644 index 4ce4def2..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultAllocationPoolTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.subnet; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -import org.junit.Test; -import org.onlab.packet.IpAddress; -import org.onosproject.vtnrsc.AllocationPool; -import org.onosproject.vtnrsc.DefaultAllocationPool; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for DefaultAllocationPool class. - */ -public class DefaultAllocationPoolTest { - - final IpAddress startIP1 = IpAddress.valueOf("192.168.1.1"); - final IpAddress startIP2 = IpAddress.valueOf("192.168.1.2"); - final IpAddress endIP1 = IpAddress.valueOf("192.168.1.1"); - final IpAddress endIP2 = IpAddress.valueOf("192.168.1.2"); - - /** - * Checks that the DefaultAllocationPool class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultAllocationPool.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - AllocationPool pool1 = new DefaultAllocationPool(startIP1, endIP1); - AllocationPool pool2 = new DefaultAllocationPool(startIP1, endIP1); - AllocationPool pool3 = new DefaultAllocationPool(startIP2, endIP2); - new EqualsTester().addEqualityGroup(pool1, pool2) - .addEqualityGroup(pool3).testEquals(); - } - - /** - * Checks the construction of a DefaultAllocationPool object. - */ - @Test - public void testConstruction() { - final AllocationPool apool = new DefaultAllocationPool(startIP1, endIP1); - assertThat(startIP1, is(apool.startIp())); - assertThat(endIP1, is(apool.endIp())); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultHostRouteTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultHostRouteTest.java deleted file mode 100644 index 2f751742..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultHostRouteTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.subnet; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -import org.junit.Test; -import org.onlab.packet.IpAddress; -import org.onlab.packet.IpPrefix; -import org.onosproject.vtnrsc.DefaultHostRoute; -import org.onosproject.vtnrsc.HostRoute; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for DefaultHostRoute class. - */ -public class DefaultHostRouteTest { - final IpAddress nexthop1 = IpAddress.valueOf("192.168.1.1"); - final IpAddress nexthop2 = IpAddress.valueOf("192.168.1.2"); - final IpPrefix destination1 = IpPrefix.valueOf("1.1.1.1/1"); - final IpPrefix destination2 = IpPrefix.valueOf("1.1.1.1/2"); - - /** - * Checks that the DefaultHostRoute class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultHostRoute.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - HostRoute route1 = new DefaultHostRoute(nexthop1, destination1); - HostRoute route2 = new DefaultHostRoute(nexthop1, destination1); - HostRoute route3 = new DefaultHostRoute(nexthop2, destination2); - new EqualsTester().addEqualityGroup(route1, route2) - .addEqualityGroup(route3).testEquals(); - } - - /** - * Checks the construction of a DefaultHostRoute object. - */ - @Test - public void testConstruction() { - final HostRoute host = new DefaultHostRoute(nexthop1, destination1); - assertThat(nexthop1, is(host.nexthop())); - assertThat(destination1, is(host.destination())); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/SubnetIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/SubnetIdTest.java deleted file mode 100644 index d18dd41a..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/SubnetIdTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.subnet; - -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.SubnetId; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for SubnetId class. - */ -public class SubnetIdTest { - - final SubnetId subnetId1 = SubnetId.subnetId("1"); - final SubnetId sameAsSubnetId1 = SubnetId.subnetId("1"); - final SubnetId subnetId2 = SubnetId.subnetId("2"); - - /** - * Checks that the SubnetId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(SubnetId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(subnetId1, sameAsSubnetId1).addEqualityGroup(subnetId2) - .testEquals(); - } - - /** - * Checks the construction of a SubnetId object. - */ - @Test - public void testConstruction() { - final String subnetIdValue = "s"; - final SubnetId subnetId = SubnetId.subnetId(subnetIdValue); - assertThat(subnetId, is(notNullValue())); - assertThat(subnetId.subnetId(), is(subnetIdValue)); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/DefaultNeutronNetworkTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/DefaultNeutronNetworkTest.java deleted file mode 100644 index 742d5933..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/DefaultNeutronNetworkTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.tenantnetwork; - -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -import org.junit.Test; -import org.onosproject.vtnrsc.DefaultTenantNetwork; -import org.onosproject.vtnrsc.PhysicalNetwork; -import org.onosproject.vtnrsc.SegmentationId; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.TenantNetwork; -import org.onosproject.vtnrsc.TenantNetworkId; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for DefaultNeutronNetwork class. - */ -public class DefaultNeutronNetworkTest { - - private String networkIdStr1 = "123"; - private String networkIdStr2 = "234"; - private String physicalNetworkStr = "1234"; - private String tenantIdStr = "345"; - private String segmentationIdStr = "1"; - private String name = "456"; - - /** - * Checks that the DefaultNeutronNetwork class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultTenantNetwork.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquality() { - TenantNetworkId networkid1 = TenantNetworkId.networkId(networkIdStr1); - TenantNetworkId networkid2 = TenantNetworkId.networkId(networkIdStr2); - PhysicalNetwork physicalNetwork = PhysicalNetwork - .physicalNetwork(physicalNetworkStr); - TenantId tenantId = TenantId.tenantId(tenantIdStr); - SegmentationId segmentationID = SegmentationId - .segmentationId(segmentationIdStr); - TenantNetwork p1 = new DefaultTenantNetwork(networkid1, name, false, - TenantNetwork.State.ACTIVE, - false, tenantId, false, - TenantNetwork.Type.LOCAL, - physicalNetwork, - segmentationID); - TenantNetwork p2 = new DefaultTenantNetwork(networkid1, name, false, - TenantNetwork.State.ACTIVE, - false, tenantId, false, - TenantNetwork.Type.LOCAL, - physicalNetwork, - segmentationID); - TenantNetwork p3 = new DefaultTenantNetwork(networkid2, name, false, - TenantNetwork.State.ACTIVE, - false, tenantId, false, - TenantNetwork.Type.LOCAL, - physicalNetwork, - segmentationID); - new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3) - .testEquals(); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/PhysicalNetworkTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/PhysicalNetworkTest.java deleted file mode 100644 index e101795e..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/PhysicalNetworkTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.tenantnetwork; - -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.PhysicalNetwork; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for PhysicalNetwork class. - */ -public class PhysicalNetworkTest { - - final PhysicalNetwork physicalNetwork1 = PhysicalNetwork.physicalNetwork("1"); - final PhysicalNetwork sameAsPhysicalNetwork1 = PhysicalNetwork.physicalNetwork("1"); - final PhysicalNetwork physicalNetwork2 = PhysicalNetwork.physicalNetwork("2"); - - /** - * Checks that the PhysicalNetwork class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(PhysicalNetwork.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(physicalNetwork1, sameAsPhysicalNetwork1) - .addEqualityGroup(physicalNetwork2).testEquals(); - } - - /** - * Checks the construction of a PhysicalNetwork object. - */ - @Test - public void testConstruction() { - final String physicalNetworkValue = "s"; - final PhysicalNetwork physicalNetwork = PhysicalNetwork - .physicalNetwork(physicalNetworkValue); - assertThat(physicalNetwork, is(notNullValue())); - assertThat(physicalNetwork.physicalNetwork(), is(physicalNetworkValue)); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/SegmentationIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/SegmentationIdTest.java deleted file mode 100644 index dea7baf6..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/SegmentationIdTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.tenantnetwork; - -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.SegmentationId; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for SegmentationId class. - */ -public class SegmentationIdTest { - - final SegmentationId segmentationID1 = SegmentationId.segmentationId("1"); - final SegmentationId sameAsSegmentationID1 = SegmentationId.segmentationId("1"); - final SegmentationId segmentationID2 = SegmentationId.segmentationId("2"); - - /** - * Checks that the SegmentationId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(SegmentationId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(segmentationID1, sameAsSegmentationID1) - .addEqualityGroup(segmentationID2).testEquals(); - } - - /** - * Checks the construction of a segmentationId object. - */ - @Test - public void testConstruction() { - final String segmentationIdValue = "s"; - final SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdValue); - assertThat(segmentationId, is(notNullValue())); - assertThat(segmentationId.segmentationId(), is(segmentationIdValue)); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantIdTest.java deleted file mode 100644 index e9216383..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantIdTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.tenantnetwork; - -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.TenantId; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for TenantId class. - */ -public class TenantIdTest { - - final TenantId tenantId1 = TenantId.tenantId("1"); - final TenantId sameAsTenantId1 = TenantId.tenantId("1"); - final TenantId tenantId2 = TenantId.tenantId("2"); - - /** - * Checks that the TenantId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(TenantId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(tenantId1, sameAsTenantId1).addEqualityGroup(tenantId2) - .testEquals(); - } - - /** - * Checks the construction of a TenantId object. - */ - @Test - public void testConstruction() { - final String tenantIdValue = "s"; - final TenantId tenantId = TenantId.tenantId(tenantIdValue); - assertThat(tenantId, is(notNullValue())); - assertThat(tenantId.tenantId(), is(tenantIdValue)); - } -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkIdTest.java deleted file mode 100644 index 8271b51c..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkIdTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.tenantnetwork; - -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.TenantNetworkId; - -import com.google.common.testing.EqualsTester; - -/** - * Unit tests for TenantNetworkId class. - */ -public class TenantNetworkIdTest { - - final TenantNetworkId networkId1 = TenantNetworkId.networkId("1"); - final TenantNetworkId sameAsnetworkId1 = TenantNetworkId.networkId("1"); - final TenantNetworkId networkId2 = TenantNetworkId.networkId("2"); - - /** - * Checks that the TenantNetworkId class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(TenantNetworkId.class); - } - - /** - * Checks the operation of equals() methods. - */ - @Test - public void testEquals() { - new EqualsTester().addEqualityGroup(networkId1, sameAsnetworkId1) - .addEqualityGroup(networkId2).testEquals(); - } - - /** - * Checks the construction of a TenantNetworkId object. - */ - @Test - public void testConstruction() { - final String networkIdValue = "s"; - final TenantNetworkId networkId = TenantNetworkId.networkId(networkIdValue); - assertThat(networkId, is(notNullValue())); - assertThat(networkId.networkId(), is(networkIdValue)); - } -} 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 deleted file mode 100644 index dabe5896..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8a0c8004..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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 deleted file mode 100644 index 1e33da09..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8c04e499..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2d63e91c..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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)); - - } -} |