Skip to content

Commit 8ffb4fb

Browse files
committed
1 parent 36e7620 commit 8ffb4fb

34 files changed

Lines changed: 529 additions & 256 deletions

src/changes/changes.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
</properties>
2424
<body>
2525
<release version="2.0" date="TBA" description="Feature and fix release.">
26+
<action dev="ggregory" type="update" issue="CODEC-119">
27+
Migrate to Java 5.
28+
</action>
29+
<action dev="ggregory" type="update" issue="CODEC-120">
30+
Migrate to JUnit 4.
31+
</action>
2632
</release>
2733
<release version="1.5" date="29 March 2011" description="Feature and fix release.">
2834
<action dev="sebb" type="fix" issue="CODEC-89">

src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,29 @@
1717

1818
package org.apache.commons.codec;
1919

20-
import junit.framework.TestCase;
20+
import org.junit.Test;
2121

2222
/**
2323
* @author Apache Software Foundation
2424
* @version $Id$
2525
*/
26-
public abstract class BinaryEncoderAbstractTest extends TestCase {
27-
28-
public BinaryEncoderAbstractTest(String name) {
29-
super(name);
30-
}
26+
public abstract class BinaryEncoderAbstractTest {
3127

3228
protected abstract BinaryEncoder makeEncoder();
3329

34-
// ------------------------------------------------------------------------
35-
30+
@Test
3631
public void testEncodeEmpty() throws Exception {
3732
BinaryEncoder encoder = makeEncoder();
3833
encoder.encode(new byte[0]);
39-
}
34+
}
4035

36+
@Test
4137
public void testEncodeNull() throws Exception {
4238
BinaryEncoder encoder = makeEncoder();
4339
try {
4440
encoder.encode(null);
4541
} catch (EncoderException ee) {
4642
// An exception should be thrown
4743
}
48-
}
44+
}
4945
}

src/test/org/apache/commons/codec/CharEncodingTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,51 @@
1818
package org.apache.commons.codec;
1919

2020
import junit.framework.Assert;
21-
import junit.framework.TestCase;
21+
22+
import org.junit.Test;
2223

