Changeset 18718 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java
r18714 r18718 163 163 public void processArguments(final String[] argArray) { 164 164 try { 165 // for right-left-hand traffic cache file, needed for preferences 166 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); 165 167 // Ensure that preferences are only in memory 166 168 Config.setPreferencesInstance(new MemoryPreferences()); … … 348 350 Logging.setLogLevel(this.logLevel); 349 351 HttpClient.setFactory(Http1Client::new); 350 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); // for right-left-hand traffic cache file351 352 Config.setUrlsProvider(JosmUrls.getInstance()); 352 353 ProjectionRegistry.setProjection(Projections.getProjectionByCode("epsg:3857".toUpperCase(Locale.ROOT))); -
trunk/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java
r18714 r18718 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.fail;8 7 9 8 import java.io.ByteArrayInputStream; … … 12 11 import java.io.OutputStream; 13 12 import java.io.PrintWriter; 14 import java. lang.reflect.InvocationTargetException;13 import java.io.UncheckedIOException; 15 14 import java.nio.charset.StandardCharsets; 16 15 import java.nio.file.Files; … … 29 28 import javax.json.JsonObject; 30 29 import javax.json.JsonReader; 31 import javax.swing.SwingUtilities; 32 30 31 import mockit.Mock; 32 import mockit.MockUp; 33 33 import org.junit.jupiter.api.AfterEach; 34 34 import org.junit.jupiter.api.BeforeEach; 35 35 import org.junit.jupiter.api.Test; 36 import org.junit.jupiter.api.extension.RegisterExtension; 36 37 import org.junit.jupiter.api.io.TempDir; 37 38 import org.junit.jupiter.params.ParameterizedTest; … … 43 44 import org.openstreetmap.josm.data.osm.DataSet; 44 45 import org.openstreetmap.josm.data.osm.Node; 45 import org.openstreetmap.josm.gui.MainApplication;46 46 import org.openstreetmap.josm.io.OsmWriter; 47 47 import org.openstreetmap.josm.io.OsmWriterFactory; 48 48 import org.openstreetmap.josm.spi.lifecycle.Lifecycle; 49 49 import org.openstreetmap.josm.spi.preferences.Config; 50 import org.openstreetmap.josm.testutils.annotations.AnnotationUtils; 50 51 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 52 import org.openstreetmap.josm.testutils.annotations.ThreadSync; 51 53 import org.openstreetmap.josm.tools.Logging; 52 54 import org.openstreetmap.josm.tools.Utils; 53 54 import mockit.Mock;55 import mockit.MockUp;56 55 57 56 /** … … 61 60 @BasicPreferences 62 61 class ValidatorCLITest { 62 @RegisterExtension 63 ThreadSync.ThreadSyncExtension threadSync = new ThreadSync.ThreadSyncExtension(); 64 63 65 @TempDir 64 66 static File temporaryDirectory; 65 67 66 68 TestHandler handler; 67 68 private static void synchronizeThreads() {69 MainApplication.worker.execute(() -> { /* Sync worker thread */ });70 try {71 SwingUtilities.invokeAndWait(() -> { /* Sync EDT thread */ });72 } catch (InterruptedException e) {73 Thread.currentThread().interrupt();74 fail(e);75 } catch (InvocationTargetException e) {76 fail(e);77 }78 }79 69 80 70 @BeforeEach … … 87 77 88 78 @AfterEach 89 void tearDown() throws InterruptedException, InvocationTargetException { 90 synchronizeThreads(); 79 void tearDown() { 91 80 Logging.getLogger().removeHandler(this.handler); 92 81 this.handler.close(); … … 113 102 return Files.copy(file.toPath(), Paths.get(temporaryDirectory.getPath(), renamedValidator)).getFileName().toString(); 114 103 } catch (IOException e) { 115 fail(e);104 throw new UncheckedIOException(e); 116 105 } 117 return null;118 106 }).map(Arguments::of); 119 107 } … … 138 126 final File outputFile = new File(outputPath); 139 127 assertTrue(outputFile.exists()); 140 synchronizeThreads();128 threadSync.threadSync(); 141 129 final List<JsonObject> errors = readJsonObjects(outputFile.toPath()); 142 130 assertEquals(3, errors.stream().map(ValidatorCLITest::getMessage).filter("Overlapping Identical Landuses"::equals).count()); … … 182 170 */ 183 171 @Test 184 void testNonRegression22898(final @TempDir Path preferencesLocation) throws IOException { 172 void testNonRegression22898(final @TempDir Path preferencesLocation) throws IOException, ReflectiveOperationException { 173 AnnotationUtils.resetStaticClass(Config.class); 185 174 final ValidatorCLI validatorCLI = new ValidatorCLI(); 186 175 final Path preferences = preferencesLocation.resolve("preferences.xml");
Note:
See TracChangeset
for help on using the changeset viewer.