Skip to content

Commit a9ec509

Browse files
committed
Use Generics and Java 5 for loop.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1088463 13f79535-47bb-0310-9956-ffa450edef68
1 parent a0425fd commit a9ec509

2 files changed

Lines changed: 11 additions & 20 deletions

File tree

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,19 @@ public void testComparatorWithSoundex() throws Exception {
5353

5454
@Test
5555
public void testComparatorWithDoubleMetaphone() throws Exception {
56-
StringEncoderComparator sCompare =
57-
new StringEncoderComparator( new DoubleMetaphone() );
58-
56+
StringEncoderComparator sCompare = new StringEncoderComparator(new DoubleMetaphone());
57+
5958
String[] testArray = { "Jordan", "Sosa", "Prior", "Pryor" };
60-
List testList = Arrays.asList( testArray );
61-
59+
List<String> testList = Arrays.asList(testArray);
60+
6261
String[] controlArray = { "Jordan", "Prior", "Pryor", "Sosa" };
6362

64-
Collections.sort( testList, sCompare);
65-
63+
Collections.sort(testList, sCompare);
64+
6665
String[] resultArray = (String[]) testList.toArray(new String[0]);
67-
68-
for( int i = 0; i < resultArray.length; i++) {
69-
assertEquals( "Result Array not Equal to Control Array at index: " + i, controlArray[i], resultArray[i] );
66+
67+
for (int i = 0; i < resultArray.length; i++) {
68+
assertEquals("Result Array not Equal to Control Array at index: " + i, controlArray[i], resultArray[i]);
7069
}
7170
}
7271

src/test/org/apache/commons/codec/binary/HexTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
import java.io.UnsupportedEncodingException;
2626
import java.nio.charset.Charset;
2727
import java.util.Arrays;
28-
import java.util.Iterator;
2928
import java.util.Random;
30-
import java.util.Set;
31-
import java.util.SortedMap;
3229

3330
import junit.framework.Assert;
3431

@@ -126,13 +123,8 @@ private void log(Throwable t) {
126123

127124
@Test
128125
public void testCustomCharset() throws UnsupportedEncodingException, DecoderException {
129-
SortedMap map = Charset.availableCharsets();
130-
Set keys = map.keySet();
131-
Iterator iterator = keys.iterator();
132-
log("testCustomCharset: Checking " + keys.size() + " charsets...");
133-
while (iterator.hasNext()) {
134-
String name = (String) iterator.next();
135-
testCustomCharset(name, "testCustomCharset");
126+
for (String name : Charset.availableCharsets().keySet()) {
127+
testCustomCharset(name, "testCustomCharset");
136128
}
137129
}
138130

0 commit comments

Comments
 (0)