aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps')
-rw-r--r--framework/src/onos/apps/routing/pom.xml2
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java85
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java10
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java20
-rw-r--r--framework/src/onos/apps/vtn/app/pom.xml72
-rw-r--r--framework/src/onos/apps/vtn/pom.xml6
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/pom.xml70
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java148
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java140
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java102
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java117
11 files changed, 631 insertions, 141 deletions
diff --git a/framework/src/onos/apps/routing/pom.xml b/framework/src/onos/apps/routing/pom.xml
index c461ef3f..2882f52e 100644
--- a/framework/src/onos/apps/routing/pom.xml
+++ b/framework/src/onos/apps/routing/pom.xml
@@ -43,7 +43,7 @@
<version>${project.version}</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-thirdparty</artifactId>
</dependency>
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
index f2d5b5e2..a3cd6875 100644
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
+++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
@@ -15,24 +15,25 @@
*/
package org.onosproject.sdnip;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.Key;
-import org.onosproject.routing.IntentSynchronizationService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static java.util.concurrent.Executors.newSingleThreadExecutor;
+import static org.onlab.util.Tools.groupedThreads;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
-import static java.util.concurrent.Executors.newSingleThreadExecutor;
-import static org.onlab.util.Tools.groupedThreads;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentService;
+import org.onosproject.net.intent.IntentState;
+import org.onosproject.net.intent.Key;
+import org.onosproject.routing.IntentSynchronizationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Synchronizes intents between the in-memory intent store and the
@@ -97,55 +98,30 @@ public class IntentSynchronizer implements IntentSynchronizationService {
synchronized (this) {
// Stop the thread(s)
intentsSynchronizerExecutor.shutdownNow();
+ log.info("Intents Synchronizer Executor shutdown completed");
- //
- // Withdraw all app related intents
- //
- if (!isElectedLeader) {
- return; // Nothing to do: not the leader anymore
- }
+ }
+ }
- //
- // NOTE: We don't withdraw the intents during shutdown, because
- // it creates flux in the data plane during switchover.
- //
-
- /*
- //
- // Build a batch operation to withdraw all intents from this
- // application.
- //
- log.debug("Intent Synchronizer shutdown: " +
- "withdrawing all intents...");
- IntentOperations.Builder builder = IntentOperations.builder(appId);
- for (Intent intent : intentService.getIntents()) {
- // Skip the intents from other applications
- if (!intent.appId().equals(appId)) {
- continue;
- }
+ /**
+ * Withdraws all intents.
+ */
+ public void removeIntents() {
+ if (!isElectedLeader) {
+ // only leader will withdraw intents
+ return;
+ }
- // Skip the intents that are already withdrawn
- IntentState intentState =
- intentService.getIntentState(intent.id());
- if ((intentState == null) ||
- intentState.equals(IntentState.WITHDRAWING) ||
- intentState.equals(IntentState.WITHDRAWN)) {
- continue;
- }
+ log.debug("Intent Synchronizer shutdown: withdrawing all intents...");
- log.trace("Intent Synchronizer withdrawing intent: {}",
- intent);
- builder.addWithdrawOperation(intent.id());
- }
- IntentOperations intentOperations = builder.build();
- intentService.execute(intentOperations);
- leaderChanged(false);
-
- peerIntents.clear();
- routeIntents.clear();
- log.debug("Intent Synchronizer shutdown completed");
- */
+ for (Entry<Key, Intent> entry : intents.entrySet()) {
+ intentService.withdraw(entry.getValue());
+ log.debug("Intent Synchronizer withdrawing intent: {}",
+ entry.getValue());
}
+
+ intents.clear();
+ log.info("Tried to clean all intents");
}
@Override
@@ -261,5 +237,4 @@ public class IntentSynchronizer implements IntentSynchronizationService {
}
log.debug("Intent synchronization completed");
}
-
}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
index a27baaf9..fb008aad 100644
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
+++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
@@ -340,15 +340,15 @@ public class PeerConnectivityManager {
private TrafficSelector buildSelector(byte ipProto, IpAddress srcIp,
IpAddress dstIp, Short srcTcpPort,
Short dstTcpPort) {
- TrafficSelector.Builder builder = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4)
- .matchIPProtocol(ipProto);
+ TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchIPProtocol(ipProto);
if (dstIp.isIp4()) {
- builder.matchIPSrc(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET_MASK_LENGTH))
+ builder.matchEthType(Ethernet.TYPE_IPV4)
+ .matchIPSrc(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET_MASK_LENGTH))
.matchIPDst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET_MASK_LENGTH));
} else {
- builder.matchIPv6Src(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET6_MASK_LENGTH))
+ builder.matchEthType(Ethernet.TYPE_IPV6)
+ .matchIPv6Src(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET6_MASK_LENGTH))
.matchIPv6Dst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET6_MASK_LENGTH));
}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
index 1b3eda9d..ace888d1 100644
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
+++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
@@ -15,12 +15,17 @@
*/
package org.onosproject.sdnip;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Objects;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
+import org.onosproject.app.ApplicationService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.ControllerNode;
import org.onosproject.cluster.LeadershipEvent;
@@ -28,8 +33,8 @@ import org.onosproject.cluster.LeadershipEventListener;
import org.onosproject.cluster.LeadershipService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.incubator.net.intf.InterfaceService;
+import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.IntentService;
import org.onosproject.routing.IntentSynchronizationService;
@@ -38,10 +43,6 @@ import org.onosproject.routing.SdnIpService;
import org.onosproject.routing.config.RoutingConfigurationService;
import org.slf4j.Logger;
-import java.util.Objects;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
/**
* Component for the SDN-IP peering application.
*/
@@ -59,6 +60,9 @@ public class SdnIp implements SdnIpService {
protected IntentService intentService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ApplicationService applicationService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected HostService hostService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -84,7 +88,7 @@ public class SdnIp implements SdnIpService {
private SdnIpFib fib;
private LeadershipEventListener leadershipEventListener =
- new InnerLeadershipEventListener();
+ new InnerLeadershipEventListener();
private ApplicationId appId;
private ControllerNode localControllerNode;
@@ -113,6 +117,10 @@ public class SdnIp implements SdnIpService {
leadershipService.addListener(leadershipEventListener);
leadershipService.runForLeadership(appId.name());
+
+ applicationService.registerDeactivateHook(appId,
+ intentSynchronizer::removeIntents);
+
}
@Deactivate
diff --git a/framework/src/onos/apps/vtn/app/pom.xml b/framework/src/onos/apps/vtn/app/pom.xml
index 4ed66172..5a877363 100644
--- a/framework/src/onos/apps/vtn/app/pom.xml
+++ b/framework/src/onos/apps/vtn/app/pom.xml
@@ -1,44 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- ~ Copyright 2014 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. -->
+<!-- ~ Copyright 2014 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-vtn</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-vtn</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
- <artifactId>onos-app-vtn-onosfw</artifactId>
- <packaging>pom</packaging>
+ <artifactId>onos-app-vtn-onosfw</artifactId>
+ <packaging>pom</packaging>
- <description>ONOS framework applications</description>
+ <description>ONOS framework applications</description>
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-vtn-rsc</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-vtn-web</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-vtn-mgr</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-vtn-rsc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-vtn-web</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-vtn-mgr</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/framework/src/onos/apps/vtn/pom.xml b/framework/src/onos/apps/vtn/pom.xml
index e91b0c9b..e8387cb7 100644
--- a/framework/src/onos/apps/vtn/pom.xml
+++ b/framework/src/onos/apps/vtn/pom.xml
@@ -36,9 +36,9 @@
<module>vtnmgr</module>
<module>vtnweb</module>
<module>app</module>
- </modules>
- <dependencies>
- <dependency>
+ </modules>
+ <dependencies>
+ <dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
diff --git a/framework/src/onos/apps/vtn/vtnrsc/pom.xml b/framework/src/onos/apps/vtn/vtnrsc/pom.xml
index 8696295c..816624cb 100644
--- a/framework/src/onos/apps/vtn/vtnrsc/pom.xml
+++ b/framework/src/onos/apps/vtn/vtnrsc/pom.xml
@@ -15,42 +15,42 @@
~ limitations under the License.
-->
<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-vtn</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-vtn</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
- <artifactId>onos-app-vtn-rsc</artifactId>
- <packaging>bundle</packaging>
+ <artifactId>onos-app-vtn-rsc</artifactId>
+ <packaging>bundle</packaging>
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-cli</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-core-serializers</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
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
new file mode 100644
index 00000000..6b0d9a64
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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/portchain/DefaultPortChainTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java
new file mode 100644
index 00000000..b9ce73d8
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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/portpair/DefaultPortPairTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java
new file mode 100644
index 00000000..91e7ab37
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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/portpairgroup/DefaultPortPairGroupTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java
new file mode 100644
index 00000000..2528fb29
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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()));
+ }
+}