Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (19 months ago)
Author:
Don-vip
Message:

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

Location:
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellEditorTest.java

    r10962 r17275  
    22package org.openstreetmap.josm.gui.conflict.tags;
    33
    4 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.Rule;
    7 import org.junit.Test;
     6import org.junit.jupiter.api.extension.RegisterExtension;
     7import org.junit.jupiter.api.Test;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
     
    1313 * Unit tests of {@link MultiValueCellEditor} class.
    1414 */
    15 public class MultiValueCellEditorTest {
     15class MultiValueCellEditorTest {
    1616
    1717    /**
    1818     * Setup test.
    1919     */
    20     @Rule
     20    @RegisterExtension
    2121    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2222    public JOSMTestRules test = new JOSMTestRules();
     
    2626     */
    2727    @Test
    28     public void testMultiValueCellEditor() {
     28    void testMultiValueCellEditor() {
    2929        assertNotNull(new MultiValueCellEditor().getTableCellEditorComponent(null, new MultiValueResolutionDecision(), false, 0, 0));
    3030    }
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRendererTest.java

    r10962 r17275  
    22package org.openstreetmap.josm.gui.conflict.tags;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
    66
    77import java.util.Arrays;
     
    1010import javax.swing.JTable;
    1111
    12 import org.junit.Rule;
    13 import org.junit.Test;
     12import org.junit.jupiter.api.extension.RegisterExtension;
     13import org.junit.jupiter.api.Test;
    1414import org.openstreetmap.josm.data.osm.Tag;
    1515import org.openstreetmap.josm.data.osm.TagCollection;
     
    2121 * Unit tests of {@link MultiValueCellRenderer} class.
    2222 */
    23 public class MultiValueCellRendererTest {
     23class MultiValueCellRendererTest {
    2424
    2525    /**
    2626     * Setup test.
    2727     */
    28     @Rule
     28    @RegisterExtension
    2929    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3030    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    3434     */
    3535    @Test
    36     public void testMultiValueCellRenderer() {
     36    void testMultiValueCellRenderer() {
    3737        TagConflictResolverModel model = new TagConflictResolverModel();
    3838        TagCollection tags = new TagCollection(Arrays.asList(new Tag("oneway", "yes"), new Tag("oneway", "no")));
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialogTest.java

    r10962 r17275  
    22package org.openstreetmap.josm.gui.conflict.tags;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertNotNull;
    7 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertNull;
    88
    99import java.awt.Insets;
    1010
    11 import org.junit.Rule;
    12 import org.junit.Test;
     11import org.junit.jupiter.api.extension.RegisterExtension;
     12import org.junit.jupiter.api.Test;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1414import org.openstreetmap.josm.gui.conflict.tags.PasteTagsConflictResolverDialog.StatisticsInfo;
     
    2222 * Unit tests of {@link PasteTagsConflictResolverDialog} class.
    2323 */
    24 public class PasteTagsConflictResolverDialogTest {
     24class PasteTagsConflictResolverDialogTest {
    2525
    2626    /**
    2727     * Setup test.
    2828     */
    29     @Rule
     29    @RegisterExtension
    3030    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3131    public JOSMTestRules test = new JOSMTestRules();
     
    3535     */
    3636    @Test
    37     public void testPaneTitles() {
     37    void testPaneTitles() {
    3838        assertNotNull(PasteTagsConflictResolverDialog.PANE_TITLES);
    3939        assertNotNull(PasteTagsConflictResolverDialog.PANE_TITLES.get(OsmPrimitiveType.NODE));
     
    4646     */
    4747    @Test
    48     public void testStatisticsInfoTable() {
     48    void testStatisticsInfoTable() {
    4949        StatisticsInfo info = new StatisticsInfo();
    5050        StatisticsTableModel model = new StatisticsTableModel();
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModelTest.java

    r10962 r17275  
    22package org.openstreetmap.josm.gui.conflict.tags;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    88import java.util.Arrays;
     
    1010import java.util.List;
    1111
    12 import org.junit.Rule;
    13 import org.junit.Test;
     12import org.junit.jupiter.api.extension.RegisterExtension;
     13import org.junit.jupiter.api.Test;
    1414import org.openstreetmap.josm.data.coor.LatLon;
    1515import org.openstreetmap.josm.data.osm.DataSet;
     
    2525 * Unit tests of {@link RelationMemberConflictResolverModel} class.
    2626 */
    27 public class RelationMemberConflictResolverModelTest {
     27class RelationMemberConflictResolverModelTest {
    2828
    2929    /**
    3030     * Setup test.
    3131     */
    32     @Rule
     32    @RegisterExtension
    3333    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3434    public JOSMTestRules test = new JOSMTestRules();
     
    5858
    5959    @Test
    60     public void testSameRoles() throws Exception {
     60    void testSameRoles() throws Exception {
    6161        final List<Way> ways = buildTestDataSet();
    6262        final Relation r = new Relation();
     
    7676
    7777    @Test
    78     public void testDifferentRoles() throws Exception {
     78    void testDifferentRoles() throws Exception {
    7979        final List<Way> ways = buildTestDataSet();
    8080        final Relation r = new Relation();
     
    8989
    9090    @Test
    91     public void testDifferentPresence() throws Exception {
     91    void testDifferentPresence() throws Exception {
    9292        final List<Way> ways = buildTestDataSet();
    9393        final Relation r = new Relation();
     
    101101
    102102    @Test
    103     public void testEveryMemberIsPresentTwice() throws Exception {
     103    void testEveryMemberIsPresentTwice() throws Exception {
    104104        final List<Way> ways = buildTestDataSet();
    105105        final Relation r = new Relation();
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverTest.java

    r10962 r17275  
    22package org.openstreetmap.josm.gui.conflict.tags;
    33
    4 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.Rule;
    7 import org.junit.Test;
     6import org.junit.jupiter.api.extension.RegisterExtension;
     7import org.junit.jupiter.api.Test;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
     
    1313 * Unit tests of {@link RelationMemberConflictResolver} class.
    1414 */
    15 public class RelationMemberConflictResolverTest {
     15class RelationMemberConflictResolverTest {
    1616
    1717    /**
    1818     * Setup test.
    1919     */
    20     @Rule
     20    @RegisterExtension
    2121    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2222    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    2626     */
    2727    @Test
    28     public void testRelationMemberConflictResolver() {
     28    void testRelationMemberConflictResolver() {
    2929        assertNotNull(new RelationMemberConflictResolver(null));
    3030    }
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolutionUtilTest.java

    r16164 r17275  
    22package org.openstreetmap.josm.gui.conflict.tags;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertNull;
    7 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
     8import static org.junit.jupiter.api.Assertions.assertThrows;
    89
    910import java.util.Arrays;
     
    1112import java.util.HashSet;
    1213import java.util.List;
     14import java.util.regex.PatternSyntaxException;
    1315import java.util.stream.Collectors;
    1416
    15 import org.junit.Rule;
    16 import org.junit.Test;
     17import org.junit.jupiter.api.Test;
     18import org.junit.jupiter.api.extension.RegisterExtension;
    1719import org.openstreetmap.josm.data.osm.Tag;
    1820import org.openstreetmap.josm.data.osm.TagCollection;
     
    2729 * Unit tests of {@link TagConflictResolutionUtil} class.
    2830 */
    29 public class TagConflictResolutionUtilTest {
     31class TagConflictResolutionUtilTest {
    3032
    3133    /**
    3234     * Setup test.
    3335     */
    34     @Rule
     36    @RegisterExtension
    3537    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3638    public JOSMTestRules test = new JOSMTestRules();
     
    4547     */
    4648    @Test
    47     public void testApplyAutomaticTagConflictResolution() {
     49    void testApplyAutomaticTagConflictResolution() {
    4850        // Check that general tag conflict are not resolved
    4951        TagCollection tc = new TagCollection();
     
    106108     * Unit tests of {@link AutomaticCombine} class.
    107109     */
    108     public static class AutomaticCombineTest {
     110    static class AutomaticCombineTest {
    109111
    110112        /**
     
    127129         * Setup test.
    128130         */
    129         @Rule
     131        @RegisterExtension
    130132        @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    131133        public JOSMTestRules test = new JOSMTestRules();
     
    135137         */
    136138        @Test
    137         public void testMatchesKeyEmptyKey() {
     139        void testMatchesKeyEmptyKey() {
    138140            for (AutomaticCombine resolver: differentlyConstructed(new AutomaticCombine("", "random description", true, ";", null))) {
    139141                assertFalse(resolver.matchesKey("a"));
     
    146148         */
    147149        @Test
    148         public void testMatchesKeyNotRegex() {
     150        void testMatchesKeyNotRegex() {
    149151            for (AutomaticCombine resolver: differentlyConstructed(new AutomaticCombine(
    150152                    "keyname", "random description", false, "|", null))) {
     
    161163         */
    162164        @Test
    163         public void testMatchesKeyRegex() {
     165        void testMatchesKeyRegex() {
    164166            for (AutomaticCombine resolver: differentlyConstructed(new AutomaticCombine("test[45].*", "", true, ";", "Integer"))) {
    165167                assertFalse(resolver.matchesKey("key"));
     
    173175         */
    174176        @Test
    175         public void testInvalidRegex() {
     177        void testInvalidRegex() {
    176178            for (AutomaticCombine resolver: differentlyConstructed(new AutomaticCombine("invalidregex.(]", "", false, ";", null))) {
    177179                // Should not raise exception if the resolver.isRexEx == false:
     
    188190         * Unit test of {@link AutomaticCombine} with invalid regex.
    189191         */
    190         @Test(expected = java.util.regex.PatternSyntaxException.class)
    191         public void testInvalidRegexExceptionDefaultConstructed() {
     192        @Test
     193        void testInvalidRegexExceptionDefaultConstructed() {
    192194            AutomaticCombine resolver = new AutomaticCombine("AB.(]", "", true, ";", null);
    193             resolver.matchesKey("AB");
    194         }
    195 
     195            assertThrows(PatternSyntaxException.class, () -> resolver.matchesKey("AB"));
     196        }
    196197
    197198        /**
    198199         * Unit test of {@link AutomaticCombine} with invalid regex.
    199200         */
    200         @Test(expected = java.util.regex.PatternSyntaxException.class)
    201         public void testInvalidRegexExceptionFullyConstructed() {
     201        @Test
     202        void testInvalidRegexExceptionFullyConstructed() {
    202203            AutomaticCombine resolver = new AutomaticCombine();
    203204            resolver.key = "AB.(]";
    204205            resolver.isRegex = true;
    205             resolver.matchesKey("AB");
     206            assertThrows(PatternSyntaxException.class, () -> resolver.matchesKey("AB"));
    206207        }
    207208
     
    210211         */
    211212        @Test
    212         public void testResolve() {
     213        void testResolve() {
    213214            for (AutomaticCombine resolver: differentlyConstructed(new AutomaticCombine("random", "", true, "|", "String"))) {
    214215                assertEquals(resolver.resolve(newHashSet("value1", "value2")), "value1|value2");
     
    230231     * Unit tests of {@link AutomaticChoice} class.
    231232     */
    232     public static class AutomaticChoiceTest {
     233    static class AutomaticChoiceTest {
    233234        /**
    234235         * Setup test.
    235236         */
    236         @Rule
     237        @RegisterExtension
    237238        @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    238239        public JOSMTestRules test = new JOSMTestRules();
     
    260261         */
    261262        @Test
    262         public void testMatchesValue() {
     263        void testMatchesValue() {
    263264            for (AutomaticChoice resolver: differentlyConstructed(new AutomaticChoice(
    264265                    "random key", "random group", "random description", false, ".*valueToMatch", "Score$0\\1"))) {
     
    282283         */
    283284        @Test
    284         public void testComputeScoreFromValue() {
     285        void testComputeScoreFromValue() {
    285286            for (AutomaticChoice resolver: differentlyConstructed(new AutomaticChoice(
    286287                    "random key", "random group", "random description", false, ".*valueToMatch", "Score$0\\1"))) {
     
    298299         */
    299300        @Test
    300         public void testInvalidRegex() {
     301        void testInvalidRegex() {
    301302            for (AutomaticChoice resolver: differentlyConstructed(new AutomaticChoice(
    302303                    "k", "g", "", false, "invalidregex.(]", "InvalidScore$0\\1$-4"))) {
     
    316317         * Unit test of {@link AutomaticChoice} when invalid regex is used.
    317318         */
    318         @Test(expected = java.util.regex.PatternSyntaxException.class)
    319         public void testMatchesValueInvalidRegex() {
     319        @Test
     320        void testMatchesValueInvalidRegex() {
    320321            AutomaticChoice resolver = new AutomaticChoice("k", "g", "", true, "invalidregex.(]", "InvalidScore$0\\1$-4");
    321             resolver.matchesValue("test");
     322            assertThrows(PatternSyntaxException.class, () -> resolver.matchesValue("test"));
    322323        }
    323324
     
    325326         * Unit test of {@link AutomaticChoice} when invalid regex is used.
    326327         */
    327         @Test(expected = java.util.regex.PatternSyntaxException.class)
    328         public void testComputeScoreFromValueInvalidRegex() {
     328        @Test
     329        void testComputeScoreFromValueInvalidRegex() {
    329330            AutomaticChoice resolver = new AutomaticChoice("k", "g", "", true, "invalidregex.(]", "valid");
    330             resolver.computeScoreFromValue("valid");
    331         }
    332 
     331            assertThrows(PatternSyntaxException.class, () -> resolver.computeScoreFromValue("valid"));
     332        }
    333333
    334334        /**
     
    336336         */
    337337        @Test
    338         public void testComputeScoreFromValueInvalidReplacement() {
     338        void testComputeScoreFromValueInvalidReplacement() {
    339339            AutomaticChoice resolver = new AutomaticChoice("k", "g", "", true, "valid", "InvalidScore$0\\1$-4");
    340340            boolean exceptionThrown = false;
     
    351351     * Unit tests of {@link AutomaticChoiceGroup} class.
    352352     */
    353     public static class AutomaticChoiceGroupTest {
     353    static class AutomaticChoiceGroupTest {
    354354        /**
    355355         * Setup test.
    356356         */
    357         @Rule
     357        @RegisterExtension
    358358        @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    359359        public JOSMTestRules test = new JOSMTestRules();
     
    373373         */
    374374        @Test
    375         public void testGroupChoices() {
     375        void testGroupChoices() {
    376376            Collection<AutomaticChoiceGroup> groups = AutomaticChoiceGroup.groupChoices(Arrays.asList(choiceKey1Group1, choiceKey1Group2));
    377377            assertEquals(2, groups.size());
     
    405405         */
    406406        @Test
    407         public void testMatchesKey() {
     407        void testMatchesKey() {
    408408            AutomaticChoiceGroup group = new AutomaticChoiceGroup(
    409409                    choiceKey1Group1.key, choiceKey1Group1.group, choiceKey1Group1.isRegex,
     
    427427         */
    428428        @Test
    429         public void testResolve() {
     429        void testResolve() {
    430430            AutomaticChoiceGroup group = new AutomaticChoiceGroup(
    431431                    choiceKey1Group1.key, choiceKey1Group1.group, choiceKey1Group1.isRegex,
Note: See TracChangeset for help on using the changeset viewer.