Skip to content

Commit

Permalink
EqualsVerifier does not work with newer Java versions -> disable test…
Browse files Browse the repository at this point in the history
…s automatically in this case

Workaround to jqno/equalsverifier#177 / raphw/byte-buddy#370
Inspired by https://issues.apache.org/jira/browse/SOLR-11606

git-svn-id: https://josm.openstreetmap.de/svn/trunk@13079 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
don-vip committed Nov 4, 2017
1 parent a18724c commit 2cc561e
Show file tree
Hide file tree
Showing 56 changed files with 124 additions and 1 deletion.
14 changes: 14 additions & 0 deletions test/unit/org/openstreetmap/josm/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Objects;
import java.util.stream.Stream;

import org.junit.Assume;
import org.openstreetmap.josm.command.Command;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -328,4 +329,17 @@ public static Component getComponentByName(Component root, String name) {
return null;
}
}

/**
* Use to assume that EqualsVerifier is working with the current JVM.
*/
public static void assumeWorkingEqualsVerifier() {
try {
// Workaround to https://github.com/jqno/equalsverifier/issues/177
// Inspired by https://issues.apache.org/jira/browse/SOLR-11606
nl.jqno.equalsverifier.internal.lib.bytebuddy.ClassFileVersion.ofThisVm();
} catch (IllegalArgumentException e) {
Assume.assumeNoException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void testTicket11957() throws IOException, IllegalDataException {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(NodePair.class).usingGetClass()
.suppress(Warning.ANNOTATION) // FIXME: remove it after https://github.com/jqno/equalsverifier/issues/152 is fixed
.withPrefabValues(Node.class, new Node(1), new Node(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void testNewFilterWithArchiveExtensions() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ExtensionFileFilter.class).usingGetClass()
.suppress(Warning.ANNOTATION) // FIXME: remove it after https://github.com/jqno/equalsverifier/issues/152 is fixed
.verify();
Expand Down
2 changes: 2 additions & 0 deletions test/unit/org/openstreetmap/josm/command/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -130,6 +131,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(AddCommand.class).usingGetClass()
.withPrefabValues(OsmPrimitive.class,
new Node(1), new Node(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -284,6 +285,7 @@ private NodeData createTestNode(int id) {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(AddPrimitivesCommand.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestData;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.DataIntegrityProblemException;
Expand Down Expand Up @@ -153,6 +154,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ChangeCommand.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestData;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.DataSet;
Expand Down Expand Up @@ -124,6 +125,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ChangeNodesCommand.class).usingGetClass()
.withPrefabValues(Way.class,
new Way(1), new Way(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestData;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -277,6 +278,7 @@ public void testChildren() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ChangePropertyCommand.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestData;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -148,6 +149,7 @@ public void testChildren() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ChangePropertyKeyCommand.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
Expand Down Expand Up @@ -145,6 +146,7 @@ public void testChildren() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ChangeRelationMemberRoleCommand.class).usingGetClass()
.withPrefabValues(Relation.class,
new Relation(1), new Relation(2))
Expand Down
2 changes: 2 additions & 0 deletions test/unit/org/openstreetmap/josm/command/CommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -37,6 +38,7 @@ public class CommandTest {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(Command.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -377,6 +378,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(DeleteCommand.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
2 changes: 2 additions & 0 deletions test/unit/org/openstreetmap/josm/command/MoveCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
import org.openstreetmap.josm.data.coor.EastNorth;
import org.openstreetmap.josm.data.coor.LatLon;
Expand Down Expand Up @@ -259,6 +260,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(MoveCommand.class).usingGetClass()
.withPrefabValues(LatLon.class,
LatLon.ZERO, new LatLon(45, 45))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
import org.openstreetmap.josm.data.conflict.Conflict;
import org.openstreetmap.josm.data.osm.DataSet;
Expand Down Expand Up @@ -144,6 +145,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(PurgeCommand.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
Expand Down Expand Up @@ -122,6 +123,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(RemoveNodesCommand.class).usingGetClass()
.withPrefabValues(Way.class,
new Way(1), new Way(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestData;
import org.openstreetmap.josm.data.coor.EastNorth;
import org.openstreetmap.josm.data.coor.LatLon;
Expand Down Expand Up @@ -135,6 +136,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(RotateCommand.class).usingGetClass()
.withPrefabValues(LatLon.class, LatLon.ZERO, new LatLon(45, 45))
.withPrefabValues(DataSet.class, new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestData;
import org.openstreetmap.josm.data.coor.EastNorth;
import org.openstreetmap.josm.data.coor.LatLon;
Expand Down Expand Up @@ -135,6 +136,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ScaleCommand.class).usingGetClass()
.withPrefabValues(LatLon.class,
LatLon.ZERO, new LatLon(45, 45))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
Expand Down Expand Up @@ -148,6 +149,7 @@ public void testDescription() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(SelectCommand.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -213,6 +214,7 @@ public void testDescription() {
@Test
public void testEqualsContract() {
DataSet ds = new DataSet();
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(SequenceCommand.class).usingGetClass()
.withPrefabValues(Command.class,
new AddCommand(ds, new Node(1)), new AddCommand(ds, new Node(2)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.User;
Expand Down Expand Up @@ -30,6 +31,7 @@ public class TransformNodesCommandTest {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(TransformNodesCommand.class).usingGetClass()
.withPrefabValues(LatLon.class,
LatLon.ZERO, new LatLon(45, 45))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestData;
import org.openstreetmap.josm.data.conflict.Conflict;
import org.openstreetmap.josm.data.osm.DataSet;
Expand Down Expand Up @@ -72,6 +73,7 @@ public void testGetDescriptionIcon() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ConflictAddCommand.class).usingGetClass()
.withPrefabValues(DataSet.class,
new DataSet(), new DataSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.conflict.Conflict;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -31,6 +32,7 @@ public class ConflictResolveCommandTest {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ConflictResolveCommand.class).usingGetClass()
.withPrefabValues(Conflict.class,
new Conflict<>(new Node(1, 1), new Node(2, 1)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.command.CommandTest.CommandTestData;
import org.openstreetmap.josm.data.conflict.Conflict;
import org.openstreetmap.josm.data.coor.LatLon;
Expand Down Expand Up @@ -89,6 +90,7 @@ public void testGetDescriptionIcon() {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(CoordinateConflictResolveCommand.class).usingGetClass()
.withPrefabValues(Conflict.class,
new Conflict<>(new Node(), new Node()), new Conflict<>(new Way(), new Way()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.conflict.Conflict;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -32,6 +33,7 @@ public class DeletedStateConflictResolveCommandTest {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(DeletedStateConflictResolveCommand.class).usingGetClass()
.withPrefabValues(Conflict.class,
new Conflict<>(new Node(), new Node()), new Conflict<>(new Way(), new Way()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.conflict.Conflict;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -32,6 +33,7 @@ public class ModifiedConflictResolveCommandTest {
*/
@Test
public void testEqualsContract() {
TestUtils.assumeWorkingEqualsVerifier();
EqualsVerifier.forClass(ModifiedConflictResolveCommand.class).usingGetClass()
.withPrefabValues(Conflict.class,
new Conflict<>(new Node(), new Node()), new Conflict<>(new Way(), new Way()))
Expand Down
Loading

0 comments on commit 2cc561e

Please sign in to comment.