Ignore:
Timestamp:
2023-03-21T14:49:10+01:00 (2 years ago)
Author:
taylor.smock
Message:

See #16567: Convert most plugin tests to JUnit 5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/SubscriberRegistryTest.java

    r34000 r36064  
    1717package org.openstreetmap.josm.eventbus;
    1818
    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;
     19import static org.junit.jupiter.api.Assertions.assertEquals;
     20import static org.junit.jupiter.api.Assertions.assertFalse;
     21import static org.junit.jupiter.api.Assertions.assertThrows;
     22import static org.junit.jupiter.api.Assertions.assertTrue;
    2323
    2424import java.util.Arrays;
     
    2626import java.util.Iterator;
    2727
    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;
     28import org.junit.jupiter.api.Assertions;
     29import org.junit.jupiter.api.Disabled;
     30import org.junit.jupiter.api.Test;
     31
    3432
    3533/**
     
    4341
    4442  @Test
    45   public void testRegister() {
     43  void testRegister() {
    4644    assertEquals(0, registry.getSubscribersForTesting(String.class).size());
    4745
     
    5856
    5957  @Test
    60   public void testUnregister() {
     58  void testUnregister() {
    6159    StringSubscriber s1 = new StringSubscriber();
    6260    StringSubscriber s2 = new StringSubscriber();
     
    7371
    7472  @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));
    8176
    8277    StringSubscriber s1 = new StringSubscriber();
    8378    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));
    9081
    9182    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() {
    10288    assertEquals(0, size(registry.getSubscribers("")));
    10389
     
    120106
    121107  @Test
    122   @Ignore("FIXME")
    123   public void testGetSubscribers_returnsImmutableSnapshot() {
     108  @Disabled("FIXME")
     109  void testGetSubscribersReturnsImmutableSnapshot() {
    124110    StringSubscriber s1 = new StringSubscriber();
    125111    StringSubscriber s2 = new StringSubscriber();
     
    186172
    187173  @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));
    197181  }
    198182
Note: See TracChangeset for help on using the changeset viewer.