aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/test/java')
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java79
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourceAllocationTest.java12
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourcePathTest.java34
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/store/persistence/PersistenceServiceAdapter.java36
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/store/persistence/TestPersistenceService.java57
5 files changed, 186 insertions, 32 deletions
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
index 56a6ff63..d113fb98 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
@@ -222,6 +222,12 @@ public class CriteriaTest {
Criterion sameAsMatchMpls1 = Criteria.matchMplsLabel(mpls1);
Criterion matchMpls2 = Criteria.matchMplsLabel(mpls2);
+ byte mplsTc1 = 1;
+ byte mplsTc2 = 2;
+ Criterion matchMplsTc1 = Criteria.matchMplsTc(mplsTc1);
+ Criterion sameAsMatchMplsTc1 = Criteria.matchMplsTc(mplsTc1);
+ Criterion matchMplsTc2 = Criteria.matchMplsTc(mplsTc2);
+
long tunnelId1 = 1;
long tunnelId2 = 2;
Criterion matchTunnelId1 = Criteria.matchTunnelId(tunnelId1);
@@ -273,6 +279,12 @@ public class CriteriaTest {
Criterion sameAsMatchOduSignalType1 = Criteria.matchOduSignalType(oduSigType1);
Criterion matchOduSignalType2 = Criteria.matchOduSignalType(oduSigType2);
+ int pbbIsid1 = 1;
+ int pbbIsid2 = 2;
+ Criterion matchPbbIsid1 = Criteria.matchPbbIsid(pbbIsid1);
+ Criterion sameAsMatchPbbIsid1 = Criteria.matchPbbIsid(pbbIsid1);
+ Criterion matchPbbIsid2 = Criteria.matchPbbIsid(pbbIsid2);
+
/**
* Checks that a Criterion object has the proper type, and then converts
* it to the proper type.
@@ -326,10 +338,12 @@ public class CriteriaTest {
assertThatClassIsImmutable(IPv6NDTargetAddressCriterion.class);
assertThatClassIsImmutable(IPv6NDLinkLayerAddressCriterion.class);
assertThatClassIsImmutable(MplsCriterion.class);
+ assertThatClassIsImmutable(MplsTcCriterion.class);
assertThatClassIsImmutable(IPv6ExthdrFlagsCriterion.class);
assertThatClassIsImmutable(LambdaCriterion.class);
assertThatClassIsImmutable(OduSignalIdCriterion.class);
assertThatClassIsImmutable(OduSignalTypeCriterion.class);
+ assertThatClassIsImmutable(PbbIsidCriterion.class);
}
// PortCriterion class
@@ -752,6 +766,19 @@ public class CriteriaTest {
// TcpFlagsCriterion class
/**
+ * Test the matchTcpFlags method.
+ */
+ @Test
+ public void testMatchTcpFlagsMethod() {
+ Criterion matchTcpFlag = Criteria.matchTcpFlags(tcpFlags1);
+ TcpFlagsCriterion tcpFlagsCriterion =
+ checkAndConvert(matchTcpFlag,
+ Criterion.Type.TCP_FLAGS,
+ TcpFlagsCriterion.class);
+ assertThat(tcpFlagsCriterion.flags(), is(equalTo(tcpFlags1)));
+ }
+
+ /**
* Test the equals() method of the TcpFlagsCriterion class.
*/
@Test
@@ -1037,6 +1064,32 @@ public class CriteriaTest {
.testEquals();
}
+ // MplsTcCriterion class
+
+ /**
+ * Test the matchMplsTc method.
+ */
+ @Test
+ public void testMatchMplsTcMethod() {
+ Criterion matchMplsTc = Criteria.matchMplsTc(mplsTc1);
+ MplsTcCriterion mplsTcCriterion =
+ checkAndConvert(matchMplsTc,
+ Criterion.Type.MPLS_TC,
+ MplsTcCriterion.class);
+ assertThat(mplsTcCriterion.tc(), is(equalTo(mplsTc1)));
+ }
+
+ /**
+ * Test the equals() method of the MplsTcCriterion class.
+ */
+ @Test
+ public void testMplsTcCriterionEquals() {
+ new EqualsTester()
+ .addEqualityGroup(matchMplsTc1, sameAsMatchMplsTc1)
+ .addEqualityGroup(matchMplsTc2)
+ .testEquals();
+ }
+
// TunnelIdCriterion class
/**
@@ -1172,4 +1225,30 @@ public class CriteriaTest {
.addEqualityGroup(matchOduSignalType2)
.testEquals();
}
+
+ // PbbIsidCriterion class
+
+ /**
+ * Test the matchPbbIsid method.
+ */
+ @Test
+ public void testMatchPbbIsidMethod() {
+ Criterion matchPbbIsid = Criteria.matchPbbIsid(pbbIsid1);
+ PbbIsidCriterion pbbIsidCriterion =
+ checkAndConvert(matchPbbIsid,
+ Criterion.Type.PBB_ISID,
+ PbbIsidCriterion.class);
+ assertThat(pbbIsidCriterion.pbbIsid(), is(equalTo(pbbIsid1)));
+ }
+
+ /**
+ * Test the equals() method of the PbbIsidCriterion class.
+ */
+ @Test
+ public void testPbbIsidCriterionEquals() {
+ new EqualsTester()
+ .addEqualityGroup(matchPbbIsid1, sameAsMatchPbbIsid1)
+ .addEqualityGroup(matchPbbIsid2)
+ .testEquals();
+ }
}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourceAllocationTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourceAllocationTest.java
index 5f448221..d21c4b1b 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourceAllocationTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourceAllocationTest.java
@@ -18,9 +18,7 @@ package org.onosproject.net.newresource;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.LinkKey;
import org.onosproject.net.PortNumber;
import org.onosproject.net.intent.IntentId;
@@ -29,18 +27,14 @@ public class ResourceAllocationTest {
private static final DeviceId D1 = DeviceId.deviceId("of:001");
private static final DeviceId D2 = DeviceId.deviceId("of:002");
private static final PortNumber P1 = PortNumber.portNumber(1);
- private static final ConnectPoint CP1_1 = new ConnectPoint(D1, P1);
- private static final ConnectPoint CP2_1 = new ConnectPoint(D2, P1);
private static final VlanId VLAN1 = VlanId.vlanId((short) 100);
private static final IntentId IID1 = IntentId.valueOf(30);
- private static final LinkKey LK1 = LinkKey.linkKey(CP1_1, CP2_1);
- private static final LinkKey LK2 = LinkKey.linkKey(CP2_1, CP1_1);
@Test
public void testEquals() {
- ResourceAllocation alloc1 = new ResourceAllocation(ResourcePath.discrete(LK1, VLAN1), IID1);
- ResourceAllocation sameAsAlloc1 = new ResourceAllocation(ResourcePath.discrete(LK1, VLAN1), IID1);
- ResourceAllocation alloc2 = new ResourceAllocation(ResourcePath.discrete(LK2, VLAN1), IID1);
+ ResourceAllocation alloc1 = new ResourceAllocation(ResourcePath.discrete(D1, P1, VLAN1), IID1);
+ ResourceAllocation sameAsAlloc1 = new ResourceAllocation(ResourcePath.discrete(D1, P1, VLAN1), IID1);
+ ResourceAllocation alloc2 = new ResourceAllocation(ResourcePath.discrete(D2, P1, VLAN1), IID1);
new EqualsTester()
.addEqualityGroup(alloc1, sameAsAlloc1)
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourcePathTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourcePathTest.java
index 35dcf1ec..4bbb458c 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourcePathTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/newresource/ResourcePathTest.java
@@ -19,9 +19,7 @@ import com.google.common.testing.EqualsTester;
import org.junit.Test;
import org.onlab.packet.VlanId;
import org.onlab.util.Bandwidth;
-import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.LinkKey;
import org.onosproject.net.PortNumber;
import java.util.Optional;
@@ -35,19 +33,17 @@ public class ResourcePathTest {
private static final DeviceId D1 = DeviceId.deviceId("of:001");
private static final DeviceId D2 = DeviceId.deviceId("of:002");
private static final PortNumber P1 = PortNumber.portNumber(1);
- private static final ConnectPoint CP1_1 = new ConnectPoint(D1, P1);
- private static final ConnectPoint CP2_1 = new ConnectPoint(D2, P1);
private static final VlanId VLAN1 = VlanId.vlanId((short) 100);
private static final Bandwidth BW1 = Bandwidth.gbps(2);
private static final Bandwidth BW2 = Bandwidth.gbps(1);
@Test
public void testEquals() {
- ResourcePath resource1 = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1), VLAN1);
- ResourcePath sameAsResource1 = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1), VLAN1);
- ResourcePath resource2 = ResourcePath.discrete(LinkKey.linkKey(CP2_1, CP1_1), VLAN1);
- ResourcePath resource3 = ResourcePath.continuous(BW1.bps(), LinkKey.linkKey(CP1_1, CP2_1), BW1);
- ResourcePath sameAsResource3 = ResourcePath.continuous(BW2.bps(), LinkKey.linkKey(CP1_1, CP2_1), BW1);
+ ResourcePath resource1 = ResourcePath.discrete(D1, P1, VLAN1);
+ ResourcePath sameAsResource1 = ResourcePath.discrete(D1, P1, VLAN1);
+ ResourcePath resource2 = ResourcePath.discrete(D2, P1, VLAN1);
+ ResourcePath resource3 = ResourcePath.continuous(BW1.bps(), D1, P1, BW1);
+ ResourcePath sameAsResource3 = ResourcePath.continuous(BW2.bps(), D1, P1, BW1);
new EqualsTester()
.addEqualityGroup(resource1, sameAsResource1)
@@ -57,13 +53,6 @@ public class ResourcePathTest {
}
@Test
- public void testCreateWithZeroComponent() {
- ResourcePath path = ResourcePath.discrete();
-
- assertThat(path, is(ResourcePath.ROOT));
- }
-
- @Test
public void testComponents() {
ResourcePath port = ResourcePath.discrete(D1, P1);
@@ -72,25 +61,24 @@ public class ResourcePathTest {
@Test
public void testThereIsParent() {
- ResourcePath path = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1), VLAN1);
- ResourcePath parent = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1));
+ ResourcePath path = ResourcePath.discrete(D1, P1, VLAN1);
+ ResourcePath parent = ResourcePath.discrete(D1, P1);
assertThat(path.parent(), is(Optional.of(parent)));
}
@Test
public void testNoParent() {
- ResourcePath path = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1));
+ ResourcePath path = ResourcePath.discrete(D1);
assertThat(path.parent(), is(Optional.of(ResourcePath.ROOT)));
}
@Test
public void testBase() {
- LinkKey linkKey = LinkKey.linkKey(CP1_1, CP2_1);
- ResourcePath path = ResourcePath.discrete(linkKey);
+ ResourcePath path = ResourcePath.discrete(D1);
- LinkKey child = (LinkKey) path.last();
- assertThat(child, is(linkKey));
+ DeviceId child = (DeviceId) path.last();
+ assertThat(child, is(D1));
}
}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/persistence/PersistenceServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/persistence/PersistenceServiceAdapter.java
new file mode 100644
index 00000000..3edfcc73
--- /dev/null
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/persistence/PersistenceServiceAdapter.java
@@ -0,0 +1,36 @@
+/*
+ * 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.store.persistence;
+
+import org.onosproject.persistence.PersistenceService;
+import org.onosproject.persistence.PersistentMapBuilder;
+import org.onosproject.persistence.PersistentSetBuilder;
+
+/**
+ * Adapter for PersistenceService.
+ */
+public class PersistenceServiceAdapter implements PersistenceService {
+
+ @Override
+ public <K, V> PersistentMapBuilder<K, V> persistentMapBuilder() {
+ return null;
+ }
+
+ @Override
+ public <E> PersistentSetBuilder<E> persistentSetBuilder() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/persistence/TestPersistenceService.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/persistence/TestPersistenceService.java
new file mode 100644
index 00000000..a6d97458
--- /dev/null
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/persistence/TestPersistenceService.java
@@ -0,0 +1,57 @@
+/*
+ * 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.store.persistence;
+
+import java.util.Map;
+
+import org.onosproject.persistence.PersistentMapBuilder;
+import org.onosproject.persistence.PersistentSetBuilder;
+import org.onosproject.store.service.Serializer;
+
+import com.google.common.collect.Maps;
+
+/**
+ * PersistenceService that produces in memory maps for use in unit testing.
+ */
+public class TestPersistenceService extends PersistenceServiceAdapter {
+ @Override
+ public <K, V> PersistentMapBuilder<K, V> persistentMapBuilder() {
+ return new TestPersistentMapBuilder<K, V>();
+ }
+
+ @Override
+ public <E> PersistentSetBuilder<E> persistentSetBuilder() {
+ throw new UnsupportedOperationException();
+ }
+
+ private static class TestPersistentMapBuilder<K, V> implements PersistentMapBuilder<K, V> {
+
+ @Override
+ public PersistentMapBuilder<K, V> withName(String name) {
+ return this;
+ }
+
+ @Override
+ public PersistentMapBuilder<K, V> withSerializer(Serializer serializer) {
+ return this;
+ }
+
+ @Override
+ public Map<K, V> build() {
+ return Maps.newConcurrentMap();
+ }
+ }
+}