source: josm/trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java

Last change on this file was 18985, checked in by taylor.smock, 2 months ago

Fix #23355: Sanity check JVM arguments on startup

See #17858: JOSM will no longer continue running if the user is on an unsupported
Java version (for this commit, older than Java 11; message indicates Java 17).
This does update the link for Azul from Java 17 to Java 21 as well.

In order to (hopefully) reduce confusion, the webstart and Java update nags will
also be reset in the event that JOSM will exit due to old Java versions. This is
mostly so that users will get the messages to update to OpenWebstart or the
appropriate Java link for their platform and architecture.

Additionally, this will (hopefully) reduce the number of tickets we have to close
due to missing JVM arguments by informing users of the missing arguments at startup.

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
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.assertTrue;
8import static org.junit.jupiter.api.Assumptions.assumeTrue;
9
10import java.io.File;
11import java.io.IOException;
12
13import org.junit.jupiter.api.BeforeAll;
14import org.junit.jupiter.api.Test;
15import org.openstreetmap.josm.spi.preferences.Config;
16
17/**
18 * Unit tests of {@link PlatformHookOsx} class.
19 */
20class PlatformHookOsxTest {
21
22 static PlatformHookOsx hook;
23
24 /**
25 * Setup test.
26 */
27 @BeforeAll
28 public static void setUp() {
29 hook = new PlatformHookOsx();
30 }
31
32 /**
33 * Test method for {@code PlatformHookOsx#startupHook}
34 */
35 @Test
36 void testStartupHook() {
37 hook.startupHook((a, b, c, d) -> System.out.println("java callback"), u -> System.out.println("webstart callback"),
38 (a, b, c) -> System.out.println("sanity check callback"));
39 }
40
41 /**
42 * Test method for {@code PlatformHookOsx#afterPrefStartupHook}
43 */
44 @Test
45 void testAfterPrefStartupHook() {
46 hook.afterPrefStartupHook();
47 }
48
49 /**
50 * Test method for {@code PlatformHookOsx#openUrl}
51 * @throws IOException if an error occurs
52 */
53 @Test
54 void testOpenUrl() throws IOException {
55 assumeTrue(PlatformManager.isPlatformOsx());
56 hook.openUrl(Config.getUrls().getJOSMWebsite());
57 }
58
59 /**
60 * Test method for {@code PlatformHookOsx#getDefaultCacheDirectory}
61 */
62 @Test
63 void testGetDefaultCacheDirectory() {
64 File cache = hook.getDefaultCacheDirectory();
65 assertNotNull(cache);
66 if (PlatformManager.isPlatformOsx()) {
67 assertTrue(cache.toString().contains("/Library/"));
68 }
69 }
70
71 /**
72 * Test method for {@code PlatformHookOsx#getDefaultPrefDirectory}
73 */
74 @Test
75 void testGetDefaultPrefDirectory() {
76 File cache = hook.getDefaultPrefDirectory();
77 assertNotNull(cache);
78 if (PlatformManager.isPlatformOsx()) {
79 assertTrue(cache.toString().contains("/Library/"));
80 }
81 }
82
83 /**
84 * Test method for {@code PlatformHookOsx#getDefaultStyle}
85 */
86 @Test
87 void testGetDefaultStyle() {
88 assertEquals("com.apple.laf.AquaLookAndFeel", hook.getDefaultStyle());
89 }
90
91 /**
92 * Test method for {@code PlatformHookOsx#getOSDescription}
93 */
94 @Test
95 void testGetOSDescription() {
96 String os = hook.getOSDescription();
97 if (PlatformManager.isPlatformOsx()) {
98 assertTrue(os.contains("Mac"));
99 } else {
100 assertFalse(os.contains("Mac"));
101 }
102 }
103
104 /**
105 * Test method for {@code PlatformHookOsx#initSystemShortcuts}
106 */
107 @Test
108 void testInitSystemShortcuts() {
109 hook.initSystemShortcuts();
110 }
111}
Note: See TracBrowser for help on using the repository browser.