Changeset 17276 in josm


Ignore:
Timestamp:
2020-10-28T22:46:55+01:00 (4 weeks ago)
Author:
Don-vip
Message:

see #16567 - fix obvious test errors + upgrade tests dependencies

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ivy.xml

    r17246 r17276  
    4545        <dependency conf="sources->default" org="org.webjars.npm" name="tag2link" rev="2020.10.18"/><!-- sources->default sic! (tag2link-sources.jar is empty, see #19335) -->
    4646        <!-- commonslang->default -->
    47         <dependency conf="commonslang->default" org="org.apache.commons" name="commons-lang3" rev="3.10"/>
     47        <dependency conf="commonslang->default" org="org.apache.commons" name="commons-lang3" rev="3.11"/>
    4848        <!-- jacocoant->default -->
    4949        <dependency conf="jacocoant->default" org="org.jacoco" name="org.jacoco.ant" rev="0.8.6">
     
    5252        <dependency conf="jmockit->default" org="org.jmockit" name="jmockit" rev="1.49"/>
    5353        <!-- test->default -->
    54         <dependency conf="test->default" org="com.github.spotbugs" name="spotbugs-annotations" rev="4.0.1"/>
    55         <dependency conf="test->default" org="com.github.stefanbirkner" name="system-rules" rev="1.19.0">
    56             <exclude module="junit-dep" />
    57         </dependency>
    58         <dependency conf="test->default" org="com.github.tomakehurst" name="wiremock" rev="2.26.3"/>
    59         <dependency conf="test->default" org="io.github.classgraph" name="classgraph" rev="4.8.67"/>
     54        <dependency conf="test->default" org="com.github.spotbugs" name="spotbugs-annotations" rev="4.1.4"/>
     55        <dependency conf="test->default" org="com.ginsberg" name="junit5-system-exit" rev="1.0.0"/>
     56        <dependency conf="test->default" org="com.github.tomakehurst" name="wiremock" rev="2.27.2"/>
     57        <dependency conf="test->default" org="io.github.classgraph" name="classgraph" rev="4.8.90"/>
    6058        <dependency conf="test->default" org="org.junit.platform" name="junit-platform-launcher" rev="1.7.0"/>
    6159        <dependency conf="test->default" org="org.junit.vintage" name="junit-vintage-engine" rev="5.7.0"/>
     
    6563        <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-migrationsupport" rev="5.7.0"/>
    6664        <dependency conf="test->default" org="net.trajano.commons" name="commons-testing" rev="2.1.0"/>
    67         <dependency conf="test->default" org="nl.jqno.equalsverifier" name="equalsverifier" rev="3.4.3"/>
    68         <dependency conf="test->default" org="org.apache.commons" name="commons-lang3" rev="3.10"/>
    69         <dependency conf="test->default" org="org.awaitility" name="awaitility" rev="4.0.2"/>
     65        <dependency conf="test->default" org="nl.jqno.equalsverifier" name="equalsverifier" rev="3.5"/>
     66        <dependency conf="test->default" org="org.apache.commons" name="commons-lang3" rev="3.11"/>
     67        <dependency conf="test->default" org="org.awaitility" name="awaitility" rev="4.0.3"/>
    7068    </dependencies>
    7169</ivy-module>
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java

    r17275 r17276  
    2828import javax.imageio.ImageIO;
    2929
    30 import org.junit.jupiter.api.BeforeEach;
    31 import org.junit.jupiter.api.Test;
    3230import 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;
     31import org.junit.jupiter.params.ParameterizedTest;
     32import org.junit.jupiter.params.provider.MethodSource;
    3633import org.openstreetmap.josm.TestUtils;
    3734import org.openstreetmap.josm.data.Bounds;
     
    5552 * @author Michael Zangl
    5653 */
    57 @RunWith(Parameterized.class)
    5854public class MapCSSRendererTest {
    5955    private static final String TEST_DATA_BASE = "/renderer/";
     
    7167    public JOSMTestRules test = new JOSMTestRules().preferences().projection();
    7268
    73     private final TestConfig testConfig;
    74 
    7569    // development flag - set to true in order to update all reference images
    7670    private static final boolean UPDATE_ALL = false;
     
    8175     * @return The parameters.
    8276     */
    83     @Parameters(name = "{1}")
    8477    public static Collection<Object[]> runs() {
    8578        return Stream.of(
     
    169162
    170163    /**
     164     * Run the test using {@code testConfig}
    171165     * @param testConfig The config to use for this test.
    172166     * @param ignored The name to print it nicely
     167     * @throws Exception if an error occurs
    173168     */
    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.
    185174        String javaHome = System.getProperty("java.home");
    186175        assumeTrue(javaHome != null && javaHome.toLowerCase(Locale.ENGLISH).contains("openjdk"), "Test requires openJDK");
     
    190179            assumeTrue(fonts.contains(font), "Test requires font: " + font);
    191180        }
    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
    200182        // Force reset of preferences
    201183        StyledMapRenderer.PREFERENCE_ANTIALIASING_USE.put(true);
  • trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java

    r17275 r17276  
    2323import java.util.Random;
    2424import java.util.TreeSet;
     25import java.util.concurrent.TimeUnit;
    2526import java.util.logging.Logger;
    2627
     
    2829import org.junit.jupiter.api.BeforeEach;
    2930import org.junit.jupiter.api.Test;
     31import org.junit.jupiter.api.Timeout;
    3032import org.junit.jupiter.api.extension.RegisterExtension;
    31 import org.junit.rules.Timeout;
    3233import org.openstreetmap.josm.JOSMFixture;
    3334import org.openstreetmap.josm.TestUtils;
     
    5152 */
    5253@SuppressFBWarnings(value = "CRLF_INJECTION_LOGS")
     54@Timeout(value = 60, unit = TimeUnit.SECONDS)
    5355class MultiFetchServerObjectReaderTest {
    5456    private static final Logger logger = Logger.getLogger(MultiFetchServerObjectReader.class.getName());
     
    6062    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    6163    public JOSMTestRules test = new JOSMTestRules().preferences();
    62 
    63     /**
    64      * Global timeout applied to all test methods.
    65      */
    66     @RegisterExtension
    67     public Timeout globalTimeout = Timeout.seconds(60);
    6864
    6965    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java

    r17275 r17276  
    44import static org.junit.jupiter.api.Assertions.assertTrue;
    55
     6import org.junit.jupiter.api.Test;
    67import org.junit.jupiter.api.extension.RegisterExtension;
    7 import org.junit.jupiter.api.Test;
    8 import org.junit.contrib.java.lang.system.ExpectedSystemExit;
    98import org.openstreetmap.josm.TestUtils;
    109import org.openstreetmap.josm.data.cache.JCSCacheManager;
    1110import org.openstreetmap.josm.gui.MainApplication;
     11import org.openstreetmap.josm.gui.io.SaveLayersDialog;
    1212import org.openstreetmap.josm.gui.progress.swing.ProgressMonitorExecutor;
    1313import org.openstreetmap.josm.testutils.JOSMTestRules;
    1414import org.openstreetmap.josm.tools.ImageProvider;
     15
     16import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
    1517
    1618import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    3234
    3335    /**
    34      * System.exit rule
    35      */
    36     @RegisterExtension
    37     public final ExpectedSystemExit exit = ExpectedSystemExit.none();
    38 
    39     /**
    4036     * Unit test of {@link ExitAction#actionPerformed}
    4137     */
    4238    @Test
     39    @ExpectSystemExitWithStatus(0)
    4340    void testActionPerformed() {
    4441        TestUtils.assumeWorkingJMockit();
    45         exit.expectSystemExitWithStatus(0);
    4642
    4743        boolean[] workerShutdownCalled = {false};
     
    5046        boolean[] imageProviderShutdownCalledNowTrue = {false};
    5147        boolean[] jcsCacheManagerShutdownCalled = {false};
     48        boolean[] saveLayersDialogCloseDialogCalled = {false};
    5249
    5350        // critically we don't proceed into the actual implementation in any of these mock methods -
     
    8986            }
    9087        };
     88        new MockUp<SaveLayersDialog>() {
     89            @Mock
     90            private void closeDialog(Invocation invocation) {
     91                saveLayersDialogCloseDialogCalled[0] = true;
     92            }
     93        };
    9194
    9295        // No layer
     
    102105            assertTrue(imageProviderShutdownCalledNowTrue[0]);
    103106            assertTrue(jcsCacheManagerShutdownCalled[0]);
     107            assertTrue(saveLayersDialogCloseDialogCalled[0]);
    104108        }
    105109    }
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/RenderingCLIAreaTest.java

    r17275 r17276  
    1212import org.hamcrest.CoreMatchers;
    1313import org.hamcrest.Matcher;
    14 import org.junit.jupiter.api.Test;
    1514import org.junit.jupiter.api.extension.RegisterExtension;
    16 import org.junit.runner.RunWith;
    17 import org.junit.runners.Parameterized;
     15import org.junit.jupiter.params.ParameterizedTest;
     16import org.junit.jupiter.params.provider.MethodSource;
    1817import org.openstreetmap.josm.data.Bounds;
    1918import org.openstreetmap.josm.data.coor.LatLon;
     
    2524 * Tests the method {@link RenderingCLI#determineRenderingArea(org.openstreetmap.josm.data.osm.DataSet)}.
    2625 */
    27 @RunWith(Parameterized.class)
    2826class RenderingCLIAreaTest {
    2927    /**
     
    3432    public JOSMTestRules test = new JOSMTestRules().projection().territories();
    3533
    36     @Parameterized.Parameters
    3734    public static Collection<Object[]> runs() {
    3835        Collection<Object[]> runs = new ArrayList<>();
     
    149146    }
    150147
    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) {
    163151        RenderingCLI cli = new RenderingCLI();
    164         cli.parseArguments(args);
     152        cli.parseArguments(args.split("\\s+", -1));
    165153        RenderingCLI.RenderingArea ra = cli.determineRenderingArea(null);
    166154        assertThat(ra.scale, scaleMatcher);
  • trunk/tools

    • Property svn:ignore
      •  

        old new  
        22jacocoant.jar
        33error_prone
         4commons-lang3.jar
Note: See TracChangeset for help on using the changeset viewer.