Changeset 18714 in josm for trunk/test/unit


Ignore:
Timestamp:
2023-04-25T16:11:37+02:00 (20 months ago)
Author:
taylor.smock
Message:

Fix #22898: JOSM Validator CLI errors out when is run with --load-preferences argument (patch by emanuel_raymond, modified)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java

    r18365 r18714  
    1010import java.io.File;
    1111import java.io.IOException;
     12import java.io.OutputStream;
    1213import java.io.PrintWriter;
    1314import java.lang.reflect.InvocationTargetException;
     
    4647import org.openstreetmap.josm.io.OsmWriterFactory;
    4748import org.openstreetmap.josm.spi.lifecycle.Lifecycle;
     49import org.openstreetmap.josm.spi.preferences.Config;
    4850import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    4951import org.openstreetmap.josm.tools.Logging;
     
    177179
    178180    /**
     181     * A non-regression test for #22898: Validator CLI errors out when is run with --load-preferences argument
     182     */
     183    @Test
     184    void testNonRegression22898(final @TempDir Path preferencesLocation) throws IOException {
     185        final ValidatorCLI validatorCLI = new ValidatorCLI();
     186        final Path preferences = preferencesLocation.resolve("preferences.xml");
     187        try (OutputStream fos = Files.newOutputStream(preferences)) {
     188            final String pref = "<config>\n" +
     189                    "    <preferences operation=\"replace\">\n" +
     190                    "        <list key='plugins'>\n" +
     191                    "          <entry value='baz'/>\n" +
     192                    "        </list>\n" +
     193                    "    </preferences>\n" +
     194                    "</config>";
     195            fos.write(pref.getBytes(StandardCharsets.UTF_8));
     196        }
     197        validatorCLI.processArguments(new String[]{"--load-preferences=" + preferences,
     198                "--input", "resources/styles/standard/elemstyles.mapcss"});
     199        assertEquals(Collections.singletonList("baz"), Config.getPref().getList("plugins"));
     200    }
     201
     202    /**
    179203     * Read json objects from a file
    180204     * @param path The file to read
Note: See TracChangeset for help on using the changeset viewer.