- Timestamp:
- 2020-10-08T21:03:02+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java
r16159 r17121 2 2 package org.openstreetmap.josm.gui.help; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 6 7 7 import java.util.Collections; … … 9 9 import javax.swing.JOptionPane; 10 10 11 import org.junit. Rule;12 import org.junit. Test;11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.extension.RegisterExtension; 13 13 import org.openstreetmap.josm.TestUtils; 14 14 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 21 21 import mockit.Expectations; 22 22 import mockit.Injectable; 23 import mockit.Mocked; 23 24 24 25 /** 25 26 * Unit tests of {@link HelpBrowser} class. 26 27 */ 27 publicclass HelpBrowserTest {28 class HelpBrowserTest { 28 29 29 30 static final String URL_1 = "https://josm.openstreetmap.de/wiki/Help"; … … 34 35 * Setup tests 35 36 */ 36 @R ule37 @RegisterExtension 37 38 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 38 public JOSMTestRules test = new JOSMTestRules().preferences().https();39 static JOSMTestRules test = new JOSMTestRules().preferences().https(); 39 40 40 41 static IHelpBrowser newHelpBrowser() { … … 76 77 */ 77 78 @Test 78 publicvoid testBackAndForwardActions() {79 void testBackAndForwardActions() { 79 80 IHelpBrowser browser = newHelpBrowser(); 80 81 browser.openUrl(URL_1); … … 92 93 */ 93 94 @Test 94 publicvoid testHomeAction() {95 void testHomeAction() { 95 96 IHelpBrowser browser = newHelpBrowser(); 96 97 assertNull(browser.getUrl()); … … 102 103 * Unit test of {@link HelpBrowser.EditAction} class handling a null url. 103 104 * @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() {{ 110 112 PlatformManager.getPlatform(); result = mockPlatformHook; minTimes = 0; 111 }};112 new Expectations() {{113 113 // should not be called 114 114 mockPlatformHook.openUrl((String) any); times = 0; … … 123 123 * Unit test of {@link HelpBrowser.EditAction} class handling an "internal" url. 124 124 * @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() {{ 131 133 PlatformManager.getPlatform(); result = mockPlatformHook; 132 }};133 new Expectations() {{134 134 mockPlatformHook.openUrl(URL_2 + "?action=edit"); result = null; times = 1; 135 135 }}; … … 144 144 * Unit test of {@link HelpBrowser.EditAction} class handling an "external" url. 145 145 * @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() {{ 152 154 PlatformManager.getPlatform(); result = mockPlatformHook; minTimes = 0; 153 }};154 new Expectations() {{155 155 // should not be called 156 156 mockPlatformHook.openUrl((String) any); times = 0; … … 178 178 /** 179 179 * 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() {{ 187 189 PlatformManager.getPlatform(); result = mockPlatformHook; 188 }};189 new Expectations() {{190 190 mockPlatformHook.openUrl(URL_1); result = null; times = 1; 191 191 }}; … … 201 201 */ 202 202 @Test 203 publicvoid testReloadAction() {203 void testReloadAction() { 204 204 IHelpBrowser browser = newHelpBrowser(); 205 205 browser.openUrl(URL_1);
Note:
See TracChangeset
for help on using the changeset viewer.