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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ limitations under the License.
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.apache.commons.codec;

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

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

/**
*/
Expand Down
17 changes: 9 additions & 8 deletions src/test/java/org/apache/commons/codec/CharEncodingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

package org.apache.commons.codec;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

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

/**
* Sanity checks for {@link CharEncoding}.
Expand All @@ -36,32 +37,32 @@ public void testConstructor() {

@Test
public void testIso8859_1() {
Assert.assertEquals("ISO-8859-1", CharEncoding.ISO_8859_1);
assertEquals("ISO-8859-1", CharEncoding.ISO_8859_1);
}

@Test
public void testUsAscii() {
Assert.assertEquals("US-ASCII", CharEncoding.US_ASCII);
assertEquals("US-ASCII", CharEncoding.US_ASCII);
}

@Test
public void testUtf16() {
Assert.assertEquals("UTF-16", CharEncoding.UTF_16);
assertEquals("UTF-16", CharEncoding.UTF_16);
}

@Test
public void testUtf16Be() {
Assert.assertEquals("UTF-16BE", CharEncoding.UTF_16BE);
assertEquals("UTF-16BE", CharEncoding.UTF_16BE);
}

@Test
public void testUtf16Le() {
Assert.assertEquals("UTF-16LE", CharEncoding.UTF_16LE);
assertEquals("UTF-16LE", CharEncoding.UTF_16LE);
}

@Test
public void testUtf8() {
Assert.assertEquals("UTF-8", CharEncoding.UTF_8);
assertEquals("UTF-8", CharEncoding.UTF_8);
}

}
25 changes: 13 additions & 12 deletions src/test/java/org/apache/commons/codec/CharsetsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

package org.apache.commons.codec;

import org.junit.jupiter.api.Test;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Sanity checks for {@link Charsets}.
Expand All @@ -31,46 +32,46 @@ public class CharsetsTest {

@Test
public void testToCharset() {
Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset((String) null));
Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset((Charset) null));
Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset(Charset.defaultCharset()));
Assert.assertEquals(StandardCharsets.UTF_8, Charsets.toCharset(StandardCharsets.UTF_8));
assertEquals(Charset.defaultCharset(), Charsets.toCharset((String) null));
assertEquals(Charset.defaultCharset(), Charsets.toCharset((Charset) null));
assertEquals(Charset.defaultCharset(), Charsets.toCharset(Charset.defaultCharset()));
assertEquals(StandardCharsets.UTF_8, Charsets.toCharset(StandardCharsets.UTF_8));
}

@SuppressWarnings("deprecation")
@Test
public void testIso8859_1() {
Assert.assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name());
assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name());
}

@SuppressWarnings("deprecation")
@Test
public void testUsAscii() {
Assert.assertEquals("US-ASCII", Charsets.US_ASCII.name());
assertEquals("US-ASCII", Charsets.US_ASCII.name());
}

@SuppressWarnings("deprecation")
@Test
public void testUtf16() {
Assert.assertEquals("UTF-16", Charsets.UTF_16.name());
assertEquals("UTF-16", Charsets.UTF_16.name());
}

@SuppressWarnings("deprecation")
@Test
public void testUtf16Be() {
Assert.assertEquals("UTF-16BE", Charsets.UTF_16BE.name());
assertEquals("UTF-16BE", Charsets.UTF_16BE.name());
}

@SuppressWarnings("deprecation")
@Test
public void testUtf16Le() {
Assert.assertEquals("UTF-16LE", Charsets.UTF_16LE.name());
assertEquals("UTF-16LE", Charsets.UTF_16LE.name());
}

@SuppressWarnings("deprecation")
@Test
public void testUtf8() {
Assert.assertEquals("UTF-8", Charsets.UTF_8.name());
assertEquals("UTF-8", Charsets.UTF_8.name());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.apache.commons.codec;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.jupiter.api.Test;

import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
* Tests {@link DecoderException}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.apache.commons.codec;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.jupiter.api.Test;

import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
* Tests {@link EncoderException}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

package org.apache.commons.codec;

import org.junit.jupiter.api.Test;

import java.util.Locale;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.*;

/**
*/
Expand All @@ -29,7 +30,7 @@ public abstract class StringEncoderAbstractTest<T extends StringEncoder> {
protected T stringEncoder = this.createStringEncoder();

public void checkEncoding(final String expected, final String source) throws EncoderException {
Assert.assertEquals("Source: " + source, expected, this.getStringEncoder().encode(source));
assertEquals(expected, this.getStringEncoder().encode(source), "Source: " + source);
}

protected void checkEncodings(final String[][] data) throws EncoderException {
Expand Down Expand Up @@ -66,16 +67,10 @@ public void testEncodeNull() throws EncoderException {

@Test
public void testEncodeWithInvalidObject() throws Exception {
boolean exceptionThrown = false;
try {
final StringEncoder encoder = this.getStringEncoder();
encoder.encode(Float.valueOf(3.4f));
} catch (final Exception e) {
exceptionThrown = true;
}
Assert.assertTrue("An exception was not thrown when we tried to encode " + "a Float object", exceptionThrown);
final StringEncoder encoder = this.getStringEncoder();
assertThrows(EncoderException.class, () -> encoder.encode(Float.valueOf(3.4f)),
"An exception was not thrown when we tried to encode a Float object");
}

@Test
public void testLocaleIndependence() throws Exception {
final StringEncoder encoder = this.getStringEncoder();
Expand All @@ -97,9 +92,9 @@ public void testLocaleIndependence() throws Exception {
try {
cur = encoder.encode(element);
} catch (final Exception e) {
Assert.fail(Locale.getDefault().toString() + ": " + e.getMessage());
fail(Locale.getDefault().toString() + ": " + e.getMessage());
}
Assert.assertEquals(Locale.getDefault().toString() + ": ", ref, cur);
assertEquals(ref, cur, Locale.getDefault().toString() + ": ");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

package org.apache.commons.codec;

import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.List;

import org.apache.commons.codec.language.DoubleMetaphone;
import org.apache.commons.codec.language.Soundex;
import org.junit.Test;
import org.junit.jupiter.api.Test;

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

/**
* Test cases for the StingEncoderComparator.
Expand All @@ -36,8 +36,8 @@ public void testComparatorWithSoundex() throws Exception {
final StringEncoderComparator sCompare =
new StringEncoderComparator( new Soundex() );

assertEquals("O'Brien and O'Brian didn't come out with " +
"the same Soundex, something must be wrong here", 0, sCompare.compare("O'Brien", "O'Brian"));
assertEquals(0, sCompare.compare("O'Brien", "O'Brian"),
"O'Brien and O'Brian didn't come out with the same Soundex, something must be wrong here");
}

@SuppressWarnings("unchecked") // cannot easily avoid this warning
Expand All @@ -55,7 +55,8 @@ public void testComparatorWithDoubleMetaphone() throws Exception {
final String[] resultArray = testList.toArray(new String[0]);

for (int i = 0; i < resultArray.length; i++) {
assertEquals("Result Array not Equal to Control Array at index: " + i, controlArray[i], resultArray[i]);
assertEquals(controlArray[i], resultArray[i],
"Result Array not Equal to Control Array at index: " + i);
}
}

Expand All @@ -65,7 +66,8 @@ public void testComparatorWithDoubleMetaphoneAndInvalidInput() throws Exception
new StringEncoderComparator( new DoubleMetaphone() );

final int compare = sCompare.compare(Double.valueOf(3.0d), Long.valueOf(3));
assertEquals( "Trying to compare objects that make no sense to the underlying encoder should return a zero compare code",
0, compare);
assertEquals(0, compare,
"Trying to compare objects that make no sense to the underlying encoder" +
" should return a zero compare code");
}
}
Loading