Skip to content

Commit

Permalink
[COLLECTIONS-777] Migrate to JUnit 5
Browse files Browse the repository at this point in the history
Remove JUnit 3 constructors
  • Loading branch information
garydgregory committed Nov 11, 2024
1 parent d2d894e commit aa13ed3
Show file tree
Hide file tree
Showing 169 changed files with 18 additions and 896 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
*/
public abstract class AbstractArrayListTest<E> extends AbstractListTest<E> {

public AbstractArrayListTest(final String testName) {
super(testName);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
*/
public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {

public AbstractLinkedListTest(final String testName) {
super(testName);
}

/**
* Returns the {@link #collection} field cast to a {@link LinkedList}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ public abstract class AbstractObjectTest extends BulkTest {
/** Current major release for Collections */
public static final int COLLECTIONS_MAJOR_VERSION = 4;

/**
* JUnit constructor.
*
* @param testName the test class name
*/
public AbstractObjectTest(final String testName) {
super(testName);
}

protected String getCanonicalEmptyCollectionName(final Object object) {
final StringBuilder retval = new StringBuilder();
retval.append(TEST_DATA_PATH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
*/
public abstract class AbstractTreeMapTest<K, V> extends AbstractMapTest<TreeMap<K, V>, K, V> {

public AbstractTreeMapTest(final String testName) {
super(testName);
}

@Override
public boolean isAllowNullKey() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
@SuppressWarnings("deprecation") // we test a deprecated class
public class ArrayStackTest<E> extends AbstractArrayListTest<E> {

public ArrayStackTest() {
super(ArrayStackTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
23 changes: 9 additions & 14 deletions src/test/java/org/apache/commons/collections4/BulkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@
*/
package org.apache.commons.collections4;

import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* A {@link TestCase} that can define both simple and bulk test methods.
* A {@code TestCase} that can define both simple and bulk test methods.
* <p>
* A <em>simple test method</em> is the type of test traditionally
* supplied by {@link TestCase}. To define a simple test, create a public
* supplied by {@code TestCase}. To define a simple test, create a public
* no-argument method whose name starts with "test". You can specify
* the name of simple test in the constructor of {@code BulkTest};
* a subsequent call to {@link TestCase#run} will run that simple test.
* a subsequent call to {@code TestCase#run} will run that simple test.
* <p>
* A <em>bulk test method</em>, on the other hand, returns a new instance
* of {@code BulkTest}, which can itself define new simple and bulk
* test methods. By using the {@link #makeSuite} method, you can
* test methods. By using the {@code #makeSuite} method, you can
* automatically create a hierarchical suite of tests and child bulk tests.
* <p>
* For instance, consider the following two classes:
Expand Down Expand Up @@ -121,11 +118,11 @@
* A subclass can override a superclass's bulk test by
* returning {@code null} from the bulk test method. If you only
* want to override specific simple tests within a bulk test, use the
* {@link #ignoredTests} method.<P>
* {@code #ignoredTests} method.<P>
*
* Note that if you want to use the bulk test methods, you <em>must</em>
* define your {@code suite()} method to use {@link #makeSuite}.
* The ordinary {@link TestSuite} constructor doesn't know how to
* define your {@code suite()} method to use {@code #makeSuite}.
* The ordinary {@code TestSuite} constructor doesn't know how to
* interpret bulk test methods.
*/
public class BulkTest implements Cloneable {
Expand Down Expand Up @@ -160,11 +157,9 @@ public class BulkTest implements Cloneable {
/**
* Constructs a new {@code BulkTest} instance that will run the
* specified simple test.
*
* @param name the name of the simple test method to run
*/
public BulkTest(final String name) {
this.name = name;
public BulkTest() {
this.name = getClass().getSimpleName();
this.verboseName = getClass().getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.apache.commons.collections4.collection.AbstractCollectionTest;
import org.apache.commons.collections4.set.AbstractSetTest;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -71,10 +70,6 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> {

public class TestBagUniqueSet extends AbstractSetTest<T> {

public TestBagUniqueSet() {
super(StringUtils.EMPTY);
}

@Override
public T[] getFullElements() {
return AbstractBagTest.this.getFullElements();
Expand Down Expand Up @@ -142,11 +137,8 @@ public void verify() {

/**
* JUnit constructor.
*
* @param testName the test class name
*/
public AbstractBagTest(final String testName) {
super(testName);
public AbstractBagTest() {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
*/
public abstract class AbstractSortedBagTest<T> extends AbstractBagTest<T> {

public AbstractSortedBagTest(final String testName) {
super(testName);
}

/**
* Returns the {@link #collection} field cast to a {@link SortedBag}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@
*/
public class CollectionBagTest<T> extends AbstractCollectionTest<T> {

/**
* JUnit constructor.
*/
public CollectionBagTest() {
super(CollectionBagTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@
*/
public class CollectionSortedBagTest<T> extends AbstractCollectionTest<T> {

/**
* JUnit constructor.
*/
public CollectionSortedBagTest() {
super(CollectionSortedBagTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
*/
public class HashBagTest<T> extends AbstractBagTest<T> {

public HashBagTest() {
super(HashBagTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public class PredicatedBagTest<T> extends AbstractBagTest<T> {

protected Predicate<T> truePredicate = TruePredicate.<T>truePredicate();

public PredicatedBagTest() {
super(PredicatedBagTest.class.getSimpleName());
}

protected Bag<T> decorateBag(final HashBag<T> bag, final Predicate<T> predicate) {
return PredicatedBag.predicatedBag(bag, predicate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ public class PredicatedSortedBagTest<T> extends AbstractSortedBagTest<T> {

protected Predicate<T> truePredicate = TruePredicate.<T>truePredicate();

public PredicatedSortedBagTest() {
super(PredicatedSortedBagTest.class.getSimpleName());
}

protected SortedBag<T> decorateBag(final SortedBag<T> bag, final Predicate<T> predicate) {
return PredicatedSortedBag.predicatedSortedBag(bag, predicate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
*/
public class SynchronizedBagTest<T> extends AbstractBagTest<T> {

public SynchronizedBagTest() {
super(SynchronizedBagTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
*/
public class TransformedBagTest<T> extends AbstractBagTest<T> {

public TransformedBagTest() {
super(TransformedBagTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
*/
public class TransformedSortedBagTest<T> extends AbstractSortedBagTest<T> {

public TransformedSortedBagTest() {
super(TransformedSortedBagTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
*/
public class TreeBagTest<T> extends AbstractSortedBagTest<T> {

public TreeBagTest() {
super(TreeBagTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
*/
public class UnmodifiableBagTest<E> extends AbstractBagTest<E> {

public UnmodifiableBagTest() {
super(UnmodifiableBagTest.class.getSimpleName());
}

@Override
public Bag<E> getCollection() {
return super.getCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
*/
public class UnmodifiableSortedBagTest<E> extends AbstractSortedBagTest<E> {

public UnmodifiableSortedBagTest() {
super(UnmodifiableSortedBagTest.class.getSimpleName());
}

@Override
public SortedBag<E> getCollection() {
return super.getCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ public void testMapEntrySetIteratorEntrySetValueCrossCheck() {

public class TestBidiMapIterator extends AbstractMapIteratorTest<K, V> {

public TestBidiMapIterator() {
super("TestBidiMapIterator");
}

@Override
public V[] addSetValues() {
return getNewSampleValues();
Expand Down Expand Up @@ -240,14 +236,6 @@ public BidiMap<V, K> makeObject() {
}
}

public AbstractBidiMapTest() {
super("Inverse");
}

public AbstractBidiMapTest(final String testName) {
super(testName);
}

public BulkTest bulkTestBidiMapIterator() {
return new TestBidiMapIterator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public OrderedBidiMap<V, K> inverseBidiMap() {
}
}

public AbstractOrderedBidiMapDecoratorTest(final String testName) {
super(testName);
}

@Override
public boolean isAllowNullKey() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ public abstract class AbstractOrderedBidiMapTest<K, V> extends AbstractBidiMapTe

public class TestBidiOrderedMapIterator extends AbstractMapIteratorTest<K, V> {

public TestBidiOrderedMapIterator() {
super("TestBidiOrderedMapIterator");
}

@Override
public V[] addSetValues() {
return getNewSampleValues();
Expand Down Expand Up @@ -91,13 +87,6 @@ public void verify() {

}

public AbstractOrderedBidiMapTest() {
}

public AbstractOrderedBidiMapTest(final String testName) {
super(testName);
}

public BulkTest bulkTestOrderedMapIterator() {
return new TestBidiOrderedMapIterator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
protected List<V> sortedValues = new ArrayList<>();
protected SortedSet<V> sortedNewValues = new TreeSet<>();

public AbstractSortedBidiMapTest(final String testName) {
super(testName);
public AbstractSortedBidiMapTest() {
sortedKeys = getAsList(getSampleKeys());
Collections.sort(sortedKeys);
sortedKeys = Collections.unmodifiableList(sortedKeys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
*/
public class DualHashBidiMapTest<K, V> extends AbstractBidiMapTest<K, V> {

public DualHashBidiMapTest() {
super(DualHashBidiMapTest.class.getSimpleName());
}

@Override
protected int getIterationBehaviour() {
return AbstractCollectionTest.UNORDERED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
*/
public class DualLinkedHashBidiMapTest<K, V> extends AbstractBidiMapTest<K, V> {

public DualLinkedHashBidiMapTest() {
super(DualLinkedHashBidiMapTest.class.getSimpleName());
}

@Override
public String getCompatibilityVersion() {
return "4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public int compare(final Integer o1, final Integer o2) {
}

public DualTreeBidiMap2Test() {
super(DualTreeBidiMap2Test.class.getSimpleName());
super();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class DualTreeBidiMapTest<K extends Comparable<K>, V extends Comparable<V>> extends AbstractSortedBidiMapTest<K, V> {

public DualTreeBidiMapTest() {
super(DualTreeBidiMapTest.class.getSimpleName());
super();
}

/**
Expand Down
Loading

0 comments on commit aa13ed3

Please sign in to comment.