source: josm/trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java@ 17275

Last change on this file since 17275 was 17275, checked in by Don-vip, 3 years ago

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

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

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer.markerlayer;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5
6import java.net.URL;
7
8import org.junit.jupiter.api.Test;
9import org.junit.jupiter.api.extension.RegisterExtension;
10import org.openstreetmap.josm.TestUtils;
11import org.openstreetmap.josm.data.coor.LatLon;
12import org.openstreetmap.josm.data.gpx.GpxData;
13import org.openstreetmap.josm.data.gpx.WayPoint;
14import org.openstreetmap.josm.testutils.JOSMTestRules;
15import org.openstreetmap.josm.tools.PlatformManager;
16import org.openstreetmap.josm.tools.PlatformHook;
17
18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19
20import mockit.Expectations;
21import mockit.Injectable;
22import mockit.Mocked;
23
24/**
25 * Unit tests of {@link WebMarker} class.
26 */
27class WebMarkerTest {
28
29 /**
30 * Setup tests
31 */
32 @RegisterExtension
33 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
34 public JOSMTestRules test = new JOSMTestRules().preferences().https();
35
36 /**
37 * Unit test of {@link WebMarker#WebMarker}.
38 * @param mockPlatformHook platform hook mock
39 * @param platformManager {@link PlatformManager} mock
40 * @throws Exception in case of error
41 */
42 @Test
43 void testWebMarker(@Injectable final PlatformHook mockPlatformHook,
44 @Mocked final PlatformManager platformManager) throws Exception {
45 TestUtils.assumeWorkingJMockit();
46 new Expectations() {{
47 PlatformManager.getPlatform(); result = mockPlatformHook;
48 mockPlatformHook.openUrl("http://example.com"); result = null; times = 1;
49 }};
50
51 WebMarker marker = new WebMarker(
52 LatLon.ZERO,
53 new URL("http://example.com"),
54 new MarkerLayer(new GpxData(), null, null, null),
55 1d, 2d);
56 marker.actionPerformed(null);
57 assertEquals("", marker.getText());
58 WayPoint wpt = marker.convertToWayPoint();
59 assertEquals(LatLon.ZERO, wpt.getCoor());
60 }
61}
Note: See TracBrowser for help on using the repository browser.