You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/01/07 17:08:07 UTC
svn commit: r1429868 [5/6] - in /commons/proper/codec/trunk/src:
main/java/org/apache/commons/codec/
main/java/org/apache/commons/codec/binary/
main/java/org/apache/commons/codec/digest/
main/java/org/apache/commons/codec/language/ main/java/org/apache...
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64TestData.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64TestData.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64TestData.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64TestData.java Mon Jan 7 16:08:05 2013
@@ -156,7 +156,7 @@ public class Base64TestData {
lastRead = status[LAST_READ_KEY];
}
if (buf.length != size) {
- byte[] smallerBuf = new byte[size];
+ final byte[] smallerBuf = new byte[size];
System.arraycopy(buf, 0, smallerBuf, 0, size);
buf = smallerBuf;
}
@@ -184,7 +184,7 @@ public class Base64TestData {
}
private static byte[] resizeArray(final byte[] bytes) {
- byte[] biggerBytes = new byte[bytes.length * 2];
+ final byte[] biggerBytes = new byte[bytes.length * 2];
System.arraycopy(bytes, 0, biggerBytes, 0, bytes.length);
return biggerBytes;
}
@@ -197,11 +197,11 @@ public class Base64TestData {
* @param urlSafe true if encoding be urlSafe
* @return two byte[] arrays: [0] = decoded, [1] = encoded
*/
- static byte[][] randomData(int size, boolean urlSafe) {
- Random r = new Random();
- byte[] decoded = new byte[size];
+ static byte[][] randomData(final int size, final boolean urlSafe) {
+ final Random r = new Random();
+ final byte[] decoded = new byte[size];
r.nextBytes(decoded);
- byte[] encoded = urlSafe ? Base64.encodeBase64URLSafe(decoded) : Base64.encodeBase64(decoded);
+ final byte[] encoded = urlSafe ? Base64.encodeBase64URLSafe(decoded) : Base64.encodeBase64(decoded);
return new byte[][] {decoded, encoded};
}
@@ -212,8 +212,8 @@ public class Base64TestData {
* @param c byte to look for
* @return true if bytes contains c, false otherwise
*/
- static boolean bytesContain(byte[] bytes, byte c) {
- for (byte b : bytes) {
+ static boolean bytesContain(final byte[] bytes, final byte c) {
+ for (final byte b : bytes) {
if (b == c) { return true; }
}
return false;
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java Mon Jan 7 16:08:05 2013
@@ -33,16 +33,16 @@ public class BaseNCodecTest {
public void setUp() {
codec = new BaseNCodec(0, 0, 0, 0) {
@Override
- protected boolean isInAlphabet(byte b) {
+ protected boolean isInAlphabet(final byte b) {
return b=='O' || b == 'K'; // allow OK
}
@Override
- void encode(byte[] pArray, int i, int length, Context context) {
+ void encode(final byte[] pArray, final int i, final int length, final Context context) {
}
@Override
- void decode(byte[] pArray, int i, int length, Context context) {
+ void decode(final byte[] pArray, final int i, final int length, final Context context) {
}
};
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java Mon Jan 7 16:08:05 2013
@@ -82,7 +82,7 @@ public class BinaryCodecTest {
public void testDecodeObjectException() {
try {
this.instance.decode(new Object());
- } catch (DecoderException e) {
+ } catch (final DecoderException e) {
// all is well.
return;
}
@@ -174,7 +174,7 @@ public class BinaryCodecTest {
* @param encodeMe
* data to encode and compare
*/
- void assertDecodeObject(byte[] bits, String encodeMe) throws DecoderException {
+ void assertDecodeObject(final byte[] bits, final String encodeMe) throws DecoderException {
byte[] decoded;
decoded = (byte[]) instance.decode(encodeMe);
assertEquals(new String(bits), new String(decoded));
@@ -1073,7 +1073,7 @@ public class BinaryCodecTest {
*/
@Test
public void testEncodeObjectNull() throws Exception {
- Object obj = new byte[0];
+ final Object obj = new byte[0];
assertEquals(0, ((char[]) instance.encode(obj)).length);
}
@@ -1084,7 +1084,7 @@ public class BinaryCodecTest {
public void testEncodeObjectException() {
try {
instance.encode("");
- } catch (EncoderException e) {
+ } catch (final EncoderException e) {
// all is well.
return;
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java Mon Jan 7 16:08:05 2013
@@ -43,7 +43,7 @@ public class Codec105ErrorInputStream ex
}
@Override
- public int read(byte b[], int pos, int len) throws IOException {
+ public int read(final byte b[], final int pos, final int len) throws IOException {
if (this.countdown-- > 0) {
b[pos] = '\n';
return 1;
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java Mon Jan 7 16:08:05 2013
@@ -45,12 +45,12 @@ public class HexTest {
private final static boolean LOG = false;
- private boolean charsetSanityCheck(String name) {
+ private boolean charsetSanityCheck(final String name) {
final String source = "the quick brown dog jumped over the lazy fox";
try {
- byte[] bytes = source.getBytes(name);
- String str = new String(bytes, name);
- boolean equals = source.equals(str);
+ final byte[] bytes = source.getBytes(name);
+ final String str = new String(bytes, name);
+ final boolean equals = source.equals(str);
if (equals == false) {
// Here with:
//
@@ -75,14 +75,14 @@ public class HexTest {
log("FAILED charsetSanityCheck=Interesting Java charset oddity: Roundtrip failed for " + name);
}
return equals;
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
// Should NEVER happen since we are getting the name from the Charset class.
if (LOG) {
log("FAILED charsetSanityCheck=" + name + ", e=" + e);
log(e);
}
return false;
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// Caught here with:
// x-JISAutoDetect on Windows XP and Java Sun 1.4.2_19 x86 32-bits
// x-JISAutoDetect on Windows XP and Java Sun 1.5.0_17 x86 32-bits
@@ -98,23 +98,23 @@ public class HexTest {
/**
* @param data
*/
- private void checkDecodeHexOddCharacters(char[] data) {
+ private void checkDecodeHexOddCharacters(final char[] data) {
try {
Hex.decodeHex(data);
fail("An exception wasn't thrown when trying to decode an odd number of characters");
- } catch (DecoderException e) {
+ } catch (final DecoderException e) {
// Expected exception
}
}
- private void log(String s) {
+ private void log(final String s) {
if (LOG) {
System.out.println(s);
System.out.flush();
}
}
- private void log(Throwable t) {
+ private void log(final Throwable t) {
if (LOG) {
t.printStackTrace(System.out);
System.out.flush();
@@ -123,7 +123,7 @@ public class HexTest {
@Test
public void testCustomCharset() throws UnsupportedEncodingException, DecoderException {
- for (String name : Charset.availableCharsets().keySet()) {
+ for (final String name : Charset.availableCharsets().keySet()) {
testCustomCharset(name, "testCustomCharset");
}
}
@@ -135,36 +135,36 @@ public class HexTest {
* @throws UnsupportedEncodingException
* @throws DecoderException
*/
- private void testCustomCharset(String name, String parent) throws UnsupportedEncodingException, DecoderException {
+ private void testCustomCharset(final String name, final String parent) throws UnsupportedEncodingException, DecoderException {
if (charsetSanityCheck(name) == false) {
return;
}
log(parent + "=" + name);
- Hex customCodec = new Hex(name);
+ final Hex customCodec = new Hex(name);
// source data
- String sourceString = "Hello World";
- byte[] sourceBytes = sourceString.getBytes(name);
+ final String sourceString = "Hello World";
+ final byte[] sourceBytes = sourceString.getBytes(name);
// test 1
// encode source to hex string to bytes with charset
- byte[] actualEncodedBytes = customCodec.encode(sourceBytes);
+ final byte[] actualEncodedBytes = customCodec.encode(sourceBytes);
// encode source to hex string...
String expectedHexString = Hex.encodeHexString(sourceBytes);
// ... and get the bytes in the expected charset
- byte[] expectedHexStringBytes = expectedHexString.getBytes(name);
+ final byte[] expectedHexStringBytes = expectedHexString.getBytes(name);
Assert.assertTrue(Arrays.equals(expectedHexStringBytes, actualEncodedBytes));
// test 2
String actualStringFromBytes = new String(actualEncodedBytes, name);
assertEquals(name + ", expectedHexString=" + expectedHexString + ", actualStringFromBytes=" + actualStringFromBytes,
expectedHexString, actualStringFromBytes);
// second test:
- Hex utf8Codec = new Hex();
+ final Hex utf8Codec = new Hex();
expectedHexString = "48656c6c6f20576f726c64";
- byte[] decodedUtf8Bytes = (byte[]) utf8Codec.decode(expectedHexString);
+ final byte[] decodedUtf8Bytes = (byte[]) utf8Codec.decode(expectedHexString);
actualStringFromBytes = new String(decodedUtf8Bytes, utf8Codec.getCharset());
// sanity check:
assertEquals(name, sourceString, actualStringFromBytes);
// actual check:
- byte[] decodedCustomBytes = customCodec.decode(actualEncodedBytes);
+ final byte[] decodedCustomBytes = customCodec.decode(actualEncodedBytes);
actualStringFromBytes = new String(decodedCustomBytes, name);
assertEquals(name, sourceString, actualStringFromBytes);
}
@@ -184,7 +184,7 @@ public class HexTest {
try {
new Hex().decode(new byte[]{65});
fail("An exception wasn't thrown when trying to decode an odd number of characters");
- } catch (DecoderException e) {
+ } catch (final DecoderException e) {
// Expected exception
}
}
@@ -194,7 +194,7 @@ public class HexTest {
try {
new Hex().decode("q0");
fail("An exception wasn't thrown when trying to decode an illegal character");
- } catch (DecoderException e) {
+ } catch (final DecoderException e) {
// Expected exception
}
}
@@ -204,7 +204,7 @@ public class HexTest {
try {
new Hex().decode("0q");
fail("An exception wasn't thrown when trying to decode an illegal character");
- } catch (DecoderException e) {
+ } catch (final DecoderException e) {
// Expected exception
}
}
@@ -214,7 +214,7 @@ public class HexTest {
try {
new Hex().decode(new int[]{65});
fail("An exception wasn't thrown when trying to decode.");
- } catch (DecoderException e) {
+ } catch (final DecoderException e) {
// Expected exception
}
}
@@ -239,7 +239,7 @@ public class HexTest {
try {
new Hex().decode("6");
fail("An exception wasn't thrown when trying to decode an odd number of characters");
- } catch (DecoderException e) {
+ } catch (final DecoderException e) {
// Expected exception
}
}
@@ -256,27 +256,27 @@ public class HexTest {
try {
new Hex().encode(new int[]{65});
fail("An exception wasn't thrown when trying to encode.");
- } catch (EncoderException e) {
+ } catch (final EncoderException e) {
// Expected exception
}
}
@Test
public void testEncodeDecodeRandom() throws DecoderException, EncoderException {
- Random random = new Random();
+ final Random random = new Random();
- Hex hex = new Hex();
+ final Hex hex = new Hex();
for (int i = 5; i > 0; i--) {
- byte[] data = new byte[random.nextInt(10000) + 1];
+ final byte[] data = new byte[random.nextInt(10000) + 1];
random.nextBytes(data);
// static API
- char[] encodedChars = Hex.encodeHex(data);
+ final char[] encodedChars = Hex.encodeHex(data);
byte[] decodedBytes = Hex.decodeHex(encodedChars);
assertTrue(Arrays.equals(data, decodedBytes));
// instance API with array parameter
- byte[] encodedStringBytes = hex.encode(data);
+ final byte[] encodedStringBytes = hex.encode(data);
decodedBytes = hex.decode(encodedStringBytes);
assertTrue(Arrays.equals(data, decodedBytes));
@@ -303,13 +303,13 @@ public class HexTest {
@Test
public void testEncodeZeroes() {
- char[] c = Hex.encodeHex(new byte[36]);
+ final char[] c = Hex.encodeHex(new byte[36]);
assertEquals("000000000000000000000000000000000000000000000000000000000000000000000000", new String(c));
}
@Test
public void testHelloWorldLowerCaseHex() {
- byte[] b = StringUtils.getBytesUtf8("Hello World");
+ final byte[] b = StringUtils.getBytesUtf8("Hello World");
final String expected = "48656c6c6f20576f726c64";
char[] actual;
actual = Hex.encodeHex(b);
@@ -322,7 +322,7 @@ public class HexTest {
@Test
public void testHelloWorldUpperCaseHex() {
- byte[] b = StringUtils.getBytesUtf8("Hello World");
+ final byte[] b = StringUtils.getBytesUtf8("Hello World");
final String expected = "48656C6C6F20576F726C64";
char[] actual;
actual = Hex.encodeHex(b);
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java Mon Jan 7 16:08:05 2013
@@ -52,61 +52,61 @@ public class StringUtilsTest {
@Test
public void testGetBytesIso8859_1() throws UnsupportedEncodingException {
- String charsetName = "ISO-8859-1";
+ final String charsetName = "ISO-8859-1";
testGetBytesUnchecked(charsetName);
- byte[] expected = STRING_FIXTURE.getBytes(charsetName);
- byte[] actual = StringUtils.getBytesIso8859_1(STRING_FIXTURE);
+ final byte[] expected = STRING_FIXTURE.getBytes(charsetName);
+ final byte[] actual = StringUtils.getBytesIso8859_1(STRING_FIXTURE);
Assert.assertTrue(Arrays.equals(expected, actual));
}
- private void testGetBytesUnchecked(String charsetName) throws UnsupportedEncodingException {
- byte[] expected = STRING_FIXTURE.getBytes(charsetName);
- byte[] actual = StringUtils.getBytesUnchecked(STRING_FIXTURE, charsetName);
+ private void testGetBytesUnchecked(final String charsetName) throws UnsupportedEncodingException {
+ final byte[] expected = STRING_FIXTURE.getBytes(charsetName);
+ final byte[] actual = StringUtils.getBytesUnchecked(STRING_FIXTURE, charsetName);
Assert.assertTrue(Arrays.equals(expected, actual));
}
@Test
public void testGetBytesUsAscii() throws UnsupportedEncodingException {
- String charsetName = "US-ASCII";
+ final String charsetName = "US-ASCII";
testGetBytesUnchecked(charsetName);
- byte[] expected = STRING_FIXTURE.getBytes(charsetName);
- byte[] actual = StringUtils.getBytesUsAscii(STRING_FIXTURE);
+ final byte[] expected = STRING_FIXTURE.getBytes(charsetName);
+ final byte[] actual = StringUtils.getBytesUsAscii(STRING_FIXTURE);
Assert.assertTrue(Arrays.equals(expected, actual));
}
@Test
public void testGetBytesUtf16() throws UnsupportedEncodingException {
- String charsetName = "UTF-16";
+ final String charsetName = "UTF-16";
testGetBytesUnchecked(charsetName);
- byte[] expected = STRING_FIXTURE.getBytes(charsetName);
- byte[] actual = StringUtils.getBytesUtf16(STRING_FIXTURE);
+ final byte[] expected = STRING_FIXTURE.getBytes(charsetName);
+ final byte[] actual = StringUtils.getBytesUtf16(STRING_FIXTURE);
Assert.assertTrue(Arrays.equals(expected, actual));
}
@Test
public void testGetBytesUtf16Be() throws UnsupportedEncodingException {
- String charsetName = "UTF-16BE";
+ final String charsetName = "UTF-16BE";
testGetBytesUnchecked(charsetName);
- byte[] expected = STRING_FIXTURE.getBytes(charsetName);
- byte[] actual = StringUtils.getBytesUtf16Be(STRING_FIXTURE);
+ final byte[] expected = STRING_FIXTURE.getBytes(charsetName);
+ final byte[] actual = StringUtils.getBytesUtf16Be(STRING_FIXTURE);
Assert.assertTrue(Arrays.equals(expected, actual));
}
@Test
public void testGetBytesUtf16Le() throws UnsupportedEncodingException {
- String charsetName = "UTF-16LE";
+ final String charsetName = "UTF-16LE";
testGetBytesUnchecked(charsetName);
- byte[] expected = STRING_FIXTURE.getBytes(charsetName);
- byte[] actual = StringUtils.getBytesUtf16Le(STRING_FIXTURE);
+ final byte[] expected = STRING_FIXTURE.getBytes(charsetName);
+ final byte[] actual = StringUtils.getBytesUtf16Le(STRING_FIXTURE);
Assert.assertTrue(Arrays.equals(expected, actual));
}
@Test
public void testGetBytesUtf8() throws UnsupportedEncodingException {
- String charsetName = "UTF-8";
+ final String charsetName = "UTF-8";
testGetBytesUnchecked(charsetName);
- byte[] expected = STRING_FIXTURE.getBytes(charsetName);
- byte[] actual = StringUtils.getBytesUtf8(STRING_FIXTURE);
+ final byte[] expected = STRING_FIXTURE.getBytes(charsetName);
+ final byte[] actual = StringUtils.getBytesUtf8(STRING_FIXTURE);
Assert.assertTrue(Arrays.equals(expected, actual));
}
@@ -115,7 +115,7 @@ public class StringUtilsTest {
try {
StringUtils.getBytesUnchecked(STRING_FIXTURE, "UNKNOWN");
Assert.fail("Expected " + IllegalStateException.class.getName());
- } catch (IllegalStateException e) {
+ } catch (final IllegalStateException e) {
// Expected
}
}
@@ -125,9 +125,9 @@ public class StringUtilsTest {
Assert.assertNull(StringUtils.getBytesUnchecked(null, "UNKNOWN"));
}
- private void testNewString(String charsetName) throws UnsupportedEncodingException {
- String expected = new String(BYTES_FIXTURE, charsetName);
- String actual = StringUtils.newString(BYTES_FIXTURE, charsetName);
+ private void testNewString(final String charsetName) throws UnsupportedEncodingException {
+ final String expected = new String(BYTES_FIXTURE, charsetName);
+ final String actual = StringUtils.newString(BYTES_FIXTURE, charsetName);
Assert.assertEquals(expected, actual);
}
@@ -136,7 +136,7 @@ public class StringUtilsTest {
try {
StringUtils.newString(BYTES_FIXTURE, "UNKNOWN");
Assert.fail("Expected " + IllegalStateException.class.getName());
- } catch (IllegalStateException e) {
+ } catch (final IllegalStateException e) {
// Expected
}
}
@@ -148,55 +148,55 @@ public class StringUtilsTest {
@Test
public void testNewStringIso8859_1() throws UnsupportedEncodingException {
- String charsetName = "ISO-8859-1";
+ final String charsetName = "ISO-8859-1";
testNewString(charsetName);
- String expected = new String(BYTES_FIXTURE, charsetName);
- String actual = StringUtils.newStringIso8859_1(BYTES_FIXTURE);
+ final String expected = new String(BYTES_FIXTURE, charsetName);
+ final String actual = StringUtils.newStringIso8859_1(BYTES_FIXTURE);
Assert.assertEquals(expected, actual);
}
@Test
public void testNewStringUsAscii() throws UnsupportedEncodingException {
- String charsetName = "US-ASCII";
+ final String charsetName = "US-ASCII";
testNewString(charsetName);
- String expected = new String(BYTES_FIXTURE, charsetName);
- String actual = StringUtils.newStringUsAscii(BYTES_FIXTURE);
+ final String expected = new String(BYTES_FIXTURE, charsetName);
+ final String actual = StringUtils.newStringUsAscii(BYTES_FIXTURE);
Assert.assertEquals(expected, actual);
}
@Test
public void testNewStringUtf16() throws UnsupportedEncodingException {
- String charsetName = "UTF-16";
+ final String charsetName = "UTF-16";
testNewString(charsetName);
- String expected = new String(BYTES_FIXTURE, charsetName);
- String actual = StringUtils.newStringUtf16(BYTES_FIXTURE);
+ final String expected = new String(BYTES_FIXTURE, charsetName);
+ final String actual = StringUtils.newStringUtf16(BYTES_FIXTURE);
Assert.assertEquals(expected, actual);
}
@Test
public void testNewStringUtf16Be() throws UnsupportedEncodingException {
- String charsetName = "UTF-16BE";
+ final String charsetName = "UTF-16BE";
testNewString(charsetName);
- String expected = new String(BYTES_FIXTURE_16BE, charsetName);
- String actual = StringUtils.newStringUtf16Be(BYTES_FIXTURE_16BE);
+ final String expected = new String(BYTES_FIXTURE_16BE, charsetName);
+ final String actual = StringUtils.newStringUtf16Be(BYTES_FIXTURE_16BE);
Assert.assertEquals(expected, actual);
}
@Test
public void testNewStringUtf16Le() throws UnsupportedEncodingException {
- String charsetName = "UTF-16LE";
+ final String charsetName = "UTF-16LE";
testNewString(charsetName);
- String expected = new String(BYTES_FIXTURE_16LE, charsetName);
- String actual = StringUtils.newStringUtf16Le(BYTES_FIXTURE_16LE);
+ final String expected = new String(BYTES_FIXTURE_16LE, charsetName);
+ final String actual = StringUtils.newStringUtf16Le(BYTES_FIXTURE_16LE);
Assert.assertEquals(expected, actual);
}
@Test
public void testNewStringUtf8() throws UnsupportedEncodingException {
- String charsetName = "UTF-8";
+ final String charsetName = "UTF-8";
testNewString(charsetName);
- String expected = new String(BYTES_FIXTURE, charsetName);
- String actual = StringUtils.newStringUtf8(BYTES_FIXTURE);
+ final String expected = new String(BYTES_FIXTURE, charsetName);
+ final String actual = StringUtils.newStringUtf8(BYTES_FIXTURE);
Assert.assertEquals(expected, actual);
}
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java Mon Jan 7 16:08:05 2013
@@ -43,8 +43,8 @@ public class Apr1CryptTest {
@Test
public void testApr1CryptBytes() {
// random salt
- byte[] keyBytes = new byte[] { '!', 'b', 'c', '.' };
- String hash = Md5Crypt.apr1Crypt(keyBytes);
+ final byte[] keyBytes = new byte[] { '!', 'b', 'c', '.' };
+ final String hash = Md5Crypt.apr1Crypt(keyBytes);
assertEquals(hash, Md5Crypt.apr1Crypt("!bc.", hash));
// An empty Bytearray equals an empty String
@@ -82,9 +82,9 @@ public class Apr1CryptTest {
@Test
public void testApr1CryptWithoutSalt() {
// Without salt, a random is generated
- String hash = Md5Crypt.apr1Crypt("secret");
+ final String hash = Md5Crypt.apr1Crypt("secret");
assertTrue(hash.matches("^\\$apr1\\$[a-zA-Z0-9\\./]{8}\\$[a-zA-Z0-9\\./]{22}$"));
- String hash2 = Md5Crypt.apr1Crypt("secret");
+ final String hash2 = Md5Crypt.apr1Crypt("secret");
assertNotSame(hash, hash2);
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/B64Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/B64Test.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/B64Test.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/B64Test.java Mon Jan 7 16:08:05 2013
@@ -31,7 +31,7 @@ public class B64Test {
@Test
public void testB64from24bit() {
- StringBuilder buffer = new StringBuilder("");
+ final StringBuilder buffer = new StringBuilder("");
B64.b64from24bit((byte) 8, (byte) 16, (byte) 64, 2, buffer);
B64.b64from24bit((byte) 7, (byte) 77, (byte) 120, 4, buffer);
assertEquals("./spo/", buffer.toString());
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/CryptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/CryptTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/CryptTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/CryptTest.java Mon Jan 7 16:08:05 2013
@@ -38,8 +38,8 @@ public class CryptTest {
@Test
public void testCryptWithBytes() {
- byte[] keyBytes = new byte[] { 'b', 'y', 't', 'e' };
- String hash = Crypt.crypt(keyBytes);
+ final byte[] keyBytes = new byte[] { 'b', 'y', 't', 'e' };
+ final String hash = Crypt.crypt(keyBytes);
assertEquals(hash, Crypt.crypt("byte", hash));
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java Mon Jan 7 16:08:05 2013
@@ -75,7 +75,7 @@ public class Sha256CryptTest {
@Test
public void testSha256LargetThanBlocksize() {
- byte[] buffer = new byte[200];
+ final byte[] buffer = new byte[200];
Arrays.fill(buffer, 0, 200, (byte)'A');
assertEquals("$5$abc$HbF3RRc15OwNKB/RZZ5F.1I6zsLcKXHQoSdB9Owx/Q8", Sha2Crypt.sha256Crypt(buffer, "$5$abc"));
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java Mon Jan 7 16:08:05 2013
@@ -87,7 +87,7 @@ public class Sha512CryptTest {
@Test
public void testSha256LargetThanBlocksize() {
- byte[] buffer = new byte[200];
+ final byte[] buffer = new byte[200];
Arrays.fill(buffer, 0, 200, (byte)'A');
assertEquals("$6$abc$oP/h8PRhCKIA66KSTjGwNsQMSLLZnuFOTjOhrqNrDkKgjTlpePSqibB0qtmDapMbP/zN1cUEYSeHFrpgqZ.GG1", Sha2Crypt.sha512Crypt(buffer, "$6$abc"));
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java Mon Jan 7 16:08:05 2013
@@ -94,9 +94,9 @@ public class UnixCryptTest {
@Test
public void testUnixCryptWithoutSalt() {
- String hash = UnixCrypt.crypt("foo");
+ final String hash = UnixCrypt.crypt("foo");
assertTrue(hash.matches("^[a-zA-Z0-9./]{13}$"));
- String hash2 = UnixCrypt.crypt("foo");
+ final String hash2 = UnixCrypt.crypt("foo");
assertNotSame(hash, hash2);
}
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java Mon Jan 7 16:08:05 2013
@@ -65,7 +65,7 @@ public class Caverphone1Test extends Str
@Test
public void testEndMb() throws EncoderException {
- String[][] data = {{"mb", "M11111"}, {"mbmb", "MPM111"}};
+ final String[][] data = {{"mb", "M11111"}, {"mbmb", "MPM111"}};
this.checkEncodings(data);
}
@@ -76,7 +76,7 @@ public class Caverphone1Test extends Str
*/
@Test
public void testIsCaverphoneEquals() throws EncoderException {
- Caverphone1 caverphone = new Caverphone1();
+ final Caverphone1 caverphone = new Caverphone1();
Assert.assertFalse("Caverphone encodings should not be equal", caverphone.isEncodeEqual("Peter", "Stevenson"));
Assert.assertTrue("Caverphone encodings should be equal", caverphone.isEncodeEqual("Peter", "Peady"));
}
@@ -88,7 +88,7 @@ public class Caverphone1Test extends Str
*/
@Test
public void testSpecificationV1Examples() throws EncoderException {
- String[][] data = {{"David", "TFT111"}, {"Whittle", "WTL111"}};
+ final String[][] data = {{"David", "TFT111"}, {"Whittle", "WTL111"}};
this.checkEncodings(data);
}
@@ -99,7 +99,7 @@ public class Caverphone1Test extends Str
*/
@Test
public void testWikipediaExamples() throws EncoderException {
- String[][] data = {{"Lee", "L11111"}, {"Thompson", "TMPSN1"}};
+ final String[][] data = {{"Lee", "L11111"}, {"Thompson", "TMPSN1"}};
this.checkEncodings(data);
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java Mon Jan 7 16:08:05 2013
@@ -70,7 +70,7 @@ public class Caverphone2Test extends Str
*/
@Test
public void testCaverphoneRevisitedExamples() throws EncoderException {
- String[][] data = {{"Stevenson", "STFNSN1111"}, {"Peter", "PTA1111111"}};
+ final String[][] data = {{"Stevenson", "STFNSN1111"}, {"Peter", "PTA1111111"}};
this.checkEncodings(data);
}
@@ -337,21 +337,21 @@ public class Caverphone2Test extends Str
@Test
public void testEndMb() throws EncoderException {
- String[][] data = {{"mb", "M111111111"}, {"mbmb", "MPM1111111"}};
+ final String[][] data = {{"mb", "M111111111"}, {"mbmb", "MPM1111111"}};
this.checkEncodings(data);
}
// Caverphone Revisited
@Test
public void testIsCaverphoneEquals() throws EncoderException {
- Caverphone2 caverphone = new Caverphone2();
+ final Caverphone2 caverphone = new Caverphone2();
Assert.assertFalse("Caverphone encodings should not be equal", caverphone.isEncodeEqual("Peter", "Stevenson"));
Assert.assertTrue("Caverphone encodings should be equal", caverphone.isEncodeEqual("Peter", "Peady"));
}
@Test
public void testSpecificationExamples() throws EncoderException {
- String[][] data = {
+ final String[][] data = {
{"Peter", "PTA1111111"},
{"ready", "RTA1111111"},
{"social", "SSA1111111"},
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java Mon Jan 7 16:08:05 2013
@@ -56,7 +56,7 @@ public class ColognePhoneticTest extends
@Test
public void testEdgeCases() throws EncoderException {
- String[][] data = {
+ final String[][] data = {
{"a", "0"},
{"e", "0"},
{"i", "0"},
@@ -91,7 +91,7 @@ public class ColognePhoneticTest extends
@Test
public void testExamples() throws EncoderException {
- String[][] data = {
+ final String[][] data = {
{"m\u00DCller", "657"}, // mÃller - why upper case U-umlaut?
{"schmidt", "862"},
{"schneider", "8627"},
@@ -125,14 +125,14 @@ public class ColognePhoneticTest extends
@Test
public void testHyphen() throws EncoderException {
- String[][] data = {{"bergisch-gladbach", "174845214"},
+ final String[][] data = {{"bergisch-gladbach", "174845214"},
{"M\u00fcller-L\u00fcdenscheidt", "65752682"}}; // Müller-Lüdenscheidt
this.checkEncodings(data);
}
@Test
public void testIsEncodeEquals() {
- String[][] data = {
+ final String[][] data = {
{"Meyer", "M\u00fcller"}, // Müller
{"Meyer", "Mayr"},
{"house", "house"},
@@ -141,20 +141,20 @@ public class ColognePhoneticTest extends
{"ganz", "Gans"},
{"ganz", "G\u00e4nse"}, // Gänse
{"Miyagi", "Miyako"}};
- for (String[] element : data) {
+ for (final String[] element : data) {
this.getStringEncoder().isEncodeEqual(element[1], element[0]);
}
}
@Test
public void testVariationsMella() throws EncoderException {
- String data[] = {"mella", "milah", "moulla", "mellah", "muehle", "mule"};
+ final String data[] = {"mella", "milah", "moulla", "mellah", "muehle", "mule"};
this.checkEncodingVariations("65", data);
}
@Test
public void testVariationsMeyer() throws EncoderException {
- String data[] = {"Meier", "Maier", "Mair", "Meyer", "Meyr", "Mejer", "Major"};
+ final String data[] = {"Meier", "Maier", "Mair", "Meyer", "Meyr", "Mejer", "Major"};
this.checkEncodingVariations("67", data);
}
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java Mon Jan 7 16:08:05 2013
@@ -1261,9 +1261,9 @@ public class DoubleMetaphone2Test extend
{"weikersheim", "AKRS", "FKRS"},
{"zhao", "J", "J"}};
- private void checkDoubleMetaphone(int typeIndex, boolean alternate) {
+ private void checkDoubleMetaphone(final int typeIndex, final boolean alternate) {
for (int i = 0; i < TEST_DATA.length; i++) {
- String value = TEST_DATA[i][0];
+ final String value = TEST_DATA[i][0];
assertEquals("Test [" + i + "]=" + value, TEST_DATA[i][typeIndex], this.getStringEncoder().doubleMetaphone(value, alternate));
}
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java Mon Jan 7 16:08:05 2013
@@ -1007,11 +1007,11 @@ public class DoubleMetaphoneTest extends
/**
* Tests encoding APIs in one place.
*/
- private void assertDoubleMetaphone(String expected, String source) {
+ private void assertDoubleMetaphone(final String expected, final String source) {
assertEquals(expected, this.getStringEncoder().encode(source));
try {
assertEquals(expected, this.getStringEncoder().encode((Object) source));
- } catch (EncoderException e) {
+ } catch (final EncoderException e) {
fail("Unexpected expection: " + e);
}
assertEquals(expected, this.getStringEncoder().doubleMetaphone(source));
@@ -1021,16 +1021,16 @@ public class DoubleMetaphoneTest extends
/**
* Tests encoding APIs in one place.
*/
- public void assertDoubleMetaphoneAlt(String expected, String source) {
+ public void assertDoubleMetaphoneAlt(final String expected, final String source) {
assertEquals(expected, this.getStringEncoder().doubleMetaphone(source, true));
}
- public void doubleMetaphoneEqualTest(String[][] pairs, boolean useAlternate) {
+ public void doubleMetaphoneEqualTest(final String[][] pairs, final boolean useAlternate) {
this.validateFixture(pairs);
- for (String[] pair : pairs) {
- String name0 = pair[0];
- String name1 = pair[1];
- String failMsg = "Expected match between " + name0 + " and " + name1 + " (use alternate: " + useAlternate + ")";
+ for (final String[] pair : pairs) {
+ final String name0 = pair[0];
+ final String name1 = pair[1];
+ final String failMsg = "Expected match between " + name0 + " and " + name1 + " (use alternate: " + useAlternate + ")";
assertTrue(failMsg, this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, useAlternate));
assertTrue(failMsg, this.getStringEncoder().isDoubleMetaphoneEqual(name1, name0, useAlternate));
if (!useAlternate) {
@@ -1040,7 +1040,7 @@ public class DoubleMetaphoneTest extends
}
}
- public void doubleMetaphoneNotEqualTest(boolean alternate) {
+ public void doubleMetaphoneNotEqualTest(final boolean alternate) {
assertFalse(this.getStringEncoder().isDoubleMetaphoneEqual("Brain", "Band", alternate));
assertFalse(this.getStringEncoder().isDoubleMetaphoneEqual("Band", "Brain", alternate));
@@ -1109,9 +1109,9 @@ public class DoubleMetaphoneTest extends
*/
@Test
public void testSetMaxCodeLength() {
- String value = "jumped";
+ final String value = "jumped";
- DoubleMetaphone doubleMetaphone = new DoubleMetaphone();
+ final DoubleMetaphone doubleMetaphone = new DoubleMetaphone();
// Sanity check of default settings
assertEquals("Default Max Code Length", 4, doubleMetaphone.getMaxCodeLen());
@@ -1127,7 +1127,7 @@ public class DoubleMetaphoneTest extends
@Test
public void testIsDoubleMetaphoneEqualBasic() {
- String[][] testFixture = new String[][] { { "Case", "case" }, {
+ final String[][] testFixture = new String[][] { { "Case", "case" }, {
"CASE", "Case" }, {
"caSe", "cAsE" }, {
"cookie", "quick" }, {
@@ -1154,7 +1154,7 @@ public class DoubleMetaphoneTest extends
@Test
public void testIsDoubleMetaphoneEqualExtended2() {
- String[][] testFixture = new String[][] { { "Jablonski", "Yablonsky" }
+ final String[][] testFixture = new String[][] { { "Jablonski", "Yablonsky" }
};
//doubleMetaphoneEqualTest(testFixture, false);
doubleMetaphoneEqualTest(testFixture, true);
@@ -1167,18 +1167,18 @@ public class DoubleMetaphoneTest extends
@Test
public void testIsDoubleMetaphoneEqualExtended3() {
this.validateFixture(FIXTURE);
- StringBuilder failures = new StringBuilder();
- StringBuilder matches = new StringBuilder();
- String cr = System.getProperty("line.separator");
+ final StringBuilder failures = new StringBuilder();
+ final StringBuilder matches = new StringBuilder();
+ final String cr = System.getProperty("line.separator");
matches.append("private static final String[][] MATCHES = {" + cr);
int failCount = 0;
for (int i = 0; i < FIXTURE.length; i++) {
- String name0 = FIXTURE[i][0];
- String name1 = FIXTURE[i][1];
- boolean match1 = this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false);
- boolean match2 = this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true);
+ final String name0 = FIXTURE[i][0];
+ final String name1 = FIXTURE[i][1];
+ final boolean match1 = this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false);
+ final boolean match2 = this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true);
if (match1 == false && match2 == false) {
- String failMsg = "[" + i + "] " + name0 + " and " + name1 + cr;
+ final String failMsg = "[" + i + "] " + name0 + " and " + name1 + cr;
failures.append(failMsg);
failCount++;
} else {
@@ -1200,10 +1200,10 @@ public class DoubleMetaphoneTest extends
public void testIsDoubleMetaphoneEqualWithMATCHES() {
this.validateFixture(MATCHES);
for (int i = 0; i < MATCHES.length; i++) {
- String name0 = MATCHES[i][0];
- String name1 = MATCHES[i][1];
- boolean match1 = this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false);
- boolean match2 = this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true);
+ final String name0 = MATCHES[i][0];
+ final String name1 = MATCHES[i][1];
+ final boolean match1 = this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false);
+ final boolean match2 = this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true);
if (match1 == false && match2 == false) {
fail("Expected match [" + i + "] " + name0 + " and " + name1);
}
@@ -1226,7 +1226,7 @@ public class DoubleMetaphoneTest extends
assertTrue(this.getStringEncoder().isDoubleMetaphoneEqual("\u00f1", "N")); // n-tilde
}
- public void validateFixture(String[][] pairs) {
+ public void validateFixture(final String[][] pairs) {
if (pairs.length == 0) {
fail("Test fixture is empty");
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java Mon Jan 7 16:08:05 2013
@@ -29,26 +29,26 @@ import org.junit.Test;
*/
public class MetaphoneTest extends StringEncoderAbstractTest<Metaphone> {
- public void assertIsMetaphoneEqual(String source, String[] matches) {
+ public void assertIsMetaphoneEqual(final String source, final String[] matches) {
// match source to all matches
- for (String matche : matches) {
+ for (final String matche : matches) {
assertTrue("Source: " + source + ", should have same Metaphone as: " + matche,
this.getStringEncoder().isMetaphoneEqual(source, matche));
}
// match to each other
- for (String matche : matches) {
- for (String matche2 : matches) {
+ for (final String matche : matches) {
+ for (final String matche2 : matches) {
assertTrue(this.getStringEncoder().isMetaphoneEqual(matche, matche2));
}
}
}
- public void assertMetaphoneEqual(String[][] pairs) {
+ public void assertMetaphoneEqual(final String[][] pairs) {
this.validateFixture(pairs);
- for (String[] pair : pairs) {
- String name0 = pair[0];
- String name1 = pair[1];
- String failMsg = "Expected match between " + name0 + " and " + name1;
+ for (final String[] pair : pairs) {
+ final String name0 = pair[0];
+ final String name1 = pair[1];
+ final String failMsg = "Expected match between " + name0 + " and " + name1;
assertTrue(failMsg, this.getStringEncoder().isMetaphoneEqual(name0, name1));
assertTrue(failMsg, this.getStringEncoder().isMetaphoneEqual(name1, name0));
}
@@ -469,7 +469,7 @@ public class MetaphoneTest extends Strin
assertEquals( "AKSKSK", this.getStringEncoder().metaphone("AXEAXEAXE") );
}
- public void validateFixture(String[][] pairs) {
+ public void validateFixture(final String[][] pairs) {
if (pairs.length == 0) {
fail("Test fixture is empty");
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java Mon Jan 7 16:08:05 2013
@@ -41,8 +41,8 @@ public class NysiisTest extends StringEn
* expected encoding.
* @throws EncoderException
*/
- private void assertEncodings(String[]... testValues) throws EncoderException {
- for (String[] arr : testValues) {
+ private void assertEncodings(final String[]... testValues) throws EncoderException {
+ for (final String[] arr : testValues) {
Assert.assertEquals("Problem with " + arr[0], arr[1], this.fullNysiis.encode(arr[0]));
}
}
@@ -52,8 +52,8 @@ public class NysiisTest extends StringEn
return new Nysiis();
}
- private void encodeAll(String[] strings, String expectedEncoding) throws EncoderException {
- for (String string : strings) {
+ private void encodeAll(final String[] strings, final String expectedEncoding) throws EncoderException {
+ for (final String string : strings) {
Assert.assertEquals("Problem with " + string, expectedEncoding, getStringEncoder().encode(string));
}
}
@@ -293,9 +293,9 @@ public class NysiisTest extends StringEn
@Test
public void testTrueVariant() {
- Nysiis encoder = new Nysiis(true);
+ final Nysiis encoder = new Nysiis(true);
- String encoded = encoder.encode("WESTERLUND");
+ final String encoded = encoder.encode("WESTERLUND");
Assert.assertTrue(encoded.length() <= 6);
Assert.assertEquals("WASTAR", encoded);
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java Mon Jan 7 16:08:05 2013
@@ -77,7 +77,7 @@ public class RefinedSoundexTest extends
@Test
public void testGetMappingCodeNonLetter() {
- char code = this.getStringEncoder().getMappingCode('#');
+ final char code = this.getStringEncoder().getMappingCode('#');
assertEquals("Code does not equals zero", 0, code);
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/SoundexTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/SoundexTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/SoundexTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/SoundexTest.java Mon Jan 7 16:08:05 2013
@@ -360,7 +360,7 @@ public class SoundexTest extends StringE
// uppercase E-acute
Assert.assertEquals("\u00c9000", this.getStringEncoder().encode("\u00e9"));
Assert.fail("Expected IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
} else {
@@ -381,7 +381,7 @@ public class SoundexTest extends StringE
// uppercase O-umlaut
Assert.assertEquals("\u00d6000", this.getStringEncoder().encode("\u00f6"));
Assert.fail("Expected IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
} else {
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java Mon Jan 7 16:08:05 2013
@@ -35,12 +35,12 @@ import org.junit.Test;
public class BeiderMorseEncoderTest extends StringEncoderAbstractTest {
private static final char[] TEST_CHARS = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'o', 'u' };
- private void assertNotEmpty(BeiderMorseEncoder bmpm, final String value) throws EncoderException {
+ private void assertNotEmpty(final BeiderMorseEncoder bmpm, final String value) throws EncoderException {
Assert.assertFalse(value, bmpm.encode(value).equals(""));
}
private BeiderMorseEncoder createGenericApproxEncoder() {
- BeiderMorseEncoder encoder = new BeiderMorseEncoder();
+ final BeiderMorseEncoder encoder = new BeiderMorseEncoder();
encoder.setNameType(NameType.GENERIC);
encoder.setRuleType(RuleType.APPROX);
return encoder;
@@ -58,7 +58,7 @@ public class BeiderMorseEncoderTest exte
*/
@Test
public void testAllChars() throws EncoderException {
- BeiderMorseEncoder bmpm = createGenericApproxEncoder();
+ final BeiderMorseEncoder bmpm = createGenericApproxEncoder();
for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) {
bmpm.encode(Character.toString(c));
}
@@ -66,7 +66,7 @@ public class BeiderMorseEncoderTest exte
@Test
public void testAsciiEncodeNotEmpty1Letter() throws EncoderException {
- BeiderMorseEncoder bmpm = createGenericApproxEncoder();
+ final BeiderMorseEncoder bmpm = createGenericApproxEncoder();
for (char c = 'a'; c <= 'z'; c++) {
final String value = Character.toString(c);
final String valueU = value.toUpperCase();
@@ -77,7 +77,7 @@ public class BeiderMorseEncoderTest exte
@Test
public void testAsciiEncodeNotEmpty2Letters() throws EncoderException {
- BeiderMorseEncoder bmpm = createGenericApproxEncoder();
+ final BeiderMorseEncoder bmpm = createGenericApproxEncoder();
for (char c1 = 'a'; c1 <= 'z'; c1++) {
for (char c2 = 'a'; c2 <= 'z'; c2++) {
final String value = new String(new char[] { c1, c2 });
@@ -90,10 +90,10 @@ public class BeiderMorseEncoderTest exte
@Test
public void testEncodeAtzNotEmpty() throws EncoderException {
- BeiderMorseEncoder bmpm = createGenericApproxEncoder();
+ final BeiderMorseEncoder bmpm = createGenericApproxEncoder();
//String[] names = { "ácz", "átz", "Ignácz", "Ignátz", "Ignác" };
- String[] names = { "\u00e1cz", "\u00e1tz", "Ign\u00e1cz", "Ign\u00e1tz", "Ign\u00e1c" };
- for (String name : names) {
+ final String[] names = { "\u00e1cz", "\u00e1tz", "Ign\u00e1cz", "Ign\u00e1tz", "Ign\u00e1c" };
+ for (final String name : names) {
assertNotEmpty(bmpm, name);
}
}
@@ -106,7 +106,7 @@ public class BeiderMorseEncoderTest exte
*/
@Test
public void testEncodeGna() throws EncoderException {
- BeiderMorseEncoder bmpm = createGenericApproxEncoder();
+ final BeiderMorseEncoder bmpm = createGenericApproxEncoder();
bmpm.encode("gna");
}
@@ -127,58 +127,58 @@ public class BeiderMorseEncoderTest exte
@Test(timeout = 10000L)
public void testLongestEnglishSurname() throws EncoderException {
- BeiderMorseEncoder bmpm = createGenericApproxEncoder();
+ final BeiderMorseEncoder bmpm = createGenericApproxEncoder();
bmpm.encode("MacGhilleseatheanaich");
}
@Test(expected = IndexOutOfBoundsException.class)
public void testNegativeIndexForRuleMatchIndexOutOfBoundsException() {
- Rule r = new Rule("a", "", "", new Rule.Phoneme("", Languages.ANY_LANGUAGE));
+ final Rule r = new Rule("a", "", "", new Rule.Phoneme("", Languages.ANY_LANGUAGE));
r.patternAndContextMatches("bob", -1);
}
@Test
public void testOOM() throws EncoderException {
- String phrase = "200697900'-->�</ bceaeef >aadaabcf\"aedfbff<!--\'-->?>cae"
+ final String phrase = "200697900'-->�</ bceaeef >aadaabcf\"aedfbff<!--\'-->?>cae"
+ "cfaaa><?&#<!--</script>&lang&fc;aadeaf?>>&bdquo< cc =\"abff\" /></ afe >"
+ "<script><!-- f(';< cf aefbeef = \"bfabadcf\" ebbfeedd = fccabeb >";
- BeiderMorseEncoder encoder = new BeiderMorseEncoder();
+ final BeiderMorseEncoder encoder = new BeiderMorseEncoder();
encoder.setNameType(NameType.GENERIC);
encoder.setRuleType(RuleType.EXACT);
encoder.setMaxPhonemes(10);
- String phonemes = encoder.encode(phrase);
+ final String phonemes = encoder.encode(phrase);
assertTrue(phonemes.length() > 0);
- String[] phonemeArr = phonemes.split("\\|");
+ final String[] phonemeArr = phonemes.split("\\|");
assertTrue(phonemeArr.length <= 10);
}
@Test
public void testSetConcat() {
- BeiderMorseEncoder bmpm = new BeiderMorseEncoder();
+ final BeiderMorseEncoder bmpm = new BeiderMorseEncoder();
bmpm.setConcat(false);
assertFalse("Should be able to set concat to false", bmpm.isConcat());
}
@Test
public void testSetNameTypeAsh() {
- BeiderMorseEncoder bmpm = new BeiderMorseEncoder();
+ final BeiderMorseEncoder bmpm = new BeiderMorseEncoder();
bmpm.setNameType(NameType.ASHKENAZI);
assertEquals("Name type should have been set to ash", NameType.ASHKENAZI, bmpm.getNameType());
}
@Test
public void testSetRuleTypeExact() {
- BeiderMorseEncoder bmpm = new BeiderMorseEncoder();
+ final BeiderMorseEncoder bmpm = new BeiderMorseEncoder();
bmpm.setRuleType(RuleType.EXACT);
assertEquals("Rule type should have been set to exact", RuleType.EXACT, bmpm.getRuleType());
}
@Test(expected = IllegalArgumentException.class)
public void testSetRuleTypeToRulesIllegalArgumentException() {
- BeiderMorseEncoder bmpm = new BeiderMorseEncoder();
+ final BeiderMorseEncoder bmpm = new BeiderMorseEncoder();
bmpm.setRuleType(RuleType.RULES);
}
@@ -189,8 +189,8 @@ public class BeiderMorseEncoderTest exte
*/
@Test(/* timeout = 20000L */)
public void testSpeedCheck() throws EncoderException {
- BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
- StringBuilder stringBuffer = new StringBuilder();
+ final BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
+ final StringBuilder stringBuffer = new StringBuilder();
stringBuffer.append(TEST_CHARS[0]);
for (int i = 0, j = 1; i < 40; i++, j++) {
if (j == TEST_CHARS.length) {
@@ -203,8 +203,8 @@ public class BeiderMorseEncoderTest exte
@Test
public void testSpeedCheck2() throws EncoderException {
- BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
- String phrase = "ItstheendoftheworldasweknowitandIfeelfine";
+ final BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
+ final String phrase = "ItstheendoftheworldasweknowitandIfeelfine";
for (int i = 1; i <= phrase.length(); i++) {
bmpm.encode(phrase.subSequence(0, i));
@@ -213,8 +213,8 @@ public class BeiderMorseEncoderTest exte
@Test
public void testSpeedCheck3() throws EncoderException {
- BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
- String phrase = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
+ final BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
+ final String phrase = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
for (int i = 1; i <= phrase.length(); i++) {
bmpm.encode(phrase.subSequence(0, i));
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java Mon Jan 7 16:08:05 2013
@@ -66,7 +66,7 @@ public class LanguageGuessingTest {
private final String language;
private final String name;
- public LanguageGuessingTest(String name, String language, String exactness) {
+ public LanguageGuessingTest(final String name, final String language, final String exactness) {
this.name = name;
this.language = language;
this.exactness = exactness;
@@ -74,7 +74,7 @@ public class LanguageGuessingTest {
@Test
public void testLanguageGuessing() {
- Languages.LanguageSet guesses = this.lang.guessLanguages(this.name);
+ final Languages.LanguageSet guesses = this.lang.guessLanguages(this.name);
assertTrue("language predicted for name '" + this.name + "' is wrong: " + guesses + " should contain '" + this.language + "'",
guesses.contains(this.language));
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java Mon Jan 7 16:08:05 2013
@@ -184,22 +184,22 @@ public class PhoneticEngineRegressionTes
* Making a JUnit test out of it to protect Solr from possible future
* regressions in Commons-Codec.
*/
- private static String encode(Map<String, String> args, boolean concat, String input) {
+ private static String encode(final Map<String, String> args, final boolean concat, final String input) {
Languages.LanguageSet languageSet;
PhoneticEngine engine;
// PhoneticEngine = NameType + RuleType + concat
// we use common-codec's defaults: GENERIC + APPROX + true
- String nameTypeArg = args.get("nameType");
- NameType nameType = (nameTypeArg == null) ? NameType.GENERIC : NameType.valueOf(nameTypeArg);
+ final String nameTypeArg = args.get("nameType");
+ final NameType nameType = (nameTypeArg == null) ? NameType.GENERIC : NameType.valueOf(nameTypeArg);
- String ruleTypeArg = args.get("ruleType");
- RuleType ruleType = (ruleTypeArg == null) ? RuleType.APPROX : RuleType.valueOf(ruleTypeArg);
+ final String ruleTypeArg = args.get("ruleType");
+ final RuleType ruleType = (ruleTypeArg == null) ? RuleType.APPROX : RuleType.valueOf(ruleTypeArg);
engine = new PhoneticEngine(nameType, ruleType, concat);
// LanguageSet: defaults to automagic, otherwise a comma-separated list.
- String languageSetArg = args.get("languageSet");
+ final String languageSetArg = args.get("languageSet");
if (languageSetArg == null || languageSetArg.equals("auto")) {
languageSet = null;
} else {
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java Mon Jan 7 16:08:05 2013
@@ -61,8 +61,8 @@ public class PhoneticEngineTest {
private final RuleType ruleType;
private final int maxPhonemes;
- public PhoneticEngineTest(String name, String phoneticExpected, NameType nameType,
- RuleType ruleType, boolean concat, int maxPhonemes) {
+ public PhoneticEngineTest(final String name, final String phoneticExpected, final NameType nameType,
+ final RuleType ruleType, final boolean concat, final int maxPhonemes) {
this.name = name;
this.phoneticExpected = phoneticExpected;
this.nameType = nameType;
@@ -73,21 +73,21 @@ public class PhoneticEngineTest {
@Test(timeout = 10000L)
public void testEncode() {
- PhoneticEngine engine = new PhoneticEngine(this.nameType, this.ruleType, this.concat, this.maxPhonemes);
+ final PhoneticEngine engine = new PhoneticEngine(this.nameType, this.ruleType, this.concat, this.maxPhonemes);
- String phoneticActual = engine.encode(this.name);
+ final String phoneticActual = engine.encode(this.name);
//System.err.println("expecting: " + this.phoneticExpected);
//System.err.println("actual: " + phoneticActual);
assertEquals("phoneme incorrect", this.phoneticExpected, phoneticActual);
if (this.concat) {
- String[] split = phoneticActual.split("\\|");
+ final String[] split = phoneticActual.split("\\|");
assertTrue(split.length <= this.maxPhonemes);
} else {
- String[] words = phoneticActual.split("-");
- for (String word : words) {
- String[] split = word.split("\\|");
+ final String[] words = phoneticActual.split("-");
+ for (final String word : words) {
+ final String[] split = word.split("\\|");
assertTrue(split.length <= this.maxPhonemes);
}
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/RuleTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/RuleTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/RuleTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/RuleTest.java Mon Jan 7 16:08:05 2013
@@ -32,25 +32,25 @@ import org.junit.Test;
public class RuleTest {
private static class NegativeIntegerBaseMatcher extends BaseMatcher<Integer> {
@Override
- public void describeTo(Description description) {
+ public void describeTo(final Description description) {
description.appendText("value should be negative");
}
@Override
- public boolean matches(Object item) {
+ public boolean matches(final Object item) {
return ((Integer) item).intValue() < 0;
}
}
private Rule.Phoneme[][] makePhonemes() {
- String[][] words = {
+ final String[][] words = {
{ "rinD", "rinDlt", "rina", "rinalt", "rino", "rinolt", "rinu", "rinult" },
{ "dortlaj", "dortlej", "ortlaj", "ortlej", "ortlej-dortlaj" } };
- Rule.Phoneme[][] phonemes = new Rule.Phoneme[words.length][];
+ final Rule.Phoneme[][] phonemes = new Rule.Phoneme[words.length][];
for (int i = 0; i < words.length; i++) {
- String[] words_i = words[i];
- Rule.Phoneme[] phonemes_i = phonemes[i] = new Rule.Phoneme[words_i.length];
+ final String[] words_i = words[i];
+ final Rule.Phoneme[] phonemes_i = phonemes[i] = new Rule.Phoneme[words_i.length];
for (int j = 0; j < words_i.length; j++) {
phonemes_i[j] = new Rule.Phoneme(words_i[j], Languages.NO_LANGUAGES);
}
@@ -61,10 +61,10 @@ public class RuleTest {
@Test
public void testPhonemeComparedToLaterIsNegative() {
- for (Rule.Phoneme[] phs : makePhonemes()) {
+ for (final Rule.Phoneme[] phs : makePhonemes()) {
for (int i = 0; i < phs.length; i++) {
for (int j = i + 1; j < phs.length; j++) {
- int c = Rule.Phoneme.COMPARATOR.compare(phs[i], phs[j]);
+ final int c = Rule.Phoneme.COMPARATOR.compare(phs[i], phs[j]);
assertThat("Comparing " + phs[i].getPhonemeText() + " to " + phs[j].getPhonemeText() + " should be negative", Integer.valueOf(c),
new NegativeIntegerBaseMatcher());
@@ -75,8 +75,8 @@ public class RuleTest {
@Test
public void testPhonemeComparedToSelfIsZero() {
- for (Rule.Phoneme[] phs : makePhonemes()) {
- for (Rule.Phoneme ph : phs) {
+ for (final Rule.Phoneme[] phs : makePhonemes()) {
+ for (final Rule.Phoneme ph : phs) {
assertEquals("Phoneme compared to itself should be zero: " + ph.getPhonemeText(), 0,
Rule.Phoneme.COMPARATOR.compare(ph, ph));
}
@@ -87,12 +87,12 @@ public class RuleTest {
public void testSubSequenceWorks() {
// AppendableCharSequence is private to Rule. We can only make it through a Phoneme.
- Rule.Phoneme a = new Rule.Phoneme("a", null);
- Rule.Phoneme b = new Rule.Phoneme("b", null);
- Rule.Phoneme cd = new Rule.Phoneme("cd", null);
- Rule.Phoneme ef = new Rule.Phoneme("ef", null);
- Rule.Phoneme ghi = new Rule.Phoneme("ghi", null);
- Rule.Phoneme jkl = new Rule.Phoneme("jkl", null);
+ final Rule.Phoneme a = new Rule.Phoneme("a", null);
+ final Rule.Phoneme b = new Rule.Phoneme("b", null);
+ final Rule.Phoneme cd = new Rule.Phoneme("cd", null);
+ final Rule.Phoneme ef = new Rule.Phoneme("ef", null);
+ final Rule.Phoneme ghi = new Rule.Phoneme("ghi", null);
+ final Rule.Phoneme jkl = new Rule.Phoneme("jkl", null);
assertEquals('a', a.getPhonemeText().charAt(0));
assertEquals('b', b.getPhonemeText().charAt(0));
@@ -107,14 +107,14 @@ public class RuleTest {
assertEquals('k', jkl.getPhonemeText().charAt(1));
assertEquals('l', jkl.getPhonemeText().charAt(2));
- Rule.Phoneme a_b = a.append(b.getPhonemeText());
+ final Rule.Phoneme a_b = a.append(b.getPhonemeText());
assertEquals('a', a_b.getPhonemeText().charAt(0));
assertEquals('b', a_b.getPhonemeText().charAt(1));
assertEquals("ab", a_b.getPhonemeText().subSequence(0, 2).toString());
assertEquals("a", a_b.getPhonemeText().subSequence(0, 1).toString());
assertEquals("b", a_b.getPhonemeText().subSequence(1, 2).toString());
- Rule.Phoneme cd_ef = cd.append(ef.getPhonemeText());
+ final Rule.Phoneme cd_ef = cd.append(ef.getPhonemeText());
assertEquals('c', cd_ef.getPhonemeText().charAt(0));
assertEquals('d', cd_ef.getPhonemeText().charAt(1));
assertEquals('e', cd_ef.getPhonemeText().charAt(2));
@@ -130,7 +130,7 @@ public class RuleTest {
assertEquals("def", cd_ef.getPhonemeText().subSequence(1, 4).toString());
assertEquals("cdef", cd_ef.getPhonemeText().subSequence(0, 4).toString());
- Rule.Phoneme a_b_cd = a.append(b.getPhonemeText()).append(cd.getPhonemeText());
+ final Rule.Phoneme a_b_cd = a.append(b.getPhonemeText()).append(cd.getPhonemeText());
assertEquals('a', a_b_cd.getPhonemeText().charAt(0));
assertEquals('b', a_b_cd.getPhonemeText().charAt(1));
assertEquals('c', a_b_cd.getPhonemeText().charAt(2));
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/BCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/BCodecTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/BCodecTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/BCodecTest.java Mon Jan 7 16:08:05 2013
@@ -41,10 +41,10 @@ public class BCodecTest {
static final int RUSSIAN_STUFF_UNICODE[] =
{ 0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438, 0x432, 0x435, 0x442 };
- private String constructString(int[] unicodeChars) {
- StringBuilder buffer = new StringBuilder();
+ private String constructString(final int[] unicodeChars) {
+ final StringBuilder buffer = new StringBuilder();
if (unicodeChars != null) {
- for (int unicodeChar : unicodeChars) {
+ for (final int unicodeChar : unicodeChars) {
buffer.append((char) unicodeChar);
}
}
@@ -53,7 +53,7 @@ public class BCodecTest {
@Test
public void testNullInput() throws Exception {
- BCodec bcodec = new BCodec();
+ final BCodec bcodec = new BCodec();
assertNull(bcodec.doDecoding(null));
assertNull(bcodec.doEncoding(null));
}
@@ -61,10 +61,10 @@ public class BCodecTest {
@Test
public void testUTF8RoundTrip() throws Exception {
- String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
- String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
+ final String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
+ final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
- BCodec bcodec = new BCodec(CharEncoding.UTF_8);
+ final BCodec bcodec = new BCodec(CharEncoding.UTF_8);
assertEquals("=?UTF-8?B?0JLRgdC10Lxf0L/RgNC40LLQtdGC?=", bcodec.encode(ru_msg));
assertEquals("=?UTF-8?B?R3LDvGV6aV96w6Rtw6Q=?=", bcodec.encode(ch_msg));
@@ -75,52 +75,52 @@ public class BCodecTest {
@Test
public void testBasicEncodeDecode() throws Exception {
- BCodec bcodec = new BCodec();
- String plain = "Hello there";
- String encoded = bcodec.encode(plain);
+ final BCodec bcodec = new BCodec();
+ final String plain = "Hello there";
+ final String encoded = bcodec.encode(plain);
assertEquals("Basic B encoding test", "=?UTF-8?B?SGVsbG8gdGhlcmU=?=", encoded);
assertEquals("Basic B decoding test", plain, bcodec.decode(encoded));
}
@Test
public void testEncodeDecodeNull() throws Exception {
- BCodec bcodec = new BCodec();
+ final BCodec bcodec = new BCodec();
assertNull("Null string B encoding test", bcodec.encode((String) null));
assertNull("Null string B decoding test", bcodec.decode((String) null));
}
@Test
public void testEncodeStringWithNull() throws Exception {
- BCodec bcodec = new BCodec();
- String test = null;
- String result = bcodec.encode(test, "charset");
+ final BCodec bcodec = new BCodec();
+ final String test = null;
+ final String result = bcodec.encode(test, "charset");
assertEquals("Result should be null", null, result);
}
@Test
public void testDecodeStringWithNull() throws Exception {
- BCodec bcodec = new BCodec();
- String test = null;
- String result = bcodec.decode(test);
+ final BCodec bcodec = new BCodec();
+ final String test = null;
+ final String result = bcodec.decode(test);
assertEquals("Result should be null", null, result);
}
@Test
public void testEncodeObjects() throws Exception {
- BCodec bcodec = new BCodec();
- String plain = "what not";
- String encoded = (String) bcodec.encode((Object) plain);
+ final BCodec bcodec = new BCodec();
+ final String plain = "what not";
+ final String encoded = (String) bcodec.encode((Object) plain);
assertEquals("Basic B encoding test", "=?UTF-8?B?d2hhdCBub3Q=?=", encoded);
- Object result = bcodec.encode((Object) null);
+ final Object result = bcodec.encode((Object) null);
assertEquals("Encoding a null Object should return null", null, result);
try {
- Object dObj = new Double(3.0);
+ final Object dObj = new Double(3.0);
bcodec.encode(dObj);
fail("Trying to url encode a Double object should cause an exception.");
- } catch (EncoderException ee) {
+ } catch (final EncoderException ee) {
// Exception expected, test segment passes.
}
}
@@ -132,19 +132,19 @@ public class BCodecTest {
@Test
public void testDecodeObjects() throws Exception {
- BCodec bcodec = new BCodec();
- String decoded = "=?UTF-8?B?d2hhdCBub3Q=?=";
- String plain = (String) bcodec.decode((Object) decoded);
+ final BCodec bcodec = new BCodec();
+ final String decoded = "=?UTF-8?B?d2hhdCBub3Q=?=";
+ final String plain = (String) bcodec.decode((Object) decoded);
assertEquals("Basic B decoding test", "what not", plain);
- Object result = bcodec.decode((Object) null);
+ final Object result = bcodec.decode((Object) null);
assertEquals("Decoding a null Object should return null", null, result);
try {
- Object dObj = new Double(3.0);
+ final Object dObj = new Double(3.0);
bcodec.decode(dObj);
fail("Trying to url encode a Double object should cause an exception.");
- } catch (DecoderException ee) {
+ } catch (final DecoderException ee) {
// Exception expected, test segment passes.
}
}
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QCodecTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QCodecTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QCodecTest.java Mon Jan 7 16:08:05 2013
@@ -47,10 +47,10 @@ public class QCodecTest {
0x432, 0x435, 0x442
};
- private String constructString(int [] unicodeChars) {
- StringBuilder buffer = new StringBuilder();
+ private String constructString(final int [] unicodeChars) {
+ final StringBuilder buffer = new StringBuilder();
if (unicodeChars != null) {
- for (int unicodeChar : unicodeChars) {
+ for (final int unicodeChar : unicodeChars) {
buffer.append((char)unicodeChar);
}
}
@@ -59,7 +59,7 @@ public class QCodecTest {
@Test
public void testNullInput() throws Exception {
- QCodec qcodec = new QCodec();
+ final QCodec qcodec = new QCodec();
assertNull(qcodec.doDecoding(null));
assertNull(qcodec.doEncoding(null));
}
@@ -67,10 +67,10 @@ public class QCodecTest {
@Test
public void testUTF8RoundTrip() throws Exception {
- String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
- String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
+ final String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
+ final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
- QCodec qcodec = new QCodec(CharEncoding.UTF_8);
+ final QCodec qcodec = new QCodec(CharEncoding.UTF_8);
assertEquals(
"=?UTF-8?Q?=D0=92=D1=81=D0=B5=D0=BC=5F=D0=BF=D1=80=D0=B8=D0=B2=D0=B5=D1=82?=",
@@ -85,9 +85,9 @@ public class QCodecTest {
@Test
public void testBasicEncodeDecode() throws Exception {
- QCodec qcodec = new QCodec();
- String plain = "= Hello there =\r\n";
- String encoded = qcodec.encode(plain);
+ final QCodec qcodec = new QCodec();
+ final String plain = "= Hello there =\r\n";
+ final String encoded = qcodec.encode(plain);
assertEquals("Basic Q encoding test",
"=?UTF-8?Q?=3D Hello there =3D=0D=0A?=", encoded);
assertEquals("Basic Q decoding test",
@@ -96,9 +96,9 @@ public class QCodecTest {
@Test
public void testUnsafeEncodeDecode() throws Exception {
- QCodec qcodec = new QCodec();
- String plain = "?_=\r\n";
- String encoded = qcodec.encode(plain);
+ final QCodec qcodec = new QCodec();
+ final String plain = "?_=\r\n";
+ final String encoded = qcodec.encode(plain);
assertEquals("Unsafe chars Q encoding test",
"=?UTF-8?Q?=3F=5F=3D=0D=0A?=", encoded);
assertEquals("Unsafe chars Q decoding test",
@@ -107,7 +107,7 @@ public class QCodecTest {
@Test
public void testEncodeDecodeNull() throws Exception {
- QCodec qcodec = new QCodec();
+ final QCodec qcodec = new QCodec();
assertNull("Null string Q encoding test",
qcodec.encode((String)null));
assertNull("Null string Q decoding test",
@@ -116,37 +116,37 @@ public class QCodecTest {
@Test
public void testEncodeStringWithNull() throws Exception {
- QCodec qcodec = new QCodec();
- String test = null;
- String result = qcodec.encode( test, "charset" );
+ final QCodec qcodec = new QCodec();
+ final String test = null;
+ final String result = qcodec.encode( test, "charset" );
assertEquals("Result should be null", null, result);
}
@Test
public void testDecodeStringWithNull() throws Exception {
- QCodec qcodec = new QCodec();
- String test = null;
- String result = qcodec.decode( test );
+ final QCodec qcodec = new QCodec();
+ final String test = null;
+ final String result = qcodec.decode( test );
assertEquals("Result should be null", null, result);
}
@Test
public void testEncodeObjects() throws Exception {
- QCodec qcodec = new QCodec();
- String plain = "1+1 = 2";
- String encoded = (String) qcodec.encode((Object) plain);
+ final QCodec qcodec = new QCodec();
+ final String plain = "1+1 = 2";
+ final String encoded = (String) qcodec.encode((Object) plain);
assertEquals("Basic Q encoding test",
"=?UTF-8?Q?1+1 =3D 2?=", encoded);
- Object result = qcodec.encode((Object) null);
+ final Object result = qcodec.encode((Object) null);
assertEquals( "Encoding a null Object should return null", null, result);
try {
- Object dObj = new Double(3.0);
+ final Object dObj = new Double(3.0);
qcodec.encode( dObj );
fail( "Trying to url encode a Double object should cause an exception.");
- } catch (EncoderException ee) {
+ } catch (final EncoderException ee) {
// Exception expected, test segment passes.
}
}
@@ -159,20 +159,20 @@ public class QCodecTest {
@Test
public void testDecodeObjects() throws Exception {
- QCodec qcodec = new QCodec();
- String decoded = "=?UTF-8?Q?1+1 =3D 2?=";
- String plain = (String) qcodec.decode((Object) decoded);
+ final QCodec qcodec = new QCodec();
+ final String decoded = "=?UTF-8?Q?1+1 =3D 2?=";
+ final String plain = (String) qcodec.decode((Object) decoded);
assertEquals("Basic Q decoding test",
"1+1 = 2", plain);
- Object result = qcodec.decode((Object) null);
+ final Object result = qcodec.decode((Object) null);
assertEquals( "Decoding a null Object should return null", null, result);
try {
- Object dObj = new Double(3.0);
+ final Object dObj = new Double(3.0);
qcodec.decode( dObj );
fail( "Trying to url encode a Double object should cause an exception.");
- } catch (DecoderException ee) {
+ } catch (final DecoderException ee) {
// Exception expected, test segment passes.
}
}
@@ -180,10 +180,10 @@ public class QCodecTest {
@Test
public void testEncodeDecodeBlanks() throws Exception {
- String plain = "Mind those pesky blanks";
- String encoded1 = "=?UTF-8?Q?Mind those pesky blanks?=";
- String encoded2 = "=?UTF-8?Q?Mind_those_pesky_blanks?=";
- QCodec qcodec = new QCodec();
+ final String plain = "Mind those pesky blanks";
+ final String encoded1 = "=?UTF-8?Q?Mind those pesky blanks?=";
+ final String encoded2 = "=?UTF-8?Q?Mind_those_pesky_blanks?=";
+ final QCodec qcodec = new QCodec();
qcodec.setEncodeBlanks(false);
String s = qcodec.encode(plain);
assertEquals("Blanks encoding with the Q codec test", encoded1, s);
@@ -199,7 +199,7 @@ public class QCodecTest {
@Test
public void testLetUsMakeCloverHappy() throws Exception {
- QCodec qcodec = new QCodec();
+ final QCodec qcodec = new QCodec();
qcodec.setEncodeBlanks(true);
assertTrue(qcodec.isEncodeBlanks());
qcodec.setEncodeBlanks(false);