diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5f3a488e4f..cc793b616d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # 4.1.3 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@c7f9125735019aa87cfc361530512d50ea439c71 # 3.25.1 + uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # 3.25.12 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@c7f9125735019aa87cfc361530512d50ea439c71 # 3.25.1 + uses: github/codeql-action/autobuild@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # 3.25.12 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@c7f9125735019aa87cfc361530512d50ea439c71 # 3.25.1 + uses: github/codeql-action/analyze@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # 3.25.12 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 1f3beb86ce..0000000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: Coverage - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - java: [ 8 ] - - steps: - - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # 4.1.3 - with: - persist-credentials: false - - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 - with: - distribution: 'temurin' - java-version: ${{ matrix.java }} - - name: Build with Maven - run: mvn --show-version --batch-mode --no-transfer-progress test jacoco:report - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4.3.0 - with: - files: ./target/site/jacoco/jacoco.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 3b5054ac74..68b2f3103a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -27,14 +27,14 @@ jobs: continue-on-error: ${{ matrix.experimental }} strategy: matrix: - java: [ 8, 11, 17, 21 ] + java: [ 8, 11, 17, 21, 22 ] experimental: [false] include: - - java: 22-ea + - java: 23-ea experimental: true steps: - - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # 4.1.3 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 @@ -49,4 +49,4 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} - name: Build with Maven - run: mvn --show-version --batch-mode --no-transfer-progress + run: mvn --errors --show-version --batch-mode --no-transfer-progress diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index c22ee1c0e1..d5269bf664 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -40,12 +40,12 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # 4.1.3 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7 with: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # 2.3.1 + uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # 2.3.3 with: results_file: results.sarif results_format: sarif @@ -57,13 +57,13 @@ jobs: publish_results: true - name: "Upload artifact" - uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 with: name: SARIF file path: results.sarif retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@c7f9125735019aa87cfc361530512d50ea439c71 # 3.25.1 + uses: github/codeql-action/upload-sarif@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # 3.25.12 with: sarif_file: results.sarif diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 62e99f8d28..d4e74f7481 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,9 +41,8 @@ Contributing to Apache Commons Codec ====================== -You have found a bug or you have an idea for a cool new feature? Contributing code is a great way to give something back to -the open source community. Before you dig right into the code there are a few guidelines that we need contributors to -follow so that we can have a chance of keeping on top of things. +Have you found a bug or have an idea for a cool new feature? Contributing code is a great way to give something back to the open-source community. +Before you dig right into the code, we need contributors to follow a few guidelines to have a chance of keeping on top of things. Getting Started --------------- @@ -62,7 +61,7 @@ Making Changes + Create a _topic branch_ for your isolated work. * Usually you should base your branch on the `master` branch. - * A good topic branch name can be the JIRA bug id plus a keyword, e.g. `CODEC-123-InputStream`. + * A good topic branch name can be the JIRA bug ID plus a keyword, e.g. `CODEC-123-InputStream`. * If you have submitted multiple JIRA issues, try to maintain separate branches and pull requests. + Make commits of logical units. * Make sure your commit messages are meaningful and in the proper format. Your commit message should contain the key of the JIRA issue. @@ -72,7 +71,7 @@ Making Changes + Create minimal diffs - disable _On Save_ actions like _Reformat Source Code_ or _Organize Imports_. If you feel the source code should be reformatted create a separate PR for this change first. + Check for unnecessary whitespace with `git diff` -- check before committing. + Make sure you have added the necessary tests for your changes, typically in `src/test/java`. -+ Run all the tests with `mvn clean verify` to assure nothing else was accidentally broken. ++ Run all the tests with `mvn clean verify` to ensure nothing else was accidentally broken. Making Trivial Changes ---------------------- diff --git a/README.md b/README.md index 6ad95c8878..d5750ab84e 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,12 @@ Apache Commons Codec =================== [![Java CI](https://github.com/apache/commons-codec/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-codec/actions/workflows/maven.yml) -[![Coverage Status](https://codecov.io/gh/apache/commons-codec/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-codec) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/commons-codec/commons-codec/badge.svg?gav=true)](https://maven-badges.herokuapp.com/maven-central/commons-codec/commons-codec/?gav=true) -[![Javadocs](https://javadoc.io/badge/commons-codec/commons-codec/1.17.0.svg)](https://javadoc.io/doc/commons-codec/commons-codec/1.17.0) +[![Javadocs](https://javadoc.io/badge/commons-codec/commons-codec/1.17.1.svg)](https://javadoc.io/doc/commons-codec/commons-codec/1.17.1) [![CodeQL](https://github.com/apache/commons-codec/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/apache/commons-codec/actions/workflows/codeql-analysis.yml) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/apache/commons-codec/badge)](https://api.securityscorecards.dev/projects/github.com/apache/commons-codec) -The Apache Commons Codec component contains encoder and decoders for +The Apache Commons Codec component contains encoders and decoders for various formats such as Base16, Base32, Base64, digest, and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities. @@ -72,7 +71,7 @@ Alternatively, you can pull it from the central Maven repositories: commons-codec commons-codec - 1.17.0 + 1.17.1 ``` @@ -92,7 +91,9 @@ There are some guidelines which will make applying PRs easier for us: + No tabs! Please use spaces for indentation. + Respect the existing code style for each file. + Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change. -+ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running ```mvn```. ++ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running `mvn`. ++ Before you pushing a PR, run `mvn` (by itself), this runs the default goal, which contains all build checks. ++ To see the code coverage report, regardless of coverage failures, run `mvn clean site -Dcommons.jacoco.haltOnFailure=false` If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas). You can learn more about contributing via GitHub in our [contribution guidelines](CONTRIBUTING.md). diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index ee1f2a3c34..57ee97eb43 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,7 +1,41 @@ +Apache Commons Codec 1.17.1 RELEASE NOTES +----------------------------------------- + +The Apache Commons Codec component contains encoders and decoders for +various formats such as Base16, Base32, Base64, digest, and Hexadecimal. In addition to these +widely used encoders and decoders, the codec package also maintains a +collection of phonetic encoding utilities. + +Feature and fix release. Requires a minimum of Java 8. + + + +Fixed Bugs +---------- + +* Md5Crypt now throws IllegalArgumentException on an invalid prefix. Thanks to Gary Gregory. + +Changes +------- + +* Bump org.apache.commons:commons-parent from 69 to 71 #286. Thanks to Gary Gregory. +* Bump org.codehaus.mojo:animal-sniffer-maven-plugin from 1.23 to 1.24 #293. Thanks to Dependabot. +* Bump org.codehaus.mojo:taglist-maven-plugin from 3.0.0 to 3.1.0 #292. Thanks to Dependabot. + + +For complete information on Apache Commons Codec, including instructions on how to submit bug reports, +patches, or suggestions for improvement, see the Apache Commons Codec website: + +https://commons.apache.org/proper/commons-codec/ + +Download page: https://commons.apache.org/proper/commons-codec/download_codec.cgi + +--------------------------------------------------------------------------------- + Apache Commons Codec 1.17.0 RELEASE NOTES ----------------------------------------- -The Apache Commons Codec component contains encoder and decoders for +The Apache Commons Codec component contains encoders and decoders for various formats such as Base16, Base32, Base64, digest, and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities. @@ -49,7 +83,7 @@ Download page: https://commons.apache.org/proper/commons-codec/download_codec.cg Apache Commons Codec 1.16.1 RELEASE NOTES ----------------------------------------- -The Apache Commons Codec component contains encoder and decoders for +The Apache Commons Codec component contains encoders and decoders for various formats such as Base16, Base32, Base64, digest, and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities. diff --git a/pom.xml b/pom.xml index 9a407f652b..b6185a1d82 100644 --- a/pom.xml +++ b/pom.xml @@ -24,15 +24,15 @@ limitations under the License. org.apache.commons commons-parent - 69 + 71 commons-codec commons-codec - 1.17.0 + 1.17.1 Apache Commons Codec 2002 - The Apache Commons Codec component contains encoder and decoders for + The Apache Commons Codec component contains encoders and decoders for various formats such as Base16, Base32, Base64, digest, and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities. @@ -50,9 +50,9 @@ limitations under the License. - stagingSite - Apache Staging Website - ${commons.deployment.protocol}://people.apache.org/www/commons.apache.org/commons-${commons.componentid}/ + apache.website + Apache Commons Site + scm:svn:https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-codec/ @@ -98,18 +98,17 @@ limitations under the License. UTF-8 ${basedir}/src/conf/checkstyle-header.txt ${basedir}/src/conf/checkstyle.xml - false - 1.17.0 - 1.16.1 - 1.17.1 + 1.17.1 + 1.17.0 + 1.17.2 RC1 true scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid} - 2024-04-20T18:05:56Z + 2024-07-12T16:14:24Z 0.8.12 - ${commons.javadoc21.java.link} + false true 0.92 0.91 @@ -209,7 +208,7 @@ limitations under the License. org.codehaus.mojo animal-sniffer-maven-plugin - 1.23 + 1.24 @@ -264,7 +263,7 @@ limitations under the License. org.codehaus.mojo taglist-maven-plugin - 3.0.0 + 3.1.0 TODO diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a8a65fdc09..8c2a9ed10a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -43,6 +43,15 @@ The type attribute can be add,update,fix,remove. Apache Commons Developers + + + Md5Crypt now throws IllegalArgumentException on an invalid prefix. + + + Bump org.apache.commons:commons-parent from 69 to 71 #286. + Bump org.codehaus.mojo:animal-sniffer-maven-plugin from 1.23 to 1.24 #293. + Bump org.codehaus.mojo:taglist-maven-plugin from 3.0.0 to 3.1.0 #292. + Wrong output of DoubleMetaphone in 1.16.1. diff --git a/src/conf/checkstyle-suppressions.xml b/src/conf/checkstyle-suppressions.xml index f5dc46ba9f..40bb184602 100644 --- a/src/conf/checkstyle-suppressions.xml +++ b/src/conf/checkstyle-suppressions.xml @@ -1,5 +1,4 @@ - - - + "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" + "https://checkstyle.org/dtds/suppressions_1_2.dtd"> diff --git a/src/main/java/org/apache/commons/codec/binary/Base64.java b/src/main/java/org/apache/commons/codec/binary/Base64.java index 443ccc6612..48ad7334e0 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base64.java +++ b/src/main/java/org/apache/commons/codec/binary/Base64.java @@ -92,7 +92,7 @@ public Base64 get() { * Sets the URL-safe encoding policy. * * @param urlSafe URL-safe encoding policy, null resets to the default. - * @return this. + * @return {@code this} instance. */ public Builder setUrlSafe(final boolean urlSafe) { return setEncodeTable(toUrlSafeEncodeTable(urlSafe)); @@ -219,7 +219,6 @@ public static byte[] decodeBase64(final String base64String) { return new Base64().decode(base64String); } - // Implementation of integer encoding used for crypto /** * Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature. * diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java index c598abc3d1..e4e3f6ae20 100644 --- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java +++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java @@ -103,7 +103,7 @@ byte getPadding() { * Sets the decoding policy. * * @param decodingPolicy the decoding policy, null resets to the default. - * @return this. + * @return {@code this} instance. */ public B setDecodingPolicy(final CodecPolicy decodingPolicy) { this.decodingPolicy = decodingPolicy != null ? decodingPolicy : DECODING_POLICY_DEFAULT; @@ -114,7 +114,7 @@ public B setDecodingPolicy(final CodecPolicy decodingPolicy) { * Sets the encode table. * * @param encodeTable the encode table, null resets to the default. - * @return this. + * @return {@code this} instance. */ public B setEncodeTable(final byte... encodeTable) { this.encodeTable = encodeTable != null ? encodeTable : defaultEncodeTable; @@ -125,7 +125,7 @@ public B setEncodeTable(final byte... encodeTable) { * Sets the line length. * * @param lineLength the line length, less than 0 resets to the default. - * @return this. + * @return {@code this} instance. */ public B setLineLength(final int lineLength) { this.lineLength = Math.max(0, lineLength); @@ -136,7 +136,7 @@ public B setLineLength(final int lineLength) { * Sets the line separator. * * @param lineSeparator the line separator, null resets to the default. - * @return this. + * @return {@code this} instance. */ public B setLineSeparator(final byte... lineSeparator) { this.lineSeparator = lineSeparator != null ? lineSeparator : CHUNK_SEPARATOR; @@ -147,7 +147,7 @@ public B setLineSeparator(final byte... lineSeparator) { * Sets the padding byte. * * @param padding the padding byte. - * @return this. + * @return {@code this} instance. */ public B setPadding(final byte padding) { this.padding = padding; diff --git a/src/main/java/org/apache/commons/codec/binary/Hex.java b/src/main/java/org/apache/commons/codec/binary/Hex.java index dc6d0806b6..7db25d5cde 100644 --- a/src/main/java/org/apache/commons/codec/binary/Hex.java +++ b/src/main/java/org/apache/commons/codec/binary/Hex.java @@ -480,7 +480,7 @@ public Object decode(final Object object) throws DecoderException { */ @Override public byte[] encode(final byte[] array) { - return encodeHexString(array).getBytes(this.getCharset()); + return encodeHexString(array).getBytes(getCharset()); } /** @@ -500,7 +500,7 @@ public byte[] encode(final byte[] array) { * @since 1.11 */ public byte[] encode(final ByteBuffer array) { - return encodeHexString(array).getBytes(this.getCharset()); + return encodeHexString(array).getBytes(getCharset()); } /** @@ -521,7 +521,7 @@ public byte[] encode(final ByteBuffer array) { public Object encode(final Object object) throws EncoderException { final byte[] byteArray; if (object instanceof String) { - byteArray = ((String) object).getBytes(this.getCharset()); + byteArray = ((String) object).getBytes(getCharset()); } else if (object instanceof ByteBuffer) { byteArray = toByteArray((ByteBuffer) object); } else { diff --git a/src/main/java/org/apache/commons/codec/digest/Blake3.java b/src/main/java/org/apache/commons/codec/digest/Blake3.java index ba6cceedf4..032ce0ffc1 100644 --- a/src/main/java/org/apache/commons/codec/digest/Blake3.java +++ b/src/main/java/org/apache/commons/codec/digest/Blake3.java @@ -455,7 +455,7 @@ private Blake3(final int[] key, final int flags) { * previously finalized bytes. Note that this can finalize up to 264 bytes per instance. * * @param out destination array to finalize bytes into - * @return this + * @return {@code this} instance. * @throws NullPointerException if out is null */ public Blake3 doFinalize(final byte[] out) { @@ -469,7 +469,7 @@ public Blake3 doFinalize(final byte[] out) { * @param out destination array to finalize bytes into * @param offset where in the array to begin writing bytes to * @param length number of bytes to finalize - * @return this + * @return {@code this} instance. * @throws NullPointerException if out is null * @throws IndexOutOfBoundsException if offset or length are negative or if offset + length is greater than the * length of the provided array @@ -498,7 +498,7 @@ public byte[] doFinalize(final int nrBytes) { /** * Resets this instance back to its initial state when it was first constructed. - * @return this + * @return {@code this} instance. */ public Blake3 reset() { engineState.reset(); @@ -509,7 +509,7 @@ public Blake3 reset() { * Updates this hash state using the provided bytes. * * @param in source array to update data from - * @return this + * @return {@code this} instance. * @throws NullPointerException if in is null */ public Blake3 update(final byte[] in) { @@ -522,7 +522,7 @@ public Blake3 update(final byte[] in) { * @param in source array to update data from * @param offset where in the array to begin reading bytes * @param length number of bytes to update - * @return this + * @return {@code this} instance. * @throws NullPointerException if in is null * @throws IndexOutOfBoundsException if offset or length are negative or if offset + length is greater than the * length of the provided array diff --git a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java index 05c6a6ce20..7d25225c6d 100644 --- a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java +++ b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java @@ -20,6 +20,7 @@ import java.security.MessageDigest; import java.security.SecureRandom; import java.util.Arrays; +import java.util.Objects; import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -238,7 +239,7 @@ public static String md5Crypt(final byte[] keyBytes, final String salt) { * real salt value without prefix or "rounds=". The salt may be null, in which case a salt * is generated for you using {@link SecureRandom}. * @param prefix - * salt prefix + * The salt prefix {@value #APR1_PREFIX}, {@value #MD5_PREFIX}. * @return the hash value * @throws IllegalArgumentException * if the salt does not match the allowed pattern @@ -261,13 +262,13 @@ public static String md5Crypt(final byte[] keyBytes, final String salt, final St * real salt value without prefix or "rounds=". The salt may be null, in which case a salt * is generated for you using {@link SecureRandom}. * @param prefix - * salt prefix + * The salt prefix {@value #APR1_PREFIX}, {@value #MD5_PREFIX}. * @param random * the instance of {@link Random} to use for generating the salt. * Consider using {@link SecureRandom} for more secure salts. * @return the hash value * @throws IllegalArgumentException - * if the salt does not match the allowed pattern + * if the salt or prefix does not match the allowed pattern * @throws IllegalArgumentException * when a {@link java.security.NoSuchAlgorithmException} is caught. * @since 1.12 @@ -280,6 +281,13 @@ public static String md5Crypt(final byte[] keyBytes, final String salt, final St if (salt == null) { saltString = B64.getRandomSalt(8, random); } else { + Objects.requireNonNull(prefix, "prefix"); + if (prefix.length() < 3) { + throw new IllegalArgumentException("Invalid prefix value: " + prefix); + } + if (prefix.charAt(0) != '$' && prefix.charAt(prefix.length() - 1) != '$') { + throw new IllegalArgumentException("Invalid prefix value: " + prefix); + } final Pattern p = Pattern.compile("^" + prefix.replace("$", "\\$") + "([\\.\\/a-zA-Z0-9]{1,8}).*"); final Matcher m = p.matcher(salt); if (!m.find()) { diff --git a/src/main/java/org/apache/commons/codec/digest/MurmurHash2.java b/src/main/java/org/apache/commons/codec/digest/MurmurHash2.java index 04038f9585..d4d5faabf1 100644 --- a/src/main/java/org/apache/commons/codec/digest/MurmurHash2.java +++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash2.java @@ -20,7 +20,7 @@ import org.apache.commons.codec.binary.StringUtils; /** - * Implementation of the MurmurHash2 32-bit and 64-bit hash functions. + * Implements the MurmurHash2 32-bit and 64-bit hash functions. * *

