JAVA-20617 Migrated spring-soap to JDK 17 (#14413)

This commit is contained in:
Dhawal Kapil 2023-08-22 16:13:03 +05:30 committed by GitHub
parent 420305fe3b
commit 93988220ea
13 changed files with 50 additions and 383 deletions

View File

@ -427,7 +427,6 @@
<!-- <module>spring-roo</module> --> <!-- Not supported JAVA-17327 -->
<module>spring-security-modules/spring-security-ldap</module>
<module>spring-soap</module>
<module>spring-swagger-codegen</module>
<module>video-tutorials</module>
</modules>
@ -594,7 +593,6 @@
<!-- <module>spring-roo</module> --> <!-- Not supported JAVA-17327 -->
<module>spring-security-modules/spring-security-ldap</module>
<module>spring-soap</module>
<module>spring-swagger-codegen</module>
<module>video-tutorials</module>
</modules>
@ -908,6 +906,7 @@
<module>spring-kafka</module>
<module>spring-native</module>
<module>spring-soap</module>
<module>spring-security-modules</module>
<module>spring-protobuf</module>
<module>spring-quartz</module>
@ -1180,6 +1179,7 @@
<module>spring-kafka</module>
<module>spring-native</module>
<module>spring-soap</module>
<module>spring-security-modules</module>
<module>spring-protobuf</module>
<module>spring-quartz</module>

View File

@ -1,2 +1,4 @@
/target/
sun-jaxb.episode
**/gen/**

View File

@ -30,6 +30,22 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
</dependencies>
<build>
@ -42,7 +58,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<version>3.1.0</version>
<executions>
<execution>
<id>xjc</id>
@ -52,8 +68,10 @@
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<sources>
<source>src/main/resources/countries.xsd</source>
</sources>
<outputDirectory>src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
@ -61,7 +79,7 @@
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<version>0.15.3</version>
<executions>
<execution>
<goals>
@ -83,4 +101,7 @@
</plugins>
</build>
<properties>
<java.version>17</java.version>
</properties>
</project>

View File

@ -1,12 +1,14 @@
package com.baeldung.springsoap;
import com.baeldung.springsoap.gen.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
import com.baeldung.springsoap.client.gen.GetCountryRequest;
import com.baeldung.springsoap.client.gen.GetCountryResponse;
@Endpoint
public class CountryEndpoint {

View File

@ -1,12 +1,15 @@
package com.baeldung.springsoap;
import com.baeldung.springsoap.gen.*;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
import com.baeldung.springsoap.client.gen.Country;
import com.baeldung.springsoap.client.gen.Currency;
@Component
public class CountryRepository {

View File

@ -17,11 +17,11 @@ import org.springframework.xml.xsd.XsdSchema;
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
return new ServletRegistrationBean<>(servlet, "/ws/*");
}
@Bean(name = "countries")

View File

@ -1,139 +0,0 @@
package com.baeldung.springsoap.client.gen;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for country complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="country"&gt;
* &lt;complexContent&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;sequence&gt;
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/&gt;
* &lt;element name="capital" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="currency" type="{http://www.baeldung.com/springsoap/gen}currency"/&gt;
* &lt;/sequence&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
* &lt;/complexType&gt;
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "country", propOrder = {
"name",
"population",
"capital",
"currency"
})
public class Country {
@XmlElement(required = true)
protected String name;
protected int population;
@XmlElement(required = true)
protected String capital;
@XmlElement(required = true)
@XmlSchemaType(name = "string")
protected Currency currency;
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
/**
* Gets the value of the population property.
*
*/
public int getPopulation() {
return population;
}
/**
* Sets the value of the population property.
*
*/
public void setPopulation(int value) {
this.population = value;
}
/**
* Gets the value of the capital property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCapital() {
return capital;
}
/**
* Sets the value of the capital property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCapital(String value) {
this.capital = value;
}
/**
* Gets the value of the currency property.
*
* @return
* possible object is
* {@link Currency }
*
*/
public Currency getCurrency() {
return currency;
}
/**
* Sets the value of the currency property.
*
* @param value
* allowed object is
* {@link Currency }
*
*/
public void setCurrency(Currency value) {
this.currency = value;
}
}

View File

@ -1,40 +0,0 @@
package com.baeldung.springsoap.client.gen;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for currency.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;simpleType name="currency"&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string"&gt;
* &lt;enumeration value="GBP"/&gt;
* &lt;enumeration value="EUR"/&gt;
* &lt;enumeration value="PLN"/&gt;
* &lt;/restriction&gt;
* &lt;/simpleType&gt;
* </pre>
*
*/
@XmlType(name = "currency")
@XmlEnum
public enum Currency {
GBP,
EUR,
PLN;
public String value() {
return name();
}
public static Currency fromValue(String v) {
return valueOf(v);
}
}

View File

@ -1,64 +0,0 @@
package com.baeldung.springsoap.client.gen;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType&gt;
* &lt;complexContent&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;sequence&gt;
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;/sequence&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
* &lt;/complexType&gt;
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"name"
})
@XmlRootElement(name = "getCountryRequest")
public class GetCountryRequest {
@XmlElement(required = true)
protected String name;
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
}

View File

@ -1,64 +0,0 @@
package com.baeldung.springsoap.client.gen;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType&gt;
* &lt;complexContent&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;sequence&gt;
* &lt;element name="country" type="{http://www.baeldung.com/springsoap/gen}country"/&gt;
* &lt;/sequence&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
* &lt;/complexType&gt;
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"country"
})
@XmlRootElement(name = "getCountryResponse")
public class GetCountryResponse {
@XmlElement(required = true)
protected Country country;
/**
* Gets the value of the country property.
*
* @return
* possible object is
* {@link Country }
*
*/
public Country getCountry() {
return country;
}
/**
* Sets the value of the country property.
*
* @param value
* allowed object is
* {@link Country }
*
*/
public void setCountry(Country value) {
this.country = value;
}
}

View File

@ -1,56 +0,0 @@
package com.baeldung.springsoap.client.gen;
import javax.xml.bind.annotation.XmlRegistry;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.baeldung.springsoap.client.gen package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.springsoap.client.gen
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link GetCountryRequest }
*
*/
public GetCountryRequest createGetCountryRequest() {
return new GetCountryRequest();
}
/**
* Create an instance of {@link GetCountryResponse }
*
*/
public GetCountryResponse createGetCountryResponse() {
return new GetCountryResponse();
}
/**
* Create an instance of {@link Country }
*
*/
public Country createCountry() {
return new Country();
}
}

View File

@ -1,2 +0,0 @@
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.baeldung.com/springsoap/gen", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.baeldung.springsoap.client.gen;

View File

@ -1,18 +1,19 @@
package com.baeldung.springsoap;
import com.baeldung.springsoap.gen.GetCountryRequest;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ClassUtils;
import org.springframework.ws.client.core.WebServiceTemplate;
import static org.assertj.core.api.Assertions.assertThat;
import com.baeldung.springsoap.client.gen.GetCountryRequest;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ -20,7 +21,8 @@ public class ApplicationIntegrationTest {
private Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
@LocalServerPort private int port = 0;
@LocalServerPort
private int port = 0;
@Before
public void init() throws Exception {
@ -34,6 +36,8 @@ public class ApplicationIntegrationTest {
GetCountryRequest request = new GetCountryRequest();
request.setName("Spain");
assertThat(ws.marshalSendAndReceive("http://localhost:" + port + "/ws", request)).isNotNull();
Object response = ws.marshalSendAndReceive("http://localhost:" + port + "/ws", request);
assertThat(response).isNotNull();
}
}