diff options
Diffstat (limited to 'framework/src/onos/core/api/src/test/java/org/onosproject/cluster')
6 files changed, 0 insertions, 421 deletions
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java deleted file mode 100644 index b88b5ff6..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2014-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.cluster; - -import java.util.Set; - -import org.joda.time.DateTime; -import org.onlab.packet.IpAddress; - -import com.google.common.collect.ImmutableSet; - -/** - * Test adapter for the cluster service. - */ -public class ClusterServiceAdapter implements ClusterService { - ControllerNode local = new DefaultControllerNode(new NodeId("local"), - IpAddress.valueOf("127.0.0.1")); - - @Override - public ControllerNode getLocalNode() { - return local; - } - - @Override - public Set<ControllerNode> getNodes() { - return ImmutableSet.of(local); - } - - @Override - public ControllerNode getNode(NodeId nodeId) { - return null; - } - - @Override - public ControllerNode.State getState(NodeId nodeId) { - return null; - } - - @Override - public DateTime getLastUpdated(NodeId nodeId) { - return null; - } - - @Override - public void addListener(ClusterEventListener listener) { - } - - @Override - public void removeListener(ClusterEventListener listener) { - } -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/ControllerNodeToNodeIdTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/ControllerNodeToNodeIdTest.java deleted file mode 100644 index 0b4d1ef6..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/ControllerNodeToNodeIdTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ -package org.onosproject.cluster; - -import static com.google.common.base.Predicates.notNull; -import static org.junit.Assert.*; -import static org.onosproject.cluster.ControllerNodeToNodeId.toNodeId; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; -import org.onlab.packet.IpAddress; - -import com.google.common.collect.FluentIterable; - - -public class ControllerNodeToNodeIdTest { - - private static final NodeId NID1 = new NodeId("foo"); - private static final NodeId NID2 = new NodeId("bar"); - private static final NodeId NID3 = new NodeId("buz"); - - private static final IpAddress IP1 = IpAddress.valueOf("127.0.0.1"); - private static final IpAddress IP2 = IpAddress.valueOf("127.0.0.2"); - private static final IpAddress IP3 = IpAddress.valueOf("127.0.0.3"); - - private static final ControllerNode CN1 = new DefaultControllerNode(NID1, IP1); - private static final ControllerNode CN2 = new DefaultControllerNode(NID2, IP2); - private static final ControllerNode CN3 = new DefaultControllerNode(NID3, IP3); - - - @Test - public final void testToNodeId() { - - final Iterable<ControllerNode> nodes = Arrays.asList(CN1, CN2, CN3, null); - final List<NodeId> nodeIds = Arrays.asList(NID1, NID2, NID3); - - assertEquals(nodeIds, - FluentIterable.from(nodes) - .transform(toNodeId()) - .filter(notNull()) - .toList()); - } - -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipEventTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipEventTest.java deleted file mode 100644 index be0321bf..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipEventTest.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.cluster; - -import org.junit.Test; - -import com.google.common.testing.EqualsTester; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -/** - * Unit tests for the leadership event test. - */ -public class LeadershipEventTest { - private final NodeId node1 = new NodeId("1"); - private final NodeId node2 = new NodeId("2"); - private final Leadership lead1 = new Leadership("topic1", node1, 1L, 2L); - private final Leadership lead2 = new Leadership("topic1", node2, 1L, 2L); - private final LeadershipEvent event1 = - new LeadershipEvent(LeadershipEvent.Type.LEADER_ELECTED, lead1); - private final long time = System.currentTimeMillis(); - private final LeadershipEvent event2 = - new LeadershipEvent(LeadershipEvent.Type.CANDIDATES_CHANGED, - lead2, time); - private final LeadershipEvent sameAsEvent2 = - new LeadershipEvent(LeadershipEvent.Type.CANDIDATES_CHANGED, - lead2, time); - private final LeadershipEvent event3 = - new LeadershipEvent(LeadershipEvent.Type.LEADER_BOOTED, lead1); - private final LeadershipEvent event4 = - new LeadershipEvent(LeadershipEvent.Type.LEADER_REELECTED, lead1); - private final LeadershipEvent event5 = - new LeadershipEvent(LeadershipEvent.Type.LEADER_REELECTED, lead2); - - /** - * Tests for proper operation of equals(), hashCode() and toString() methods. - */ - @Test - public void checkEquals() { - new EqualsTester() - .addEqualityGroup(event1) - .addEqualityGroup(event2, sameAsEvent2) - .addEqualityGroup(event3) - .addEqualityGroup(event4) - .addEqualityGroup(event5) - .testEquals(); - } - - /** - * Tests that objects are created properly. - */ - @Test - public void checkConstruction() { - assertThat(event1.type(), is(LeadershipEvent.Type.LEADER_ELECTED)); - assertThat(event1.subject(), is(lead1)); - - assertThat(event2.time(), is(time)); - assertThat(event2.type(), is(LeadershipEvent.Type.CANDIDATES_CHANGED)); - assertThat(event2.subject(), is(lead2)); - } - -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipServiceAdapter.java deleted file mode 100644 index e1d421d0..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipServiceAdapter.java +++ /dev/null @@ -1,87 +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.cluster; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -/** - * Test adapter for leadership service. - */ -public class LeadershipServiceAdapter implements LeadershipService { - - @Override - public NodeId getLeader(String path) { - return null; - } - - @Override - public Leadership getLeadership(String path) { - return null; - } - - @Override - public Set<String> ownedTopics(NodeId nodeId) { - return null; - } - - @Override - public CompletableFuture<Leadership> runForLeadership(String path) { - return null; - } - - @Override - public CompletableFuture<Void> withdraw(String path) { - return null; - } - - @Override - public Map<String, Leadership> getLeaderBoard() { - return null; - } - - @Override - public void addListener(LeadershipEventListener listener) { - - } - - @Override - public void removeListener(LeadershipEventListener listener) { - - } - - @Override - public Map<String, List<NodeId>> getCandidates() { - return null; - } - - @Override - public List<NodeId> getCandidates(String path) { - return null; - } - - @Override - public boolean stepdown(String path) { - return false; - } - - @Override - public boolean makeTopCandidate(String path, NodeId nodeId) { - return false; - } -}
\ No newline at end of file diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipTest.java deleted file mode 100644 index e2a86587..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/LeadershipTest.java +++ /dev/null @@ -1,75 +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.cluster; - -import org.junit.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.testing.EqualsTester; - -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -/** - * Unit tests for the Leadership class. - */ -public class LeadershipTest { - private final NodeId node1 = new NodeId("1"); - private final NodeId node2 = new NodeId("2"); - private final Leadership lead1 = new Leadership("topic1", node1, 1L, 2L); - private final Leadership sameAsLead1 = new Leadership("topic1", node1, 1L, 2L); - private final Leadership lead2 = new Leadership("topic2", node1, 1L, 2L); - private final Leadership lead3 = new Leadership("topic1", node1, 2L, 2L); - private final Leadership lead4 = new Leadership("topic1", node1, 3L, 2L); - private final Leadership lead5 = new Leadership("topic1", node1, 3L, 3L); - private final Leadership lead6 = new Leadership("topic1", node1, - ImmutableList.of(node2), 1L, 2L); - private final Leadership lead7 = new Leadership("topic1", - ImmutableList.of(node2), 1L, 2L); - - /** - * Tests for proper operation of equals(), hashCode() and toString() methods. - */ - @Test - public void checkEquals() { - new EqualsTester() - .addEqualityGroup(lead1, sameAsLead1) - .addEqualityGroup(lead2) - .addEqualityGroup(lead3) - .addEqualityGroup(lead4) - .addEqualityGroup(lead5) - .addEqualityGroup(lead6) - .addEqualityGroup(lead7) - .testEquals(); - } - - /** - * Tests that objects are created properly and accessor methods return - * the correct vsalues. - */ - @Test - public void checkConstruction() { - assertThat(lead6.electedTime(), is(2L)); - assertThat(lead6.epoch(), is(1L)); - assertThat(lead6.leader(), is(node1)); - assertThat(lead6.topic(), is("topic1")); - assertThat(lead6.candidates(), hasSize(1)); - assertThat(lead6.candidates(), contains(node2)); - } - -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/RoleInfoTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/RoleInfoTest.java deleted file mode 100644 index 4998bf5a..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/cluster/RoleInfoTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2014-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.cluster; - -import java.util.List; - -import org.junit.Test; - -import com.google.common.collect.Lists; -import com.google.common.testing.EqualsTester; - -import static org.junit.Assert.assertEquals; - -/** - * Test to check behavioral correctness of the RoleInfo structure. - */ -public class RoleInfoTest { - private static final NodeId N1 = new NodeId("n1"); - private static final NodeId N2 = new NodeId("n2"); - private static final NodeId N3 = new NodeId("n3"); - private static final NodeId N4 = new NodeId("n4"); - - private static final List<NodeId> BKUP1 = Lists.newArrayList(N2, N3); - private static final List<NodeId> BKUP2 = Lists.newArrayList(N3, N4); - - private static final RoleInfo RI1 = new RoleInfo(N1, BKUP1); - private static final RoleInfo RI2 = new RoleInfo(N1, BKUP2); - private static final RoleInfo RI3 = new RoleInfo(N2, BKUP1); - private static final RoleInfo RI4 = new RoleInfo(null, BKUP2); - - @Test - public void testEquality() { - new EqualsTester() - .addEqualityGroup(RI1, new RoleInfo(new NodeId("n1"), Lists.newArrayList(N2, N3))) - .addEqualityGroup(RI3); - } - - @Test - public void basics() { - assertEquals("wrong master", new NodeId("n1"), RI1.master()); - assertEquals("wrong Backups", RI1.backups(), Lists.newArrayList(N2, N3)); - assertEquals("wrong empty master", RI4.master(), null); - - List<NodeId> bkup3 = Lists.newArrayList(N3, new NodeId("n4")); - assertEquals("equals() broken", new RoleInfo(N1, bkup3), RI2); - } -} |