Skip to content

Commit d2e24e9

Browse files
authored
Upgrade to Jakarta 10 (#48)
* Upgrade to Jakarta 10 * Update JAXB plugin to Jakarta spec 3.0 * Explicit namespace prefixes for XJC generated Netlicensing classes * Use JDK http client, drop Jersey dependency * Migrate to JUnit5 * Update dependencies
1 parent e73aa70 commit d2e24e9

64 files changed

Lines changed: 861 additions & 763 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/netlicesning-client-ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ jobs:
2424
# TODO(2K): This can be better solved by preparing a custom image for the container.
2525
MAVEN_OPTS: -Duser.home=/github/home
2626
strategy:
27+
fail-fast: false
2728
matrix:
2829
java-version: [11, 17]
2930
include:
3031
- java-version: 11
31-
jdk-suffix:
32+
jdk-suffix: ""
3233
- java-version: 17
3334
jdk-suffix: -jdk17
3435

NetLicensingClient-demo/pom.xml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
<artifact>*:*</artifact>
3636
<excludes>
3737
<exclude>module-info.class</exclude>
38-
<exclude>META-INF/*.SF</exclude>
39-
<exclude>META-INF/*.DSA</exclude>
40-
<exclude>META-INF/*.RSA</exclude>
38+
<exclude>META-INF/**</exclude>
39+
<exclude>LICENSE</exclude>
40+
<exclude>NOTICE</exclude>
4141
</excludes>
4242
</filter>
4343
</filters>
@@ -69,6 +69,11 @@
6969
<artifactId>netlicensing-client</artifactId>
7070
<version>${project.version}</version>
7171
</dependency>
72+
<!-- com.helger.ph-xmldsig is using slf4j, avoid warning for no provider -->
73+
<dependency>
74+
<groupId>org.slf4j</groupId>
75+
<artifactId>slf4j-nop</artifactId>
76+
</dependency>
7277
<dependency>
7378
<groupId>commons-io</groupId>
7479
<artifactId>commons-io</artifactId>
@@ -77,9 +82,12 @@
7782
<groupId>commons-cli</groupId>
7883
<artifactId>commons-cli</artifactId>
7984
</dependency>
85+
86+
<!-- Testing framework dependencies -->
8087
<dependency>
81-
<groupId>junit</groupId>
82-
<artifactId>junit</artifactId>
88+
<groupId>org.junit.jupiter</groupId>
89+
<artifactId>junit-jupiter</artifactId>
90+
<scope>test</scope>
8391
</dependency>
8492
</dependencies>
8593

NetLicensingClient-demo/src/main/java/com/labs64/netlicensing/examples/OfflineValidation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import java.io.IOException;
44
import java.io.StringReader;
55

6-
import javax.xml.bind.JAXBContext;
7-
import javax.xml.bind.JAXBException;
8-
import javax.xml.bind.Unmarshaller;
6+
import jakarta.xml.bind.JAXBContext;
7+
import jakarta.xml.bind.JAXBException;
8+
import jakarta.xml.bind.Unmarshaller;
99

1010
import com.labs64.netlicensing.domain.vo.Context;
1111
import com.labs64.netlicensing.domain.vo.MetaInfo;

NetLicensingClient-demo/src/test/java/com/labs64/netlicensing/examples/RunExamples.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.labs64.netlicensing.examples;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
public class RunExamples {
66

NetLicensingClient/pom.xml

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@
1616

1717
<dependencies>
1818
<dependency>
19-
<groupId>org.glassfish.jersey.core</groupId>
20-
<artifactId>jersey-client</artifactId>
21-
</dependency>
22-
<dependency> <!-- from 2.16 on: https://jersey.java.net/documentation/latest/migration.html#mig-2.16 -->
23-
<groupId>org.glassfish.jersey.media</groupId>
24-
<artifactId>jersey-media-jaxb</artifactId>
19+
<groupId>com.helger</groupId>
20+
<artifactId>ph-xmldsig</artifactId>
2521
</dependency>
26-
<dependency><!-- from 2.26 on: https://github.com/jersey/jersey/issues/3584 -->
27-
<groupId>org.glassfish.jersey.inject</groupId>
28-
<artifactId>jersey-hk2</artifactId>
22+
<dependency>
23+
<groupId>com.sun.xml.bind</groupId>
24+
<artifactId>jaxb-impl</artifactId>
2925
</dependency>
3026
<dependency>
3127
<groupId>org.apache.commons</groupId>
@@ -35,44 +31,42 @@
3531
<groupId>org.apache.commons</groupId>
3632
<artifactId>commons-collections4</artifactId>
3733
</dependency>
34+
35+
<!-- Testing framework dependencies -->
3836
<dependency>
39-
<groupId>org.apache.commons</groupId>
40-
<artifactId>commons-text</artifactId>
37+
<groupId>org.junit.jupiter</groupId>
38+
<artifactId>junit-jupiter</artifactId>
4139
<scope>test</scope>
4240
</dependency>
4341
<dependency>
44-
<groupId>commons-io</groupId>
45-
<artifactId>commons-io</artifactId>
42+
<groupId>org.glassfish.jersey.test-framework</groupId>
43+
<artifactId>jersey-test-framework-core</artifactId>
4644
<scope>test</scope>
4745
</dependency>
48-
<!--Support JAXB in Java 9 +-->
49-
<dependency>
50-
<groupId>org.glassfish.jaxb</groupId>
51-
<artifactId>jaxb-runtime</artifactId>
52-
</dependency>
5346
<dependency>
54-
<groupId>org.apache.logging.log4j</groupId>
55-
<artifactId>log4j-api</artifactId>
47+
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
48+
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
49+
<scope>test</scope>
5650
</dependency>
5751
<dependency>
58-
<groupId>junit</groupId>
59-
<artifactId>junit</artifactId>
52+
<groupId>org.glassfish.jersey.inject</groupId>
53+
<artifactId>jersey-hk2</artifactId>
6054
<scope>test</scope>
6155
</dependency>
6256
<dependency>
63-
<groupId>com.helger</groupId>
64-
<artifactId>ph-xmldsig</artifactId>
57+
<groupId>org.apache.commons</groupId>
58+
<artifactId>commons-text</artifactId>
59+
<scope>test</scope>
6560
</dependency>
66-
67-
<!-- Testing framework dependencies -->
6861
<dependency>
69-
<groupId>org.glassfish.jersey.test-framework</groupId>
70-
<artifactId>jersey-test-framework-core</artifactId>
62+
<groupId>commons-io</groupId>
63+
<artifactId>commons-io</artifactId>
7164
<scope>test</scope>
7265
</dependency>
66+
<!-- com.helger.ph-xmldsig is using slf4j, avoid warning for no provider -->
7367
<dependency>
74-
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
75-
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
68+
<groupId>org.slf4j</groupId>
69+
<artifactId>slf4j-nop</artifactId>
7670
<scope>test</scope>
7771
</dependency>
7872
</dependencies>
@@ -93,10 +87,10 @@
9387
</instructions>
9488
</configuration>
9589
</plugin>
96-
<!-- Maven JAXB2 Plugin Documentation : https://confluence.highsource.org/x/HgBJ -->
90+
<!-- Maven JAXB2 Plugin Documentation : https://github.com/highsource/jaxb-tools/wiki/Using-JAXB2-Basics-Plugins -->
9791
<plugin>
98-
<groupId>org.jvnet.jaxb2.maven2</groupId>
99-
<artifactId>maven-jaxb2-plugin</artifactId>
92+
<groupId>org.jvnet.jaxb</groupId>
93+
<artifactId>jaxb-maven-plugin</artifactId>
10094
<executions>
10195
<execution>
10296
<goals>
@@ -114,20 +108,20 @@
114108
Please refer to the following link for more information:
115109
https://github.com/highsource/maven-jaxb2-plugin/wiki/Catalogs-in-Strict-Mode -->
116110
<strict>false</strict>
117-
<!-- see also https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-89 -->
118111
<bindingDirectory>src/main/resources</bindingDirectory>
119112
<bindingIncludes>
120113
<bindingInclude>nlic-schema-bindings.xjb</bindingInclude>
121114
</bindingIncludes>
122-
<specVersion>2.1</specVersion>
115+
<specVersion>3.0</specVersion>
123116
<extension>true</extension>
124117
<args>
125118
<arg>-Xvalue-constructor</arg>
119+
<arg>-Xnamespace-prefix</arg>
126120
</args>
127121
<plugins>
128122
<plugin>
129-
<groupId>org.jvnet.jaxb2_commons</groupId>
130-
<artifactId>jaxb2-value-constructor</artifactId>
123+
<groupId>org.jvnet.jaxb</groupId>
124+
<artifactId>jaxb-plugins</artifactId>
131125
</plugin>
132126
</plugins>
133127
</configuration>

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/BaseEntity.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import java.io.Serializable;
1616
import java.util.Map;
1717

18-
import javax.ws.rs.core.Form;
19-
2018
/**
2119
* Defines properties common to all (or most) of other entities.
2220
*/
@@ -39,13 +37,6 @@ public interface BaseEntity extends Serializable {
3937
void addProperty(String property, String value);
4038

4139
void removeProperty(final String property);
42-
43-
/**
44-
* Converts properties of the entity to the body of POST request
45-
*
46-
* @return object that represents HTML form data request encoded using the "application/x-www-form-urlencoded"
47-
* content type
48-
*/
49-
Form asRequestForm();
50-
40+
41+
Map<String, Object> asMap();
5142
}

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/impl/BaseEntityImpl.java

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@
1313
package com.labs64.netlicensing.domain.entity.impl;
1414

1515
import java.util.ArrayList;
16-
import java.util.Collection;
1716
import java.util.HashMap;
1817
import java.util.List;
1918
import java.util.Map;
20-
import java.util.Map.Entry;
21-
22-
import javax.ws.rs.core.Form;
23-
import javax.ws.rs.core.MultivaluedHashMap;
24-
import javax.ws.rs.core.MultivaluedMap;
2519

2620
import com.labs64.netlicensing.domain.Constants;
2721
import com.labs64.netlicensing.domain.entity.BaseEntity;
@@ -95,51 +89,35 @@ public void removeProperty(final String property) {
9589

9690
@Override
9791
public String toString() {
98-
return toString(asPropertiesMap());
92+
return toString(asMap());
9993
}
100-
94+
10195
@Override
102-
public Form asRequestForm() {
103-
final Form form = new Form();
104-
for (final Entry<String, List<Object>> prop : asPropertiesMap().entrySet()) {
105-
for (final Object value : prop.getValue()) {
106-
if (value != null) {
107-
form.param(prop.getKey(), value.toString());
108-
}
109-
}
110-
}
111-
return form;
112-
}
113-
114-
protected MultivaluedMap<String, Object> asPropertiesMap() {
115-
final MultivaluedMap<String, Object> map = new MultivaluedHashMap<>();
116-
map.add(Constants.NUMBER, getNumber());
117-
map.add(Constants.ACTIVE, getActive());
96+
public Map<String, Object> asMap() {
97+
final Map<String, Object> map = new HashMap<>();
98+
map.put(Constants.NUMBER, getNumber());
99+
map.put(Constants.ACTIVE, getActive());
118100
if (properties != null) {
119101
for (final Map.Entry<String, String> lp : properties.entrySet()) {
120-
map.add(lp.getKey(), lp.getValue());
102+
map.put(lp.getKey(), lp.getValue());
121103
}
122104
}
123105
return map;
124106
}
125107

126-
protected String toString(final MultivaluedMap<String, Object> propMap) {
108+
protected String toString(final Map<String, Object> propMap) {
127109
final StringBuilder builder = new StringBuilder(this.getClass().getSimpleName());
128110
builder.append(" [");
129111
boolean firstProp = true;
130112
for (final String propKey : propMap.keySet()) {
131113
final Object propValue = propMap.get(propKey);
132-
if ((propValue != null) && (!(propValue instanceof Collection<?>) || (((Collection<?>) propValue).size() > 0))) {
114+
if (propValue != null) {
133115
builder.append(firstProp ? "" : ", ");
134116
firstProp = false;
135117

136118
builder.append(propKey).append("=");
137-
if (propValue instanceof Collection<?>) {
138-
builder.append(propValue.toString());
139-
} else {
140-
final String propValueStr = String.valueOf(propValue);
141-
builder.append(propValueStr.length() > 50 ? propValueStr.substring(0, 50) : propValue);
142-
}
119+
final String propValueStr = String.valueOf(propValue);
120+
builder.append(propValueStr.length() > 50 ? propValueStr.substring(0, 50) : propValue);
143121
}
144122
}
145123
return builder.append("]").toString();

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/impl/BundleImpl.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
import java.math.BigDecimal;
44
import java.util.ArrayList;
55
import java.util.List;
6-
7-
import javax.ws.rs.core.MultivaluedMap;
6+
import java.util.Map;
87

98
import com.labs64.netlicensing.domain.Constants;
109
import com.labs64.netlicensing.domain.entity.Bundle;
1110
import com.labs64.netlicensing.domain.vo.Currency;
1211

1312
public class BundleImpl extends BaseEntityImpl implements Bundle {
13+
14+
private static final long serialVersionUID = -1666422065511383898L;
15+
1416
private String name;
1517

1618
private String description;
@@ -100,19 +102,19 @@ public static List<String> getReservedProps() {
100102
}
101103

102104
@Override
103-
protected MultivaluedMap<String, Object> asPropertiesMap() {
104-
final MultivaluedMap<String, Object> map = super.asPropertiesMap();
105-
map.add(Constants.NAME, getName());
105+
public Map<String, Object> asMap() {
106+
final Map<String, Object> map = super.asMap();
107+
map.put(Constants.NAME, getName());
106108

107109
if (getDescription() != null) {
108-
map.add(Constants.Bundle.DESCRIPTION, getDescription());
110+
map.put(Constants.Bundle.DESCRIPTION, getDescription());
109111
}
110112

111-
map.add(Constants.PRICE, getPrice());
112-
map.add(Constants.CURRENCY, getCurrency());
113+
map.put(Constants.PRICE, getPrice());
114+
map.put(Constants.CURRENCY, getCurrency());
113115

114116
if (getLicenseTemplateNumbers() != null) {
115-
map.add(Constants.Bundle.LICENSE_TEMPLATE_NUMBERS, String.join(",", getLicenseTemplateNumbers()));
117+
map.put(Constants.Bundle.LICENSE_TEMPLATE_NUMBERS, String.join(",", getLicenseTemplateNumbers()));
116118
}
117119

118120
return map;

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/impl/CountryImpl.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
package com.labs64.netlicensing.domain.entity.impl;
1414

1515
import java.math.BigDecimal;
16-
17-
import javax.ws.rs.core.MultivaluedMap;
16+
import java.util.Map;
1817

1918
import com.labs64.netlicensing.domain.Constants;
2019
import com.labs64.netlicensing.domain.entity.Country;
@@ -75,12 +74,12 @@ public boolean getIsEu() {
7574
}
7675

7776
@Override
78-
protected MultivaluedMap<String, Object> asPropertiesMap() {
79-
final MultivaluedMap<String, Object> map = super.asPropertiesMap();
80-
map.add(Constants.Country.CODE, getCode());
81-
map.add(Constants.Country.NAME, getName());
82-
map.add(Constants.Country.VAT_PERCENT, getVatPercent());
83-
map.add(Constants.Country.IS_EU, getIsEu());
77+
public Map<String, Object> asMap() {
78+
final Map<String, Object> map = super.asMap();
79+
map.put(Constants.Country.CODE, getCode());
80+
map.put(Constants.Country.NAME, getName());
81+
map.put(Constants.Country.VAT_PERCENT, getVatPercent());
82+
map.put(Constants.Country.IS_EU, getIsEu());
8483
return map;
8584
}
8685

0 commit comments

Comments
 (0)