summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/test/java/org/onosproject/event
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/test/java/org/onosproject/event')
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/event/AbstractEventTest.java79
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/event/BrokenListener.java28
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/event/DefaultEventSinkRegistryTest.java71
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java58
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/event/ListenerRegistryTest.java74
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/event/TestEvent.java34
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/event/TestListener.java34
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/event/TestListenerRegistry.java36
8 files changed, 0 insertions, 414 deletions
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/AbstractEventTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/AbstractEventTest.java
deleted file mode 100644
index c66c4b84..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/AbstractEventTest.java
+++ /dev/null
@@ -1,79 +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.event;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.onosproject.event.TestEvent.Type.FOO;
-
-/**
- * Tests of the base event abstraction.
- */
-public class AbstractEventTest {
-
- /**
- * Validates the base attributes of an event.
- *
- * @param event event to validate
- * @param type event type
- * @param subject event subject
- * @param time event time
- * @param <T> type of event
- * @param <S> type of subject
- */
- protected static <T extends Enum, S>
- void validateEvent(Event<T, S> event, T type, S subject, long time) {
- assertEquals("incorrect type", type, event.type());
- assertEquals("incorrect subject", subject, event.subject());
- assertEquals("incorrect time", time, event.time());
- }
-
- /**
- * Validates the base attributes of an event.
- *
- * @param event event to validate
- * @param type event type
- * @param subject event subject
- * @param minTime minimum event time inclusive
- * @param maxTime maximum event time inclusive
- * @param <T> type of event
- * @param <S> type of subject
- */
- protected static <T extends Enum, S>
- void validateEvent(Event<T, S> event, T type, S subject,
- long minTime, long maxTime) {
- assertEquals("incorrect type", type, event.type());
- assertEquals("incorrect subject", subject, event.subject());
- assertTrue("incorrect time", minTime <= event.time() && event.time() <= maxTime);
- }
-
- @Test
- public void withTime() {
- TestEvent event = new TestEvent(FOO, "foo", 123L);
- validateEvent(event, FOO, "foo", 123L);
- }
-
- @Test
- public void withoutTime() {
- long before = System.currentTimeMillis();
- TestEvent event = new TestEvent(FOO, "foo");
- long after = System.currentTimeMillis();
- validateEvent(event, FOO, "foo", before, after);
- }
-
-}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/BrokenListener.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/BrokenListener.java
deleted file mode 100644
index 1a013ada..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/BrokenListener.java
+++ /dev/null
@@ -1,28 +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.event;
-
-/**
- * Test event listener fixture.
- */
-public class BrokenListener extends TestListener {
-
- public void event(TestEvent event) {
- throw new IllegalStateException("boom");
- }
-
-}
-
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/DefaultEventSinkRegistryTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/DefaultEventSinkRegistryTest.java
deleted file mode 100644
index 2e24228a..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/DefaultEventSinkRegistryTest.java
+++ /dev/null
@@ -1,71 +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.event;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests of the default event sink registry.
- */
-public class DefaultEventSinkRegistryTest {
-
- private DefaultEventSinkRegistry registry;
-
- private static class FooEvent extends TestEvent {
- public FooEvent(String subject) {
- super(Type.FOO, subject);
- }
- }
-
- private static class BarEvent extends TestEvent {
- public BarEvent(String subject) {
- super(Type.BAR, subject);
- }
- }
-
- private static class FooSink implements EventSink<FooEvent> {
- @Override public void process(FooEvent event) {}
- }
-
- private static class BarSink implements EventSink<BarEvent> {
- @Override public void process(BarEvent event) {}
- }
-
- @Before
- public void setUp() {
- registry = new DefaultEventSinkRegistry();
- }
-
- @Test
- public void basics() {
- FooSink fooSink = new FooSink();
- BarSink barSink = new BarSink();
- registry.addSink(FooEvent.class, fooSink);
- registry.addSink(BarEvent.class, barSink);
-
- assertEquals("incorrect sink count", 2, registry.getSinks().size());
- assertEquals("incorrect sink", fooSink, registry.getSink(FooEvent.class));
- assertEquals("incorrect sink", barSink, registry.getSink(BarEvent.class));
-
- registry.removeSink(FooEvent.class);
- assertNull("incorrect sink", registry.getSink(FooEvent.class));
- assertEquals("incorrect sink", barSink, registry.getSink(BarEvent.class));
-
- }
-}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java
deleted file mode 100644
index b81155e6..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java
+++ /dev/null
@@ -1,58 +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.event;
-
-import java.util.Set;
-
-/**
- * Testing adapter for the event delivery service.
- */
-public class EventDeliveryServiceAdapter implements EventDeliveryService {
- @Override
- public void setDispatchTimeLimit(long millis) {
-
- }
-
- @Override
- public long getDispatchTimeLimit() {
- return 0;
- }
-
- @Override
- public void post(Event event) {
-
- }
-
- @Override
- public <E extends Event> void addSink(Class<E> eventClass, EventSink<E> sink) {
-
- }
-
- @Override
- public <E extends Event> void removeSink(Class<E> eventClass) {
-
- }
-
- @Override
- public <E extends Event> EventSink<E> getSink(Class<E> eventClass) {
- return null;
- }
-
- @Override
- public Set<Class<? extends Event>> getSinks() {
- return null;
- }
-}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/ListenerRegistryTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/ListenerRegistryTest.java
deleted file mode 100644
index 8cce6417..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/ListenerRegistryTest.java
+++ /dev/null
@@ -1,74 +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.event;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit tests for {@link ListenerRegistry}.
- */
-public class ListenerRegistryTest {
-
- private static final TestEvent FOO_EVENT =
- new TestEvent(TestEvent.Type.FOO, "foo");
- private static final TestEvent BAR_EVENT =
- new TestEvent(TestEvent.Type.BAR, "bar");
-
- private TestListener listener;
- private TestListener secondListener;
- private TestListenerRegistry manager;
-
- @Before
- public void setUp() {
- listener = new TestListener();
- secondListener = new TestListener();
- manager = new TestListenerRegistry();
- }
-
- @Test
- public void basics() {
- manager.addListener(listener);
- manager.addListener(secondListener);
-
- manager.process(BAR_EVENT);
- assertTrue("BAR not processed", listener.events.contains(BAR_EVENT));
- assertTrue("BAR not processed", secondListener.events.contains(BAR_EVENT));
-
- manager.removeListener(listener);
-
- manager.process(FOO_EVENT);
- assertFalse("FOO processed", listener.events.contains(FOO_EVENT));
- assertTrue("FOO not processed", secondListener.events.contains(FOO_EVENT));
- }
-
- @Test
- public void badListener() {
- listener = new BrokenListener();
-
- manager.addListener(listener);
- manager.addListener(secondListener);
-
- manager.process(BAR_EVENT);
- assertFalse("BAR processed", listener.events.contains(BAR_EVENT));
- assertFalse("error not reported", manager.errors.isEmpty());
- assertTrue("BAR not processed", secondListener.events.contains(BAR_EVENT));
- }
-
-}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestEvent.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestEvent.java
deleted file mode 100644
index 8a507151..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestEvent.java
+++ /dev/null
@@ -1,34 +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.event;
-
-/**
- * Test event fixture.
- */
-public class TestEvent extends AbstractEvent<TestEvent.Type, String> {
-
- public enum Type { FOO, BAR }
-
- public TestEvent(Type type, String subject) {
- super(type, subject);
- }
-
- public TestEvent(Type type, String subject, long timestamp) {
- super(type, subject, timestamp);
- }
-
-}
-
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestListener.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestListener.java
deleted file mode 100644
index 213f8c59..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestListener.java
+++ /dev/null
@@ -1,34 +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.event;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Test event listener fixture.
- */
-public class TestListener implements EventListener<TestEvent> {
-
- public final List<TestEvent> events = new ArrayList<>();
-
- @Override
- public void event(TestEvent event) {
- events.add(event);
- }
-
-}
-
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestListenerRegistry.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestListenerRegistry.java
deleted file mode 100644
index fd9b6d08..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/TestListenerRegistry.java
+++ /dev/null
@@ -1,36 +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.event;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Test event listener manager fixture.
- */
-public class TestListenerRegistry
- extends ListenerRegistry<TestEvent, TestListener> {
-
- public final List<Throwable> errors = new ArrayList<>();
-
- @Override
- protected void reportProblem(TestEvent event, Throwable error) {
- super.reportProblem(event, error);
- errors.add(error);
- }
-
-}
-