MurmurHash is a non-cryptographic hash function suitable for general * hash-based lookup. The name comes from two basic operations, multiply (MU) diff --git a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java index 197c70537e..10ce3b8a2e 100644 --- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java +++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java @@ -20,7 +20,7 @@ import org.apache.commons.codec.binary.StringUtils; /** - * Implementation of the MurmurHash3 32-bit and 128-bit hash functions. + * Implements the MurmurHash3 32-bit and 128-bit hash functions. * *

* MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup. The name comes from two basic diff --git a/src/main/java/org/apache/commons/codec/digest/XXHash32.java b/src/main/java/org/apache/commons/codec/digest/XXHash32.java index fd46fc0c3c..16f59b8be3 100644 --- a/src/main/java/org/apache/commons/codec/digest/XXHash32.java +++ b/src/main/java/org/apache/commons/codec/digest/XXHash32.java @@ -22,7 +22,7 @@ import java.util.zip.Checksum; /** - * Implementation of the xxHash32 hash algorithm. + * Implements the xxHash32 hash algorithm. * *

* Copied from Commons Compress 1.14 < this.getMaxCodeLen() && n < wdsz) { // max code size of 4 works well + while (code.length() < getMaxCodeLen() && n < wdsz) { // max code size of 4 works well final char symb = local.charAt(n); // remove duplicate letters except C if (symb != 'C' && isPreviousChar(local, n, symb)) { - n++; } else { // not dup switch (symb) { case 'A': @@ -252,14 +251,10 @@ public String metaphone(final String txt) { code.append('K'); break; } - if (isNextChar(local, n, 'H')) { // detect CH - if (n == 0 && wdsz >= 3 && isVowel(local, 2)) { // CH consonant -> K consonant - code.append('K'); - } else { - code.append('X'); // CHvowel -> X - } - } else { + if (!isNextChar(local, n, 'H') || (n == 0 && wdsz >= 3 && isVowel(local, 2))) { // CH consonant -> K consonant code.append('K'); + } else { + code.append('X'); // CHvowel -> X } break; case 'D': @@ -370,10 +365,10 @@ public String metaphone(final String txt) { // do nothing break; } // end switch - n++; } // end else from symb != 'C' - if (code.length() > this.getMaxCodeLen()) { - code.setLength(this.getMaxCodeLen()); + n++; + if (code.length() > getMaxCodeLen()) { + code.setLength(getMaxCodeLen()); } } return code.toString(); diff --git a/src/main/java/org/apache/commons/codec/language/Nysiis.java b/src/main/java/org/apache/commons/codec/language/Nysiis.java index 10b4a8f08c..f33b7ce156 100644 --- a/src/main/java/org/apache/commons/codec/language/Nysiis.java +++ b/src/main/java/org/apache/commons/codec/language/Nysiis.java @@ -214,7 +214,7 @@ public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException("Parameter supplied to Nysiis encode is not of type java.lang.String"); } - return this.nysiis((String) obj); + return nysiis((String) obj); } /** @@ -228,7 +228,7 @@ public Object encode(final Object obj) throws EncoderException { */ @Override public String encode(final String str) { - return this.nysiis(str); + return nysiis(str); } /** @@ -316,7 +316,7 @@ public String nysiis(String str) { } final String string = key.toString(); - return this.isStrict() ? string.substring(0, Math.min(TRUE_LENGTH, string.length())) : string; + return isStrict() ? string.substring(0, Math.min(TRUE_LENGTH, string.length())) : string; } } diff --git a/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java b/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java index 6dd8007723..86d2e89501 100644 --- a/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java +++ b/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java @@ -448,7 +448,7 @@ public Object decode(final Object obj) throws DecoderException { */ @Override public String decode(final String sourceStr) throws DecoderException { - return this.decode(sourceStr, this.getCharset()); + return this.decode(sourceStr, getCharset()); } /** diff --git a/src/main/java/org/apache/commons/codec/net/RFC1522Codec.java b/src/main/java/org/apache/commons/codec/net/RFC1522Codec.java index 39064c52a6..a77548d983 100644 --- a/src/main/java/org/apache/commons/codec/net/RFC1522Codec.java +++ b/src/main/java/org/apache/commons/codec/net/RFC1522Codec.java @@ -155,9 +155,9 @@ protected String encodeText(final String text, final Charset charset) throws Enc buffer.append(PREFIX); buffer.append(charset); buffer.append(SEP); - buffer.append(this.getEncoding()); + buffer.append(getEncoding()); buffer.append(SEP); - buffer.append(StringUtils.newStringUsAscii(this.doEncoding(text.getBytes(charset)))); + buffer.append(StringUtils.newStringUsAscii(doEncoding(text.getBytes(charset)))); buffer.append(POSTFIX); return buffer.toString(); } diff --git a/src/site/xdoc/download_codec.xml b/src/site/xdoc/download_codec.xml index 21317e594b..ad48414247 100644 --- a/src/site/xdoc/download_codec.xml +++ b/src/site/xdoc/download_codec.xml @@ -113,32 +113,32 @@ limitations under the License.

-
+
- - - + + + - - - + + +
commons-codec-1.17.0-bin.tar.gzsha512pgpcommons-codec-1.17.1-bin.tar.gzsha512pgp
commons-codec-1.17.0-bin.zipsha512pgpcommons-codec-1.17.1-bin.zipsha512pgp
- - - + + + - - - + + +
commons-codec-1.17.0-src.tar.gzsha512pgpcommons-codec-1.17.1-src.tar.gzsha512pgp
commons-codec-1.17.0-src.zipsha512pgpcommons-codec-1.17.1-src.zipsha512pgp
diff --git a/src/test/java/org/apache/commons/codec/binary/Base16Test.java b/src/test/java/org/apache/commons/codec/binary/Base16Test.java index b01046c449..5b1a1a4dc7 100644 --- a/src/test/java/org/apache/commons/codec/binary/Base16Test.java +++ b/src/test/java/org/apache/commons/codec/binary/Base16Test.java @@ -224,9 +224,9 @@ public void testEmptyBase16() { @Test public void testEncodeDecodeRandom() { for (int i = 1; i < 5; i++) { - final int len = this.getRandom().nextInt(10000) + 1; + final int len = getRandom().nextInt(10000) + 1; final byte[] data = new byte[len]; - this.getRandom().nextBytes(data); + getRandom().nextBytes(data); final byte[] enc = new Base16().encode(data); final byte[] data2 = new Base16().decode(enc); assertArrayEquals(data, data2); @@ -238,7 +238,7 @@ public void testEncodeDecodeRandom() { public void testEncodeDecodeSmall() { for (int i = 0; i < 12; i++) { final byte[] data = new byte[i]; - this.getRandom().nextBytes(data); + getRandom().nextBytes(data); final byte[] enc = new Base16().encode(data); final byte[] data2 = new Base16().decode(enc); assertArrayEquals(data, data2, toString(data) + " equals " + toString(data2)); diff --git a/src/test/java/org/apache/commons/codec/binary/Base64Test.java b/src/test/java/org/apache/commons/codec/binary/Base64Test.java index e96e9fa790..11e2946c57 100644 --- a/src/test/java/org/apache/commons/codec/binary/Base64Test.java +++ b/src/test/java/org/apache/commons/codec/binary/Base64Test.java @@ -636,8 +636,8 @@ private void testEncodeDecode(final String plainText) { @Test public void testEncodeDecodeRandom() { for (int i = 1; i < 5; i++) { - final byte[] data = new byte[this.getRandom().nextInt(10000) + 1]; - this.getRandom().nextBytes(data); + final byte[] data = new byte[getRandom().nextInt(10000) + 1]; + getRandom().nextBytes(data); final byte[] enc = Base64.encodeBase64(data); assertTrue(Base64.isBase64(enc)); final byte[] data2 = Base64.decodeBase64(enc); @@ -650,7 +650,7 @@ public void testEncodeDecodeRandom() { public void testEncodeDecodeSmall() { for (int i = 0; i < 12; i++) { final byte[] data = new byte[i]; - this.getRandom().nextBytes(data); + getRandom().nextBytes(data); final byte[] enc = Base64.encodeBase64(data); assertTrue(Base64.isBase64(enc), "\"" + new String(enc) + "\" is Base64 data."); final byte[] data2 = Base64.decodeBase64(enc); diff --git a/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java b/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java index 8eac52f9a0..bde44765aa 100644 --- a/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java +++ b/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java @@ -32,7 +32,17 @@ public class Md5CryptTest { @Test public void testCtor() { - assertNotNull(new Md5Crypt()); // for code-coverage + assertNotNull(new Md5Crypt()); + } + + @Test + public void testInvalidPrefix() { + assertThrows(IllegalArgumentException.class, () -> Md5Crypt.md5Crypt(new byte[] { 1, 2, 3, 4, 5 }, + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!", "(.*a){10000}")); + assertThrows(IllegalArgumentException.class, () -> Md5Crypt.md5Crypt(new byte[] { 1, 2, 3, 4, 5 }, + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!", "$(.*a){10000}$")); + assertThrows(IllegalArgumentException.class, () -> Md5Crypt.md5Crypt(new byte[] { 1, 2, 3, 4, 5 }, + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "$(.*a){10000}$")); } @Test diff --git a/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java b/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java index 059f7d1c46..d359fd0040 100644 --- a/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java +++ b/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java @@ -43,7 +43,7 @@ protected Caverphone1 createStringEncoder() { */ @Test public void testCaverphoneRevisitedCommonCodeAT1111() throws EncoderException { - this.checkEncodingVariations("AT1111", new String[]{ + checkEncodingVariations("AT1111", new String[]{ "add", "aid", "at", @@ -64,7 +64,7 @@ public void testCaverphoneRevisitedCommonCodeAT1111() throws EncoderException { @Test public void testEndMb() throws EncoderException { final String[][] data = {{"mb", "M11111"}, {"mbmb", "MPM111"}}; - this.checkEncodings(data); + checkEncodings(data); } /** @@ -87,7 +87,7 @@ public void testIsCaverphoneEquals() throws EncoderException { @Test public void testSpecificationV1Examples() throws EncoderException { final String[][] data = {{"David", "TFT111"}, {"Whittle", "WTL111"}}; - this.checkEncodings(data); + checkEncodings(data); } /** @@ -98,7 +98,7 @@ public void testSpecificationV1Examples() throws EncoderException { @Test public void testWikipediaExamples() throws EncoderException { final String[][] data = {{"Lee", "L11111"}, {"Thompson", "TMPSN1"}}; - this.checkEncodings(data); + checkEncodings(data); } } diff --git a/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java b/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java index 067b357a95..12172261f4 100644 --- a/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java +++ b/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java @@ -42,7 +42,7 @@ protected Caverphone2 createStringEncoder() { * @throws EncoderException for some failure scenarios */ @Test public void testCaverphoneRevisitedCommonCodeAT11111111() throws EncoderException { - this.checkEncodingVariations("AT11111111", new String[]{ + checkEncodingVariations("AT11111111", new String[]{ "add", "aid", "at", @@ -67,7 +67,7 @@ public void testCaverphoneRevisitedCommonCodeAT11111111() throws EncoderExceptio @Test public void testCaverphoneRevisitedExamples() throws EncoderException { final String[][] data = {{"Stevenson", "STFNSN1111"}, {"Peter", "PTA1111111"}}; - this.checkEncodings(data); + checkEncodings(data); } /** @@ -76,7 +76,7 @@ public void testCaverphoneRevisitedExamples() throws EncoderException { * @throws EncoderException for some failure scenarios */ @Test public void testCaverphoneRevisitedRandomNameKLN1111111() throws EncoderException { - this.checkEncodingVariations("KLN1111111", new String[]{ + checkEncodingVariations("KLN1111111", new String[]{ "Cailean", "Calan", "Calen", @@ -167,7 +167,7 @@ public void testCaverphoneRevisitedRandomNameKLN1111111() throws EncoderExceptio * @throws EncoderException for some failure scenarios */ @Test public void testCaverphoneRevisitedRandomNameTN11111111() throws EncoderException { - this.checkEncodingVariations("TN11111111", new String[]{ + checkEncodingVariations("TN11111111", new String[]{ "Dan", "Dane", "Dann", @@ -245,7 +245,7 @@ public void testCaverphoneRevisitedRandomNameTN11111111() throws EncoderExceptio * @throws EncoderException for some failure scenarios */ @Test public void testCaverphoneRevisitedRandomNameTTA1111111() throws EncoderException { - this.checkEncodingVariations("TTA1111111", new String[]{ + checkEncodingVariations("TTA1111111", new String[]{ "Darda", "Datha", "Dedie", @@ -322,15 +322,15 @@ public void testCaverphoneRevisitedRandomNameTTA1111111() throws EncoderExceptio * @throws EncoderException for some failure scenarios */ @Test public void testCaverphoneRevisitedRandomWords() throws EncoderException { - this.checkEncodingVariations("RTA1111111", new String[]{"rather", "ready", "writer"}); - this.checkEncoding("SSA1111111", "social"); - this.checkEncodingVariations("APA1111111", new String[]{"able", "appear"}); + checkEncodingVariations("RTA1111111", new String[]{"rather", "ready", "writer"}); + checkEncoding("SSA1111111", "social"); + checkEncodingVariations("APA1111111", new String[]{"able", "appear"}); } @Test public void testEndMb() throws EncoderException { final String[][] data = {{"mb", "M111111111"}, {"mbmb", "MPM1111111"}}; - this.checkEncodings(data); + checkEncodings(data); } // Caverphone Revisited @@ -351,7 +351,7 @@ public void testSpecificationExamples() throws EncoderException { {"Tedder", "TTA1111111"}, {"Karleen", "KLN1111111"}, {"Dyun", "TN11111111"}}; - this.checkEncodings(data); + checkEncodings(data); } } diff --git a/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java b/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java index 3578a6b7b2..c14ec97d2f 100644 --- a/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java +++ b/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java @@ -114,12 +114,12 @@ protected ColognePhonetic createStringEncoder() { @Test public void testAabjoe() throws EncoderException { - this.checkEncoding("01", "Aabjoe"); + checkEncoding("01", "Aabjoe"); } @Test public void testAaclan() throws EncoderException { - this.checkEncoding("0856", "Aaclan"); + checkEncoding("0856", "Aaclan"); } /** @@ -129,13 +129,13 @@ public void testAaclan() throws EncoderException { */ @Test public void testAychlmajrForCodec122() throws EncoderException { - this.checkEncoding("04567", "Aychlmajr"); + checkEncoding("04567", "Aychlmajr"); } @Test // Ensure that override still allows tests to work public void testCanFail() { - assertThrows(AssertionFailedError.class, () -> this.checkEncoding("/", "Fehler")); + assertThrows(AssertionFailedError.class, () -> checkEncoding("/", "Fehler")); } @Test @@ -175,7 +175,7 @@ public void testEdgeCases() throws EncoderException { { "r", "7" } }; // @formatter:on - this.checkEncodings(data); + checkEncodings(data); } @Test @@ -218,13 +218,13 @@ public void testExamples() throws EncoderException { { "heithabu", "021" } }; // @formatter:on - this.checkEncodings(data); + checkEncodings(data); } @Test public void testHyphen() throws EncoderException { final String[][] data = { { "bergisch-gladbach", "174845214" }, { "M\u00fcller-L\u00fcdenscheidt", "65752682" } }; // Müller-Lüdenscheidt - this.checkEncodings(data); + checkEncodings(data); } @Test @@ -242,7 +242,7 @@ public void testIsEncodeEquals() { }; //@formatter:on for (final String[] element : data) { - final boolean encodeEqual = this.getStringEncoder().isEncodeEqual(element[1], element[0]); + final boolean encodeEqual = getStringEncoder().isEncodeEqual(element[1], element[0]); assertTrue(encodeEqual, element[1] + " != " + element[0]); } } @@ -250,18 +250,18 @@ public void testIsEncodeEquals() { @Test public void testSpecialCharsBetweenSameLetters() throws EncoderException { final String[] data = { "Test test", "Testtest", "Test-test", "TesT#Test", "TesT?test" }; - this.checkEncodingVariations("28282", data); + checkEncodingVariations("28282", data); } @Test public void testVariationsMella() throws EncoderException { final String[] data = { "mella", "milah", "moulla", "mellah", "muehle", "mule" }; - this.checkEncodingVariations("65", data); + checkEncodingVariations("65", data); } @Test public void testVariationsMeyer() throws EncoderException { final String[] data = { "Meier", "Maier", "Mair", "Meyer", "Meyr", "Mejer", "Major" }; - this.checkEncodingVariations("67", data); + checkEncodingVariations("67", data); } } diff --git a/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java b/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java index a52cc80011..7d749abbbc 100644 --- a/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java +++ b/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java @@ -81,7 +81,7 @@ public void testEncodeBasic() { @Test public void testEncodeIgnoreApostrophes() throws EncoderException { - this.checkEncodingVariations("079600", new String[] { "OBrien", "'OBrien", "O'Brien", "OB'rien", "OBr'ien", + checkEncodingVariations("079600", new String[] { "OBrien", "'OBrien", "O'Brien", "OB'rien", "OBr'ien", "OBri'en", "OBrie'n", "OBrien'" }); } @@ -91,7 +91,7 @@ public void testEncodeIgnoreApostrophes() throws EncoderException { * @throws EncoderException for some failure scenarios */ @Test public void testEncodeIgnoreHyphens() throws EncoderException { - this.checkEncodingVariations("565463", new String[] { "KINGSMITH", "-KINGSMITH", "K-INGSMITH", "KI-NGSMITH", + checkEncodingVariations("565463", new String[] { "KINGSMITH", "-KINGSMITH", "K-INGSMITH", "KI-NGSMITH", "KIN-GSMITH", "KING-SMITH", "KINGS-MITH", "KINGSM-ITH", "KINGSMI-TH", "KINGSMIT-H", "KINGSMITH-" }); } diff --git a/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java b/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java index b64fdbe9bc..29bcf7ed59 100644 --- a/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java +++ b/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java @@ -1263,7 +1263,7 @@ public class DoubleMetaphone2Test extends AbstractStringEncoderTest< TEST_DATA.length; i++) { final String value = TEST_DATA[i][0]; - assertEquals(TEST_DATA[i][typeIndex], this.getStringEncoder().doubleMetaphone(value, alternate), "Test [" + i + "]=" + value); + assertEquals(TEST_DATA[i][typeIndex], getStringEncoder().doubleMetaphone(value, alternate), "Test [" + i + "]=" + value); } } @@ -1277,7 +1277,7 @@ protected DoubleMetaphone createStringEncoder() { */ @Test public void testDoubleMetaphoneAlternate() { - this.checkDoubleMetaphone(ALTERNATE_INDEX, true); + checkDoubleMetaphone(ALTERNATE_INDEX, true); } /** @@ -1285,6 +1285,6 @@ public void testDoubleMetaphoneAlternate() { */ @Test public void testDoubleMetaphonePrimary() { - this.checkDoubleMetaphone(PRIMARY_INDEX, false); + checkDoubleMetaphone(PRIMARY_INDEX, false); } } diff --git a/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java b/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java index 0efcfb85b8..603980f440 100644 --- a/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java +++ b/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java @@ -1008,21 +1008,21 @@ public class DoubleMetaphoneTest extends AbstractStringEncoderTest< FIXTURE.length; i++) { 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); + final boolean match1 = getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false); + final boolean match2 = getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true); if (!match1 && !match2) { final String failMsg = "[" + i + "] " + name0 + " and " + name1 + cr; failures.append(failMsg); @@ -1199,12 +1199,12 @@ public void testIsDoubleMetaphoneEqualExtended3() { @Test public void testIsDoubleMetaphoneEqualWithMATCHES() { - this.validateFixture(MATCHES); + validateFixture(MATCHES); for (int i = 0; i < MATCHES.length; i++) { 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); + final boolean match1 = getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false); + final boolean match2 = getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true); if (!match1 && !match2) { fail("Expected match [" + i + "] " + name0 + " and " + name1); } @@ -1219,7 +1219,7 @@ public void testIsDoubleMetaphoneNotEqual() { @Test public void testNTilde() { - assertTrue(this.getStringEncoder().isDoubleMetaphoneEqual("\u00f1", "N")); // n-tilde + assertTrue(getStringEncoder().isDoubleMetaphoneEqual("\u00f1", "N")); // n-tilde } /** diff --git a/src/test/java/org/apache/commons/codec/language/MatchRatingApproachEncoderTest.java b/src/test/java/org/apache/commons/codec/language/MatchRatingApproachEncoderTest.java index cf8c6e2441..dd61a1f804 100644 --- a/src/test/java/org/apache/commons/codec/language/MatchRatingApproachEncoderTest.java +++ b/src/test/java/org/apache/commons/codec/language/MatchRatingApproachEncoderTest.java @@ -42,252 +42,252 @@ protected MatchRatingApproachEncoder createStringEncoder() { @Test public final void testAccentRemoval_AllLower_SuccessfullyRemoved() { - assertEquals("aeiou", this.getStringEncoder().removeAccents("áéíóú")); + assertEquals("aeiou", getStringEncoder().removeAccents("áéíóú")); } @Test public final void testAccentRemoval_ComprehensiveAccentMix_AllSuccessfullyRemoved() { - assertEquals("E,E,E,E,U,U,I,I,A,A,O,e,e,e,e,u,u,i,i,a,a,o,c", this.getStringEncoder().removeAccents("È,É,Ê,Ë,Û,Ù,Ï,Î,À,Â,Ô,è,é,ê,ë,û,ù,ï,î,à,â,ô,ç")); + assertEquals("E,E,E,E,U,U,I,I,A,A,O,e,e,e,e,u,u,i,i,a,a,o,c", getStringEncoder().removeAccents("È,É,Ê,Ë,Û,Ù,Ï,Î,À,Â,Ô,è,é,ê,ë,û,ù,ï,î,à,â,ô,ç")); } @Test public final void testAccentRemoval_GerSpanFrenMix_SuccessfullyRemoved() { - assertEquals("aeoußAEOUnNa", this.getStringEncoder().removeAccents("äëöüßÄËÖÜñÑà")); + assertEquals("aeoußAEOUnNa", getStringEncoder().removeAccents("äëöüßÄËÖÜñÑà")); } @Test public final void testAccentRemoval_MixedWithUnusualChars_SuccessfullyRemovedAndUnusualCharactersInvariant() { - assertEquals("A-e'i.,o&u", this.getStringEncoder().removeAccents("Á-e'í.,ó&ú")); + assertEquals("A-e'i.,o&u", getStringEncoder().removeAccents("Á-e'í.,ó&ú")); } @Test public final void testAccentRemoval_NINO_NoChange() { - assertEquals("", this.getStringEncoder().removeAccents("")); + assertEquals("", getStringEncoder().removeAccents("")); } @Test public final void testAccentRemoval_NullValue_ReturnNullSuccessfully() { - assertNull(this.getStringEncoder().removeAccents(null)); + assertNull(getStringEncoder().removeAccents(null)); } @Test public final void testAccentRemoval_UpperAndLower_SuccessfullyRemovedAndCaseInvariant() { - assertEquals("AeiOuu", this.getStringEncoder().removeAccents("ÁeíÓuu")); + assertEquals("AeiOuu", getStringEncoder().removeAccents("ÁeíÓuu")); } @Test public final void testAccentRemoval_WithSpaces_SuccessfullyRemovedAndSpacesInvariant() { - assertEquals("ae io u", this.getStringEncoder().removeAccents("áé íó ú")); + assertEquals("ae io u", getStringEncoder().removeAccents("áé íó ú")); } @Test public final void testAccentRemovalNormalString_NoChange() { - assertEquals("Colorless green ideas sleep furiously", this.getStringEncoder().removeAccents("Colorless green ideas sleep furiously")); + assertEquals("Colorless green ideas sleep furiously", getStringEncoder().removeAccents("Colorless green ideas sleep furiously")); } @Test public final void testCleanName_SuccessfullyClean() { - assertEquals("THISISATEST", this.getStringEncoder().cleanName("This-ís a t.,es &t")); + assertEquals("THISISATEST", getStringEncoder().cleanName("This-ís a t.,es &t")); } @Test public final void testCompare_BRIAN_BRYAN_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Brian", "Bryan")); + assertTrue(getStringEncoder().isEncodeEquals("Brian", "Bryan")); } @Test public final void testCompare_BURNS_BOURNE_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Burns", "Bourne")); + assertTrue(getStringEncoder().isEncodeEquals("Burns", "Bourne")); } @Test public final void testCompare_CATHERINE_KATHRYN_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Catherine", "Kathryn")); + assertTrue(getStringEncoder().isEncodeEquals("Catherine", "Kathryn")); } @Test public final void testCompare_COLM_COLIN_WithAccentsAndSymbolsAndSpaces_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Cólm. ", "C-olín")); + assertTrue(getStringEncoder().isEncodeEquals("Cólm. ", "C-olín")); } @Test public final void testCompare_Forenames_SEAN_JOHN_MatchExpected() { - assertTrue(this.getStringEncoder().isEncodeEquals("Sean", "John")); + assertTrue(getStringEncoder().isEncodeEquals("Sean", "John")); } @Test public final void testCompare_Forenames_SEAN_PETE_NoMatchExpected() { - assertFalse(this.getStringEncoder().isEncodeEquals("Sean", "Pete")); + assertFalse(getStringEncoder().isEncodeEquals("Sean", "Pete")); } @Test public final void testCompare_Forenames_UNA_OONAGH_ShouldSuccessfullyMatchButDoesNot() { - assertFalse(this.getStringEncoder().isEncodeEquals("Úna", "Oonagh")); // Disappointing + assertFalse(getStringEncoder().isEncodeEquals("Úna", "Oonagh")); // Disappointing } @Test public final void testCompare_FRANCISZEK_FRANCES_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Franciszek", "Frances")); + assertTrue(getStringEncoder().isEncodeEquals("Franciszek", "Frances")); } @Test public final void testCompare_KARL_ALESSANDRO_DoesNotMatch() { - assertFalse(this.getStringEncoder().isEncodeEquals("Karl", "Alessandro")); + assertFalse(getStringEncoder().isEncodeEquals("Karl", "Alessandro")); } @Test public final void testCompare_LongSurnames_MORIARTY_OMUIRCHEARTAIGH_DoesNotSuccessfulMatch() { - assertFalse(this.getStringEncoder().isEncodeEquals("Moriarty", "OMuircheartaigh")); + assertFalse(getStringEncoder().isEncodeEquals("Moriarty", "OMuircheartaigh")); } @Test public final void testCompare_LongSurnames_OMUIRCHEARTAIGH_OMIREADHAIGH_SuccessfulMatch() { - assertTrue(this.getStringEncoder().isEncodeEquals("o'muireadhaigh", "Ó 'Muircheartaigh ")); + assertTrue(getStringEncoder().isEncodeEquals("o'muireadhaigh", "Ó 'Muircheartaigh ")); } @Test public final void testCompare_MCGOWAN_MCGEOGHEGAN_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("McGowan", "Mc Geoghegan")); + assertTrue(getStringEncoder().isEncodeEquals("McGowan", "Mc Geoghegan")); } @Test public final void testCompare_MICKY_MICHAEL_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Micky", "Michael")); + assertTrue(getStringEncoder().isEncodeEquals("Micky", "Michael")); } @Test public final void testCompare_OONA_OONAGH_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Oona", "Oonagh")); + assertTrue(getStringEncoder().isEncodeEquals("Oona", "Oonagh")); } @Test public final void testCompare_PETERSON_PETERS_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Peterson", "Peters")); + assertTrue(getStringEncoder().isEncodeEquals("Peterson", "Peters")); } @Test public final void testCompare_SAM_SAMUEL_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Sam", "Samuel")); + assertTrue(getStringEncoder().isEncodeEquals("Sam", "Samuel")); } @Test public final void testCompare_SEAN_SHAUN_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Séan", "Shaun")); + assertTrue(getStringEncoder().isEncodeEquals("Séan", "Shaun")); } @Test public final void testCompare_ShortNames_AL_ED_WorksButNoMatch() { - assertFalse(this.getStringEncoder().isEncodeEquals("Al", "Ed")); + assertFalse(getStringEncoder().isEncodeEquals("Al", "Ed")); } @Test public final void testCompare_SmallInput_CARK_Kl_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Kl", "Karl")); + assertTrue(getStringEncoder().isEncodeEquals("Kl", "Karl")); } @Test public final void testCompare_SMITH_SMYTH_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("smith", "smyth")); + assertTrue(getStringEncoder().isEncodeEquals("smith", "smyth")); } @Test public final void testCompare_SOPHIE_SOFIA_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Sophie", "Sofia")); + assertTrue(getStringEncoder().isEncodeEquals("Sophie", "Sofia")); } @Test public final void testCompare_STEPHEN_STEFAN_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Stephen", "Stefan")); + assertTrue(getStringEncoder().isEncodeEquals("Stephen", "Stefan")); } @Test public final void testCompare_STEPHEN_STEVEN_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Stephen", "Steven")); + assertTrue(getStringEncoder().isEncodeEquals("Stephen", "Steven")); } @Test public final void testCompare_STEVEN_STEFAN_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Steven", "Stefan")); + assertTrue(getStringEncoder().isEncodeEquals("Steven", "Stefan")); } @Test public final void testCompare_Surname_AUERBACH_UHRBACH_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Auerbach", "Uhrbach")); + assertTrue(getStringEncoder().isEncodeEquals("Auerbach", "Uhrbach")); } @Test public final void testCompare_Surname_COOPERFLYNN_SUPERLYN_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Cooper-Flynn", "Super-Lyn")); + assertTrue(getStringEncoder().isEncodeEquals("Cooper-Flynn", "Super-Lyn")); } @Test public final void testCompare_Surname_HAILEY_HALLEY_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Hailey", "Halley")); + assertTrue(getStringEncoder().isEncodeEquals("Hailey", "Halley")); } @Test public final void testCompare_Surname_LEWINSKY_LEVINSKI_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("LEWINSKY", "LEVINSKI")); + assertTrue(getStringEncoder().isEncodeEquals("LEWINSKY", "LEVINSKI")); } @Test public final void testCompare_Surname_LIPSHITZ_LIPPSZYC_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("LIPSHITZ", "LIPPSZYC")); + assertTrue(getStringEncoder().isEncodeEquals("LIPSHITZ", "LIPPSZYC")); } @Test public final void testCompare_Surname_MOSKOWITZ_MOSKOVITZ_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Moskowitz", "Moskovitz")); + assertTrue(getStringEncoder().isEncodeEquals("Moskowitz", "Moskovitz")); } @Test public final void testCompare_Surname_OSULLIVAN_OSUILLEABHAIN_SuccessfulMatch() { - assertTrue(this.getStringEncoder().isEncodeEquals("O'Sullivan", "Ó ' Súilleabháin")); + assertTrue(getStringEncoder().isEncodeEquals("O'Sullivan", "Ó ' Súilleabháin")); } @Test public final void testCompare_Surname_PRZEMYSL_PSHEMESHIL_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals(" P rz e m y s l", " P sh e m e sh i l")); + assertTrue(getStringEncoder().isEncodeEquals(" P rz e m y s l", " P sh e m e sh i l")); } @Test public final void testCompare_Surname_ROSOCHOWACIEC_ROSOKHOVATSETS_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("R o s o ch o w a c ie c", " R o s o k ho v a ts e ts")); + assertTrue(getStringEncoder().isEncodeEquals("R o s o ch o w a c ie c", " R o s o k ho v a ts e ts")); } @Test public final void testCompare_Surname_SZLAMAWICZ_SHLAMOVITZ_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("SZLAMAWICZ", "SHLAMOVITZ")); + assertTrue(getStringEncoder().isEncodeEquals("SZLAMAWICZ", "SHLAMOVITZ")); } @Test public final void testCompare_SurnameCornerCase_Nulls_NoMatch() { - assertFalse(this.getStringEncoder().isEncodeEquals(null, null)); + assertFalse(getStringEncoder().isEncodeEquals(null, null)); } @Test public final void testCompare_Surnames_MURPHY_LYNCH_NoMatchExpected() { - assertFalse(this.getStringEncoder().isEncodeEquals("Murphy", "Lynch")); + assertFalse(getStringEncoder().isEncodeEquals("Murphy", "Lynch")); } @Test public final void testCompare_SurnamesCornerCase_MURPHY_NoSpace_NoMatch() { - assertFalse(this.getStringEncoder().isEncodeEquals("Murphy", "")); + assertFalse(getStringEncoder().isEncodeEquals("Murphy", "")); } @Test public final void testCompare_SurnamesCornerCase_MURPHY_Space_NoMatch() { - assertFalse(this.getStringEncoder().isEncodeEquals("Murphy", " ")); + assertFalse(getStringEncoder().isEncodeEquals("Murphy", " ")); } @Test public final void testCompare_TOMASZ_TOM_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Tomasz", "tom")); + assertTrue(getStringEncoder().isEncodeEquals("Tomasz", "tom")); } @Test public final void testCompare_ZACH_ZAKARIA_SuccessfullyMatched() { - assertTrue(this.getStringEncoder().isEncodeEquals("Zach", "Zacharia")); + assertTrue(getStringEncoder().isEncodeEquals("Zach", "Zacharia")); } @Test @@ -302,220 +302,220 @@ public final void testCompareNameSameNames_ReturnsFalseSuccessfully() { @Test public final void testCompareNameToSingleLetter_KARL_C_DoesNotMatch() { - assertFalse(this.getStringEncoder().isEncodeEquals("Karl", "C")); + assertFalse(getStringEncoder().isEncodeEquals("Karl", "C")); } @Test public final void testGetEncoding_HARPER_HRPR() { - assertEquals("HRPR", this.getStringEncoder().encode("HARPER")); + assertEquals("HRPR", getStringEncoder().encode("HARPER")); } @Test public final void testGetEncoding_NoSpace_to_Nothing() { - assertEquals("", this.getStringEncoder().encode("")); + assertEquals("", getStringEncoder().encode("")); } @Test public final void testGetEncoding_Null_to_Nothing() { - assertEquals("", this.getStringEncoder().encode(null)); + assertEquals("", getStringEncoder().encode(null)); } @Test public final void testGetEncoding_One_Letter_to_Nothing() { - assertEquals("", this.getStringEncoder().encode("E")); + assertEquals("", getStringEncoder().encode("E")); } @Test public final void testGetEncoding_SMITH_to_SMTH() { - assertEquals("SMTH", this.getStringEncoder().encode("Smith")); + assertEquals("SMTH", getStringEncoder().encode("Smith")); } @Test public final void testGetEncoding_SMYTH_to_SMYTH() { - assertEquals("SMYTH", this.getStringEncoder().encode("Smyth")); + assertEquals("SMYTH", getStringEncoder().encode("Smyth")); } @Test public final void testGetEncoding_Space_to_Nothing() { - assertEquals("", this.getStringEncoder().encode(" ")); + assertEquals("", getStringEncoder().encode(" ")); } @Test public final void testGetFirstLast3__ALEXANDER_Returns_Aleder() { - assertEquals("Aleder", this.getStringEncoder().getFirst3Last3("Alexzander")); + assertEquals("Aleder", getStringEncoder().getFirst3Last3("Alexzander")); } @Test public final void testGetFirstLast3_PETE_Returns_PETE() { - assertEquals("PETE", this.getStringEncoder().getFirst3Last3("PETE")); + assertEquals("PETE", getStringEncoder().getFirst3Last3("PETE")); } @Test public final void testGetMinRating_1_Returns5_Successfully() { - assertEquals(5, this.getStringEncoder().getMinRating(1)); + assertEquals(5, getStringEncoder().getMinRating(1)); } @Test public final void testgetMinRating_10_Returns3_Successfully() { - assertEquals(3, this.getStringEncoder().getMinRating(10)); + assertEquals(3, getStringEncoder().getMinRating(10)); } @Test public final void testgetMinRating_11_Returns_3_Successfully() { - assertEquals(3, this.getStringEncoder().getMinRating(11)); + assertEquals(3, getStringEncoder().getMinRating(11)); } @Test public final void testGetMinRating_13_Returns_1_Successfully() { - assertEquals(1, this.getStringEncoder().getMinRating(13)); + assertEquals(1, getStringEncoder().getMinRating(13)); } @Test public final void testGetMinRating_2_Returns5_Successfully() { - assertEquals(5, this.getStringEncoder().getMinRating(2)); + assertEquals(5, getStringEncoder().getMinRating(2)); } @Test public final void testgetMinRating_5_Returns4_Successfully() { - assertEquals(4, this.getStringEncoder().getMinRating(5)); + assertEquals(4, getStringEncoder().getMinRating(5)); } @Test public final void testgetMinRating_5_Returns4_Successfully2() { - assertEquals(4, this.getStringEncoder().getMinRating(5)); + assertEquals(4, getStringEncoder().getMinRating(5)); } @Test public final void testgetMinRating_6_Returns4_Successfully() { - assertEquals(4, this.getStringEncoder().getMinRating(6)); + assertEquals(4, getStringEncoder().getMinRating(6)); } @Test public final void testGetMinRating_7_Return4_Successfully() { - assertEquals(4, this.getStringEncoder().getMinRating(7)); + assertEquals(4, getStringEncoder().getMinRating(7)); } // ***** Begin Region - Test Get Encoding - Surnames @Test public final void testgetMinRating_7_Returns4_Successfully() { - assertEquals(4, this.getStringEncoder().getMinRating(7)); + assertEquals(4, getStringEncoder().getMinRating(7)); } @Test public final void testgetMinRating_8_Returns3_Successfully() { - assertEquals(3, this.getStringEncoder().getMinRating(8)); + assertEquals(3, getStringEncoder().getMinRating(8)); } @Test public final void testIsEncodeEquals_CornerCase_FirstNameJust1Letter_ReturnsFalse() { - assertFalse(this.getStringEncoder().isEncodeEquals("t", "test")); + assertFalse(getStringEncoder().isEncodeEquals("t", "test")); } @Test public final void testIsEncodeEquals_CornerCase_FirstNameJustSpace_ReturnsFalse() { - assertFalse(this.getStringEncoder().isEncodeEquals(" ", "test")); + assertFalse(getStringEncoder().isEncodeEquals(" ", "test")); } @Test public final void testIsEncodeEquals_CornerCase_FirstNameNothing_ReturnsFalse() { - assertFalse(this.getStringEncoder().isEncodeEquals("", "test")); + assertFalse(getStringEncoder().isEncodeEquals("", "test")); } @Test public final void testIsEncodeEquals_CornerCase_FirstNameNull_ReturnsFalse() { - assertFalse(this.getStringEncoder().isEncodeEquals(null, "test")); + assertFalse(getStringEncoder().isEncodeEquals(null, "test")); } @Test public final void testIsEncodeEquals_CornerCase_SecondNameJustSpace_ReturnsFalse() { - assertFalse(this.getStringEncoder().isEncodeEquals("test", " ")); + assertFalse(getStringEncoder().isEncodeEquals("test", " ")); } @Test public final void testIsEncodeEquals_CornerCase_SecondNameNothing_ReturnsFalse() { - assertFalse(this.getStringEncoder().isEncodeEquals("test", "")); + assertFalse(getStringEncoder().isEncodeEquals("test", "")); } @Test public final void testIsEncodeEquals_CornerCase_SecondNameNull_ReturnsFalse() { - assertFalse(this.getStringEncoder().isEncodeEquals("test", null)); + assertFalse(getStringEncoder().isEncodeEquals("test", null)); } @Test public final void testIsEncodeEqualsSecondNameJust1Letter_ReturnsFalse() { - assertFalse(this.getStringEncoder().isEncodeEquals("test", "t")); + assertFalse(getStringEncoder().isEncodeEquals("test", "t")); } @Test public final void testIsVowel_CapitalA_ReturnsTrue() { - assertTrue(this.getStringEncoder().isVowel("A")); + assertTrue(getStringEncoder().isVowel("A")); } @Test public final void testIsVowel_SingleVowel_ReturnsTrue() { - assertTrue(this.getStringEncoder().isVowel("I")); + assertTrue(getStringEncoder().isVowel("I")); } @Test public final void testIsVowel_SmallD_ReturnsFalse() { - assertFalse(this.getStringEncoder().isVowel("d")); + assertFalse(getStringEncoder().isVowel("d")); } @Test public final void testLeftToRightThenRightToLeft_ALEXANDER_ALEXANDRA_Returns4() { - assertEquals(4, this.getStringEncoder().leftToRightThenRightToLeftProcessing("ALEXANDER", "ALEXANDRA")); + assertEquals(4, getStringEncoder().leftToRightThenRightToLeftProcessing("ALEXANDER", "ALEXANDRA")); } @Test public final void testLeftToRightThenRightToLeft_EINSTEIN_MICHAELA_Returns0() { - assertEquals(0, this.getStringEncoder().leftToRightThenRightToLeftProcessing("EINSTEIN", "MICHAELA")); + assertEquals(0, getStringEncoder().leftToRightThenRightToLeftProcessing("EINSTEIN", "MICHAELA")); } @Test public final void testPunctuationOnly() { - assertEquals(this.getStringEncoder().encode(".,-"), ""); + assertEquals(getStringEncoder().encode(".,-"), ""); } @Test public final void testRemoveDoubleConsonants_MISSISSIPPI_RemovedSuccessfully() { - assertEquals("MISISIPI", this.getStringEncoder().removeDoubleConsonants("MISSISSIPPI")); + assertEquals("MISISIPI", getStringEncoder().removeDoubleConsonants("MISSISSIPPI")); } @Test public final void testRemoveDoubleDoubleVowel_BEETLE_NotRemoved() { - assertEquals("BEETLE", this.getStringEncoder().removeDoubleConsonants("BEETLE")); + assertEquals("BEETLE", getStringEncoder().removeDoubleConsonants("BEETLE")); } @Test public final void testRemoveSingleDoubleConsonants_BUBLE_RemovedSuccessfully() { - assertEquals("BUBLE", this.getStringEncoder().removeDoubleConsonants("BUBBLE")); + assertEquals("BUBLE", getStringEncoder().removeDoubleConsonants("BUBBLE")); } @Test public final void testRemoveVowel__AIDAN_Returns_ADN() { - assertEquals("ADN", this.getStringEncoder().removeVowels("AIDAN")); + assertEquals("ADN", getStringEncoder().removeVowels("AIDAN")); } @Test public final void testRemoveVowel__DECLAN_Returns_DCLN() { - assertEquals("DCLN", this.getStringEncoder().removeVowels("DECLAN")); + assertEquals("DCLN", getStringEncoder().removeVowels("DECLAN")); } // ***** END REGION - TEST GET MRA COMPARISONS @Test public final void testRemoveVowel_ALESSANDRA_Returns_ALSSNDR() { - assertEquals("ALSSNDR", this.getStringEncoder().removeVowels("ALESSANDRA")); + assertEquals("ALSSNDR", getStringEncoder().removeVowels("ALESSANDRA")); } @Test public final void testVowelAndPunctuationOnly() { - assertEquals(this.getStringEncoder().encode("uoiea.,-AEIOU"), "U"); + assertEquals(getStringEncoder().encode("uoiea.,-AEIOU"), "U"); } @Test public final void testVowelOnly() { - assertEquals(this.getStringEncoder().encode("aeiouAEIOU"), "A"); + assertEquals(getStringEncoder().encode("aeiouAEIOU"), "A"); } } diff --git a/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java b/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java index 0bc3e68a45..98699f511d 100644 --- a/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java +++ b/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java @@ -31,24 +31,24 @@ public class MetaphoneTest extends AbstractStringEncoderTest { public void assertIsMetaphoneEqual(final String source, final String[] matches) { // match source to all matches for (final String matche : matches) { - assertTrue(this.getStringEncoder().isMetaphoneEqual(source, matche), "Source: " + source + ", should have same Metaphone as: " + matche); + assertTrue(getStringEncoder().isMetaphoneEqual(source, matche), "Source: " + source + ", should have same Metaphone as: " + matche); } // match to each other for (final String matche : matches) { for (final String matche2 : matches) { - assertTrue(this.getStringEncoder().isMetaphoneEqual(matche, matche2)); + assertTrue(getStringEncoder().isMetaphoneEqual(matche, matche2)); } } } public void assertMetaphoneEqual(final String[][] pairs) { - this.validateFixture(pairs); + validateFixture(pairs); 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(this.getStringEncoder().isMetaphoneEqual(name0, name1), failMsg); - assertTrue(this.getStringEncoder().isMetaphoneEqual(name1, name0), failMsg); + assertTrue(getStringEncoder().isMetaphoneEqual(name0, name1), failMsg); + assertTrue(getStringEncoder().isMetaphoneEqual(name1, name0), failMsg); } } @@ -59,35 +59,35 @@ protected Metaphone createStringEncoder() { @Test public void testDiscardOfSCEOrSCIOrSCY() { - assertEquals("SNS", this.getStringEncoder().metaphone("SCIENCE")); - assertEquals("SN", this.getStringEncoder().metaphone("SCENE")); - assertEquals("S", this.getStringEncoder().metaphone("SCY")); + assertEquals("SNS", getStringEncoder().metaphone("SCIENCE")); + assertEquals("SN", getStringEncoder().metaphone("SCENE")); + assertEquals("S", getStringEncoder().metaphone("SCY")); } @Test public void testDiscardOfSilentGN() { // NOTE: This does not test for silent GN, but for starting with GN - assertEquals("N", this.getStringEncoder().metaphone("GNU")); + assertEquals("N", getStringEncoder().metaphone("GNU")); // NOTE: Trying to test for GNED, but expected code does not appear to execute - assertEquals("SNT", this.getStringEncoder().metaphone("SIGNED")); + assertEquals("SNT", getStringEncoder().metaphone("SIGNED")); } @Test public void testDiscardOfSilentHAfterG() { - assertEquals("KNT", this.getStringEncoder().metaphone("GHENT")); - assertEquals("B", this.getStringEncoder().metaphone("BAUGH")); + assertEquals("KNT", getStringEncoder().metaphone("GHENT")); + assertEquals("B", getStringEncoder().metaphone("BAUGH")); } @Test public void testExceedLength() { // should be AKSKS, but is truncated by Max Code Length - assertEquals("AKSK", this.getStringEncoder().metaphone("AXEAXE")); + assertEquals("AKSK", getStringEncoder().metaphone("AXEAXE")); } @Test public void testIsMetaphoneEqual1() { - this.assertMetaphoneEqual(new String[][] { { "Case", "case" }, { "CASE", "Case" }, { "caSe", "cAsE" }, { "quick", "cookie" } }); + assertMetaphoneEqual(new String[][] { { "Case", "case" }, { "CASE", "Case" }, { "caSe", "cAsE" }, { "quick", "cookie" } }); } /** @@ -95,7 +95,7 @@ public void testIsMetaphoneEqual1() { */ @Test public void testIsMetaphoneEqual2() { - this.assertMetaphoneEqual(new String[][] { { "Lawrence", "Lorenza" }, { "Gary", "Cahra" }, }); + assertMetaphoneEqual(new String[][] { { "Lawrence", "Lorenza" }, { "Gary", "Cahra" }, }); } /** @@ -105,7 +105,7 @@ public void testIsMetaphoneEqual2() { */ @Test public void testIsMetaphoneEqualAero() { - this.assertIsMetaphoneEqual("Aero", new String[] { "Eure" }); + assertIsMetaphoneEqual("Aero", new String[] { "Eure" }); } /** @@ -115,7 +115,7 @@ public void testIsMetaphoneEqualAero() { */ @Test public void testIsMetaphoneEqualAlbert() { - this.assertIsMetaphoneEqual("Albert", new String[] { "Ailbert", "Alberik", "Albert", "Alberto", "Albrecht" }); + assertIsMetaphoneEqual("Albert", new String[] { "Ailbert", "Alberik", "Albert", "Alberto", "Albrecht" }); } /** @@ -123,7 +123,7 @@ public void testIsMetaphoneEqualAlbert() { */ @Test public void testIsMetaphoneEqualGary() { - this.assertIsMetaphoneEqual("Gary", + assertIsMetaphoneEqual("Gary", new String[] { "Cahra", "Cara", "Carey", "Cari", "Caria", "Carie", "Caro", "Carree", "Carri", "Carrie", "Carry", "Cary", "Cora", "Corey", "Cori", "Corie", "Correy", "Corri", "Corrie", "Corry", "Cory", "Gray", "Kara", "Kare", "Karee", "Kari", "Karia", "Karie", "Karrah", "Karrie", "Karry", "Kary", "Keri", "Kerri", "Kerrie", "Kerry", "Kira", "Kiri", "Kora", "Kore", "Kori", "Korie", "Korrie", "Korry" }); @@ -134,7 +134,7 @@ public void testIsMetaphoneEqualGary() { */ @Test public void testIsMetaphoneEqualJohn() { - this.assertIsMetaphoneEqual("John", + assertIsMetaphoneEqual("John", new String[] { "Gena", "Gene", "Genia", "Genna", "Genni", "Gennie", "Genny", "Giana", "Gianna", "Gina", "Ginni", "Ginnie", "Ginny", "Jaine", "Jan", "Jana", "Jane", "Janey", "Jania", "Janie", "Janna", "Jany", "Jayne", "Jean", "Jeana", "Jeane", "Jeanie", "Jeanna", "Jeanne", "Jeannie", "Jen", "Jena", "Jeni", "Jenn", "Jenna", "Jennee", "Jenni", "Jennie", "Jenny", "Jinny", "Jo Ann", "Jo-Ann", "Jo-Anne", "Joan", @@ -149,7 +149,7 @@ public void testIsMetaphoneEqualJohn() { */ @Test public void testIsMetaphoneEqualKnight() { - this.assertIsMetaphoneEqual("Knight", new String[] { "Hynda", "Nada", "Nadia", "Nady", "Nat", "Nata", "Natty", "Neda", "Nedda", "Nedi", "Netta", + assertIsMetaphoneEqual("Knight", new String[] { "Hynda", "Nada", "Nadia", "Nady", "Nat", "Nata", "Natty", "Neda", "Nedda", "Nedi", "Netta", "Netti", "Nettie", "Netty", "Nita", "Nydia" }); } @@ -158,7 +158,7 @@ public void testIsMetaphoneEqualKnight() { */ @Test public void testIsMetaphoneEqualMary() { - this.assertIsMetaphoneEqual("Mary", new String[] { "Mair", "Maire", "Mara", "Mareah", "Mari", "Maria", "Marie", "Mary", "Maura", "Maure", "Meara", + assertIsMetaphoneEqual("Mary", new String[] { "Mair", "Maire", "Mara", "Mareah", "Mari", "Maria", "Marie", "Mary", "Maura", "Maure", "Meara", "Merrie", "Merry", "Mira", "Moira", "Mora", "Moria", "Moyra", "Muire", "Myra", "Myrah" }); } @@ -167,7 +167,7 @@ public void testIsMetaphoneEqualMary() { */ @Test public void testIsMetaphoneEqualParis() { - this.assertIsMetaphoneEqual("Paris", new String[] { "Pearcy", "Perris", "Piercy", "Pierz", "Pryse" }); + assertIsMetaphoneEqual("Paris", new String[] { "Pearcy", "Perris", "Piercy", "Pierz", "Pryse" }); } /** @@ -175,7 +175,7 @@ public void testIsMetaphoneEqualParis() { */ @Test public void testIsMetaphoneEqualPeter() { - this.assertIsMetaphoneEqual("Peter", new String[] { "Peadar", "Peder", "Pedro", "Peter", "Petr", "Peyter", "Pieter", "Pietro", "Piotr" }); + assertIsMetaphoneEqual("Peter", new String[] { "Peadar", "Peder", "Pedro", "Peter", "Petr", "Peyter", "Pieter", "Pietro", "Piotr" }); } /** @@ -183,7 +183,7 @@ public void testIsMetaphoneEqualPeter() { */ @Test public void testIsMetaphoneEqualRay() { - this.assertIsMetaphoneEqual("Ray", new String[] { "Ray", "Rey", "Roi", "Roy", "Ruy" }); + assertIsMetaphoneEqual("Ray", new String[] { "Ray", "Rey", "Roi", "Roy", "Ruy" }); } /** @@ -191,7 +191,7 @@ public void testIsMetaphoneEqualRay() { */ @Test public void testIsMetaphoneEqualSusan() { - this.assertIsMetaphoneEqual("Susan", + assertIsMetaphoneEqual("Susan", new String[] { "Siusan", "Sosanna", "Susan", "Susana", "Susann", "Susanna", "Susannah", "Susanne", "Suzann", "Suzanna", "Suzanne", "Zuzana" }); } @@ -202,7 +202,7 @@ public void testIsMetaphoneEqualSusan() { */ @Test public void testIsMetaphoneEqualWhite() { - this.assertIsMetaphoneEqual("White", + assertIsMetaphoneEqual("White", new String[] { "Wade", "Wait", "Waite", "Wat", "Whit", "Wiatt", "Wit", "Wittie", "Witty", "Wood", "Woodie", "Woody" }); } @@ -213,7 +213,7 @@ public void testIsMetaphoneEqualWhite() { */ @Test public void testIsMetaphoneEqualWright() { - this.assertIsMetaphoneEqual("Wright", new String[] { "Rota", "Rudd", "Ryde" }); + assertIsMetaphoneEqual("Wright", new String[] { "Rota", "Rudd", "Ryde" }); } /** @@ -221,69 +221,69 @@ public void testIsMetaphoneEqualWright() { */ @Test public void testIsMetaphoneEqualXalan() { - this.assertIsMetaphoneEqual("Xalan", new String[] { "Celene", "Celina", "Celine", "Selena", "Selene", "Selina", "Seline", "Suellen", "Xylina" }); + assertIsMetaphoneEqual("Xalan", new String[] { "Celene", "Celina", "Celine", "Selena", "Selene", "Selina", "Seline", "Suellen", "Xylina" }); } @Test public void testMetaphone() { - assertEquals("HL", this.getStringEncoder().metaphone("howl")); - assertEquals("TSTN", this.getStringEncoder().metaphone("testing")); - assertEquals("0", this.getStringEncoder().metaphone("The")); - assertEquals("KK", this.getStringEncoder().metaphone("quick")); - assertEquals("BRN", this.getStringEncoder().metaphone("brown")); - assertEquals("FKS", this.getStringEncoder().metaphone("fox")); - assertEquals("JMPT", this.getStringEncoder().metaphone("jumped")); - assertEquals("OFR", this.getStringEncoder().metaphone("over")); - assertEquals("0", this.getStringEncoder().metaphone("the")); - assertEquals("LS", this.getStringEncoder().metaphone("lazy")); - assertEquals("TKS", this.getStringEncoder().metaphone("dogs")); + assertEquals("HL", getStringEncoder().metaphone("howl")); + assertEquals("TSTN", getStringEncoder().metaphone("testing")); + assertEquals("0", getStringEncoder().metaphone("The")); + assertEquals("KK", getStringEncoder().metaphone("quick")); + assertEquals("BRN", getStringEncoder().metaphone("brown")); + assertEquals("FKS", getStringEncoder().metaphone("fox")); + assertEquals("JMPT", getStringEncoder().metaphone("jumped")); + assertEquals("OFR", getStringEncoder().metaphone("over")); + assertEquals("0", getStringEncoder().metaphone("the")); + assertEquals("LS", getStringEncoder().metaphone("lazy")); + assertEquals("TKS", getStringEncoder().metaphone("dogs")); } @Test public void testPHTOF() { - assertEquals("FX", this.getStringEncoder().metaphone("PHISH")); + assertEquals("FX", getStringEncoder().metaphone("PHISH")); } @Test public void testSetMaxLengthWithTruncation() { // should be AKSKS, but istruncated by Max Code Length - this.getStringEncoder().setMaxCodeLen(6); - assertEquals("AKSKSK", this.getStringEncoder().metaphone("AXEAXEAXE")); + getStringEncoder().setMaxCodeLen(6); + assertEquals("AKSKSK", getStringEncoder().metaphone("AXEAXEAXE")); } @Test public void testSHAndSIOAndSIAToX() { - assertEquals("XT", this.getStringEncoder().metaphone("SHOT")); - assertEquals("OTXN", this.getStringEncoder().metaphone("ODSIAN")); - assertEquals("PLXN", this.getStringEncoder().metaphone("PULSION")); + assertEquals("XT", getStringEncoder().metaphone("SHOT")); + assertEquals("OTXN", getStringEncoder().metaphone("ODSIAN")); + assertEquals("PLXN", getStringEncoder().metaphone("PULSION")); } @Test public void testTCH() { - assertEquals("RX", this.getStringEncoder().metaphone("RETCH")); - assertEquals("WX", this.getStringEncoder().metaphone("WATCH")); + assertEquals("RX", getStringEncoder().metaphone("RETCH")); + assertEquals("WX", getStringEncoder().metaphone("WATCH")); } @Test public void testTIOAndTIAToX() { - assertEquals("OX", this.getStringEncoder().metaphone("OTIA")); - assertEquals("PRXN", this.getStringEncoder().metaphone("PORTION")); + assertEquals("OX", getStringEncoder().metaphone("OTIA")); + assertEquals("PRXN", getStringEncoder().metaphone("PORTION")); } @Test public void testTranslateOfSCHAndCH() { - assertEquals("SKTL", this.getStringEncoder().metaphone("SCHEDULE")); - assertEquals("SKMT", this.getStringEncoder().metaphone("SCHEMATIC")); + assertEquals("SKTL", getStringEncoder().metaphone("SCHEDULE")); + assertEquals("SKMT", getStringEncoder().metaphone("SCHEMATIC")); - assertEquals("KRKT", this.getStringEncoder().metaphone("CHARACTER")); - assertEquals("TX", this.getStringEncoder().metaphone("TEACH")); + assertEquals("KRKT", getStringEncoder().metaphone("CHARACTER")); + assertEquals("TX", getStringEncoder().metaphone("TEACH")); } @Test public void testTranslateToJOfDGEOrDGIOrDGY() { - assertEquals("TJ", this.getStringEncoder().metaphone("DODGY")); - assertEquals("TJ", this.getStringEncoder().metaphone("DODGE")); - assertEquals("AJMT", this.getStringEncoder().metaphone("ADGIEMTI")); + assertEquals("TJ", getStringEncoder().metaphone("DODGY")); + assertEquals("TJ", getStringEncoder().metaphone("DODGE")); + assertEquals("AJMT", getStringEncoder().metaphone("ADGIEMTI")); } /** @@ -292,19 +292,19 @@ public void testTranslateToJOfDGEOrDGIOrDGY() { @Test public void testWhy() { // PHP returns "H". The original metaphone returns an empty string. - assertEquals("", this.getStringEncoder().metaphone("WHY")); + assertEquals("", getStringEncoder().metaphone("WHY")); } @Test public void testWordEndingInMB() { - assertEquals("KM", this.getStringEncoder().metaphone("COMB")); - assertEquals("TM", this.getStringEncoder().metaphone("TOMB")); - assertEquals("WM", this.getStringEncoder().metaphone("WOMB")); + assertEquals("KM", getStringEncoder().metaphone("COMB")); + assertEquals("TM", getStringEncoder().metaphone("TOMB")); + assertEquals("WM", getStringEncoder().metaphone("WOMB")); } @Test public void testWordsWithCIA() { - assertEquals("XP", this.getStringEncoder().metaphone("CIAPO")); + assertEquals("XP", getStringEncoder().metaphone("CIAPO")); } public void validateFixture(final String[][] pairs) { diff --git a/src/test/java/org/apache/commons/codec/language/NysiisTest.java b/src/test/java/org/apache/commons/codec/language/NysiisTest.java index f50051e6f2..10f1d968c3 100644 --- a/src/test/java/org/apache/commons/codec/language/NysiisTest.java +++ b/src/test/java/org/apache/commons/codec/language/NysiisTest.java @@ -62,19 +62,19 @@ public void testBran() { @Test public void testCap() { - this.encodeAll(new String[] { "Capp", "Cope", "Copp", "Kipp" }, "CAP"); + encodeAll(new String[] { "Capp", "Cope", "Copp", "Kipp" }, "CAP"); } @Test public void testDad() { // Data Quality and Record Linkage Techniques P.121 claims this is DAN, // but it should be DAD, verified also with dropby.com - this.encodeAll(new String[] { "Dent" }, "DAD"); + encodeAll(new String[] { "Dent" }, "DAD"); } @Test public void testDan() { - this.encodeAll(new String[] { "Dane", "Dean", "Dionne" }, "DAN"); + encodeAll(new String[] { "Dane", "Dean", "Dionne" }, "DAN"); } /** @@ -87,7 +87,7 @@ public void testDropBy() { // prepended to the test string. The referenced rules refer to the outlined steps the // class description for Nysiis. - this.assertEncodings( + assertEncodings( // 1. Transcode first characters of name new String[] { "MACINTOSH", "MCANT" }, // violates 4j: the second N should not be added, as the first @@ -141,14 +141,14 @@ public void testDropBy() { @Test public void testFal() { - this.encodeAll(new String[] { "Phil" }, "FAL"); + encodeAll(new String[] { "Phil" }, "FAL"); } /** * Tests data gathered from around the internets.*/ @Test public void testOthers() { - this.assertEncodings( + assertEncodings( new String[] { "O'Daniel", "ODANAL" }, new String[] { "O'Donnel", "ODANAL" }, new String[] { "Cory", "CARY" }, @@ -162,7 +162,7 @@ public void testOthers() { * Tests rule 1: Translate first characters of name: MAC → MCC, KN → N, K → C, PH, PF → FF, SCH → SSS*/ @Test public void testRule1() { - this.assertEncodings( + assertEncodings( new String[] { "MACX", "MCX" }, new String[] { "KNX", "NX" }, new String[] { "KX", "CX" }, @@ -175,7 +175,7 @@ public void testRule1() { * Tests rule 2: Translate last characters of name: EE → Y, IE → Y, DT, RT, RD, NT, ND → D*/ @Test public void testRule2() { - this.assertEncodings( + assertEncodings( new String[] { "XEE", "XY" }, new String[] { "XIE", "XY" }, new String[] { "XDT", "XD" }, @@ -189,7 +189,7 @@ public void testRule2() { * Tests rule 4.1: EV → AF else A, E, I, O, U → A*/ @Test public void testRule4Dot1() { - this.assertEncodings( + assertEncodings( new String[] { "XEV", "XAF" }, new String[] { "XAX", "XAX" }, new String[] { "XEX", "XAX" }, @@ -202,7 +202,7 @@ public void testRule4Dot1() { * Tests rule 4.2: Q → G, Z → S, M → N*/ @Test public void testRule4Dot2() { - this.assertEncodings( + assertEncodings( new String[] { "XQ", "XG" }, new String[] { "XZ", "X" }, new String[] { "XM", "XN" }); @@ -212,7 +212,7 @@ public void testRule4Dot2() { * Tests rule 5: If last character is S, remove it.*/ @Test public void testRule5() { - this.assertEncodings( + assertEncodings( new String[] { "XS", "X" }, new String[] { "XSS", "X" }); } @@ -221,7 +221,7 @@ public void testRule5() { * Tests rule 6: If last characters are AY, replace with Y.*/ @Test public void testRule6() { - this.assertEncodings( + assertEncodings( new String[] { "XAY", "XY" }, new String[] { "XAYS", "XY" }); // Rules 5, 6 } @@ -230,7 +230,7 @@ public void testRule6() { * Tests rule 7: If last character is A, remove it.*/ @Test public void testRule7() { - this.assertEncodings( + assertEncodings( new String[] { "XA", "X" }, new String[] { "XAS", "X" }); // Rules 5, 7 } @@ -238,28 +238,28 @@ public void testRule7() { public void testSnad() { // Data Quality and Record Linkage Techniques P.121 claims this is SNAT, // but it should be SNAD - this.encodeAll(new String[] { "Schmidt" }, "SNAD"); + encodeAll(new String[] { "Schmidt" }, "SNAD"); } @Test public void testSnat() { - this.encodeAll(new String[] { "Smith", "Schmit" }, "SNAT"); + encodeAll(new String[] { "Smith", "Schmit" }, "SNAT"); } @Test public void testSpecialBranches() { - this.encodeAll(new String[] { "Kobwick" }, "CABWAC"); - this.encodeAll(new String[] { "Kocher" }, "CACAR"); - this.encodeAll(new String[] { "Fesca" }, "FASC"); - this.encodeAll(new String[] { "Shom" }, "SAN"); - this.encodeAll(new String[] { "Ohlo" }, "OL"); - this.encodeAll(new String[] { "Uhu" }, "UH"); - this.encodeAll(new String[] { "Um" }, "UN"); + encodeAll(new String[] { "Kobwick" }, "CABWAC"); + encodeAll(new String[] { "Kocher" }, "CACAR"); + encodeAll(new String[] { "Fesca" }, "FASC"); + encodeAll(new String[] { "Shom" }, "SAN"); + encodeAll(new String[] { "Ohlo" }, "OL"); + encodeAll(new String[] { "Uhu" }, "UH"); + encodeAll(new String[] { "Um" }, "UN"); } @Test public void testTranan() { - this.encodeAll(new String[] { "Trueman", "Truman" }, "TRANAN"); + encodeAll(new String[] { "Trueman", "Truman" }, "TRANAN"); } @Test diff --git a/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java b/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java index 5e5bbd73d8..20aa3dd157 100644 --- a/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java +++ b/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java @@ -36,38 +36,38 @@ protected RefinedSoundex createStringEncoder() { @Test public void testDifference() throws EncoderException { // Edge cases - assertEquals(0, this.getStringEncoder().difference(null, null)); - assertEquals(0, this.getStringEncoder().difference("", "")); - assertEquals(0, this.getStringEncoder().difference(" ", " ")); + assertEquals(0, getStringEncoder().difference(null, null)); + assertEquals(0, getStringEncoder().difference("", "")); + assertEquals(0, getStringEncoder().difference(" ", " ")); // Normal cases - assertEquals(6, this.getStringEncoder().difference("Smith", "Smythe")); - assertEquals(3, this.getStringEncoder().difference("Ann", "Andrew")); - assertEquals(1, this.getStringEncoder().difference("Margaret", "Andrew")); - assertEquals(1, this.getStringEncoder().difference("Janet", "Margaret")); + assertEquals(6, getStringEncoder().difference("Smith", "Smythe")); + assertEquals(3, getStringEncoder().difference("Ann", "Andrew")); + assertEquals(1, getStringEncoder().difference("Margaret", "Andrew")); + assertEquals(1, getStringEncoder().difference("Janet", "Margaret")); // Examples from // https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp - assertEquals(5, this.getStringEncoder().difference("Green", "Greene")); - assertEquals(1, this.getStringEncoder().difference("Blotchet-Halls", "Greene")); + assertEquals(5, getStringEncoder().difference("Green", "Greene")); + assertEquals(1, getStringEncoder().difference("Blotchet-Halls", "Greene")); // Examples from // https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_setu-sus_3o6w.asp - assertEquals(6, this.getStringEncoder().difference("Smith", "Smythe")); - assertEquals(8, this.getStringEncoder().difference("Smithers", "Smythers")); - assertEquals(5, this.getStringEncoder().difference("Anothers", "Brothers")); + assertEquals(6, getStringEncoder().difference("Smith", "Smythe")); + assertEquals(8, getStringEncoder().difference("Smithers", "Smythers")); + assertEquals(5, getStringEncoder().difference("Anothers", "Brothers")); } @Test public void testEncode() { - assertEquals("T6036084", this.getStringEncoder().encode("testing")); - assertEquals("T6036084", this.getStringEncoder().encode("TESTING")); - assertEquals("T60", this.getStringEncoder().encode("The")); - assertEquals("Q503", this.getStringEncoder().encode("quick")); - assertEquals("B1908", this.getStringEncoder().encode("brown")); - assertEquals("F205", this.getStringEncoder().encode("fox")); - assertEquals("J408106", this.getStringEncoder().encode("jumped")); - assertEquals("O0209", this.getStringEncoder().encode("over")); - assertEquals("T60", this.getStringEncoder().encode("the")); - assertEquals("L7050", this.getStringEncoder().encode("lazy")); - assertEquals("D6043", this.getStringEncoder().encode("dogs")); + assertEquals("T6036084", getStringEncoder().encode("testing")); + assertEquals("T6036084", getStringEncoder().encode("TESTING")); + assertEquals("T60", getStringEncoder().encode("The")); + assertEquals("Q503", getStringEncoder().encode("quick")); + assertEquals("B1908", getStringEncoder().encode("brown")); + assertEquals("F205", getStringEncoder().encode("fox")); + assertEquals("J408106", getStringEncoder().encode("jumped")); + assertEquals("O0209", getStringEncoder().encode("over")); + assertEquals("T60", getStringEncoder().encode("the")); + assertEquals("L7050", getStringEncoder().encode("lazy")); + assertEquals("D6043", getStringEncoder().encode("dogs")); // Testing CODEC-56 assertEquals("D6043", RefinedSoundex.US_ENGLISH.encode("dogs")); @@ -75,7 +75,7 @@ public void testEncode() { @Test public void testGetMappingCodeNonLetter() { - final char code = this.getStringEncoder().getMappingCode('#'); + final char code = getStringEncoder().getMappingCode('#'); assertEquals(0, code, "Code does not equals zero"); } diff --git a/src/test/java/org/apache/commons/codec/language/SoundexTest.java b/src/test/java/org/apache/commons/codec/language/SoundexTest.java index 3bb2f02c9a..1fd1297fca 100644 --- a/src/test/java/org/apache/commons/codec/language/SoundexTest.java +++ b/src/test/java/org/apache/commons/codec/language/SoundexTest.java @@ -41,7 +41,7 @@ protected Soundex createStringEncoder() { @Test public void testB650() throws EncoderException { - this.checkEncodingVariations("B650", new String[]{ + checkEncodingVariations("B650", new String[]{ "BARHAM", "BARONE", "BARRON", @@ -86,42 +86,42 @@ public void testB650() throws EncoderException { @Test public void testBadCharacters() { - assertEquals("H452", this.getStringEncoder().encode("HOL>MES")); + assertEquals("H452", getStringEncoder().encode("HOL>MES")); } @Test public void testDifference() throws EncoderException { // Edge cases - assertEquals(0, this.getStringEncoder().difference(null, null)); - assertEquals(0, this.getStringEncoder().difference("", "")); - assertEquals(0, this.getStringEncoder().difference(" ", " ")); + assertEquals(0, getStringEncoder().difference(null, null)); + assertEquals(0, getStringEncoder().difference("", "")); + assertEquals(0, getStringEncoder().difference(" ", " ")); // Normal cases - assertEquals(4, this.getStringEncoder().difference("Smith", "Smythe")); - assertEquals(2, this.getStringEncoder().difference("Ann", "Andrew")); - assertEquals(1, this.getStringEncoder().difference("Margaret", "Andrew")); - assertEquals(0, this.getStringEncoder().difference("Janet", "Margaret")); + assertEquals(4, getStringEncoder().difference("Smith", "Smythe")); + assertEquals(2, getStringEncoder().difference("Ann", "Andrew")); + assertEquals(1, getStringEncoder().difference("Margaret", "Andrew")); + assertEquals(0, getStringEncoder().difference("Janet", "Margaret")); // Examples from https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp - assertEquals(4, this.getStringEncoder().difference("Green", "Greene")); - assertEquals(0, this.getStringEncoder().difference("Blotchet-Halls", "Greene")); + assertEquals(4, getStringEncoder().difference("Green", "Greene")); + assertEquals(0, getStringEncoder().difference("Blotchet-Halls", "Greene")); // Examples from https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_setu-sus_3o6w.asp - assertEquals(4, this.getStringEncoder().difference("Smith", "Smythe")); - assertEquals(4, this.getStringEncoder().difference("Smithers", "Smythers")); - assertEquals(2, this.getStringEncoder().difference("Anothers", "Brothers")); + assertEquals(4, getStringEncoder().difference("Smith", "Smythe")); + assertEquals(4, getStringEncoder().difference("Smithers", "Smythers")); + assertEquals(2, getStringEncoder().difference("Anothers", "Brothers")); } @Test public void testEncodeBasic() { - assertEquals("T235", this.getStringEncoder().encode("testing")); - assertEquals("T000", this.getStringEncoder().encode("The")); - assertEquals("Q200", this.getStringEncoder().encode("quick")); - assertEquals("B650", this.getStringEncoder().encode("brown")); - assertEquals("F200", this.getStringEncoder().encode("fox")); - assertEquals("J513", this.getStringEncoder().encode("jumped")); - assertEquals("O160", this.getStringEncoder().encode("over")); - assertEquals("T000", this.getStringEncoder().encode("the")); - assertEquals("L200", this.getStringEncoder().encode("lazy")); - assertEquals("D200", this.getStringEncoder().encode("dogs")); + assertEquals("T235", getStringEncoder().encode("testing")); + assertEquals("T000", getStringEncoder().encode("The")); + assertEquals("Q200", getStringEncoder().encode("quick")); + assertEquals("B650", getStringEncoder().encode("brown")); + assertEquals("F200", getStringEncoder().encode("fox")); + assertEquals("J513", getStringEncoder().encode("jumped")); + assertEquals("O160", getStringEncoder().encode("over")); + assertEquals("T000", getStringEncoder().encode("the")); + assertEquals("L200", getStringEncoder().encode("lazy")); + assertEquals("D200", getStringEncoder().encode("dogs")); } /** @@ -129,22 +129,22 @@ public void testEncodeBasic() { */ @Test public void testEncodeBatch2() { - assertEquals("A462", this.getStringEncoder().encode("Allricht")); - assertEquals("E166", this.getStringEncoder().encode("Eberhard")); - assertEquals("E521", this.getStringEncoder().encode("Engebrethson")); - assertEquals("H512", this.getStringEncoder().encode("Heimbach")); - assertEquals("H524", this.getStringEncoder().encode("Hanselmann")); - assertEquals("H431", this.getStringEncoder().encode("Hildebrand")); - assertEquals("K152", this.getStringEncoder().encode("Kavanagh")); - assertEquals("L530", this.getStringEncoder().encode("Lind")); - assertEquals("L222", this.getStringEncoder().encode("Lukaschowsky")); - assertEquals("M235", this.getStringEncoder().encode("McDonnell")); - assertEquals("M200", this.getStringEncoder().encode("McGee")); - assertEquals("O155", this.getStringEncoder().encode("Opnian")); - assertEquals("O155", this.getStringEncoder().encode("Oppenheimer")); - assertEquals("R355", this.getStringEncoder().encode("Riedemanas")); - assertEquals("Z300", this.getStringEncoder().encode("Zita")); - assertEquals("Z325", this.getStringEncoder().encode("Zitzmeinn")); + assertEquals("A462", getStringEncoder().encode("Allricht")); + assertEquals("E166", getStringEncoder().encode("Eberhard")); + assertEquals("E521", getStringEncoder().encode("Engebrethson")); + assertEquals("H512", getStringEncoder().encode("Heimbach")); + assertEquals("H524", getStringEncoder().encode("Hanselmann")); + assertEquals("H431", getStringEncoder().encode("Hildebrand")); + assertEquals("K152", getStringEncoder().encode("Kavanagh")); + assertEquals("L530", getStringEncoder().encode("Lind")); + assertEquals("L222", getStringEncoder().encode("Lukaschowsky")); + assertEquals("M235", getStringEncoder().encode("McDonnell")); + assertEquals("M200", getStringEncoder().encode("McGee")); + assertEquals("O155", getStringEncoder().encode("Opnian")); + assertEquals("O155", getStringEncoder().encode("Oppenheimer")); + assertEquals("R355", getStringEncoder().encode("Riedemanas")); + assertEquals("Z300", getStringEncoder().encode("Zita")); + assertEquals("Z325", getStringEncoder().encode("Zitzmeinn")); } /** @@ -152,15 +152,15 @@ public void testEncodeBatch2() { */ @Test public void testEncodeBatch3() { - assertEquals("W252", this.getStringEncoder().encode("Washington")); - assertEquals("L000", this.getStringEncoder().encode("Lee")); - assertEquals("G362", this.getStringEncoder().encode("Gutierrez")); - assertEquals("P236", this.getStringEncoder().encode("Pfister")); - assertEquals("J250", this.getStringEncoder().encode("Jackson")); - assertEquals("T522", this.getStringEncoder().encode("Tymczak")); + assertEquals("W252", getStringEncoder().encode("Washington")); + assertEquals("L000", getStringEncoder().encode("Lee")); + assertEquals("G362", getStringEncoder().encode("Gutierrez")); + assertEquals("P236", getStringEncoder().encode("Pfister")); + assertEquals("J250", getStringEncoder().encode("Jackson")); + assertEquals("T522", getStringEncoder().encode("Tymczak")); // For VanDeusen: D-250 (D, 2 for the S, 5 for the N, 0 added) is also // possible. - assertEquals("V532", this.getStringEncoder().encode("VanDeusen")); + assertEquals("V532", getStringEncoder().encode("VanDeusen")); } /** @@ -168,20 +168,20 @@ public void testEncodeBatch3() { */ @Test public void testEncodeBatch4() { - assertEquals("H452", this.getStringEncoder().encode("HOLMES")); - assertEquals("A355", this.getStringEncoder().encode("ADOMOMI")); - assertEquals("V536", this.getStringEncoder().encode("VONDERLEHR")); - assertEquals("B400", this.getStringEncoder().encode("BALL")); - assertEquals("S000", this.getStringEncoder().encode("SHAW")); - assertEquals("J250", this.getStringEncoder().encode("JACKSON")); - assertEquals("S545", this.getStringEncoder().encode("SCANLON")); - assertEquals("S532", this.getStringEncoder().encode("SAINTJOHN")); + assertEquals("H452", getStringEncoder().encode("HOLMES")); + assertEquals("A355", getStringEncoder().encode("ADOMOMI")); + assertEquals("V536", getStringEncoder().encode("VONDERLEHR")); + assertEquals("B400", getStringEncoder().encode("BALL")); + assertEquals("S000", getStringEncoder().encode("SHAW")); + assertEquals("J250", getStringEncoder().encode("JACKSON")); + assertEquals("S545", getStringEncoder().encode("SCANLON")); + assertEquals("S532", getStringEncoder().encode("SAINTJOHN")); } @Test public void testEncodeIgnoreApostrophes() throws EncoderException { - this.checkEncodingVariations("O165", new String[]{ + checkEncodingVariations("O165", new String[]{ "OBrien", "'OBrien", "O'Brien", @@ -198,7 +198,7 @@ public void testEncodeIgnoreApostrophes() throws EncoderException { * @throws EncoderException for some failure scenarios */ @Test public void testEncodeIgnoreHyphens() throws EncoderException { - this.checkEncodingVariations("K525", new String[]{ + checkEncodingVariations("K525", new String[]{ "KINGSMITH", "-KINGSMITH", "K-INGSMITH", @@ -214,7 +214,7 @@ public void testEncodeIgnoreHyphens() throws EncoderException { @Test public void testEncodeIgnoreTrimmable() { - assertEquals("W252", this.getStringEncoder().encode(" \t\n\r Washington \t\n\r ")); + assertEquals("W252", getStringEncoder().encode(" \t\n\r Washington \t\n\r ")); } @Test @@ -240,10 +240,10 @@ public void testHWRuleEx1() { // http://www.archives.gov/research_room/genealogy/census/soundex.html: // Ashcraft is coded A-261 (A, 2 for the S, C ignored, 6 for the R, 1 // for the F). It is not coded A-226. - assertEquals("A261", this.getStringEncoder().encode("Ashcraft")); - assertEquals("A261", this.getStringEncoder().encode("Ashcroft")); - assertEquals("Y330", this.getStringEncoder().encode("yehudit")); - assertEquals("Y330", this.getStringEncoder().encode("yhwdyt")); + assertEquals("A261", getStringEncoder().encode("Ashcraft")); + assertEquals("A261", getStringEncoder().encode("Ashcroft")); + assertEquals("Y330", getStringEncoder().encode("yehudit")); + assertEquals("Y330", getStringEncoder().encode("yhwdyt")); } /** @@ -253,8 +253,8 @@ public void testHWRuleEx1() { */ @Test public void testHWRuleEx2() { - assertEquals("B312", this.getStringEncoder().encode("BOOTHDAVIS")); - assertEquals("B312", this.getStringEncoder().encode("BOOTH-DAVIS")); + assertEquals("B312", getStringEncoder().encode("BOOTHDAVIS")); + assertEquals("B312", getStringEncoder().encode("BOOTH-DAVIS")); } /** @@ -263,10 +263,10 @@ public void testHWRuleEx2() { * @throws EncoderException for some failure scenarios */ @Test public void testHWRuleEx3() throws EncoderException { - assertEquals("S460", this.getStringEncoder().encode("Sgler")); - assertEquals("S460", this.getStringEncoder().encode("Swhgler")); + assertEquals("S460", getStringEncoder().encode("Sgler")); + assertEquals("S460", getStringEncoder().encode("Swhgler")); // Also S460: - this.checkEncodingVariations("S460", new String[]{ + checkEncodingVariations("S460", new String[]{ "SAILOR", "SALYER", "SAYLOR", @@ -291,8 +291,8 @@ public void testHWRuleEx3() throws EncoderException { */ @Test public void testMsSqlServer1() { - assertEquals("S530", this.getStringEncoder().encode("Smith")); - assertEquals("S530", this.getStringEncoder().encode("Smythe")); + assertEquals("S530", getStringEncoder().encode("Smith")); + assertEquals("S530", getStringEncoder().encode("Smythe")); } /** @@ -303,7 +303,7 @@ public void testMsSqlServer1() { * @throws EncoderException for some failure scenarios */ @Test public void testMsSqlServer2() throws EncoderException { - this.checkEncodingVariations("E625", new String[]{"Erickson", "Erickson", "Erikson", "Ericson", "Ericksen", "Ericsen"}); + checkEncodingVariations("E625", new String[]{"Erickson", "Erickson", "Erikson", "Ericson", "Ericksen", "Ericsen"}); } /** @@ -311,15 +311,15 @@ public void testMsSqlServer2() throws EncoderException { */ @Test public void testMsSqlServer3() { - assertEquals("A500", this.getStringEncoder().encode("Ann")); - assertEquals("A536", this.getStringEncoder().encode("Andrew")); - assertEquals("J530", this.getStringEncoder().encode("Janet")); - assertEquals("M626", this.getStringEncoder().encode("Margaret")); - assertEquals("S315", this.getStringEncoder().encode("Steven")); - assertEquals("M240", this.getStringEncoder().encode("Michael")); - assertEquals("R163", this.getStringEncoder().encode("Robert")); - assertEquals("L600", this.getStringEncoder().encode("Laura")); - assertEquals("A500", this.getStringEncoder().encode("Anne")); + assertEquals("A500", getStringEncoder().encode("Ann")); + assertEquals("A536", getStringEncoder().encode("Andrew")); + assertEquals("J530", getStringEncoder().encode("Janet")); + assertEquals("M626", getStringEncoder().encode("Margaret")); + assertEquals("S315", getStringEncoder().encode("Steven")); + assertEquals("M240", getStringEncoder().encode("Michael")); + assertEquals("R163", getStringEncoder().encode("Robert")); + assertEquals("L600", getStringEncoder().encode("Laura")); + assertEquals("A500", getStringEncoder().encode("Anne")); } /** @@ -383,12 +383,12 @@ public void testUsEnglishStatic() { */ @Test public void testUsMappingEWithAcute() { - assertEquals("E000", this.getStringEncoder().encode("e")); + assertEquals("E000", getStringEncoder().encode("e")); if (Character.isLetter('\u00e9')) { // e-acute // uppercase E-acute assertThrows(IllegalArgumentException.class, () -> getStringEncoder().encode("\u00e9")); } else { - assertEquals("", this.getStringEncoder().encode("\u00e9")); + assertEquals("", getStringEncoder().encode("\u00e9")); } } @@ -399,12 +399,12 @@ public void testUsMappingEWithAcute() { */ @Test public void testUsMappingOWithDiaeresis() { - assertEquals("O000", this.getStringEncoder().encode("o")); + assertEquals("O000", getStringEncoder().encode("o")); if (Character.isLetter('\u00f6')) { // o-umlaut // uppercase O-umlaut assertThrows(IllegalArgumentException.class, () -> getStringEncoder().encode("\u00f6")); } else { - assertEquals("", this.getStringEncoder().encode("\u00f6")); + assertEquals("", getStringEncoder().encode("\u00f6")); } } @@ -413,11 +413,11 @@ public void testUsMappingOWithDiaeresis() { */ @Test public void testWikipediaAmericanSoundex() { - assertEquals("R163", this.getStringEncoder().encode("Robert")); - assertEquals("R163", this.getStringEncoder().encode("Rupert")); - assertEquals("A261", this.getStringEncoder().encode("Ashcraft")); - assertEquals("A261", this.getStringEncoder().encode("Ashcroft")); - assertEquals("T522", this.getStringEncoder().encode("Tymczak")); - assertEquals("P236", this.getStringEncoder().encode("Pfister")); + assertEquals("R163", getStringEncoder().encode("Robert")); + assertEquals("R163", getStringEncoder().encode("Rupert")); + assertEquals("A261", getStringEncoder().encode("Ashcraft")); + assertEquals("A261", getStringEncoder().encode("Ashcroft")); + assertEquals("T522", getStringEncoder().encode("Tymczak")); + assertEquals("P236", getStringEncoder().encode("Pfister")); } } diff --git a/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java b/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java index 3e4be391aa..6558cb08b1 100644 --- a/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java +++ b/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java @@ -189,7 +189,7 @@ public void testSetRuleTypeToRulesIllegalArgumentException() { */ @Test /* timeout = 20000L */ public void testSpeedCheck() throws EncoderException { - final BeiderMorseEncoder bmpm = this.createGenericApproxEncoder(); + final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); final StringBuilder stringBuffer = new StringBuilder(); stringBuffer.append(TEST_CHARS[0]); for (int i = 0, j = 1; i < 40; i++, j++) { @@ -203,7 +203,7 @@ public void testSpeedCheck() throws EncoderException { @Test public void testSpeedCheck2() throws EncoderException { - final BeiderMorseEncoder bmpm = this.createGenericApproxEncoder(); + final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); final String phrase = "ItstheendoftheworldasweknowitandIfeelfine"; for (int i = 1; i <= phrase.length(); i++) { @@ -213,7 +213,7 @@ public void testSpeedCheck2() throws EncoderException { @Test public void testSpeedCheck3() throws EncoderException { - final BeiderMorseEncoder bmpm = this.createGenericApproxEncoder(); + final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); final String phrase = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; for (int i = 1; i <= phrase.length(); i++) { diff --git a/src/test/java/org/apache/commons/codec/net/URLCodecTest.java b/src/test/java/org/apache/commons/codec/net/URLCodecTest.java index 2f6dcc39bc..c6d5b50e07 100644 --- a/src/test/java/org/apache/commons/codec/net/URLCodecTest.java +++ b/src/test/java/org/apache/commons/codec/net/URLCodecTest.java @@ -54,7 +54,7 @@ public void testBasicEncodeDecode() throws Exception { final String encoded = urlCodec.encode(plain); assertEquals("Hello+there%21", encoded, "Basic URL encoding test"); assertEquals(plain, urlCodec.decode(encoded), "Basic URL decoding test"); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -66,7 +66,7 @@ public void testDecodeInvalid() throws Exception { assertThrows(DecoderException.class, () -> urlCodec.decode("%WW")); // Bad 2nd char after % assertThrows(DecoderException.class, () -> urlCodec.decode("%0W")); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -79,7 +79,7 @@ public void testDecodeInvalidContent() throws DecoderException { for (int i = 0; i < input.length; i++) { assertEquals(input[i], output[i]); } - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -97,7 +97,7 @@ public void testDecodeObjects() throws Exception { assertNull(result, "Decoding a null Object should return null"); assertThrows(DecoderException.class, () -> urlCodec.decode(Double.valueOf(3.0d)), "Trying to url encode a Double object should cause an exception."); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -123,7 +123,7 @@ public void testDefaultEncoding() throws Exception { final String encoded1 = urlCodec.encode(plain, "UnicodeBig"); final String encoded2 = urlCodec.encode(plain); assertEquals(encoded1, encoded2); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -131,7 +131,7 @@ public void testEncodeDecodeNull() throws Exception { final URLCodec urlCodec = new URLCodec(); assertNull(urlCodec.encode((String) null), "Null string URL encoding test"); assertNull(urlCodec.decode((String) null), "Null string URL decoding test"); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -140,7 +140,7 @@ public void testEncodeNull() throws Exception { final byte[] plain = null; final byte[] encoded = urlCodec.encode(plain); assertNull(encoded, "Encoding a null string should return null"); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -159,7 +159,7 @@ public void testEncodeObjects() throws Exception { assertNull(result, "Encoding a null Object should return null"); assertThrows(EncoderException.class, () -> urlCodec.encode(Double.valueOf(3.0d)), "Trying to url encode a Double object should cause an exception."); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -177,7 +177,7 @@ public void testEncodeUrlWithNullBitSet() throws Exception { final String encoded = new String(URLCodec.encodeUrl(null, plain.getBytes(StandardCharsets.UTF_8))); assertEquals("Hello+there%21", encoded, "Basic URL encoding test"); assertEquals(plain, urlCodec.decode(encoded), "Basic URL decoding test"); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -186,7 +186,7 @@ public void testInvalidEncoding() { final String plain = "Hello there!"; assertThrows(EncoderException.class, () -> urlCodec.encode(plain), "We set the encoding to a bogus NONSENSE value"); assertThrows(DecoderException.class, () -> urlCodec.decode(plain), "We set the encoding to a bogus NONSENSE value"); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -196,7 +196,7 @@ public void testSafeCharEncodeDecode() throws Exception { final String encoded = urlCodec.encode(plain); assertEquals(plain, encoded, "Safe chars URL encoding test"); assertEquals(plain, urlCodec.decode(encoded), "Safe chars URL decoding test"); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -206,7 +206,7 @@ public void testUnsafeEncodeDecode() throws Exception { final String encoded = urlCodec.encode(plain); assertEquals("%7E%21%40%23%24%25%5E%26%28%29%2B%7B%7D%22%5C%3B%3A%60%2C%2F%5B%5D", encoded, "Unsafe chars URL encoding test"); assertEquals(plain, urlCodec.decode(encoded), "Unsafe chars URL decoding test"); - this.validateState(urlCodec); + validateState(urlCodec); } @Test @@ -216,14 +216,14 @@ public void testUTF8RoundTrip() throws Exception { final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE); final URLCodec urlCodec = new URLCodec(); - this.validateState(urlCodec); + validateState(urlCodec); assertEquals("%D0%92%D1%81%D0%B5%D0%BC_%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82", urlCodec.encode(ru_msg, CharEncoding.UTF_8)); assertEquals("Gr%C3%BCezi_z%C3%A4m%C3%A4", urlCodec.encode(ch_msg, CharEncoding.UTF_8)); assertEquals(ru_msg, urlCodec.decode(urlCodec.encode(ru_msg, CharEncoding.UTF_8), CharEncoding.UTF_8)); assertEquals(ch_msg, urlCodec.decode(urlCodec.encode(ch_msg, CharEncoding.UTF_8), CharEncoding.UTF_8)); - this.validateState(urlCodec); + validateState(urlCodec); } private void validateState(final URLCodec urlCodec) {