Skip to content

Commit

Permalink
GH-56: JAXB Upgrade Plan, Migration to Jakarta EE 10, Migration to Ja…
Browse files Browse the repository at this point in the history
…va 11 (#153)

* Migration to Java 11
* Migration to Jakarta EE 10
---------

Co-authored-by: Nicolas Filotto <nfilotto@talend.com>
Co-authored-by: ptorres-prowide <90214684+ptorres-prowide@users.noreply.github.com>
Co-authored-by: ptorres-prowide <pablo.torres@prowidesoftware.com>
  • Loading branch information
4 people committed Jun 5, 2023
1 parent 943eb67 commit 9e6b724
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 58 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ dependencies {
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.code.gson:gson:2.9.0'

compileOnly 'javax.persistence:javax.persistence-api:2.2'
compileOnly 'javax.xml.bind:jaxb-api:2.3.1'
compileOnly 'javax.validation:validation-api:2.0.1.Final'
compileOnly 'jakarta.persistence:jakarta.persistence-api:3.1.0'
compileOnly 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
compileOnly 'jakarta.validation:jakarta.validation-api:3.0.2'

testImplementation 'javax.persistence:javax.persistence-api:2.2'
testImplementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
testImplementation('org.junit.jupiter:junit-jupiter:5.8.2')
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.22.0'
testImplementation group: 'org.xmlunit', name: 'xmlunit-core', version: '2.9.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import static java.lang.annotation.ElementType.*;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

/**
* Bean validation for BIC numbers.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

import com.prowidesoftware.swift.model.BIC;
import com.prowidesoftware.swift.model.BicValidationResult;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
* Implementation of the BIC validation constraint
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import static java.lang.annotation.ElementType.*;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

/**
* Bean validation for ISO Alpha-2 country codes.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
package com.prowidesoftware.swift.constraints;

import com.prowidesoftware.swift.utils.IsoUtils;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
* Implementation of the ISO Alpha-2 country validation constraint
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import static java.lang.annotation.ElementType.*;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

/**
* Bean validation for ISO currency codes.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
package com.prowidesoftware.swift.constraints;

import com.prowidesoftware.swift.utils.IsoUtils;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
* Implementation of the ISO currency code validation constraint
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import static java.lang.annotation.ElementType.*;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

/**
* Bean validation for IBAN numbers.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

import com.prowidesoftware.swift.model.IBAN;
import com.prowidesoftware.swift.model.IbanValidationResult;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
* Implementation of the IBAN validation constraint
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.prowidesoftware.deprecation.ProwideDeprecated;
import com.prowidesoftware.deprecation.TargetYear;
import com.prowidesoftware.swift.utils.Lib;
import jakarta.persistence.*;
import jakarta.xml.bind.annotation.XmlTransient;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
Expand All @@ -33,9 +35,6 @@
import java.text.NumberFormat;
import java.util.*;

import javax.persistence.*;
import javax.xml.bind.annotation.XmlTransient;

/**
* Base entity for MT and MX message persistence.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt.DefaultMtMetadataStrategy;
import com.prowidesoftware.swift.model.mt.MTVariant;
import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
Expand All @@ -36,10 +39,6 @@
import java.util.Optional;
import java.util.logging.Level;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;


/**
* MT messages entity for JPA persistence.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package com.prowidesoftware.swift.model;

import java.util.Calendar;
import jakarta.persistence.*;

import javax.persistence.*;
import java.util.Calendar;

/**
* Comments associated to a message for application only usage (not part of the standard).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package com.prowidesoftware.swift.model;

import static javax.persistence.FetchType.LAZY;
import static jakarta.persistence.FetchType.LAZY;

import jakarta.persistence.*;

import java.util.Calendar;
import java.util.Objects;

import javax.persistence.*;

/**
* A revision is a snapshot of message content and is used to track the history of changes in a message.
* Applications may use to store revisions each time a message is edited.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package com.prowidesoftware.swift.model;

import static javax.persistence.FetchType.LAZY;
import static jakarta.persistence.FetchType.LAZY;

import jakarta.persistence.*;

import java.util.Calendar;
import java.util.Objects;

import javax.persistence.*;

/**
* Status tracking record for application only usage (not part of the standard).<br>
* The status name identifier is modeled with plain String, nevertheless
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public void testSimpleBlockConsumerBlock3_3_KnownToFail() throws IOException {
assertEquals("00112233", b.getTagValue("108"));
assertTrue(b.containsTag("4"));
assertEquals("foobar", b.getTagValue("4"));
assertEquals(b.getUnparsedTextsSize(), new Integer(1));
assertEquals(b.getUnparsedTextsSize(), Integer.valueOf(1));
assertEquals(b.unparsedTextGetText(0), "blockdata");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void test_staticIsMessage() {
@Test
public void test_addText() {
t.addText(someText);
assertEquals(t.size(), new Integer(1));
assertEquals(t.size(), Integer.valueOf(1));
assertEquals(t.getText(0), someText);
}

Expand All @@ -72,9 +72,9 @@ public void test_isMessage() {

@Test
public void test_size() {
assertEquals(t.size(), new Integer(0));
assertEquals(t.size(), Integer.valueOf(0));
t.addText(someText);
assertEquals(t.size(), new Integer(1));
assertEquals(t.size(), Integer.valueOf(1));
}

@Test
Expand Down Expand Up @@ -113,7 +113,7 @@ public void test_addTextMessage() {
t.addText(msg);

// check things out
assertEquals(t.size(), new Integer(1));
assertEquals(t.size(), Integer.valueOf(1));
assertEquals(t.getText(0), msgString);
}

Expand All @@ -123,7 +123,7 @@ public void test_removeIndexOK() {
t.addText(someMsg);
t.removeText(0);
assertEquals(t.getText(0), someMsg);
assertEquals(t.size(), new Integer(1));
assertEquals(t.size(), Integer.valueOf(1));
}

@Test
Expand All @@ -137,7 +137,7 @@ public void test_removeText() {
t.addText(someMsg);
t.removeText(someText);
assertEquals(t.getText(0), someMsg);
assertEquals(t.size(), new Integer(1));
assertEquals(t.size(), Integer.valueOf(1));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void test() throws Exception {
int missing = 0;
int availableOK = 0;
int availableError = 0;
for (Class c : classes) {
Field f = (Field) c.newInstance();
for (Class<?> c : classes) {
Field f = (Field) c.getDeclaredConstructor().newInstance();
int size = f.getComponents().size();
final String label = Field.getLabelComponents(f.getName(), null, null, null);
if (label.endsWith(".components")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ public void testGetNumber() {
//this test does not work but this format is not used

assertNotNull(SwiftFormatUtils.getNumber("1,2"));
assertEquals(new Double(1.2), new Double(SwiftFormatUtils.getNumber("1,2").doubleValue()));
assertEquals(Double.valueOf(1.2), Double.valueOf(SwiftFormatUtils.getNumber("1,2").doubleValue()));

assertNotNull(SwiftFormatUtils.getNumber("12,34"));
assertEquals(new Double(12.34), new Double(SwiftFormatUtils.getNumber("12,34").doubleValue()));
assertEquals(Double.valueOf(12.34), Double.valueOf(SwiftFormatUtils.getNumber("12,34").doubleValue()));

assertNotNull(SwiftFormatUtils.getNumber("12,3456"));
assertEquals(new Double(12.3456), new Double(SwiftFormatUtils.getNumber("12,3456").doubleValue()));
assertEquals(Double.valueOf(12.3456), Double.valueOf(SwiftFormatUtils.getNumber("12,3456").doubleValue()));

assertNotNull(SwiftFormatUtils.getNumber("0,"));
assertEquals(new Double(0), new Double(SwiftFormatUtils.getNumber("0,").doubleValue()));
assertEquals(Double.valueOf(0), Double.valueOf(SwiftFormatUtils.getNumber("0,").doubleValue()));

assertNotNull(SwiftFormatUtils.getNumber("299000,34"));
assertEquals(new Double(299000.34), new Double(SwiftFormatUtils.getNumber("299000,34").doubleValue()));
assertEquals(Double.valueOf(299000.34), Double.valueOf(SwiftFormatUtils.getNumber("299000,34").doubleValue()));

assertNotNull(SwiftFormatUtils.getNumber(",34"));
assertEquals(new Double(0.34), new Double(SwiftFormatUtils.getNumber(",34").doubleValue()));
assertEquals(Double.valueOf(0.34), Double.valueOf(SwiftFormatUtils.getNumber(",34").doubleValue()));
}

@Test
Expand Down

0 comments on commit 9e6b724

Please sign in to comment.