Split one single test file into multiple files
Change-Id: I699bd3df001eab704afc4aaa8b8a5514e4b175f8
diff --git a/core/api/src/test/java/org/onosproject/net/newresource/ContinuousResourceIdTest.java b/core/api/src/test/java/org/onosproject/net/newresource/ContinuousResourceIdTest.java
new file mode 100644
index 0000000..cf6e0e8
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/newresource/ContinuousResourceIdTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 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.net.newresource;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onlab.util.Bandwidth;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+/**
+ * Unit test for ContinuousResourceId.
+ */
+public class ContinuousResourceIdTest {
+
+ private static final DeviceId D1 = DeviceId.deviceId("of:001");
+ private static final PortNumber P1 = PortNumber.portNumber(1);
+ private static final Bandwidth BW1 = Bandwidth.gbps(2);
+ private static final Bandwidth BW2 = Bandwidth.gbps(1);
+
+ @Test
+ public void testEquality() {
+ ContinuousResourceId id1 = Resources.continuous(D1, P1, Bandwidth.class)
+ .resource(BW1.bps()).id();
+ // intentionally set a different value
+ ContinuousResourceId sameAsId1 = Resources.continuous(D1, P1, Bandwidth.class)
+ .resource(BW2.bps()).id();
+
+ new EqualsTester()
+ .addEqualityGroup(id1, sameAsId1);
+ }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/newresource/ContinuousResourceTest.java b/core/api/src/test/java/org/onosproject/net/newresource/ContinuousResourceTest.java
new file mode 100644
index 0000000..c5952ae
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/newresource/ContinuousResourceTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 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.net.newresource;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onlab.packet.VlanId;
+import org.onlab.util.Bandwidth;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+import java.util.Optional;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.*;
+
+/**
+ * Unit test for ContinuousResource.
+ */
+public class ContinuousResourceTest {
+
+ private static final DeviceId D1 = DeviceId.deviceId("of:001");
+ private static final PortNumber P1 = PortNumber.portNumber(1);
+ private static final Bandwidth BW1 = Bandwidth.gbps(2);
+
+ @Test
+ public void testEquals() {
+ ContinuousResource resource1 = Resources.continuous(D1, P1, Bandwidth.class)
+ .resource(BW1.bps());
+ ContinuousResource sameAsResource1 = Resources.continuous(D1, P1, Bandwidth.class)
+ .resource(BW1.bps());
+
+ new EqualsTester()
+ .addEqualityGroup(resource1, sameAsResource1)
+ .testEquals();
+ }
+
+ @Test
+ public void testTypeOf() {
+ ContinuousResource continuous = Resources.continuous(D1, P1, Bandwidth.class)
+ .resource(BW1.bps());
+ assertThat(continuous.isTypeOf(DeviceId.class), is(false));
+ assertThat(continuous.isTypeOf(PortNumber.class), is(false));
+ assertThat(continuous.isTypeOf(Bandwidth.class), is(true));
+ }
+
+ @Test
+ public void testSubTypeOf() {
+ ContinuousResource continuous = Resources.continuous(D1, P1, Bandwidth.class)
+ .resource(BW1.bps());
+ assertThat(continuous.isSubTypeOf(DeviceId.class), is(true));
+ assertThat(continuous.isSubTypeOf(PortNumber.class), is(true));
+ assertThat(continuous.isSubTypeOf(Bandwidth.class), is(true));
+ assertThat(continuous.isSubTypeOf(VlanId.class), is(false));
+ }
+
+ @Test
+ public void testValueAs() {
+ ContinuousResource resource = Resources.continuous(D1, P1, Bandwidth.class)
+ .resource(BW1.bps());
+
+ Optional<Double> volume = resource.valueAs(double.class);
+ assertThat(volume.get(), is(BW1.bps()));
+ }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/newresource/DiscreteResourceIdTest.java b/core/api/src/test/java/org/onosproject/net/newresource/DiscreteResourceIdTest.java
new file mode 100644
index 0000000..6178150
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/newresource/DiscreteResourceIdTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 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.net.newresource;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onlab.packet.VlanId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+/**
+ * Unit test for DiscreteResourceId.
+ */
+public class DiscreteResourceIdTest {
+
+ 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 VlanId VLAN1 = VlanId.vlanId((short) 100);
+
+ @Test
+ public void testEquality() {
+ DiscreteResourceId id1 = Resources.discrete(D1, P1, VLAN1).id();
+ DiscreteResourceId sameAsId1 = Resources.discrete(D1, P1, VLAN1).id();
+ DiscreteResourceId id2 = Resources.discrete(D2, P1, VLAN1).id();
+
+ new EqualsTester()
+ .addEqualityGroup(id1, sameAsId1)
+ .addEqualityGroup(id2);
+ }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/newresource/DiscreteResourceTest.java b/core/api/src/test/java/org/onosproject/net/newresource/DiscreteResourceTest.java
new file mode 100644
index 0000000..7333ef7
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/newresource/DiscreteResourceTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2016 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.net.newresource;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onlab.packet.VlanId;
+import org.onlab.util.Bandwidth;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+import java.util.Optional;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.*;
+
+/**
+ * Unit test for DiscreteResource.
+ */
+public class DiscreteResourceTest {
+
+ 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 VlanId VLAN1 = VlanId.vlanId((short) 100);
+ private static final Bandwidth BW1 = Bandwidth.gbps(2);
+
+ @Test
+ public void testEquals() {
+ DiscreteResource resource1 = Resources.discrete(D1, P1, VLAN1).resource();
+ DiscreteResource sameAsResource1 = Resources.discrete(D1, P1, VLAN1).resource();
+ DiscreteResource resource2 = Resources.discrete(D2, P1, VLAN1).resource();
+
+ new EqualsTester()
+ .addEqualityGroup(resource1, sameAsResource1)
+ .addEqualityGroup(resource2)
+ .testEquals();
+ }
+
+ @Test
+ public void testChild() {
+ DiscreteResource r1 = Resources.discrete(D1).resource().child(P1);
+ DiscreteResource sameAsR2 = Resources.discrete(D1, P1).resource();
+
+ assertThat(r1, is(sameAsR2));
+ }
+
+ @Test
+ public void testThereIsParent() {
+ DiscreteResource resource = Resources.discrete(D1, P1, VLAN1).resource();
+ DiscreteResource parent = Resources.discrete(D1, P1).resource();
+
+ assertThat(resource.parent(), is(Optional.of(parent)));
+ }
+
+ @Test
+ public void testNoParent() {
+ DiscreteResource resource = Resources.discrete(D1).resource();
+
+ assertThat(resource.parent(), is(Optional.of(Resource.ROOT)));
+ }
+
+ @Test
+ public void testTypeOf() {
+ DiscreteResource discrete = Resources.discrete(D1, P1, VLAN1).resource();
+ assertThat(discrete.isTypeOf(DeviceId.class), is(false));
+ assertThat(discrete.isTypeOf(PortNumber.class), is(false));
+ assertThat(discrete.isTypeOf(VlanId.class), is(true));
+ }
+
+ @Test
+ public void testSubTypeOf() {
+ DiscreteResource discrete = Resources.discrete(D1, P1, VLAN1).resource();
+ assertThat(discrete.isSubTypeOf(DeviceId.class), is(true));
+ assertThat(discrete.isSubTypeOf(PortNumber.class), is(true));
+ assertThat(discrete.isSubTypeOf(VlanId.class), is(true));
+ assertThat(discrete.isSubTypeOf(Bandwidth.class), is(false));
+ }
+
+ @Test
+ public void testBase() {
+ DiscreteResource resource = Resources.discrete(D1).resource();
+
+ DeviceId child = (DeviceId) resource.last();
+ assertThat(child, is(D1));
+ }
+
+ @Test
+ public void testValueAs() {
+ DiscreteResource resource = Resources.discrete(D1).resource();
+
+ Optional<DeviceId> volume = resource.valueAs(DeviceId.class);
+ assertThat(volume.get(), is(D1));
+ }
+
+ @Test
+ public void testValueOfRoot() {
+ DiscreteResource resource = Resource.ROOT;
+
+ assertThat(resource.valueAs(Object.class), is(Optional.empty()));
+ }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/newresource/ResourceTest.java b/core/api/src/test/java/org/onosproject/net/newresource/ResourceTest.java
deleted file mode 100644
index b404d10..0000000
--- a/core/api/src/test/java/org/onosproject/net/newresource/ResourceTest.java
+++ /dev/null
@@ -1,150 +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.net.newresource;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-import org.onlab.packet.VlanId;
-import org.onlab.util.Bandwidth;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-
-import java.util.Optional;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-public class ResourceTest {
-
- 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 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() {
- Resource resource1 = Resources.discrete(D1, P1, VLAN1).resource();
- Resource sameAsResource1 = Resources.discrete(D1, P1, VLAN1).resource();
- Resource resource2 = Resources.discrete(D2, P1, VLAN1).resource();
- Resource resource3 = Resources.continuous(D1, P1, Bandwidth.class).resource(BW1.bps());
- Resource sameAsResource3 = Resources.continuous(D1, P1, Bandwidth.class).resource(BW1.bps());
-
- new EqualsTester()
- .addEqualityGroup(resource1, sameAsResource1)
- .addEqualityGroup(resource2)
- .addEqualityGroup(resource3, sameAsResource3)
- .testEquals();
- }
-
- @Test
- public void testIdEquality() {
- ResourceId id1 = Resources.discrete(D1, P1, VLAN1).id();
- ResourceId sameAsId1 = Resources.discrete(D1, P1, VLAN1).id();
- ResourceId id2 = Resources.discrete(D2, P1, VLAN1).id();
- ResourceId id3 = Resources.continuous(D1, P1, Bandwidth.class).resource(BW1.bps()).id();
- // intentionally set a different value
- ResourceId sameAsId3 = Resources.continuous(D1, P1, Bandwidth.class).resource(BW2.bps()).id();
-
- new EqualsTester()
- .addEqualityGroup(id1, sameAsId1)
- .addEqualityGroup(id2)
- .addEqualityGroup(id3, sameAsId3);
- }
-
- @Test
- public void testChild() {
- Resource r1 = Resources.discrete(D1).resource().child(P1);
- Resource sameAsR2 = Resources.discrete(D1, P1).resource();
-
- assertThat(r1, is(sameAsR2));
- }
-
- @Test
- public void testThereIsParent() {
- Resource resource = Resources.discrete(D1, P1, VLAN1).resource();
- Resource parent = Resources.discrete(D1, P1).resource();
-
- assertThat(resource.parent(), is(Optional.of(parent)));
- }
-
- @Test
- public void testNoParent() {
- Resource resource = Resources.discrete(D1).resource();
-
- assertThat(resource.parent(), is(Optional.of(Resource.ROOT)));
- }
-
- @Test
- public void testTypeOf() {
- DiscreteResource discrete = Resources.discrete(D1, P1, VLAN1).resource();
- assertThat(discrete.isTypeOf(DeviceId.class), is(false));
- assertThat(discrete.isTypeOf(PortNumber.class), is(false));
- assertThat(discrete.isTypeOf(VlanId.class), is(true));
-
- ContinuousResource continuous = Resources.continuous(D1, P1, Bandwidth.class).resource(BW1.bps());
- assertThat(continuous.isTypeOf(DeviceId.class), is(false));
- assertThat(continuous.isTypeOf(PortNumber.class), is(false));
- assertThat(continuous.isTypeOf(Bandwidth.class), is(true));
- }
-
- @Test
- public void testSubTypeOf() {
- DiscreteResource discrete = Resources.discrete(D1, P1, VLAN1).resource();
- assertThat(discrete.isSubTypeOf(DeviceId.class), is(true));
- assertThat(discrete.isSubTypeOf(PortNumber.class), is(true));
- assertThat(discrete.isSubTypeOf(VlanId.class), is(true));
- assertThat(discrete.isSubTypeOf(Bandwidth.class), is(false));
-
- ContinuousResource continuous = Resources.continuous(D1, P1, Bandwidth.class).resource(BW1.bps());
- assertThat(continuous.isSubTypeOf(DeviceId.class), is(true));
- assertThat(continuous.isSubTypeOf(PortNumber.class), is(true));
- assertThat(continuous.isSubTypeOf(Bandwidth.class), is(true));
- assertThat(continuous.isSubTypeOf(VlanId.class), is(false));
- }
-
- @Test
- public void testBase() {
- Resource resource = Resources.discrete(D1).resource();
-
- DeviceId child = (DeviceId) resource.last();
- assertThat(child, is(D1));
- }
-
- @Test
- public void testValueOfDiscrete() {
- Resource resource = Resources.discrete(D1).resource();
-
- Optional<DeviceId> volume = resource.valueAs(DeviceId.class);
- assertThat(volume.get(), is(D1));
- }
-
- @Test
- public void testValueOfRoot() {
- Resource resource = Resource.ROOT;
-
- assertThat(resource.valueAs(Object.class), is(Optional.empty()));
- }
-
- @Test
- public void testValueOfContinuous() {
- Resource resource = Resources.continuous(D1, P1, Bandwidth.class).resource(BW1.bps());
-
- Optional<Double> volume = resource.valueAs(double.class);
- assertThat(volume.get(), is(BW1.bps()));
- }
-}