Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,20 @@
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.Bounds;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.AfterEach;

import org.junit.After;
import org.junit.Ignore;
import org.openstreetmap.josm.tools.JosmRuntimeException;
import org.openstreetmap.josm.tools.ReflectionUtils;

import mockit.Mock;
import mockit.MockUp;
import mockit.Invocation;

@Ignore
public class BaseQuadTreeMetaTest extends BaseRectTest {
public abstract class BaseQuadTreeMetaTest extends BaseRectTest {
/* change to true to get debug output in commandline */
Boolean debug = false;

Expand Down Expand Up @@ -148,7 +147,7 @@ public BaseQuadTreeMetaTest(int scenarioIndex_, Integer seenRectOrderSeed_, Inte
this.quadTreeMeta = new QuadTreeMeta(this.tileSize, Color.PINK, 0.5, autoOptimize);
}

@After
@AfterEach
public void destroyQuadTreeMeta() throws Exception {
final ThreadPoolExecutor quadTreeEditExecutor = ((ThreadPoolExecutor)
TestUtils.getPrivateField(quadTreeMeta, "quadTreeEditExecutor"));
Expand Down Expand Up @@ -246,8 +245,8 @@ protected void inspectReferenceTiles(
} catch (InterruptedException e) {
System.out.println(e);
}
assertTrue("assertContents will not work reliably in non-default order",
orderSeed == null || constReferenceMask != null || !assertContents);
assertTrue(orderSeed == null || constReferenceMask != null || !assertContents,
"assertContents will not work reliably in non-default order");
assertEquals(dynamicReferences.length, referenceTiles_.length);

List<Integer> remapping = getRemapping(referenceTiles_.length, orderSeed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

import org.openstreetmap.josm.data.Bounds;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Ignore;

@Ignore
public class BaseQuadTreeNodeTest extends BaseRectTest {
public abstract class BaseQuadTreeNodeTest extends BaseRectTest {
/* change to true to get debug output in commandline */
Boolean debug = false;

Expand Down Expand Up @@ -136,8 +134,8 @@ protected void inspectReferenceTiles(
boolean write,
InspectExtraAssertion extraAssertion
) {
assertTrue("assertContents will not work reliably in non-default order",
orderSeed == null || constReferenceMask != null || !assertContents);
assertTrue(orderSeed == null || constReferenceMask != null || !assertContents,
"assertContents will not work reliably in non-default order");
final List<Integer> remapping = getRemapping(referenceTiles_.length, orderSeed);

for (int i = 0; i < referenceTiles_.length; i++) {
Expand All @@ -153,8 +151,8 @@ protected void inspectReferenceTiles(
boolean refMaskOptAliasable = referenceTileInfo.length >= 5 ? (boolean) referenceTileInfo[4] : false;

assertFalse(
"refMask must be boolean if refMaskOptAliasable is true",
refMaskOptAliasable && !Boolean.class.isInstance(refMask)
refMaskOptAliasable && !Boolean.class.isInstance(refMask),
"refMask must be boolean if refMaskOptAliasable is true"
);

QuadTreeNode node = quadTreeMeta.quadTreeRoot.getNodeForTile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@

import org.openstreetmap.josm.data.Bounds;

import org.junit.Ignore;

@Ignore
public class BaseRectTest extends BaseTest {
public abstract class BaseRectTest extends BaseTest {
// parametrized variables
protected final int scenarioIndex;
protected final Integer seenRectOrderSeed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import java.io.InputStream;
import java.io.IOException;

import org.junit.Ignore;

@Ignore
public class BaseTest {
public abstract class BaseTest {
protected static byte[] byteArrayFromResource(String resourcePath) throws IOException {
InputStream resourceStream = BaseTest.class.getClassLoader().getResourceAsStream(resourcePath);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.markseen;

import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

public class MarkSeenRegulaFalsiFailureTest {
@Test(expected = MarkSeenRegulaFalsi.ExceededIterationsException.class)
@Test
public void testExceededIterations() throws Exception {
MarkSeenRegulaFalsi.regulaFalsi(
x -> Math.cos(x) + (0.1*x*x) - 2.,
0,
10,
0.0001,
4
);
assertThrows(MarkSeenRegulaFalsi.ExceededIterationsException.class, () ->
MarkSeenRegulaFalsi.regulaFalsi(
x -> Math.cos(x) + (0.1 * x * x) - 2.,
0,
10,
0.0001,
4
));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void testDoublePositive() throws Exception {
MarkSeenRegulaFalsi.regulaFalsi(
x -> Math.sin(x),
3.2,
3.3,
0.001,
8
);
assertThrows(UnsupportedOperationException.class, () ->
MarkSeenRegulaFalsi.regulaFalsi(
x -> Math.sin(x),
3.2,
3.3,
0.001,
8
));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void testDoubleNegative() throws Exception {
MarkSeenRegulaFalsi.regulaFalsi(
x -> Math.sin(x),
2.9,
3.0,
0.001,
8
);
assertThrows(UnsupportedOperationException.class, () ->
MarkSeenRegulaFalsi.regulaFalsi(
x -> Math.sin(x),
2.9,
3.0,
0.001,
8
));
}

@Test(expected = MarkSeenRegulaFalsi.ExceededRangeDetermination.class)
@Test
public void testGeometricSearchExceedRange() throws Exception {
// searching upwards, this will never change sign
MarkSeenRegulaFalsi.regulaFalsiGeometricSearch(
x -> x*x,
9.9,
2.,
0.001,
8
);
assertThrows(MarkSeenRegulaFalsi.ExceededRangeDetermination.class, () ->
// searching upwards, this will never change sign
MarkSeenRegulaFalsi.regulaFalsiGeometricSearch(
x -> x * x,
9.9,
2.,
0.001,
8
));
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.markseen;

import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.DoubleUnaryOperator;

import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.MethodSource;

@RunWith(Parameterized.class)
@ParameterizedClass(name = "{index}-fx-{0}-{1}-lbx-{5}")
@MethodSource("getParameters")
public class MarkSeenRegulaFalsiGeometricSearchTest {
@Parameters(name = "{index}-fx-{0}-{1}-lbx-{5}")
public static Collection<Object[]> getParameters() throws Exception {
final Object[][] unexpanded = new Object[][] {
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.markseen;

import static org.junit.jupiter.api.Assertions.fail;

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.DoubleUnaryOperator;

import static org.junit.Assert.fail;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.MethodSource;

@RunWith(Parameterized.class)
@ParameterizedClass(name = "{index}-fx-{0}-{1}-{2}-x0-{6}-x1-{7}")
@MethodSource("getParameters")
public class MarkSeenRegulaFalsiTest {
@Parameters(name = "{index}-fx-{0}-{1}-{2}-x0-{6}-x1-{7}")
public static Collection<Object[]> getParameters() throws Exception {
final Object[][] unexpanded = new Object[][] {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,37 @@

import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.Main;
import org.openstreetmap.josm.testutils.annotations.FullPreferences;
import org.openstreetmap.josm.testutils.annotations.Projection;
import org.openstreetmap.josm.testutils.annotations.FakeImagery;
import org.openstreetmap.josm.testutils.ImagePatternMatching;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

import org.awaitility.Awaitility;

import com.google.common.collect.ImmutableMap;

@Main
@FullPreferences
@Projection
@FakeImagery
@Timeout(value = 70, threadMode = Timeout.ThreadMode.SEPARATE_THREAD)
public class MarkSeenRootTest {
private static BufferedImage originalErrorImage;
private static BufferedImage originalLoadingImage;

@Rule public JOSMTestRules test = new JOSMTestRules().main().preferences().projection().fakeImagery().timeout(70000);

@Before
@BeforeEach
public void setUp() {
// Add a test layer to the layer manager to get the MapFrame & MapView
MainApplication.getLayerManager().addLayer(new TestLayer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@
import java.util.Collection;
import java.util.concurrent.ThreadPoolExecutor;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.awaitility.Awaitility;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.MethodSource;

import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;

@RunWith(Parameterized.class)
@BasicPreferences
@Timeout(value = 20, threadMode = Timeout.ThreadMode.SEPARATE_THREAD)
@ParameterizedClass(name = "{index}-scenario-{0}-batchSize-{1}-pause-{2}ms")
@MethodSource("getParameters")
public class QuadTreeMetaAutoOptimizeTest extends BaseQuadTreeMetaTest {
private static final int variants = 2;

// additional test parameters
protected final int batchSize;
protected final int pauseMS;

@Parameters(name = "{index}-scenario-{0}-batchSize-{1}-pause-{2}ms")
public static Collection<Object[]> getParameters() throws IOException {
ArrayList<Object[]> paramSets = new ArrayList<Object[]>();
Object[][] scenarios = getTestScenarios();
Expand All @@ -51,8 +52,6 @@ public static Collection<Object[]> getParameters() throws IOException {
return paramSets;
}

@Rule public JOSMTestRules test = new JOSMTestRules().main().preferences().timeout(20000);

public QuadTreeMetaAutoOptimizeTest(int scenarioIndex_, int batchSize_, int pauseMS_)
throws IOException {
super(scenarioIndex_, null, null, true);
Expand Down Expand Up @@ -99,10 +98,10 @@ public void test() throws Exception {
(i, j, dynamicReference, refMask, resultMaskBytes, refMaskBytes, aliasable) -> {
if (aliasable) {
assertTrue(
"Failed asserting identity " + refMask.toString() + " of ref tile " + j,
dynamicReference.maskReadOperation(
dynamicReference.<Boolean>maskReadOperation(
mask -> mask == ((boolean) refMask ? this.quadTreeMeta.FULL_MASK : this.quadTreeMeta.EMPTY_MASK)
)
),
"Failed asserting identity " + refMask.toString() + " of ref tile " + j
);
}
}
Expand Down
Loading