Changeset 17276 in josm for trunk/test
- Timestamp:
- 2020-10-28T22:46:55+01:00 (5 years ago)
- Location:
- trunk/test
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
r17275 r17276 28 28 import javax.imageio.ImageIO; 29 29 30 import org.junit.jupiter.api.BeforeEach;31 import org.junit.jupiter.api.Test;32 30 import org.junit.jupiter.api.extension.RegisterExtension; 33 import org.junit.runner.RunWith; 34 import org.junit.runners.Parameterized; 35 import org.junit.runners.Parameterized.Parameters; 31 import org.junit.jupiter.params.ParameterizedTest; 32 import org.junit.jupiter.params.provider.MethodSource; 36 33 import org.openstreetmap.josm.TestUtils; 37 34 import org.openstreetmap.josm.data.Bounds; … … 55 52 * @author Michael Zangl 56 53 */ 57 @RunWith(Parameterized.class)58 54 public class MapCSSRendererTest { 59 55 private static final String TEST_DATA_BASE = "/renderer/"; … … 71 67 public JOSMTestRules test = new JOSMTestRules().preferences().projection(); 72 68 73 private final TestConfig testConfig;74 75 69 // development flag - set to true in order to update all reference images 76 70 private static final boolean UPDATE_ALL = false; … … 81 75 * @return The parameters. 82 76 */ 83 @Parameters(name = "{1}")84 77 public static Collection<Object[]> runs() { 85 78 return Stream.of( … … 169 162 170 163 /** 164 * Run the test using {@code testConfig} 171 165 * @param testConfig The config to use for this test. 172 166 * @param ignored The name to print it nicely 167 * @throws Exception if an error occurs 173 168 */ 174 public MapCSSRendererTest(TestConfig testConfig, String ignored) { 175 this.testConfig = testConfig; 176 } 177 178 /** 179 * This test only runs on OpenJDK. 180 * It is ignored for other Java versions since they differ slightly in their rendering engine. 181 * @since 11691 182 */ 183 @BeforeEach 184 public void forOpenJDK() { 169 @ParameterizedTest(name = "{1}") 170 @MethodSource("runs") 171 void testRender(TestConfig testConfig, String ignored) throws Exception { 172 // This test only runs on OpenJDK. 173 // It is ignored for other Java versions since they differ slightly in their rendering engine. 185 174 String javaHome = System.getProperty("java.home"); 186 175 assumeTrue(javaHome != null && javaHome.toLowerCase(Locale.ENGLISH).contains("openjdk"), "Test requires openJDK"); … … 190 179 assumeTrue(fonts.contains(font), "Test requires font: " + font); 191 180 } 192 } 193 194 /** 195 * Run the test using {@link #testConfig} 196 * @throws Exception if an error occurs 197 */ 198 @Test 199 void testRender() throws Exception { 181 200 182 // Force reset of preferences 201 183 StyledMapRenderer.PREFERENCE_ANTIALIASING_USE.put(true); -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r17275 r17276 23 23 import java.util.Random; 24 24 import java.util.TreeSet; 25 import java.util.concurrent.TimeUnit; 25 26 import java.util.logging.Logger; 26 27 … … 28 29 import org.junit.jupiter.api.BeforeEach; 29 30 import org.junit.jupiter.api.Test; 31 import org.junit.jupiter.api.Timeout; 30 32 import org.junit.jupiter.api.extension.RegisterExtension; 31 import org.junit.rules.Timeout;32 33 import org.openstreetmap.josm.JOSMFixture; 33 34 import org.openstreetmap.josm.TestUtils; … … 51 52 */ 52 53 @SuppressFBWarnings(value = "CRLF_INJECTION_LOGS") 54 @Timeout(value = 60, unit = TimeUnit.SECONDS) 53 55 class MultiFetchServerObjectReaderTest { 54 56 private static final Logger logger = Logger.getLogger(MultiFetchServerObjectReader.class.getName()); … … 60 62 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 61 63 public JOSMTestRules test = new JOSMTestRules().preferences(); 62 63 /**64 * Global timeout applied to all test methods.65 */66 @RegisterExtension67 public Timeout globalTimeout = Timeout.seconds(60);68 64 69 65 /** -
trunk/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java
r17275 r17276 4 4 import static org.junit.jupiter.api.Assertions.assertTrue; 5 5 6 import org.junit.jupiter.api.Test; 6 7 import org.junit.jupiter.api.extension.RegisterExtension; 7 import org.junit.jupiter.api.Test;8 import org.junit.contrib.java.lang.system.ExpectedSystemExit;9 8 import org.openstreetmap.josm.TestUtils; 10 9 import org.openstreetmap.josm.data.cache.JCSCacheManager; 11 10 import org.openstreetmap.josm.gui.MainApplication; 11 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 12 12 import org.openstreetmap.josm.gui.progress.swing.ProgressMonitorExecutor; 13 13 import org.openstreetmap.josm.testutils.JOSMTestRules; 14 14 import org.openstreetmap.josm.tools.ImageProvider; 15 16 import com.ginsberg.junit.exit.ExpectSystemExitWithStatus; 15 17 16 18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 32 34 33 35 /** 34 * System.exit rule35 */36 @RegisterExtension37 public final ExpectedSystemExit exit = ExpectedSystemExit.none();38 39 /**40 36 * Unit test of {@link ExitAction#actionPerformed} 41 37 */ 42 38 @Test 39 @ExpectSystemExitWithStatus(0) 43 40 void testActionPerformed() { 44 41 TestUtils.assumeWorkingJMockit(); 45 exit.expectSystemExitWithStatus(0);46 42 47 43 boolean[] workerShutdownCalled = {false}; … … 50 46 boolean[] imageProviderShutdownCalledNowTrue = {false}; 51 47 boolean[] jcsCacheManagerShutdownCalled = {false}; 48 boolean[] saveLayersDialogCloseDialogCalled = {false}; 52 49 53 50 // critically we don't proceed into the actual implementation in any of these mock methods - … … 89 86 } 90 87 }; 88 new MockUp<SaveLayersDialog>() { 89 @Mock 90 private void closeDialog(Invocation invocation) { 91 saveLayersDialogCloseDialogCalled[0] = true; 92 } 93 }; 91 94 92 95 // No layer … … 102 105 assertTrue(imageProviderShutdownCalledNowTrue[0]); 103 106 assertTrue(jcsCacheManagerShutdownCalled[0]); 107 assertTrue(saveLayersDialogCloseDialogCalled[0]); 104 108 } 105 109 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/RenderingCLIAreaTest.java
r17275 r17276 12 12 import org.hamcrest.CoreMatchers; 13 13 import org.hamcrest.Matcher; 14 import org.junit.jupiter.api.Test;15 14 import org.junit.jupiter.api.extension.RegisterExtension; 16 import org.junit. runner.RunWith;17 import org.junit. runners.Parameterized;15 import org.junit.jupiter.params.ParameterizedTest; 16 import org.junit.jupiter.params.provider.MethodSource; 18 17 import org.openstreetmap.josm.data.Bounds; 19 18 import org.openstreetmap.josm.data.coor.LatLon; … … 25 24 * Tests the method {@link RenderingCLI#determineRenderingArea(org.openstreetmap.josm.data.osm.DataSet)}. 26 25 */ 27 @RunWith(Parameterized.class)28 26 class RenderingCLIAreaTest { 29 27 /** … … 34 32 public JOSMTestRules test = new JOSMTestRules().projection().territories(); 35 33 36 @Parameterized.Parameters37 34 public static Collection<Object[]> runs() { 38 35 Collection<Object[]> runs = new ArrayList<>(); … … 149 146 } 150 147 151 private final String[] args; 152 private final Matcher<Double> scaleMatcher; 153 private final Matcher<Bounds> boundsMatcher; 154 155 RenderingCLIAreaTest(String args, Matcher<Double> scaleMatcher, Matcher<Bounds> boundsMatcher) { 156 this.args = args.split("\\s+", -1); 157 this.scaleMatcher = scaleMatcher; 158 this.boundsMatcher = boundsMatcher; 159 } 160 161 @Test 162 void testDetermineRenderingArea() { 148 @ParameterizedTest 149 @MethodSource("runs") 150 void testDetermineRenderingArea(String args, Matcher<Double> scaleMatcher, Matcher<Bounds> boundsMatcher) { 163 151 RenderingCLI cli = new RenderingCLI(); 164 cli.parseArguments(args); 152 cli.parseArguments(args.split("\\s+", -1)); 165 153 RenderingCLI.RenderingArea ra = cli.determineRenderingArea(null); 166 154 assertThat(ra.scale, scaleMatcher);
Note:
See TracChangeset
for help on using the changeset viewer.