[Git][java-team/libsejda-eventstudio-java][upstream] New upstream version 2.0.1
Markus Koschany
gitlab at salsa.debian.org
Sat Jan 30 23:53:03 GMT 2021
Markus Koschany pushed to branch upstream at Debian Java Maintainers / libsejda-eventstudio-java
Commits:
1da4c32d by Markus Koschany at 2021-01-31T00:41:20+01:00
New upstream version 2.0.1
- - - - -
12 changed files:
- pom.xml
- src/test/java/org/pdfsam/eventstudio/DefaultEventStudioTest.java
- src/test/java/org/pdfsam/eventstudio/EntityTest.java
- src/test/java/org/pdfsam/eventstudio/EnvelopeTest.java
- src/test/java/org/pdfsam/eventstudio/ListenersTest.java
- src/test/java/org/pdfsam/eventstudio/StaticStudioTest.java
- src/test/java/org/pdfsam/eventstudio/StationTest.java
- src/test/java/org/pdfsam/eventstudio/StationsTest.java
- src/test/java/org/pdfsam/eventstudio/TestAnnotatedBean.java
- src/test/java/org/pdfsam/eventstudio/TestPrioritizedAnnotatedBean.java
- src/test/java/org/pdfsam/eventstudio/util/ReflectionUtilsTest.java
- src/test/java/org/pdfsam/eventstudio/util/StringUtilsTest.java
Changes:
=====================================
pom.xml
=====================================
@@ -5,7 +5,7 @@
<artifactId>eventstudio</artifactId>
<packaging>jar</packaging>
<name>eventstudio</name>
- <version>2.0.0</version>
+ <version>2.0.1</version>
<description>A simple even bus implementation providing pub/sub event exchange between components</description>
<url>https://pdfsam.org</url>
@@ -37,7 +37,7 @@
<connection>scm:git:git at github.com:torakiki/event-studio.git</connection>
<developerConnection>scm:git:git at github.com:torakiki/event-studio.git</developerConnection>
<url>scm:git:git at github.com:torakiki/event-studio.git</url>
- <tag>v2.0.0</tag>
+ <tag>v2.0.1</tag>
</scm>
<developers>
@@ -67,7 +67,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>3.0.1</version>
+ <version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -131,18 +131,20 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>3.1.2</version>
+ <version>3.2.0</version>
<configuration>
- <manifestEntries>
- <Built-By>Sober Lemur S.a.s.</Built-By>
- <Automatic-Module-Name>org.pdfsam.eventstudio</Automatic-Module-Name>
- </manifestEntries>
+ <archive>
+ <manifestEntries>
+ <Built-By>Sober Lemur S.a.s.</Built-By>
+ <Automatic-Module-Name>org.pdfsam.eventstudio</Automatic-Module-Name>
+ </manifestEntries>
+ </archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <version>3.1.0</version>
+ <version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
@@ -155,7 +157,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>3.0.0-M4</version>
+ <version>3.0.0-M5</version>
</plugin>
</plugins>
</build>
@@ -163,7 +165,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.29</version>
+ <version>1.7.30</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
@@ -174,13 +176,13 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>3.0.0</version>
+ <version>3.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.12</version>
+ <version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
=====================================
src/test/java/org/pdfsam/eventstudio/DefaultEventStudioTest.java
=====================================
@@ -37,175 +37,175 @@ import org.mockito.MockitoAnnotations;
*/
public class DefaultEventStudioTest {
- private static final String STATION = "station";
- @Mock
- private Station anotherStation, station, hidden;
- @Mock
- private Stations stations;
- @Mock
- private Supervisor supervisor;
- @Mock
- private Listener<Object> listener;
- @Mock
- private Object event;
- @InjectMocks
- private DefaultEventStudio victim;
-
- @Before
- public void initMocks() {
- MockitoAnnotations.initMocks(this);
- when(stations.getStation(DefaultEventStudio.HIDDEN_STATION)).thenReturn(hidden);
- when(stations.getStation(STATION)).thenReturn(station);
- when(stations.getStation("anotherStation")).thenReturn(anotherStation);
- List<Station> stationsCollection = new ArrayList<>();
- stationsCollection.add(hidden);
- stationsCollection.add(station);
- when(stations.getStations()).thenReturn(stationsCollection);
- }
-
- @Test
- public void addHiddenStation() {
- victim.add(listener);
- verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
- verify(hidden).add(listener, 0, ReferenceStrength.STRONG);
- }
-
- @Test
- public void addHiddenStationWithEventClass() {
- victim.add(Object.class, listener);
- verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
- verify(hidden).add(Object.class, listener, 0, ReferenceStrength.STRONG);
- }
-
- @Test
- public void addStation() {
- victim.add(listener, STATION);
- verify(stations).getStation(STATION);
- verify(station).add(listener, 0, ReferenceStrength.STRONG);
- }
-
- @Test
- public void addStationWithEventClass() {
- victim.add(Object.class, listener, STATION);
- verify(stations).getStation(STATION);
- verify(station).add(Object.class, listener, 0, ReferenceStrength.STRONG);
- }
-
- @Test
- public void addHiddenStationWithPriority() {
- victim.add(listener, 1, ReferenceStrength.SOFT);
- verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
- verify(hidden).add(listener, 1, ReferenceStrength.SOFT);
- }
-
- @Test
- public void addHiddenStationWithPriorityAndEventClass() {
- victim.add(Object.class, listener, 1, ReferenceStrength.SOFT);
- verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
- verify(hidden).add(Object.class, listener, 1, ReferenceStrength.SOFT);
- }
-
- @Test
- public void addStationWithPriority() {
- victim.add(listener, STATION, 1, ReferenceStrength.SOFT);
- verify(stations).getStation(STATION);
- verify(station).add(listener, 1, ReferenceStrength.SOFT);
- }
-
- @Test
- public void addStationWithPriorityAndEventClass() {
- victim.add(Object.class, listener, STATION, 1, ReferenceStrength.SOFT);
- verify(stations).getStation(STATION);
- verify(station).add(Object.class, listener, 1, ReferenceStrength.SOFT);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void nullSupervisor() {
- victim.supervisor(null);
- }
-
- @Test
- public void removeHidden() {
- victim.remove(listener);
- verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
- verify(hidden).remove(listener);
- }
-
- @Test
- public void removeHiddenWithClass() {
- victim.remove(Object.class, listener);
- verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
- verify(hidden).remove(Object.class, listener);
- }
-
- @Test
- public void removeFromStation() {
- victim.remove(listener, STATION);
- verify(stations).getStation(STATION);
- verify(station).remove(listener);
- }
-
- @Test
- public void removeFromStationWithClass() {
- victim.remove(Object.class, listener, STATION);
- verify(stations).getStation(STATION);
- verify(station).remove(Object.class, listener);
- }
-
- @Test
- public void SupervisorHidden() {
- victim.supervisor(supervisor);
- verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
- verify(hidden).supervior(supervisor);
- }
-
- @Test
- public void Supervisor() {
- victim.supervisor(supervisor, STATION);
- verify(stations).getStation(STATION);
- verify(station).supervior(supervisor);
- }
-
- @Test
- public void clearHidden() {
- victim.clear();
- verify(stations).clear(DefaultEventStudio.HIDDEN_STATION);
- }
-
- @Test
- public void clear() {
- victim.clear(STATION);
- verify(stations).clear(STATION);
- }
-
- @Test
- public void broadcastHidden() {
- victim.broadcast(event);
- verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
- verify(hidden).broadcast(event);
- }
-
- @Test
- public void broadcastStation() {
- victim.broadcast(event, STATION);
- verify(stations).getStation(STATION);
- verify(station).broadcast(event);
- }
-
- @Test
- public void broadcastAll() {
- victim.broadcastToEveryStation(event);
- verify(hidden).broadcast(event);
- verify(station).broadcast(event);
- }
-
- @Test
- public void addAnnotatedListeners() {
- TestAnnotatedBean bean = new TestAnnotatedBean();
- victim.addAnnotatedListeners(bean);
- verify(stations).getStation(STATION);
- verify(stations).getStation("anotherStation");
- verify(station).addAll(eq(bean), anyList());
- verify(anotherStation).addAll(eq(bean), anyList());
- }
+ private static final String STATION = "station";
+ @Mock
+ private Station anotherStation, station, hidden;
+ @Mock
+ private Stations stations;
+ @Mock
+ private Supervisor supervisor;
+ @Mock
+ private Listener<Object> listener;
+ @Mock
+ private Object event;
+ @InjectMocks
+ private DefaultEventStudio victim;
+
+ @Before
+ public void initMocks() {
+ MockitoAnnotations.openMocks(this);
+ when(stations.getStation(DefaultEventStudio.HIDDEN_STATION)).thenReturn(hidden);
+ when(stations.getStation(STATION)).thenReturn(station);
+ when(stations.getStation("anotherStation")).thenReturn(anotherStation);
+ List<Station> stationsCollection = new ArrayList<>();
+ stationsCollection.add(hidden);
+ stationsCollection.add(station);
+ when(stations.getStations()).thenReturn(stationsCollection);
+ }
+
+ @Test
+ public void addHiddenStation() {
+ victim.add(listener);
+ verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
+ verify(hidden).add(listener, 0, ReferenceStrength.STRONG);
+ }
+
+ @Test
+ public void addHiddenStationWithEventClass() {
+ victim.add(Object.class, listener);
+ verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
+ verify(hidden).add(Object.class, listener, 0, ReferenceStrength.STRONG);
+ }
+
+ @Test
+ public void addStation() {
+ victim.add(listener, STATION);
+ verify(stations).getStation(STATION);
+ verify(station).add(listener, 0, ReferenceStrength.STRONG);
+ }
+
+ @Test
+ public void addStationWithEventClass() {
+ victim.add(Object.class, listener, STATION);
+ verify(stations).getStation(STATION);
+ verify(station).add(Object.class, listener, 0, ReferenceStrength.STRONG);
+ }
+
+ @Test
+ public void addHiddenStationWithPriority() {
+ victim.add(listener, 1, ReferenceStrength.SOFT);
+ verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
+ verify(hidden).add(listener, 1, ReferenceStrength.SOFT);
+ }
+
+ @Test
+ public void addHiddenStationWithPriorityAndEventClass() {
+ victim.add(Object.class, listener, 1, ReferenceStrength.SOFT);
+ verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
+ verify(hidden).add(Object.class, listener, 1, ReferenceStrength.SOFT);
+ }
+
+ @Test
+ public void addStationWithPriority() {
+ victim.add(listener, STATION, 1, ReferenceStrength.SOFT);
+ verify(stations).getStation(STATION);
+ verify(station).add(listener, 1, ReferenceStrength.SOFT);
+ }
+
+ @Test
+ public void addStationWithPriorityAndEventClass() {
+ victim.add(Object.class, listener, STATION, 1, ReferenceStrength.SOFT);
+ verify(stations).getStation(STATION);
+ verify(station).add(Object.class, listener, 1, ReferenceStrength.SOFT);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void nullSupervisor() {
+ victim.supervisor(null);
+ }
+
+ @Test
+ public void removeHidden() {
+ victim.remove(listener);
+ verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
+ verify(hidden).remove(listener);
+ }
+
+ @Test
+ public void removeHiddenWithClass() {
+ victim.remove(Object.class, listener);
+ verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
+ verify(hidden).remove(Object.class, listener);
+ }
+
+ @Test
+ public void removeFromStation() {
+ victim.remove(listener, STATION);
+ verify(stations).getStation(STATION);
+ verify(station).remove(listener);
+ }
+
+ @Test
+ public void removeFromStationWithClass() {
+ victim.remove(Object.class, listener, STATION);
+ verify(stations).getStation(STATION);
+ verify(station).remove(Object.class, listener);
+ }
+
+ @Test
+ public void SupervisorHidden() {
+ victim.supervisor(supervisor);
+ verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
+ verify(hidden).supervior(supervisor);
+ }
+
+ @Test
+ public void Supervisor() {
+ victim.supervisor(supervisor, STATION);
+ verify(stations).getStation(STATION);
+ verify(station).supervior(supervisor);
+ }
+
+ @Test
+ public void clearHidden() {
+ victim.clear();
+ verify(stations).clear(DefaultEventStudio.HIDDEN_STATION);
+ }
+
+ @Test
+ public void clear() {
+ victim.clear(STATION);
+ verify(stations).clear(STATION);
+ }
+
+ @Test
+ public void broadcastHidden() {
+ victim.broadcast(event);
+ verify(stations).getStation(DefaultEventStudio.HIDDEN_STATION);
+ verify(hidden).broadcast(event);
+ }
+
+ @Test
+ public void broadcastStation() {
+ victim.broadcast(event, STATION);
+ verify(stations).getStation(STATION);
+ verify(station).broadcast(event);
+ }
+
+ @Test
+ public void broadcastAll() {
+ victim.broadcastToEveryStation(event);
+ verify(hidden).broadcast(event);
+ verify(station).broadcast(event);
+ }
+
+ @Test
+ public void addAnnotatedListeners() {
+ TestAnnotatedBean bean = new TestAnnotatedBean();
+ victim.addAnnotatedListeners(bean);
+ verify(stations).getStation(STATION);
+ verify(stations).getStation("anotherStation");
+ verify(station).addAll(eq(bean), anyList());
+ verify(anotherStation).addAll(eq(bean), anyList());
+ }
}
=====================================
src/test/java/org/pdfsam/eventstudio/EntityTest.java
=====================================
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertNull;
import java.lang.ref.SoftReference;
import org.junit.Test;
-import org.pdfsam.eventstudio.Entity;
import org.pdfsam.eventstudio.Entity.ReferencedEntity;
import org.pdfsam.eventstudio.Entity.StrongEntity;
=====================================
src/test/java/org/pdfsam/eventstudio/EnvelopeTest.java
=====================================
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.pdfsam.eventstudio.Envelope;
/**
* @author Andrea Vacondio
=====================================
src/test/java/org/pdfsam/eventstudio/ListenersTest.java
=====================================
@@ -26,10 +26,6 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import org.pdfsam.eventstudio.Annotations;
-import org.pdfsam.eventstudio.Listener;
-import org.pdfsam.eventstudio.Listeners;
-import org.pdfsam.eventstudio.ReferenceStrength;
import org.pdfsam.eventstudio.Annotations.ReflectiveListenerDescriptor;
import org.pdfsam.eventstudio.Annotations.ReflectiveMetadata;
import org.pdfsam.eventstudio.Listeners.ListenerReferenceHolder;
@@ -41,168 +37,172 @@ import org.pdfsam.eventstudio.annotation.EventListener;
*/
public class ListenersTest {
- private Listeners victim;
-
- @Before
- public void setUp() {
- victim = new Listeners();
- }
-
- @Test
- public void add() {
- assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
- victim.add(TestEvent.class, new TestListener(), 0, ReferenceStrength.STRONG);
- assertFalse(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
- assertEquals(1, victim.nullSafeGetListeners(TestEvent.class).size());
- }
-
- @Test
- public void addSameListener() {
- TestListener listener = new TestListener();
- victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, listener, -1, ReferenceStrength.STRONG);
- assertEquals(2, victim.nullSafeGetListeners(TestEvent.class).size());
- }
-
- @Test
- public void addManyDiffenent() {
- victim.add(AnotherTestEvent.class, new AnotherTestListener(), 0, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, new TestListener(), -1, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, new SecondTestListener(), -1, ReferenceStrength.STRONG);
- assertEquals(2, victim.nullSafeGetListeners(TestEvent.class).size());
- assertEquals(1, victim.nullSafeGetListeners(AnotherTestEvent.class).size());
- }
-
- @Test
- public void remove() {
- TestListener listener = new TestListener();
- assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
- victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
- assertFalse(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
- victim.remove(TestEvent.class, listener);
- assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
- }
-
- @Test
- public void removeMany() {
- TestListener listener = new TestListener();
- SecondTestListener listener2 = new SecondTestListener();
- AnotherTestListener anotherListener = new AnotherTestListener();
- victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, listener2, 0, ReferenceStrength.WEAK);
- victim.add(AnotherTestEvent.class, anotherListener, 0, ReferenceStrength.SOFT);
- assertFalse(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
- assertFalse(victim.nullSafeGetListeners(AnotherTestEvent.class).isEmpty());
- assertTrue(victim.remove(TestEvent.class, listener2));
- assertTrue(victim.remove(AnotherTestEvent.class, anotherListener));
- assertTrue(victim.nullSafeGetListeners(AnotherTestEvent.class).isEmpty());
- assertEquals(1, victim.nullSafeGetListeners(TestEvent.class).size());
- }
-
- @Test
- public void removeHolder() {
- TestListener listener = new TestListener();
- assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
- victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
- for (ListenerReferenceHolder holder : victim.nullSafeGetListeners(TestEvent.class)) {
- assertTrue(victim.remove(TestEvent.class, holder));
- }
- assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
- }
-
- @Test
- public void falseRemove() {
- TestListener listener = new TestListener();
- AnotherTestListener anotherListener = new AnotherTestListener();
- victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
- assertFalse(victim.remove(AnotherTestEvent.class, anotherListener));
- }
-
- @Test
- public void priorityOrder() throws IllegalAccessException, InvocationTargetException {
-
- TestListener prio0 = new TestListener();
- TestListener prio1 = new TestListener();
- TestListener prio2 = new TestListener();
- TestListener prio3 = new TestListener();
- TestListener prio4 = new TestListener();
- TestListener prio5 = new TestListener();
- TestListener prio6 = new TestListener();
- TestListener prio7 = new TestListener();
- TestListener prio8 = new TestListener();
- TestListener prio9 = new TestListener();
- victim.add(TestEvent.class, prio7, 7, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio9, 9, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio0, 0, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio1, 1, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio2, 2, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio5, 5, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio6, 6, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio8, 8, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio3, 3, ReferenceStrength.STRONG);
- victim.add(TestEvent.class, prio4, 4, ReferenceStrength.STRONG);
- ReflectiveTestListener bean = new ReflectiveTestListener();
- ReflectiveMetadata metadata = Annotations.process(bean);
- for (List<ReflectiveListenerDescriptor> descriptors : metadata.getDescriptors().values()) {
- victim.addAll(bean, descriptors);
- }
- List<ListenerReferenceHolder> listeners = victim.nullSafeGetListeners(TestEvent.class);
- assertEquals(Integer.MIN_VALUE, listeners.get(0).priority);
- assertEquals(0, listeners.get(1).priority);
- assertEquals(1, listeners.get(2).priority);
- assertEquals(2, listeners.get(3).priority);
- assertEquals(3, listeners.get(4).priority);
- assertEquals(4, listeners.get(5).priority);
- assertEquals(4, listeners.get(6).priority);
- assertEquals(5, listeners.get(7).priority);
- assertEquals(6, listeners.get(8).priority);
- assertEquals(7, listeners.get(9).priority);
- assertEquals(8, listeners.get(10).priority);
- assertEquals(9, listeners.get(11).priority);
- assertEquals(Integer.MAX_VALUE, listeners.get(12).priority);
- }
-
- private static class AnotherTestListener implements Listener<AnotherTestEvent> {
- public void onEvent(AnotherTestEvent event) {
- // nothing
- }
- }
-
- private static class SecondTestListener implements Listener<TestEvent> {
- public void onEvent(TestEvent event) {
- // nothing
- }
- }
-
- private static class TestListener implements Listener<TestEvent> {
- public void onEvent(TestEvent event) {
- // nothing
- }
- }
-
- private static class ReflectiveTestListener implements Listener<TestEvent> {
- @EventListener(priority = 4)
- public void onEvent(TestEvent event) {
- // nothing
- }
-
- @EventListener(priority = Integer.MIN_VALUE)
- public void onSuperPrioEvent(TestEvent event) {
- // nothing
- }
-
- @EventListener(priority = Integer.MAX_VALUE)
- public void onLowestPrioEvent(TestEvent event) {
- // nothing
- }
- }
-
- private static class TestEvent {
- // nothing
- }
-
- private static class AnotherTestEvent {
- // nothing
- }
+ private Listeners victim;
+
+ @Before
+ public void setUp() {
+ victim = new Listeners();
+ }
+
+ @Test
+ public void add() {
+ assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
+ victim.add(TestEvent.class, new TestListener(), 0, ReferenceStrength.STRONG);
+ assertFalse(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
+ assertEquals(1, victim.nullSafeGetListeners(TestEvent.class).size());
+ }
+
+ @Test
+ public void addSameListener() {
+ TestListener listener = new TestListener();
+ victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, listener, -1, ReferenceStrength.STRONG);
+ assertEquals(2, victim.nullSafeGetListeners(TestEvent.class).size());
+ }
+
+ @Test
+ public void addManyDiffenent() {
+ victim.add(AnotherTestEvent.class, new AnotherTestListener(), 0, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, new TestListener(), -1, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, new SecondTestListener(), -1, ReferenceStrength.STRONG);
+ assertEquals(2, victim.nullSafeGetListeners(TestEvent.class).size());
+ assertEquals(1, victim.nullSafeGetListeners(AnotherTestEvent.class).size());
+ }
+
+ @Test
+ public void remove() {
+ TestListener listener = new TestListener();
+ assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
+ victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
+ assertFalse(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
+ victim.remove(TestEvent.class, listener);
+ assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
+ }
+
+ @Test
+ public void removeMany() {
+ TestListener listener = new TestListener();
+ SecondTestListener listener2 = new SecondTestListener();
+ AnotherTestListener anotherListener = new AnotherTestListener();
+ victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, listener2, 0, ReferenceStrength.WEAK);
+ victim.add(AnotherTestEvent.class, anotherListener, 0, ReferenceStrength.SOFT);
+ assertFalse(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
+ assertFalse(victim.nullSafeGetListeners(AnotherTestEvent.class).isEmpty());
+ assertTrue(victim.remove(TestEvent.class, listener2));
+ assertTrue(victim.remove(AnotherTestEvent.class, anotherListener));
+ assertTrue(victim.nullSafeGetListeners(AnotherTestEvent.class).isEmpty());
+ assertEquals(1, victim.nullSafeGetListeners(TestEvent.class).size());
+ }
+
+ @Test
+ public void removeHolder() {
+ TestListener listener = new TestListener();
+ assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
+ victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
+ for (ListenerReferenceHolder holder : victim.nullSafeGetListeners(TestEvent.class)) {
+ assertTrue(victim.remove(TestEvent.class, holder));
+ }
+ assertTrue(victim.nullSafeGetListeners(TestEvent.class).isEmpty());
+ }
+
+ @Test
+ public void falseRemove() {
+ TestListener listener = new TestListener();
+ AnotherTestListener anotherListener = new AnotherTestListener();
+ victim.add(TestEvent.class, listener, 0, ReferenceStrength.STRONG);
+ assertFalse(victim.remove(AnotherTestEvent.class, anotherListener));
+ }
+
+ @Test
+ public void priorityOrder() throws IllegalAccessException, InvocationTargetException {
+
+ TestListener prio0 = new TestListener();
+ TestListener prio1 = new TestListener();
+ TestListener prio2 = new TestListener();
+ TestListener prio3 = new TestListener();
+ TestListener prio4 = new TestListener();
+ TestListener prio5 = new TestListener();
+ TestListener prio6 = new TestListener();
+ TestListener prio7 = new TestListener();
+ TestListener prio8 = new TestListener();
+ TestListener prio9 = new TestListener();
+ victim.add(TestEvent.class, prio7, 7, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio9, 9, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio0, 0, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio1, 1, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio2, 2, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio5, 5, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio6, 6, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio8, 8, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio3, 3, ReferenceStrength.STRONG);
+ victim.add(TestEvent.class, prio4, 4, ReferenceStrength.STRONG);
+ ReflectiveTestListener bean = new ReflectiveTestListener();
+ ReflectiveMetadata metadata = Annotations.process(bean);
+ for (List<ReflectiveListenerDescriptor> descriptors : metadata.getDescriptors().values()) {
+ victim.addAll(bean, descriptors);
+ }
+ List<ListenerReferenceHolder> listeners = victim.nullSafeGetListeners(TestEvent.class);
+ assertEquals(Integer.MIN_VALUE, listeners.get(0).priority);
+ assertEquals(0, listeners.get(1).priority);
+ assertEquals(1, listeners.get(2).priority);
+ assertEquals(2, listeners.get(3).priority);
+ assertEquals(3, listeners.get(4).priority);
+ assertEquals(4, listeners.get(5).priority);
+ assertEquals(4, listeners.get(6).priority);
+ assertEquals(5, listeners.get(7).priority);
+ assertEquals(6, listeners.get(8).priority);
+ assertEquals(7, listeners.get(9).priority);
+ assertEquals(8, listeners.get(10).priority);
+ assertEquals(9, listeners.get(11).priority);
+ assertEquals(Integer.MAX_VALUE, listeners.get(12).priority);
+ }
+
+ private static class AnotherTestListener implements Listener<AnotherTestEvent> {
+ @Override
+ public void onEvent(AnotherTestEvent event) {
+ // nothing
+ }
+ }
+
+ private static class SecondTestListener implements Listener<TestEvent> {
+ @Override
+ public void onEvent(TestEvent event) {
+ // nothing
+ }
+ }
+
+ private static class TestListener implements Listener<TestEvent> {
+ @Override
+ public void onEvent(TestEvent event) {
+ // nothing
+ }
+ }
+
+ private static class ReflectiveTestListener implements Listener<TestEvent> {
+ @Override
+ @EventListener(priority = 4)
+ public void onEvent(TestEvent event) {
+ // nothing
+ }
+
+ @EventListener(priority = Integer.MIN_VALUE)
+ public void onSuperPrioEvent(TestEvent event) {
+ // nothing
+ }
+
+ @EventListener(priority = Integer.MAX_VALUE)
+ public void onLowestPrioEvent(TestEvent event) {
+ // nothing
+ }
+ }
+
+ private static class TestEvent {
+ // nothing
+ }
+
+ private static class AnotherTestEvent {
+ // nothing
+ }
}
=====================================
src/test/java/org/pdfsam/eventstudio/StaticStudioTest.java
=====================================
@@ -20,7 +20,6 @@ package org.pdfsam.eventstudio;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
-import org.pdfsam.eventstudio.StaticStudio;
/**
* @author Andrea Vacondio
=====================================
src/test/java/org/pdfsam/eventstudio/StationTest.java
=====================================
@@ -18,7 +18,7 @@
package org.pdfsam.eventstudio;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -35,13 +35,7 @@ import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.pdfsam.eventstudio.Annotations;
-import org.pdfsam.eventstudio.EventStudio;
-import org.pdfsam.eventstudio.Listener;
-import org.pdfsam.eventstudio.ReferenceStrength;
-import org.pdfsam.eventstudio.Station;
-import org.pdfsam.eventstudio.Supervisor;
+import org.mockito.junit.MockitoJUnitRunner;
import org.pdfsam.eventstudio.Annotations.ReflectiveMetadata;
import org.pdfsam.eventstudio.annotation.EventListener;
import org.pdfsam.eventstudio.exception.BroadcastInterruptionException;
@@ -235,6 +229,7 @@ public class StationTest {
}
private class SecondTestListener<T extends Object> implements Listener<T> {
+ @Override
public void onEvent(T event) {
// nothing
}
=====================================
src/test/java/org/pdfsam/eventstudio/StationsTest.java
=====================================
@@ -22,8 +22,6 @@ import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;
-import org.pdfsam.eventstudio.Station;
-import org.pdfsam.eventstudio.Stations;
/**
* @author Andrea Vacondio
=====================================
src/test/java/org/pdfsam/eventstudio/TestAnnotatedBean.java
=====================================
@@ -17,7 +17,6 @@
*/
package org.pdfsam.eventstudio;
-import org.pdfsam.eventstudio.ReferenceStrength;
import org.pdfsam.eventstudio.annotation.EventListener;
import org.pdfsam.eventstudio.annotation.EventStation;
=====================================
src/test/java/org/pdfsam/eventstudio/TestPrioritizedAnnotatedBean.java
=====================================
@@ -17,7 +17,6 @@
*/
package org.pdfsam.eventstudio;
-import org.pdfsam.eventstudio.ReferenceStrength;
import org.pdfsam.eventstudio.annotation.EventListener;
/**
=====================================
src/test/java/org/pdfsam/eventstudio/util/ReflectionUtilsTest.java
=====================================
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.pdfsam.eventstudio.Listener;
-import org.pdfsam.eventstudio.util.ReflectionUtils;
/**
* @author Andrea Vacondio
=====================================
src/test/java/org/pdfsam/eventstudio/util/StringUtilsTest.java
=====================================
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.pdfsam.eventstudio.util.StringUtils;
/**
* @author Andrea Vacondio
*
View it on GitLab: https://salsa.debian.org/java-team/libsejda-eventstudio-java/-/commit/1da4c32dd755d9f35e56348a975ac2e3ae2445d5
--
View it on GitLab: https://salsa.debian.org/java-team/libsejda-eventstudio-java/-/commit/1da4c32dd755d9f35e56348a975ac2e3ae2445d5
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20210130/f138435d/attachment.html>
More information about the pkg-java-commits
mailing list