2324
/**
2425
* Sanity checks for {@link CharEncoding}.
2526
*
2627
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
2728
* @version $Id$
2829
*/
29-
public class CharEncodingTest extends TestCase {
30+
public class CharEncodingTest {
3031

3132
/**
3233
* We could make the constructor private in the future, it's a matter a style.
3334
*/
35+
@Test
3436
public void testConstructor() {
3537
new CharEncoding();
3638
}
3739

40+
@Test
3841
public void testIso8859_1() {
3942
Assert.assertEquals("ISO-8859-1", CharEncoding.ISO_8859_1);
4043
}
4144

45+
@Test
4246
public void testUsAscii() {
4347
Assert.assertEquals("US-ASCII", CharEncoding.US_ASCII);
4448
}
4549

50+
@Test
4651
public void testUtf16() {
4752
Assert.assertEquals("UTF-16", CharEncoding.UTF_16);
4853
}
4954

55+
@Test
5056
public void testUtf16Be() {
5157
Assert.assertEquals("UTF-16BE", CharEncoding.UTF_16BE);
5258
}
5359

60+
@Test
5461
public void testUtf16Le() {
5562
Assert.assertEquals("UTF-16LE", CharEncoding.UTF_16LE);
5663
}
5764

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

src/test/org/apache/commons/codec/DecoderExceptionTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,45 @@
1717

1818
package org.apache.commons.codec;
1919

20-
import junit.framework.TestCase;
20+
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertNull;
22+
23+
import org.junit.Test;
2124

2225
/**
2326
* Tests {@link DecoderException}.
2427
*
2528
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
2629
* @version $Id$
2730
*/
28-
public class DecoderExceptionTest extends TestCase {
31+
public class DecoderExceptionTest {
2932

3033
private static final String MSG = "TEST";
3134

3235
private static final Throwable t = new Exception();
3336

37+
@Test
3438
public void testConstructor0() {
3539
DecoderException e = new DecoderException();
3640
assertNull(e.getMessage());
3741
assertNull(e.getCause());
3842
}
3943

44+
@Test
4045
public void testConstructorString() {
4146
DecoderException e = new DecoderException(MSG);
4247
assertEquals(MSG, e.getMessage());
4348
assertNull(e.getCause());
4449
}
4550

51+
@Test
4652
public void testConstructorStringThrowable() {
4753
DecoderException e = new DecoderException(MSG, t);
4854
assertEquals(MSG, e.getMessage());
4955
assertEquals(t, e.getCause());
5056
}
5157

58+
@Test
5259
public void testConstructorThrowable() {
5360
DecoderException e = new DecoderException(t);
5461
assertEquals(t.getClass().getName(), e.getMessage());

src/test/org/apache/commons/codec/EncoderExceptionTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,45 @@
1717

1818
package org.apache.commons.codec;
1919

20-
import junit.framework.TestCase;
20+
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertNull;
22+
23+
import org.junit.Test;
2124

2225
/**
2326
* Tests {@link EncoderException}.
2427
*
2528
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
2629
* @version $Id$
2730
*/
28-
public class EncoderExceptionTest extends TestCase {
31+
public class EncoderExceptionTest {
2932

3033
private static final String MSG = "TEST";
3134

3235
private static final Throwable t = new Exception();
3336

37+
@Test
3438
public void testConstructor0() {
3539
EncoderException e = new EncoderException();
3640
assertNull(e.getMessage());
3741
assertNull(e.getCause());
3842
}
3943

44+
@Test
4045
public void testConstructorString() {
4146
EncoderException e = new EncoderException(MSG);
4247
assertEquals(MSG, e.getMessage());
4348
assertNull(e.getCause());
4449
}
4550

51+
@Test
4652
public void testConstructorStringThrowable() {
4753
EncoderException e = new EncoderException(MSG, t);
4854
assertEquals(MSG, e.getMessage());
4955
assertEquals(t, e.getCause());
5056
}
5157

58+
@Test
5259
public void testConstructorThrowable() {
5360
EncoderException e = new EncoderException(t);
5461
assertEquals(t.getClass().getName(), e.getMessage());

src/test/org/apache/commons/codec/StringEncoderAbstractTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@
2020
import java.util.Locale;
2121

2222
import junit.framework.Assert;
23-
import junit.framework.TestCase;
23+
24+
import org.junit.Test;
2425

2526
/**
2627
* @author Apache Software Foundation
2728
* @version $Id$
2829
*/
29-
public abstract class StringEncoderAbstractTest extends TestCase {
30+
public abstract class StringEncoderAbstractTest {
3031

3132
protected StringEncoder stringEncoder = this.createStringEncoder();
3233

33-
public StringEncoderAbstractTest(String name) {
34-
super(name);
35-
}
36-
3734
public void checkEncoding(String expected, String source) throws EncoderException {
3835
Assert.assertEquals("Source: " + source, expected, this.getStringEncoder().encode(source));
3936
}
@@ -56,13 +53,15 @@ public StringEncoder getStringEncoder() {
5653
return this.stringEncoder;
5754
}
5855

56+
@Test
5957
public void testEncodeEmpty() throws Exception {
6058
Encoder encoder = this.getStringEncoder();
6159
encoder.encode("");
6260
encoder.encode(" ");
6361
encoder.encode("\t");
6462
}
6563

64+
@Test
6665
public void testEncodeNull() throws Exception {
6766
StringEncoder encoder = this.getStringEncoder();
6867
try {
@@ -72,19 +71,19 @@ public void testEncodeNull() throws Exception {
7271
}
7372
}
7473

74+
@Test
7575
public void testEncodeWithInvalidObject() throws Exception {
76-
7776
boolean exceptionThrown = false;
7877
try {
7978
StringEncoder encoder = this.getStringEncoder();
8079
encoder.encode(new Float(3.4));
8180
} catch (Exception e) {
8281
exceptionThrown = true;
8382
}
84-
8583
Assert.assertTrue("An exception was not thrown when we tried to encode " + "a Float object", exceptionThrown);
8684
}
8785

86+
@Test
8887
public void testLocaleIndependence() throws Exception {
8988
StringEncoder encoder = this.getStringEncoder();
9089

src/test/org/apache/commons/codec/StringEncoderComparatorTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,31 @@
1717

1818
package org.apache.commons.codec;
1919

20+
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertTrue;
22+
2023
import java.util.Arrays;
2124
import java.util.Collections;
2225
import java.util.List;
2326

24-
import junit.framework.TestCase;
25-
2627
import org.apache.commons.codec.language.DoubleMetaphone;
2728
import org.apache.commons.codec.language.Soundex;
29+
import org.junit.Test;
2830

2931
/**
3032
* Test cases for the StingEncoderComparator.
3133
*
3234
* @author Apache Software Foundation
3335
* @version $Id$
3436
*/
35-
public class StringEncoderComparatorTest extends TestCase {
36-
37-
public StringEncoderComparatorTest(String name) {
38-
super(name);
39-
}
37+
public class StringEncoderComparatorTest {
4038

39+
@Test
4140
public void testComparatorNoArgCon() throws Exception {
4241
new StringEncoderComparator();
4342
}
4443

44+
@Test
4545
public void testComparatorWithSoundex() throws Exception {
4646
StringEncoderComparator sCompare =
4747
new StringEncoderComparator( new Soundex() );
@@ -51,6 +51,7 @@ public void testComparatorWithSoundex() throws Exception {
5151
0 == sCompare.compare( "O'Brien", "O'Brian" ) );
5252
}
5353

54+
@Test
5455
public void testComparatorWithDoubleMetaphone() throws Exception {
5556
StringEncoderComparator sCompare =
5657
new StringEncoderComparator( new DoubleMetaphone() );
@@ -69,13 +70,13 @@ public void testComparatorWithDoubleMetaphone() throws Exception {
6970
}
7071
}
7172

73+
@Test
7274
public void testComparatorWithDoubleMetaphoneAndInvalidInput() throws Exception {
7375
StringEncoderComparator sCompare =
7476
new StringEncoderComparator( new DoubleMetaphone() );
7577

7678
int compare = sCompare.compare(new Double(3.0), new Long(3));
7779
assertEquals( "Trying to compare objects that make no sense to the underlying encoder should return a zero compare code",
7880
0, compare);
79-
8081
}
8182
}

0 commit comments

Comments
 (0)