Changeset 17121 in josm


Ignore:
Timestamp:
2020-10-08T21:03:02+02:00 (6 months ago)
Author:
simon04
Message:

see #18200 - Fix HelpBrowserTest after JMockit update (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java

    r16159 r17121  
    22package org.openstreetmap.josm.gui.help;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNull;
    66
    77import java.util.Collections;
     
    99import javax.swing.JOptionPane;
    1010
    11 import org.junit.Rule;
    12 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
     12import org.junit.jupiter.api.extension.RegisterExtension;
    1313import org.openstreetmap.josm.TestUtils;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    2121import mockit.Expectations;
    2222import mockit.Injectable;
     23import mockit.Mocked;
    2324
    2425/**
    2526 * Unit tests of {@link HelpBrowser} class.
    2627 */
    27 public class HelpBrowserTest {
     28class HelpBrowserTest {
    2829
    2930    static final String URL_1 = "https://josm.openstreetmap.de/wiki/Help";
     
    3435     * Setup tests
    3536     */
    36     @Rule
     37    @RegisterExtension
    3738    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().preferences().https();
     39    static JOSMTestRules test = new JOSMTestRules().preferences().https();
    3940
    4041    static IHelpBrowser newHelpBrowser() {
     
    7677     */
    7778    @Test
    78     public void testBackAndForwardActions() {
     79    void testBackAndForwardActions() {
    7980        IHelpBrowser browser = newHelpBrowser();
    8081        browser.openUrl(URL_1);
     
    9293     */
    9394    @Test
    94     public void testHomeAction() {
     95    void testHomeAction() {
    9596        IHelpBrowser browser = newHelpBrowser();
    9697        assertNull(browser.getUrl());
     
    102103     * Unit test of {@link HelpBrowser.EditAction} class handling a null url.
    103104     * @param mockPlatformHook platform hook mock
    104      * @throws Exception  in case of error
    105      */
    106     @Test
    107     public void testEditActionNull(@Injectable final PlatformHook mockPlatformHook) throws Exception {
    108         TestUtils.assumeWorkingJMockit();
    109         new Expectations(PlatformManager.class) {{
     105     * @param platformManager {@link PlatformManager} mock
     106     * @throws Exception  in case of error
     107     */
     108    @Test
     109    void testEditActionNull(@Injectable final PlatformHook mockPlatformHook, @Mocked final PlatformManager platformManager) throws Exception {
     110        TestUtils.assumeWorkingJMockit();
     111        new Expectations() {{
    110112            PlatformManager.getPlatform(); result = mockPlatformHook; minTimes = 0;
    111         }};
    112         new Expectations() {{
    113113            // should not be called
    114114            mockPlatformHook.openUrl((String) any); times = 0;
     
    123123     * Unit test of {@link HelpBrowser.EditAction} class handling an "internal" url.
    124124     * @param mockPlatformHook platform hook mock
    125      * @throws Exception  in case of error
    126      */
    127     @Test
    128     public void testEditActionInternal(@Injectable final PlatformHook mockPlatformHook) throws Exception {
    129         TestUtils.assumeWorkingJMockit();
    130         new Expectations(PlatformManager.class) {{
     125     * @param platformManager {@link PlatformManager} mock
     126     * @throws Exception  in case of error
     127     */
     128    @Test
     129    void testEditActionInternal(@Injectable final PlatformHook mockPlatformHook,
     130                                @Mocked final PlatformManager platformManager) throws Exception {
     131        TestUtils.assumeWorkingJMockit();
     132        new Expectations() {{
    131133            PlatformManager.getPlatform(); result = mockPlatformHook;
    132         }};
    133         new Expectations() {{
    134134            mockPlatformHook.openUrl(URL_2 + "?action=edit"); result = null; times = 1;
    135135        }};
     
    144144     * Unit test of {@link HelpBrowser.EditAction} class handling an "external" url.
    145145     * @param mockPlatformHook platform hook mock
    146      * @throws Exception  in case of error
    147      */
    148     @Test
    149     public void testEditActionExternal(@Injectable final PlatformHook mockPlatformHook) throws Exception {
    150         TestUtils.assumeWorkingJMockit();
    151         new Expectations(PlatformManager.class) {{
     146     * @param platformManager {@link PlatformManager} mock
     147     * @throws Exception  in case of error
     148     */
     149    @Test
     150    void testEditActionExternal(@Injectable final PlatformHook mockPlatformHook,
     151                                @Mocked final PlatformManager platformManager) throws Exception {
     152        TestUtils.assumeWorkingJMockit();
     153        new Expectations() {{
    152154            PlatformManager.getPlatform(); result = mockPlatformHook; minTimes = 0;
    153         }};
    154         new Expectations() {{
    155155            // should not be called
    156156            mockPlatformHook.openUrl((String) any); times = 0;
     
    178178    /**
    179179     * Unit test of {@link HelpBrowser.OpenInBrowserAction} class.
    180      * @param mockPlatformHook platform hook mock
    181      * @throws Exception  in case of error
    182      */
    183     @Test
    184     public void testOpenInBrowserAction(@Injectable final PlatformHook mockPlatformHook) throws Exception {
    185         TestUtils.assumeWorkingJMockit();
    186         new Expectations(PlatformManager.class) {{
     180     * @param mockPlatformHook platform hook moc
     181     * @param platformManager {@link PlatformManager} mock
     182     * @throws Exception  in case of error
     183     */
     184    @Test
     185    void testOpenInBrowserAction(@Injectable final PlatformHook mockPlatformHook,
     186                                 @Mocked final PlatformManager platformManager) throws Exception {
     187        TestUtils.assumeWorkingJMockit();
     188        new Expectations() {{
    187189            PlatformManager.getPlatform(); result = mockPlatformHook;
    188         }};
    189         new Expectations() {{
    190190            mockPlatformHook.openUrl(URL_1); result = null; times = 1;
    191191        }};
     
    201201     */
    202202    @Test
    203     public void testReloadAction() {
     203    void testReloadAction() {
    204204        IHelpBrowser browser = newHelpBrowser();
    205205        browser.openUrl(URL_1);
Note: See TracChangeset for help on using the changeset viewer.