Skip to content

Commit

Permalink
IBANValidatorTest: parameterise SWIFT registry version; update to v99
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed Dec 20, 2024
1 parent 5a27e11 commit 47c6acb
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 68 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<artifactId>apache-rat-plugin</artifactId>
<configuration>
<excludes combine.children="append">
<exclude>src/test/resources/org/apache/commons/validator/routines/iban_registry_v98.txt</exclude>
<exclude>src/test/resources/org/apache/commons/validator/routines/iban_registry_v*.txt</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="sebb" issue="VALIDATOR-495" due-to="Slawomir Jaranowski">IBANValidator: add Yemen.</action>
<action type="update" dev="ggregory" due-to="Leonard Wicke, Gary Gregory">Add IBANValidator.Validator.getIbanLength().</action>
<!-- UPDATE -->
<action type="update" dev="sebb">IBANValidatorTest: parameterise SWIFT registry version; update to v99</action>
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.apache.commons:commons-parent from 70 to 78 #231, #245, #253, #256, #262, #267, #272, #278.</action>
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump commons-logging:commons-logging from 1.3.2 to 1.3.4 #238, #254.</action>
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.apache.commons:commons-lang3 from 3.15.0 to 3.17.0 #248, #257.</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class IBANValidatorTest {
private static final Pattern IBAN_PAT = Pattern
.compile(IBAN_PART + IBAN_PART + IBAN_PART + IBAN_PART + "?" + IBAN_PART + "?" + IBAN_PART + "?" + IBAN_PART + "?");

private static final String IBAN_REGISTRY = "iban_registry_v99.txt";

// It's not clear whether IBANs can contain lower case characters
// so we test for both where possible
// Note that the BIC near the start of the code is always upper case or digits
Expand Down Expand Up @@ -249,11 +251,11 @@ private static String formatToRE(final String type, final int len) {
}
}

static Collection<Arguments> ibanRegistryV98Source() throws Exception {
final Path ibanRegistryV98 = Paths.get(IBANValidator.class.getResource("iban_registry_v98.txt").toURI());
static Collection<Arguments> ibanRegistrySource() throws Exception {
final Path ibanRegistry = Paths.get(IBANValidator.class.getResource(IBAN_REGISTRY).toURI());

final CSVFormat format = CSVFormat.DEFAULT.builder().setDelimiter('\t').build();
final Reader rdr = Files.newBufferedReader(ibanRegistryV98, StandardCharsets.ISO_8859_1);
final Reader rdr = Files.newBufferedReader(ibanRegistry, StandardCharsets.ISO_8859_1);

CSVRecord country = null;
CSVRecord cc = null;
Expand Down Expand Up @@ -307,11 +309,11 @@ static Collection<Arguments> ibanRegistryV98Source() throws Exception {
return result;
}

static Collection<Arguments> ibanRegistryV98SourceExamples() throws Exception {
final Path ibanRegistryV98 = Paths.get(IBANValidator.class.getResource("iban_registry_v98.txt").toURI());
static Collection<Arguments> ibanRegistrySourceExamples() throws Exception {
final Path ibanRegistry = Paths.get(IBANValidator.class.getResource(IBAN_REGISTRY).toURI());

final CSVFormat format = CSVFormat.DEFAULT.builder().setDelimiter('\t').build();
final Reader rdr = Files.newBufferedReader(ibanRegistryV98, StandardCharsets.ISO_8859_1);
final Reader rdr = Files.newBufferedReader(ibanRegistry, StandardCharsets.ISO_8859_1);

CSVRecord country = null;
CSVRecord electronicExample = null;
Expand Down Expand Up @@ -344,7 +346,7 @@ static Collection<Arguments> ibanRegistryV98SourceExamples() throws Exception {
}

@ParameterizedTest
@MethodSource("ibanRegistryV98SourceExamples")
@MethodSource("ibanRegistrySourceExamples")
public void exampleAccountsShouldBeValid(final String countryName, final String example) {
Assumptions.assumeFalse(INVALID_IBAN_FIXTURES.contains(example), "Skip invalid example: " + example + " for " + countryName);
assertTrue(IBANValidator.getInstance().isValid(example), "IBAN validator returned false for " + example + " for " + countryName);
Expand Down Expand Up @@ -440,7 +442,7 @@ public void testValid(final String iban) {
}

@ParameterizedTest
@MethodSource("ibanRegistryV98Source")
@MethodSource("ibanRegistrySource")
public void validatorShouldExistWithProperConfiguration(final String countryName, final String countryCode, final List<String> acountyCode, final int ibanLength, final String structure) throws Exception {
final String countryInfo = " countryCode: " + countryCode + ", countryName: " + countryName;
final Validator validator = IBANValidator.getInstance().getValidator(countryCode);
Expand Down
Loading

0 comments on commit 47c6acb

Please sign in to comment.