Changeset 36064 in osm for applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/SubscriberRegistryTest.java
- Timestamp:
- 2023-03-21T14:49:10+01:00 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/SubscriberRegistryTest.java
r34000 r36064 17 17 package org.openstreetmap.josm.eventbus; 18 18 19 import static org.junit. Assert.assertEquals;20 import static org.junit. Assert.assertFalse;21 import static org.junit. Assert.assertTrue;22 import static org.junit. Assert.fail;19 import static org.junit.jupiter.api.Assertions.assertEquals; 20 import static org.junit.jupiter.api.Assertions.assertFalse; 21 import static org.junit.jupiter.api.Assertions.assertThrows; 22 import static org.junit.jupiter.api.Assertions.assertTrue; 23 23 24 24 import java.util.Arrays; … … 26 26 import java.util.Iterator; 27 27 28 import org.junit.Ignore; 29 import org.junit.Test; 30 import org.openstreetmap.josm.eventbus.EventBus; 31 import org.openstreetmap.josm.eventbus.Subscribe; 32 import org.openstreetmap.josm.eventbus.Subscriber; 33 import org.openstreetmap.josm.eventbus.SubscriberRegistry; 28 import org.junit.jupiter.api.Assertions; 29 import org.junit.jupiter.api.Disabled; 30 import org.junit.jupiter.api.Test; 31 34 32 35 33 /** … … 43 41 44 42 @Test 45 publicvoid testRegister() {43 void testRegister() { 46 44 assertEquals(0, registry.getSubscribersForTesting(String.class).size()); 47 45 … … 58 56 59 57 @Test 60 publicvoid testUnregister() {58 void testUnregister() { 61 59 StringSubscriber s1 = new StringSubscriber(); 62 60 StringSubscriber s2 = new StringSubscriber(); … … 73 71 74 72 @Test 75 public void testUnregister_notRegistered() { 76 try { 77 registry.unregister(new StringSubscriber()); 78 fail(); 79 } catch (IllegalArgumentException expected) { 80 } 73 void testUnregisterNotRegistered() { 74 StringSubscriber temp = new StringSubscriber(); 75 assertThrows(IllegalArgumentException.class, () -> registry.unregister(temp)); 81 76 82 77 StringSubscriber s1 = new StringSubscriber(); 83 78 registry.register(s1); 84 try { 85 registry.unregister(new StringSubscriber()); 86 fail(); 87 } catch (IllegalArgumentException expected) { 88 // a StringSubscriber was registered, but not the same one we tried to unregister 89 } 79 // a StringSubscriber was registered, but not the same one we tried to unregister 80 assertThrows(IllegalArgumentException.class, () -> registry.unregister(temp)); 90 81 91 82 registry.unregister(s1); 92 93 try { 94 registry.unregister(s1); 95 fail(); 96 } catch (IllegalArgumentException expected) { 97 } 98 } 99 100 @Test 101 public void testGetSubscribers() { 83 assertThrows(IllegalArgumentException.class, () -> registry.unregister(s1)); 84 } 85 86 @Test 87 void testGetSubscribers() { 102 88 assertEquals(0, size(registry.getSubscribers(""))); 103 89 … … 120 106 121 107 @Test 122 @ Ignore("FIXME")123 publicvoid testGetSubscribers_returnsImmutableSnapshot() {108 @Disabled("FIXME") 109 void testGetSubscribersReturnsImmutableSnapshot() { 124 110 StringSubscriber s1 = new StringSubscriber(); 125 111 StringSubscriber s2 = new StringSubscriber(); … … 186 172 187 173 @Test 188 public void testFlattenHierarchy() { 189 assertEquals( 190 new HashSet<>(Arrays.asList( 191 Object.class, 192 HierarchyFixtureInterface.class, 193 HierarchyFixtureSubinterface.class, 194 HierarchyFixtureParent.class, 195 HierarchyFixture.class)), 196 SubscriberRegistry.flattenHierarchy(HierarchyFixture.class)); 174 void testFlattenHierarchy() { 175 assertEquals(new HashSet<>(Arrays.asList( 176 Object.class, 177 HierarchyFixtureInterface.class, 178 HierarchyFixtureSubinterface.class, 179 HierarchyFixtureParent.class, 180 HierarchyFixture.class)), SubscriberRegistry.flattenHierarchy(HierarchyFixture.class)); 197 181 } 198 182
Note:
See TracChangeset
for help on using the changeset viewer.