diff --git a/pom.xml b/pom.xml index 6c30b28b..01517b9b 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,7 @@ UTF-8 UTF-8 0.0.5 + 0.0.43 2.33.0 1.9.22 @@ -117,6 +118,21 @@ + + + io.spring.javaformat + spring-javaformat-maven-plugin + ${spring-javaformat.version} + + + validate + + validate + + + + + diff --git a/spring-ws-core/src/main/java/org/springframework/ws/FaultAwareWebServiceMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/FaultAwareWebServiceMessage.java index 9efb5eb0..7f83e9e5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/FaultAwareWebServiceMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/FaultAwareWebServiceMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,9 @@ package org.springframework.ws; import javax.xml.namespace.QName; /** - * Sub-interface of {@link WebServiceMessage} that can contain special Fault messages. Fault messages (such as - * {@link org.springframework.ws.soap.SoapFault} SOAP Faults) often require different processing rules. + * Sub-interface of {@link WebServiceMessage} that can contain special Fault messages. + * Fault messages (such as {@link org.springframework.ws.soap.SoapFault} SOAP Faults) + * often require different processing rules. * * @author Arjen Poutsma * @see org.springframework.ws.soap.SoapMessage @@ -30,7 +31,6 @@ public interface FaultAwareWebServiceMessage extends WebServiceMessage { /** * Does this message have a fault? - * * @return {@code true} if the message has a fault. * @see #getFaultReason() */ @@ -43,9 +43,10 @@ public interface FaultAwareWebServiceMessage extends WebServiceMessage { /** * Returns the fault reason message. - * - * @return the fault reason message, if any; returns {@code null} when no fault is present. + * @return the fault reason message, if any; returns {@code null} when no fault is + * present. * @see #hasFault() */ String getFaultReason(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/InvalidXmlException.java b/spring-ws-core/src/main/java/org/springframework/ws/InvalidXmlException.java index b73e1f40..a183b39b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/InvalidXmlException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/InvalidXmlException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -17,8 +17,8 @@ package org.springframework.ws; /** - * Exception thrown when a {@link WebServiceMessageFactory} cannot parse the XML passed on to - * {@link WebServiceMessageFactory#createWebServiceMessage(java.io.InputStream)}. + * Exception thrown when a {@link WebServiceMessageFactory} cannot parse the XML passed on + * to {@link WebServiceMessageFactory#createWebServiceMessage(java.io.InputStream)}. * * @author Arjen Poutsma * @since 2.0.4 @@ -29,4 +29,5 @@ public final class InvalidXmlException extends WebServiceException { public InvalidXmlException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/NoEndpointFoundException.java b/spring-ws-core/src/main/java/org/springframework/ws/NoEndpointFoundException.java index 88e8ba46..410e4ac3 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/NoEndpointFoundException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/NoEndpointFoundException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -28,4 +28,5 @@ public final class NoEndpointFoundException extends WebServiceException { public NoEndpointFoundException(WebServiceMessage request) { super("No endpoint can be found for request [" + request + "]"); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/WebServiceException.java b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceException.java index 6be4f4e5..33d432db 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/WebServiceException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,7 +29,6 @@ public abstract class WebServiceException extends NestedRuntimeException { /** * Create a new instance of the {@code WebServiceException} class. - * * @param msg the detail message */ public WebServiceException(String msg) { @@ -38,7 +37,6 @@ public abstract class WebServiceException extends NestedRuntimeException { /** * Create a new instance of the {@code WebServiceException} class. - * * @param msg the detail message * @param ex the root {@link Throwable exception} */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessage.java index c75ed0f5..677427e7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -37,8 +37,8 @@ public interface WebServiceMessage { /** * Returns the contents of the message as a {@link Source}. *

- * Depending on the implementation, this can be retrieved multiple times, or just a single time. - * + * Depending on the implementation, this can be retrieved multiple times, or just a + * single time. * @return the message contents */ Source getPayloadSource(); @@ -48,8 +48,8 @@ public interface WebServiceMessage { *

* Calling this method removes the current payload. *

- * Implementations that are read-only will throw an {@link UnsupportedOperationException}. - * + * Implementations that are read-only will throw an + * {@link UnsupportedOperationException}. * @return the message contents * @throws UnsupportedOperationException if the message is read-only */ @@ -58,9 +58,9 @@ public interface WebServiceMessage { /** * Writes the entire message to the given output stream. *

- * If the given stream is an instance of {@link org.springframework.ws.transport.TransportOutputStream}, the - * corresponding headers will be written as well. - * + * If the given stream is an instance of + * {@link org.springframework.ws.transport.TransportOutputStream}, the corresponding + * headers will be written as well. * @param outputStream the stream to write to * @throws IOException if an I/O exception occurs */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageException.java b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageException.java index 689e981c..ff51413d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public abstract class WebServiceMessageException extends WebServiceException { public WebServiceMessageException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageFactory.java b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageFactory.java index 370db05c..031c6aac 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageFactory.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,8 +20,8 @@ import java.io.IOException; import java.io.InputStream; /** - * The {@code WebServiceMessageFactory} serves as a factory for {@link org.springframework.ws.WebServiceMessage - * WebServiceMessages}. + * The {@code WebServiceMessageFactory} serves as a factory for + * {@link org.springframework.ws.WebServiceMessage WebServiceMessages}. *

* Allows the creation of empty messages, or messages based on {@code InputStream}s. * @@ -33,7 +33,6 @@ public interface WebServiceMessageFactory { /** * Creates a new, empty {@code WebServiceMessage}. - * * @return the empty message */ WebServiceMessage createWebServiceMessage(); @@ -41,9 +40,9 @@ public interface WebServiceMessageFactory { /** * Reads a {@link WebServiceMessage} from the given input stream. *

- * If the given stream is an instance of {@link org.springframework.ws.transport.TransportInputStream - * TransportInputStream}, the headers will be read from the request. - * + * If the given stream is an instance of + * {@link org.springframework.ws.transport.TransportInputStream TransportInputStream}, + * the headers will be read from the request. * @param inputStream the input stream to read the message from * @return the created message * @throws InvalidXmlException if the XML read from the input stream is invalid diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceClientException.java b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceClientException.java index 273f09a0..39a77bf5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceClientException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceClientException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,7 +29,6 @@ public abstract class WebServiceClientException extends WebServiceException { /** * Create a new instance of the {@code WebServiceClientException} class. - * * @param msg the detail message */ public WebServiceClientException(String msg) { @@ -38,7 +37,6 @@ public abstract class WebServiceClientException extends WebServiceException { /** * Create a new instance of the {@code WebServiceClientException} class. - * * @param msg the detail message * @param ex the root {@link Throwable exception} */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java index cedb7b0c..18c9c535 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -37,7 +37,6 @@ public class WebServiceFaultException extends WebServiceClientException { /** * Create a new instance of the {@code WebServiceFaultException} class. - * * @param faultMessage the fault message */ public WebServiceFaultException(FaultAwareWebServiceMessage faultMessage) { @@ -49,4 +48,5 @@ public class WebServiceFaultException extends WebServiceClientException { public FaultAwareWebServiceMessage getWebServiceMessage() { return faultMessage; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceIOException.java b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceIOException.java index 517cff09..5003d62e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceIOException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceIOException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,7 +29,6 @@ public class WebServiceIOException extends WebServiceClientException { /** * Create a new instance of the {@code WebServiceIOException} class. - * * @param msg the detail message */ public WebServiceIOException(String msg) { @@ -38,7 +37,6 @@ public class WebServiceIOException extends WebServiceClientException { /** * Create a new instance of the {@code WebServiceIOException} class. - * * @param msg the detail message * @param ex the root {@link IOException} */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransformerException.java b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransformerException.java index 94fcdaf2..14dc5e66 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransformerException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransformerException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,7 +29,6 @@ public class WebServiceTransformerException extends WebServiceClientException { /** * Create a new instance of the {@code WebServiceTransformerException} class. - * * @param msg the detail message */ public WebServiceTransformerException(String msg) { @@ -38,7 +37,6 @@ public class WebServiceTransformerException extends WebServiceClientException { /** * Create a new instance of the {@code WebServiceTransformerException} class. - * * @param msg the detail message * @param ex the root {@link Throwable exception} */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransportException.java b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransportException.java index 74abcccb..891d95de 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransportException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransportException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,7 +29,6 @@ public class WebServiceTransportException extends WebServiceIOException { /** * Create a new instance of the {@code WebServiceTransportException} class. - * * @param msg the detail message */ public WebServiceTransportException(String msg) { @@ -38,7 +37,6 @@ public class WebServiceTransportException extends WebServiceIOException { /** * Create a new instance of the {@code WebServiceTransportException} class. - * * @param msg the detail message * @param ex the root {@link TransportException} */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/core/FaultMessageResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/client/core/FaultMessageResolver.java index 32701e07..c7b07351 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/core/FaultMessageResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/core/FaultMessageResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,7 +30,6 @@ public interface FaultMessageResolver { /** * Try to resolve the given fault message that got received. - * * @param message the fault message */ void resolveFault(WebServiceMessage message) throws IOException; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/core/SimpleFaultMessageResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/client/core/SimpleFaultMessageResolver.java index 31003eb2..131c0420 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/core/SimpleFaultMessageResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/core/SimpleFaultMessageResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,7 +21,8 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.client.WebServiceFaultException; /** - * Simple fault resolver that simply throws a {@link WebServiceFaultException} when a fault occurs. + * Simple fault resolver that simply throws a {@link WebServiceFaultException} when a + * fault occurs. * * @author Arjen Poutsma * @see WebServiceFaultException @@ -34,8 +35,10 @@ public class SimpleFaultMessageResolver implements FaultMessageResolver { public void resolveFault(WebServiceMessage message) { if (message instanceof FaultAwareWebServiceMessage) { throw new WebServiceFaultException((FaultAwareWebServiceMessage) message); - } else { + } + else { throw new WebServiceFaultException("Message has unknown fault: " + message); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/core/SourceExtractor.java b/spring-ws-core/src/main/java/org/springframework/ws/client/core/SourceExtractor.java index 43720b9a..ea732050 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/core/SourceExtractor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/core/SourceExtractor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,15 +22,17 @@ import javax.xml.transform.Source; import javax.xml.transform.TransformerException; /** - * Callback interface for extracting a result object from a {@link javax.xml.transform.Source} instance. + * Callback interface for extracting a result object from a + * {@link javax.xml.transform.Source} instance. *

- * Used for output object creation in {@link WebServiceTemplate}. Alternatively, output sources can also be returned to - * client code as-is. In case of a source as execution result, you will almost always want to implement a - * {@code SourceExtractor}, to be able to read the message content in a managed fashion, with the connection still open - * while reading the message. + * Used for output object creation in {@link WebServiceTemplate}. Alternatively, output + * sources can also be returned to client code as-is. In case of a source as execution + * result, you will almost always want to implement a {@code SourceExtractor}, to be able + * to read the message content in a managed fashion, with the connection still open while + * reading the message. *

- * Implementations of this interface perform the actual work of extracting results, but don't need to worry about - * exception handling, or resource handling. + * Implementations of this interface perform the actual work of extracting results, but + * don't need to worry about exception handling, or resource handling. * * @author Arjen Poutsma * @see org.springframework.ws.client.core.WebServiceTemplate @@ -39,11 +41,11 @@ import javax.xml.transform.TransformerException; public interface SourceExtractor { /** - * Process the data in the given {@code Source}, creating a corresponding result object. - * + * Process the data in the given {@code Source}, creating a corresponding result + * object. * @param source the message payload to extract data from - * @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the latter - * case) + * @return an arbitrary result object, or {@code null} if none (the extractor will + * typically be stateful in the latter case) * @throws IOException in case of I/O errors */ T extractData(Source source) throws IOException, TransformerException; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageCallback.java b/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageCallback.java index 9c41f0bf..c34a5caf 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageCallback.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageCallback.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,8 +25,8 @@ import org.springframework.ws.WebServiceMessage; /** * Generic callback interface for code that operates on a {@link WebServiceMessage}. *

- * Implementations can execute any number of operations on the message, such as set the contents of the message, or set - * the {@code SOAPAction} header. + * Implementations can execute any number of operations on the message, such as set the + * contents of the message, or set the {@code SOAPAction} header. * * @author Arjen Poutsma * @since 1.0.0 @@ -35,7 +35,6 @@ public interface WebServiceMessageCallback { /** * Execute any number of operations on the supplied {@code message}. - * * @param message the message * @throws IOException in case of I/O errors * @throws TransformerException in case of transformation errors diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageExtractor.java b/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageExtractor.java index 4d3352f8..14ce76d7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageExtractor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageExtractor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,15 +23,17 @@ import javax.xml.transform.TransformerException; import org.springframework.ws.WebServiceMessage; /** - * Callback interface for extracting a result object from a {@link WebServiceMessage} instance. + * Callback interface for extracting a result object from a {@link WebServiceMessage} + * instance. *

- * Used for output object creation in {@link WebServiceTemplate}. Alternatively, output messages can also be returned to - * client code as-is. In case of a message as execution result, you will almost always want to implement a - * {@code WebServiceMessageExtractor}, to be able to read the message in a managed fashion, with the connection still - * open while reading the message. + * Used for output object creation in {@link WebServiceTemplate}. Alternatively, output + * messages can also be returned to client code as-is. In case of a message as execution + * result, you will almost always want to implement a {@code WebServiceMessageExtractor}, + * to be able to read the message in a managed fashion, with the connection still open + * while reading the message. *

- * Implementations of this interface perform the actual work of extracting results, but don't need to worry about - * exception handling, or resource handling. + * Implementations of this interface perform the actual work of extracting results, but + * don't need to worry about exception handling, or resource handling. * * @author Arjen Poutsma * @since 1.0.0 @@ -39,11 +41,11 @@ import org.springframework.ws.WebServiceMessage; public interface WebServiceMessageExtractor { /** - * Process the data in the given {@code WebServiceMessage}, creating a corresponding result object. - * + * Process the data in the given {@code WebServiceMessage}, creating a corresponding + * result object. * @param message the message to extract data from (possibly a {@code SoapMessage}) - * @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the latter - * case) + * @return an arbitrary result object, or {@code null} if none (the extractor will + * typically be stateful in the latter case) * @throws IOException in case of I/O errors * @throws TransformerException in case of transformation errors */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java b/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java index 12320f25..8ee2171e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,9 @@ import org.springframework.oxm.XmlMappingException; import org.springframework.ws.client.WebServiceClientException; /** - * Specifies a basic set of Web service operations. Implemented by {@link WebServiceTemplate}. Not often used directly, - * but a useful option to enhance testability, as it can easily be mocked or stubbed. + * Specifies a basic set of Web service operations. Implemented by + * {@link WebServiceTemplate}. Not often used directly, but a useful option to enhance + * testability, as it can easily be mocked or stubbed. * * @author Arjen Poutsma * @see WebServiceTemplate @@ -33,55 +34,61 @@ import org.springframework.ws.client.WebServiceClientException; public interface WebServiceOperations { /** - * Sends a web service message that can be manipulated with the given callback, reading the result with a - * {@code WebServiceMessageExtractor}. + * Sends a web service message that can be manipulated with the given callback, + * reading the result with a {@code WebServiceMessageExtractor}. *

* This will only work with a default uri specified! - * - * @param requestCallback the requestCallback to be used for manipulating the request message + * @param requestCallback the requestCallback to be used for manipulating the request + * message * @param responseExtractor object that will extract results - * @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor} - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @return an arbitrary result object, as returned by the + * {@code WebServiceMessageExtractor} + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ T sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageExtractor responseExtractor) throws WebServiceClientException; /** - * Sends a web service message that can be manipulated with the given callback, reading the result with a - * {@code WebServiceMessageExtractor}. - * + * Sends a web service message that can be manipulated with the given callback, + * reading the result with a {@code WebServiceMessageExtractor}. * @param uri the URI to send the message to - * @param requestCallback the requestCallback to be used for manipulating the request message + * @param requestCallback the requestCallback to be used for manipulating the request + * message * @param responseExtractor object that will extract results - * @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor} - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @return an arbitrary result object, as returned by the + * {@code WebServiceMessageExtractor} + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ T sendAndReceive(String uri, WebServiceMessageCallback requestCallback, WebServiceMessageExtractor responseExtractor) throws WebServiceClientException; /** - * Sends a web service message that can be manipulated with the given request callback, handling the response with a - * response callback. + * Sends a web service message that can be manipulated with the given request + * callback, handling the response with a response callback. *

* This will only work with a default uri specified! - * * @param requestCallback the callback to be used for manipulating the request message - * @param responseCallback the callback to be used for manipulating the response message + * @param responseCallback the callback to be used for manipulating the response + * message * @return {@code true} if a response was received; {@code false} otherwise - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ boolean sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback) throws WebServiceClientException; /** - * Sends a web service message that can be manipulated with the given request callback, handling the response with a - * response callback. - * + * Sends a web service message that can be manipulated with the given request + * callback, handling the response with a response callback. * @param uri the URI to send the message to * @param requestCallback the callback to be used for manipulating the request message - * @param responseCallback the callback to be used for manipulating the response message + * @param responseCallback the callback to be used for manipulating the response + * message * @return {@code true} if a response was received; {@code false} otherwise - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ boolean sendAndReceive(String uri, WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback) throws WebServiceClientException; @@ -91,46 +98,53 @@ public interface WebServiceOperations { // ----------------------------------------------------------------------------------------------------------------- /** - * Sends a web service message that contains the given payload, marshalled by the configured {@code Marshaller}. - * Returns the unmarshalled payload of the response message, if any. + * Sends a web service message that contains the given payload, marshalled by the + * configured {@code Marshaller}. Returns the unmarshalled payload of the response + * message, if any. *

* This will only work with a default uri specified! - * * @param requestPayload the object to marshal into the request message payload - * @return the unmarshalled payload of the response message, or {@code null} if no response is given + * @return the unmarshalled payload of the response message, or {@code null} if no + * response is given * @throws XmlMappingException if there is a problem marshalling or unmarshalling - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message * @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller) * @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller) */ Object marshalSendAndReceive(Object requestPayload) throws XmlMappingException, WebServiceClientException; /** - * Sends a web service message that contains the given payload, marshalled by the configured {@code Marshaller}. - * Returns the unmarshalled payload of the response message, if any. - * + * Sends a web service message that contains the given payload, marshalled by the + * configured {@code Marshaller}. Returns the unmarshalled payload of the response + * message, if any. * @param uri the URI to send the message to * @param requestPayload the object to marshal into the request message payload - * @return the unmarshalled payload of the response message, or {@code null} if no response is given + * @return the unmarshalled payload of the response message, or {@code null} if no + * response is given * @throws XmlMappingException if there is a problem marshalling or unmarshalling - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message * @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller) * @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller) */ - Object marshalSendAndReceive(String uri, Object requestPayload) throws XmlMappingException, WebServiceClientException; + Object marshalSendAndReceive(String uri, Object requestPayload) + throws XmlMappingException, WebServiceClientException; /** - * Sends a web service message that contains the given payload, marshalled by the configured {@code Marshaller}. - * Returns the unmarshalled payload of the response message, if any. The given callback allows changing of the request - * message after the payload has been marshalled to it. + * Sends a web service message that contains the given payload, marshalled by the + * configured {@code Marshaller}. Returns the unmarshalled payload of the response + * message, if any. The given callback allows changing of the request message after + * the payload has been marshalled to it. *

* This will only work with a default uri specified! - * * @param requestPayload the object to marshal into the request message payload * @param requestCallback callback to change message, can be {@code null} - * @return the unmarshalled payload of the response message, or {@code null} if no response is given + * @return the unmarshalled payload of the response message, or {@code null} if no + * response is given * @throws XmlMappingException if there is a problem marshalling or unmarshalling - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message * @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller) * @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller) */ @@ -138,16 +152,18 @@ public interface WebServiceOperations { throws XmlMappingException, WebServiceClientException; /** - * Sends a web service message that contains the given payload, marshalled by the configured {@code Marshaller}. - * Returns the unmarshalled payload of the response message, if any. The given callback allows changing of the request - * message after the payload has been marshalled to it. - * + * Sends a web service message that contains the given payload, marshalled by the + * configured {@code Marshaller}. Returns the unmarshalled payload of the response + * message, if any. The given callback allows changing of the request message after + * the payload has been marshalled to it. * @param uri the URI to send the message to * @param requestPayload the object to marshal into the request message payload * @param requestCallback callback to change message, can be {@code null} - * @return the unmarshalled payload of the response message, or {@code null} if no response is given + * @return the unmarshalled payload of the response message, or {@code null} if no + * response is given * @throws XmlMappingException if there is a problem marshalling or unmarshalling - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message * @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller) * @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller) */ @@ -159,57 +175,63 @@ public interface WebServiceOperations { // ----------------------------------------------------------------------------------------------------------------- /** - * Sends a web service message that contains the given payload, reading the result with a {@code SourceExtractor}. + * Sends a web service message that contains the given payload, reading the result + * with a {@code SourceExtractor}. *

* This will only work with a default uri specified! - * * @param requestPayload the payload of the request message * @param responseExtractor object that will extract results * @return an arbitrary result object, as returned by the {@code SourceExtractor} - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ T sendSourceAndReceive(Source requestPayload, SourceExtractor responseExtractor) throws WebServiceClientException; /** - * Sends a web service message that contains the given payload, reading the result with a {@code SourceExtractor}. - * + * Sends a web service message that contains the given payload, reading the result + * with a {@code SourceExtractor}. * @param uri the URI to send the message to * @param requestPayload the payload of the request message * @param responseExtractor object that will extract results * @return an arbitrary result object, as returned by the {@code SourceExtractor} - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ T sendSourceAndReceive(String uri, Source requestPayload, SourceExtractor responseExtractor) throws WebServiceClientException; /** - * Sends a web service message that contains the given payload, reading the result with a {@code SourceExtractor}. + * Sends a web service message that contains the given payload, reading the result + * with a {@code SourceExtractor}. *

- * The given callback allows changing of the request message after the payload has been written to it. + * The given callback allows changing of the request message after the payload has + * been written to it. *

* This will only work with a default uri specified! - * * @param requestPayload the payload of the request message * @param requestCallback callback to change message, can be {@code null} * @param responseExtractor object that will extract results * @return an arbitrary result object, as returned by the {@code SourceExtractor} - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ T sendSourceAndReceive(Source requestPayload, WebServiceMessageCallback requestCallback, SourceExtractor responseExtractor) throws WebServiceClientException; /** - * Sends a web service message that contains the given payload, reading the result with a {@code SourceExtractor}. + * Sends a web service message that contains the given payload, reading the result + * with a {@code SourceExtractor}. *

- * The given callback allows changing of the request message after the payload has been written to it. - * + * The given callback allows changing of the request message after the payload has + * been written to it. * @param uri the URI to send the message to * @param requestPayload the payload of the request message * @param requestCallback callback to change message, can be {@code null} * @param responseExtractor object that will extract results * @return an arbitrary result object, as returned by the {@code SourceExtractor} - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ T sendSourceAndReceive(String uri, Source requestPayload, WebServiceMessageCallback requestCallback, SourceExtractor responseExtractor) throws WebServiceClientException; @@ -219,60 +241,62 @@ public interface WebServiceOperations { // ----------------------------------------------------------------------------------------------------------------- /** - * Sends a web service message that contains the given payload. Writes the response, if any, to the given - * {@code Result}. + * Sends a web service message that contains the given payload. Writes the response, + * if any, to the given {@code Result}. *

* This will only work with a default uri specified! - * * @param requestPayload the payload of the request message * @param responseResult the result to write the response payload to * @return {@code true} if a response was received; {@code false} otherwise - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ boolean sendSourceAndReceiveToResult(Source requestPayload, Result responseResult) throws WebServiceClientException; /** - * Sends a web service message that contains the given payload. Writes the response, if any, to the given - * {@code Result}. - * + * Sends a web service message that contains the given payload. Writes the response, + * if any, to the given {@code Result}. * @param uri the URI to send the message to * @param requestPayload the payload of the request message * @param responseResult the result to write the response payload to * @return {@code true} if a response was received; {@code false} otherwise - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, Result responseResult) throws WebServiceClientException; /** - * Sends a web service message that contains the given payload. Writes the response, if any, to the given - * {@code Result}. + * Sends a web service message that contains the given payload. Writes the response, + * if any, to the given {@code Result}. *

- * The given callback allows changing of the request message after the payload has been written to it. + * The given callback allows changing of the request message after the payload has + * been written to it. *

* This will only work with a default uri specified! - * * @param requestPayload the payload of the request message * @param requestCallback callback to change message, can be {@code null} * @param responseResult the result to write the response payload to * @return {@code true} if a response was received; {@code false} otherwise - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ boolean sendSourceAndReceiveToResult(Source requestPayload, WebServiceMessageCallback requestCallback, Result responseResult) throws WebServiceClientException; /** - * Sends a web service message that contains the given payload. Writes the response, if any, to the given - * {@code Result}. + * Sends a web service message that contains the given payload. Writes the response, + * if any, to the given {@code Result}. *

- * The given callback allows changing of the request message after the payload has been written to it. - * + * The given callback allows changing of the request message after the payload has + * been written to it. * @param uri the URI to send the message to * @param requestPayload the payload of the request message * @param requestCallback callback to change message, can be {@code null} * @param responseResult the result to write the response payload to * @return {@code true} if a response was received; {@code false} otherwise - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @throws WebServiceClientException if there is a problem sending or receiving the + * message */ boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, WebServiceMessageCallback requestCallback, Result responseResult) throws WebServiceClientException; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java b/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java index 9eefaec8..c53a8c2b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,10 +22,15 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.List; -import javax.xml.transform.*; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.BeanInitializationException; import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; @@ -57,47 +62,57 @@ import org.springframework.ws.transport.http.HttpUrlConnectionMessageSender; import org.springframework.ws.transport.support.TransportUtils; /** - * The central class for client-side Web services. It provides a message-driven approach to sending and - * receiving {@link WebServiceMessage} instances. + * The central class for client-side Web services. It provides a + * message-driven approach to sending and receiving {@link WebServiceMessage} instances. *

- * Code using this class need only implement callback interfaces, provide {@link Source} objects to read data from, or - * use the pluggable {@link Marshaller} support. For invoking the {@link #marshalSendAndReceive marshalling methods}, - * the {@link #setMarshaller(Marshaller) marshaller} and {@link #setUnmarshaller(Unmarshaller) unmarshaller} properties - * must be set. + * Code using this class need only implement callback interfaces, provide {@link Source} + * objects to read data from, or use the pluggable {@link Marshaller} support. For + * invoking the {@link #marshalSendAndReceive marshalling methods}, the + * {@link #setMarshaller(Marshaller) marshaller} and {@link #setUnmarshaller(Unmarshaller) + * unmarshaller} properties must be set. *

- * This template uses a {@link SoapFaultMessageResolver} to handle fault response messages. Another - * {@link FaultMessageResolver} can be defined with with {@link #setFaultMessageResolver(FaultMessageResolver) - * faultMessageResolver} property. If this property is set to {@code null}, no fault resolving is performed. + * This template uses a {@link SoapFaultMessageResolver} to handle fault response + * messages. Another {@link FaultMessageResolver} can be defined with with + * {@link #setFaultMessageResolver(FaultMessageResolver) faultMessageResolver} property. + * If this property is set to {@code null}, no fault resolving is performed. *

* This template uses the following algorithm for sending and receiving. *

    *
  1. Call {@link #createConnection(URI) createConnection()}.
  2. - *
  3. Call {@link WebServiceMessageFactory#createWebServiceMessage() createWebServiceMessage()} on the registered - * message factory to create a request message.
  4. - *
  5. Invoke {@link WebServiceMessageCallback#doWithMessage(WebServiceMessage) doWithMessage()} on the request - * callback, if any. This step stores content in the request message, based on {@code Source}, marshalling, etc.
  6. - *
  7. Invoke {@link ClientInterceptor#handleRequest(MessageContext) handleRequest()} on the registered - * {@link #setInterceptors(ClientInterceptor[]) interceptors}. Interceptors are executed in order. If any of the - * interceptors creates a response message in the message context, skip to step 7.
  8. - *
  9. Call {@link WebServiceConnection#send(WebServiceMessage) send()} on the connection.
  10. - *
  11. Call {@link #hasError(WebServiceConnection,WebServiceMessage) hasError()} to check if the connection has an - * error. For an HTTP transport, a status code other than {@code 2xx} indicates an error. However, since a status code - * of 500 can also indicate a SOAP fault, the template verifies whether the error is not a fault.
  12. + *
  13. Call {@link WebServiceMessageFactory#createWebServiceMessage() + * createWebServiceMessage()} on the registered message factory to create a request + * message.
  14. + *
  15. Invoke {@link WebServiceMessageCallback#doWithMessage(WebServiceMessage) + * doWithMessage()} on the request callback, if any. This step stores content in the + * request message, based on {@code Source}, marshalling, etc.
  16. + *
  17. Invoke {@link ClientInterceptor#handleRequest(MessageContext) handleRequest()} on + * the registered {@link #setInterceptors(ClientInterceptor[]) interceptors}. Interceptors + * are executed in order. If any of the interceptors creates a response message in the + * message context, skip to step 7.
  18. + *
  19. Call {@link WebServiceConnection#send(WebServiceMessage) send()} on the + * connection.
  20. + *
  21. Call {@link #hasError(WebServiceConnection,WebServiceMessage) hasError()} to check + * if the connection has an error. For an HTTP transport, a status code other than + * {@code 2xx} indicates an error. However, since a status code of 500 can also indicate a + * SOAP fault, the template verifies whether the error is not a fault.
  22. *
      - *
    • If the connection has an error, call the {@link #handleError handleError()} method, which by default throws a - * {@link WebServiceTransportException}.
    • + *
    • If the connection has an error, call the {@link #handleError handleError()} method, + * which by default throws a {@link WebServiceTransportException}.
    • *
    • If the connection has no error, continue with the next step.
    • *
    - *
  23. Invoke {@link WebServiceConnection#receive(WebServiceMessageFactory) receive} on the connection to read the - * response message, if any.
  24. + *
  25. Invoke {@link WebServiceConnection#receive(WebServiceMessageFactory) receive} on + * the connection to read the response message, if any.
  26. *
      *
    • If no response was received, return {@code null} or {@code false}
    • - *
    • Call {@link #hasFault(WebServiceConnection,WebServiceMessage) hasFault()} to determine whether the response has a - * fault. If it has, call {@link ClientInterceptor#handleFault(MessageContext)} and the {@link #handleFault + *
    • Call {@link #hasFault(WebServiceConnection,WebServiceMessage) hasFault()} to + * determine whether the response has a fault. If it has, call + * {@link ClientInterceptor#handleFault(MessageContext)} and the {@link #handleFault * handleFault()} method.
    • *
    • Otherwise, invoke {@link ClientInterceptor#handleResponse(MessageContext)} and - * {@link WebServiceMessageExtractor#extractData(WebServiceMessage) extractData()} on the response extractor, or - * {@link WebServiceMessageCallback#doWithMessage(WebServiceMessage) doWithMessage} on the response callback.
    • + * {@link WebServiceMessageExtractor#extractData(WebServiceMessage) extractData()} on the + * response extractor, or + * {@link WebServiceMessageCallback#doWithMessage(WebServiceMessage) doWithMessage} on the + * response callback. *
    *
  27. Call to {@link WebServiceConnection#close() close} on the connection.
  28. *
@@ -112,11 +127,11 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** Additional logger to use for sent message tracing. */ protected static final Log sentMessageTracingLogger = LogFactory - .getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".sent"); + .getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".sent"); /** Additional logger to use for received message tracing. */ protected static final Log receivedMessageTracingLogger = LogFactory - .getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".received"); + .getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".received"); private Marshaller marshaller; @@ -139,7 +154,6 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * Creates a new {@code WebServiceTemplate} based on the given message factory. - * * @param messageFactory the message factory to use */ public WebServiceTemplate(WebServiceMessageFactory messageFactory) { @@ -148,15 +162,15 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Creates a new {@code WebServiceTemplate} with the given marshaller. If the given {@link Marshaller} also implements - * the {@link Unmarshaller} interface, it is used for both marshalling and unmarshalling. Otherwise, an exception is - * thrown. + * Creates a new {@code WebServiceTemplate} with the given marshaller. If the given + * {@link Marshaller} also implements the {@link Unmarshaller} interface, it is used + * for both marshalling and unmarshalling. Otherwise, an exception is thrown. *

- * Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, so - * that you can safely use this constructor. - * + * Note that all {@link Marshaller} implementations in Spring also implement the + * {@link Unmarshaller} interface, so that you can safely use this constructor. * @param marshaller object used as marshaller and unmarshaller - * @throws IllegalArgumentException when {@code marshaller} does not implement the {@link Unmarshaller} interface + * @throws IllegalArgumentException when {@code marshaller} does not implement the + * {@link Unmarshaller} interface * @since 2.0.3 */ public WebServiceTemplate(Marshaller marshaller) { @@ -165,7 +179,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + "interface. Please set an Unmarshaller explicitly by using the " + "WebServiceTemplate(Marshaller, Unmarshaller) constructor."); - } else { + } + else { this.setMarshaller(marshaller); this.setUnmarshaller((Unmarshaller) marshaller); } @@ -173,8 +188,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller and unmarshaller. - * + * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller + * and unmarshaller. * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use * @since 2.0.3 @@ -187,12 +202,15 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService initDefaultStrategies(); } - /** Returns the default URI to be used on operations that do not have a URI parameter. */ + /** + * Returns the default URI to be used on operations that do not have a URI parameter. + */ public String getDefaultUri() { if (destinationProvider != null) { URI uri = destinationProvider.getDestination(); return uri != null ? uri.toString() : null; - } else { + } + else { return null; } } @@ -200,8 +218,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * Set the default URI to be used on operations that do not have a URI parameter. *

- * Typically, either this property is set, or {@link #setDestinationProvider(DestinationProvider)}, but not both. - * + * Typically, either this property is set, or + * {@link #setDestinationProvider(DestinationProvider)}, but not both. * @see #marshalSendAndReceive(Object) * @see #marshalSendAndReceive(Object,WebServiceMessageCallback) * @see #sendSourceAndReceiveToResult(Source,Result) @@ -219,16 +237,20 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService }; } - /** Returns the destination provider used on operations that do not have a URI parameter. */ + /** + * Returns the destination provider used on operations that do not have a URI + * parameter. + */ public DestinationProvider getDestinationProvider() { return destinationProvider; } /** - * Set the destination provider URI to be used on operations that do not have a URI parameter. + * Set the destination provider URI to be used on operations that do not have a URI + * parameter. *

- * Typically, either this property is set, or {@link #setDefaultUri(String)}, but not both. - * + * Typically, either this property is set, or {@link #setDefaultUri(String)}, but not + * both. * @see #marshalSendAndReceive(Object) * @see #marshalSendAndReceive(Object,WebServiceMessageCallback) * @see #sendSourceAndReceiveToResult(Source,Result) @@ -268,52 +290,60 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * Sets the fault resolver for this template. Default is the - * {@link org.springframework.ws.soap.client.core.SoapFaultMessageResolver SoapFaultMessageResolver}, but may be set - * to {@code null} to disable fault handling. + * {@link org.springframework.ws.soap.client.core.SoapFaultMessageResolver + * SoapFaultMessageResolver}, but may be set to {@code null} to disable fault + * handling. */ public void setFaultMessageResolver(FaultMessageResolver faultMessageResolver) { this.faultMessageResolver = faultMessageResolver; } /** - * Indicates whether the {@linkplain WebServiceConnection#hasError() connection} should be checked for error - * indicators ({@code true}), or whether these should be ignored ({@code false}). The default is {@code true}. + * Indicates whether the {@linkplain WebServiceConnection#hasError() connection} + * should be checked for error indicators ({@code true}), or whether these should be + * ignored ({@code false}). The default is {@code true}. *

- * When using an HTTP transport, this property defines whether to check the HTTP response status code is in the 2xx - * Successful range. Both the SOAP specification and the WS-I Basic Profile define that a Web service must return a - * "200 OK" or "202 Accepted" HTTP status code for a normal response. Setting this property to {@code false} allows - * this template to deal with non-conforming services. - * + * When using an HTTP transport, this property defines whether to check the HTTP + * response status code is in the 2xx Successful range. Both the SOAP specification + * and the WS-I Basic Profile define that a Web service must return a "200 OK" or "202 + * Accepted" HTTP status code for a normal response. Setting this property to + * {@code false} allows this template to deal with non-conforming services. * @see #hasError(WebServiceConnection, WebServiceMessage) - * @see SOAP 1.1 specification - * @see WS-I Basic Profile + * @see SOAP 1.1 + * specification + * @see WS-I + * Basic Profile */ public void setCheckConnectionForError(boolean checkConnectionForError) { this.checkConnectionForError = checkConnectionForError; } /** - * Indicates whether the {@linkplain FaultAwareWebServiceConnection#hasFault() connection} should be checked for fault - * indicators ({@code true}), or whether we should rely on the {@link FaultAwareWebServiceMessage#hasFault() message} - * only ({@code false}). The default is {@code true}. + * Indicates whether the {@linkplain FaultAwareWebServiceConnection#hasFault() + * connection} should be checked for fault indicators ({@code true}), or whether we + * should rely on the {@link FaultAwareWebServiceMessage#hasFault() message} only + * ({@code false}). The default is {@code true}. *

- * When using an HTTP transport, this property defines whether to check the HTTP response status code for fault - * indicators. Both the SOAP specification and the WS-I Basic Profile define that a Web service must return a "500 - * Internal Server Error" HTTP status code if the response envelope is a Fault. Setting this property to {@code false} - * allows this template to deal with non-conforming services. - * + * When using an HTTP transport, this property defines whether to check the HTTP + * response status code for fault indicators. Both the SOAP specification and the WS-I + * Basic Profile define that a Web service must return a "500 Internal Server Error" + * HTTP status code if the response envelope is a Fault. Setting this property to + * {@code false} allows this template to deal with non-conforming services. * @see #hasFault(WebServiceConnection,WebServiceMessage) - * @see SOAP 1.1 specification - * @see WS-I Basic - * Profile + * @see SOAP 1.1 + * specification + * @see WS-I + * Basic Profile */ public void setCheckConnectionForFault(boolean checkConnectionForFault) { this.checkConnectionForFault = checkConnectionForFault; } /** - * Returns the client interceptors to apply to all web service invocations made by this template. - * + * Returns the client interceptors to apply to all web service invocations made by + * this template. * @return array of endpoint interceptors, or {@code null} if none */ public ClientInterceptor[] getInterceptors() { @@ -321,8 +351,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Sets the client interceptors to apply to all web service invocations made by this template. - * + * Sets the client interceptors to apply to all web service invocations made by this + * template. * @param interceptors array of endpoint interceptors, or {@code null} if none */ public final void setInterceptors(ClientInterceptor[] interceptors) { @@ -330,9 +360,10 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Initialize the default implementations for the template's strategies: {@link SoapFaultMessageResolver}, - * {@link org.springframework.ws.soap.saaj.SaajSoapMessageFactory}, and {@link HttpUrlConnectionMessageSender}. - * + * Initialize the default implementations for the template's strategies: + * {@link SoapFaultMessageResolver}, + * {@link org.springframework.ws.soap.saaj.SaajSoapMessageFactory}, and + * {@link HttpUrlConnectionMessageSender}. * @throws BeanInitializationException in case of initalization errors * @see #setFaultMessageResolver(FaultMessageResolver) * @see #setMessageFactory(WebServiceMessageFactory) @@ -394,7 +425,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService if (requestPayload != null) { Marshaller marshaller = getMarshaller(); if (marshaller == null) { - throw new IllegalStateException("No marshaller registered. Check configuration of WebServiceTemplate."); + throw new IllegalStateException( + "No marshaller registered. Check configuration of WebServiceTemplate."); } MarshallingUtils.marshal(marshaller, requestPayload, request); if (requestCallback != null) { @@ -407,7 +439,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService public Object extractData(WebServiceMessage response) throws IOException { Unmarshaller unmarshaller = getUnmarshaller(); if (unmarshaller == null) { - throw new IllegalStateException("No unmarshaller registered. Check configuration of WebServiceTemplate."); + throw new IllegalStateException( + "No unmarshaller registered. Check configuration of WebServiceTemplate."); } return MarshallingUtils.unmarshal(unmarshaller, response); } @@ -450,7 +483,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } }); return retVal != null && retVal; - } catch (TransformerConfigurationException ex) { + } + catch (TransformerConfigurationException ex) { throw new WebServiceTransformerException("Could not create transformer", ex); } } @@ -482,7 +516,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService try { return doSendAndReceive(uri, createTransformer(), requestPayload, requestCallback, responseExtractor); - } catch (TransformerConfigurationException ex) { + } + catch (TransformerConfigurationException ex) { throw new WebServiceTransformerException("Could not create transformer", ex); } } @@ -505,7 +540,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService // @Override - public boolean sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback) { + public boolean sendAndReceive(WebServiceMessageCallback requestCallback, + WebServiceMessageCallback responseCallback) { return sendAndReceive(getDefaultUri(), requestCallback, responseCallback); } @@ -537,32 +573,39 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService MessageContext messageContext = new DefaultMessageContext(getMessageFactory()); return doSendAndReceive(messageContext, connection, requestCallback, responseExtractor); - } catch (TransportException ex) { + } + catch (TransportException ex) { throw new WebServiceTransportException("Could not use transport: " + ex.getMessage(), ex); - } catch (IOException ex) { + } + catch (IOException ex) { throw new WebServiceIOException("I/O error: " + ex.getMessage(), ex); - } finally { + } + finally { TransportUtils.closeConnection(connection); TransportContextHolder.setTransportContext(previousTransportContext); } } /** - * Sends and receives a {@link MessageContext}. Sends the {@link MessageContext#getRequest() request message}, and - * received to the {@link MessageContext#getResponse() repsonse message}. Invocates the defined + * Sends and receives a {@link MessageContext}. Sends the + * {@link MessageContext#getRequest() request message}, and received to the + * {@link MessageContext#getResponse() repsonse message}. Invocates the defined * {@link #setInterceptors(ClientInterceptor[]) interceptors} as part of the process. - * * @param messageContext the message context * @param connection the connection to use - * @param requestCallback the requestCallback to be used for manipulating the request message + * @param requestCallback the requestCallback to be used for manipulating the request + * message * @param responseExtractor object that will extract results - * @return an arbitrary result object, as returned by the {@code WebServiceMessageExtractor} - * @throws WebServiceClientException if there is a problem sending or receiving the message + * @return an arbitrary result object, as returned by the + * {@code WebServiceMessageExtractor} + * @throws WebServiceClientException if there is a problem sending or receiving the + * message * @throws IOException in case of I/O errors */ @SuppressWarnings("unchecked") protected T doSendAndReceive(MessageContext messageContext, WebServiceConnection connection, - WebServiceMessageCallback requestCallback, WebServiceMessageExtractor responseExtractor) throws IOException { + WebServiceMessageCallback requestCallback, WebServiceMessageExtractor responseExtractor) + throws IOException { int interceptorIndex = -1; try { if (requestCallback != null) { @@ -596,19 +639,23 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService triggerHandleResponse(interceptorIndex, messageContext); triggerAfterCompletion(interceptorIndex, messageContext, null); return responseExtractor.extractData(messageContext.getResponse()); - } else { + } + else { triggerHandleFault(interceptorIndex, messageContext); triggerAfterCompletion(interceptorIndex, messageContext, null); return (T) handleFault(connection, messageContext); } - } else { + } + else { triggerAfterCompletion(interceptorIndex, messageContext, null); return null; } - } catch (TransformerException ex) { + } + catch (TransformerException ex) { triggerAfterCompletion(interceptorIndex, messageContext, ex); throw new WebServiceTransformerException("Transformation error: " + ex.getMessage(), ex); - } catch (RuntimeException | IOException ex) { + } + catch (RuntimeException | IOException ex) { // Trigger after-completion for thrown exception. triggerAfterCompletion(interceptorIndex, messageContext, ex); throw ex; @@ -621,7 +668,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService ByteArrayOutputStream os = new ByteArrayOutputStream(); request.writeTo(os); sentMessageTracingLogger.trace("Sent request [" + os.toString(StandardCharsets.UTF_8) + "]"); - } else if (sentMessageTracingLogger.isDebugEnabled()) { + } + else if (sentMessageTracingLogger.isDebugEnabled()) { sentMessageTracingLogger.debug("Sent request [" + request + "]"); } connection.send(request); @@ -630,9 +678,9 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * Determines whether the given connection or message context has an error. *

- * This implementation checks the {@link WebServiceConnection#hasError() connection} first. If it indicates an error, - * it makes sure that it is not a {@link FaultAwareWebServiceConnection#hasFault() fault}. - * + * This implementation checks the {@link WebServiceConnection#hasError() connection} + * first. If it indicates an error, it makes sure that it is not a + * {@link FaultAwareWebServiceConnection#hasFault() fault}. * @param connection the connection (possibly a {@link FaultAwareWebServiceConnection} * @param request the response message (possibly a {@link FaultAwareWebServiceMessage} * @return {@code true} if the connection has an error; {@code false} otherwise @@ -644,7 +692,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService if (checkConnectionForFault && connection instanceof FaultAwareWebServiceConnection) { FaultAwareWebServiceConnection faultConnection = (FaultAwareWebServiceConnection) connection; return !(faultConnection.hasFault() && request instanceof FaultAwareWebServiceMessage); - } else { + } + else { return true; } } @@ -652,12 +701,13 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Handles an error on the given connection. The default implementation throws a {@link WebServiceTransportException}. - * + * Handles an error on the given connection. The default implementation throws a + * {@link WebServiceTransportException}. * @param connection the erroneous connection * @param request the corresponding request message * @return the object to be returned from - * {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)}, if any + * {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)}, + * if any */ protected Object handleError(WebServiceConnection connection, WebServiceMessage request) throws IOException { if (logger.isDebugEnabled()) { @@ -673,15 +723,19 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService messageContext.getRequest().writeTo(requestStream); ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); messageContext.getResponse().writeTo(responseStream); - receivedMessageTracingLogger.trace("Received response [" + responseStream.toString(StandardCharsets.UTF_8) + "] for request [" - + requestStream.toString(StandardCharsets.UTF_8) + "]"); - } else if (receivedMessageTracingLogger.isDebugEnabled()) { - receivedMessageTracingLogger.debug("Received response [" + messageContext.getResponse() + "] for request [" - + messageContext.getRequest() + "]"); + receivedMessageTracingLogger + .trace("Received response [" + responseStream.toString(StandardCharsets.UTF_8) + "] for request [" + + requestStream.toString(StandardCharsets.UTF_8) + "]"); } - } else { + else if (receivedMessageTracingLogger.isDebugEnabled()) { + receivedMessageTracingLogger.debug("Received response [" + messageContext.getResponse() + + "] for request [" + messageContext.getRequest() + "]"); + } + } + else { if (receivedMessageTracingLogger.isDebugEnabled()) { - receivedMessageTracingLogger.debug("Received no response for request [" + messageContext.getRequest() + "]"); + receivedMessageTracingLogger + .debug("Received no response for request [" + messageContext.getRequest() + "]"); } } } @@ -689,13 +743,15 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * Determines whether the given connection or message has a fault. *

- * This implementation checks the {@link FaultAwareWebServiceConnection#hasFault() connection} if the - * {@link #setCheckConnectionForFault(boolean) checkConnectionForFault} property is true, and defaults to the + * This implementation checks the {@link FaultAwareWebServiceConnection#hasFault() + * connection} if the {@link #setCheckConnectionForFault(boolean) + * checkConnectionForFault} property is true, and defaults to the * {@link FaultAwareWebServiceMessage#hasFault() message} otherwise. - * * @param connection the connection (possibly a {@link FaultAwareWebServiceConnection} - * @param response the response message (possibly a {@link FaultAwareWebServiceMessage} - * @return {@code true} if either the connection or the message has a fault; {@code false} otherwise + * @param response the response message (possibly a + * {@link FaultAwareWebServiceMessage} + * @return {@code true} if either the connection or the message has a fault; + * {@code false} otherwise * @throws IOException in case of I/O errors */ protected boolean hasFault(WebServiceConnection connection, WebServiceMessage response) throws IOException { @@ -707,7 +763,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } } if (response instanceof FaultAwareWebServiceMessage) { - // either the connection has a fault, or checkConnectionForFault is false: let's verify the fault + // either the connection has a fault, or checkConnectionForFault is false: + // let's verify the fault FaultAwareWebServiceMessage faultMessage = (FaultAwareWebServiceMessage) response; return faultMessage.hasFault(); } @@ -715,9 +772,9 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Trigger handleResponse on the defined ClientInterceptors. Will just invoke said method on all interceptors whose - * handleRequest invocation returned {@code true}, in addition to the last interceptor who returned {@code false}. - * + * Trigger handleResponse on the defined ClientInterceptors. Will just invoke said + * method on all interceptors whose handleRequest invocation returned {@code true}, in + * addition to the last interceptor who returned {@code false}. * @param interceptorIndex index of last interceptor that was called * @param messageContext the message context, whose request and response are filled * @see ClientInterceptor#handleResponse(MessageContext) @@ -734,9 +791,9 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Trigger handleFault on the defined ClientInterceptors. Will just invoke said method on all interceptors whose - * handleRequest invocation returned {@code true}, in addition to the last interceptor who returned {@code false}. - * + * Trigger handleFault on the defined ClientInterceptors. Will just invoke said method + * on all interceptors whose handleRequest invocation returned {@code true}, in + * addition to the last interceptor who returned {@code false}. * @param interceptorIndex index of last interceptor that was called * @param messageContext the message context, whose request and response are filled * @see ClientInterceptor#handleResponse(MessageContext) @@ -753,10 +810,10 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Trigger afterCompletion callbacks on the mapped ClientInterceptors. Will just invoke afterCompletion for all - * interceptors whose handleRequest invocation has successfully completed and returned true, in addition to the last - * interceptor who returned {@code false}. - * + * Trigger afterCompletion callbacks on the mapped ClientInterceptors. Will just + * invoke afterCompletion for all interceptors whose handleRequest invocation has + * successfully completed and returned true, in addition to the last interceptor who + * returned {@code false}. * @param interceptorIndex index of last interceptor that successfully completed * @param messageContext the message context * @param ex Exception thrown on handler execution, or {@code null} if none @@ -772,13 +829,14 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } /** - * Handles an fault in the given response message. The default implementation invokes the {@link FaultMessageResolver - * fault resolver} if registered, or invokes {@link #handleError(WebServiceConnection, WebServiceMessage)} otherwise. - * + * Handles an fault in the given response message. The default implementation invokes + * the {@link FaultMessageResolver fault resolver} if registered, or invokes + * {@link #handleError(WebServiceConnection, WebServiceMessage)} otherwise. * @param connection the faulty connection * @param messageContext the message context * @return the object to be returned from - * {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)}, if any + * {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)}, + * if any */ protected Object handleFault(WebServiceConnection connection, MessageContext messageContext) throws IOException { if (logger.isDebugEnabled()) { @@ -787,12 +845,16 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService if (getFaultMessageResolver() != null) { getFaultMessageResolver().resolveFault(messageContext.getResponse()); return null; - } else { + } + else { return handleError(connection, messageContext.getRequest()); } } - /** Adapter to enable use of a WebServiceMessageCallback inside a WebServiceMessageExtractor. */ + /** + * Adapter to enable use of a WebServiceMessageCallback inside a + * WebServiceMessageExtractor. + */ private static class WebServiceMessageCallbackMessageExtractor implements WebServiceMessageExtractor { private final WebServiceMessageCallback callback; @@ -806,6 +868,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService callback.doWithMessage(message); return Boolean.TRUE; } + } /** Adapter to enable use of a SourceExtractor inside a WebServiceMessageExtractor. */ @@ -821,6 +884,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService public T extractData(WebServiceMessage message) throws IOException, TransformerException { return sourceExtractor.extractData(message.getPayloadSource()); } + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/core/support/WebServiceGatewaySupport.java b/spring-ws-core/src/main/java/org/springframework/ws/client/core/support/WebServiceGatewaySupport.java index 1cd4ae86..f0b39341 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/core/support/WebServiceGatewaySupport.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/core/support/WebServiceGatewaySupport.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,17 +31,22 @@ import org.springframework.ws.transport.WebServiceMessageSender; /** * Convenient super class for application classes that need Web service access. *

- * Requires a {@link WebServiceMessageFactory} or a {@link WebServiceTemplate} instance to be set. It will create its - * own {@code WebServiceTemplate} if {@code WebServiceMessageFactory} is passed in. + * Requires a {@link WebServiceMessageFactory} or a {@link WebServiceTemplate} instance to + * be set. It will create its own {@code WebServiceTemplate} if + * {@code WebServiceMessageFactory} is passed in. *

- * In addition to the message factory property, this gateway offers {@link Marshaller} and {@link Unmarshaller} - * properties. Setting these is required when the {@link WebServiceTemplate#marshalSendAndReceive(Object) marshalling - * methods} of the template are to be used. + * In addition to the message factory property, this gateway offers {@link Marshaller} and + * {@link Unmarshaller} properties. Setting these is required when the + * {@link WebServiceTemplate#marshalSendAndReceive(Object) marshalling methods} of the + * template are to be used. *

- * Note that when {@link #setWebServiceTemplate(WebServiceTemplate) injecting a {@code WebServiceTemplate}} directly, - * the convenience setters ({@link #setMarshaller(Marshaller)}, {@link #setUnmarshaller(Unmarshaller)}, - * {@link #setMessageSender(WebServiceMessageSender)}, {@link #setMessageSenders(WebServiceMessageSender[])}, and - * {@link #setDefaultUri(String)}) should not be used on this class, but on the template directly. + * Note that when {@link #setWebServiceTemplate(WebServiceTemplate) injecting a + * {@code WebServiceTemplate}} directly, the convenience setters + * ({@link #setMarshaller(Marshaller)}, {@link #setUnmarshaller(Unmarshaller)}, + * {@link #setMessageSender(WebServiceMessageSender)}, + * {@link #setMessageSenders(WebServiceMessageSender[])}, and + * {@link #setDefaultUri(String)}) should not be used on this class, but on the template + * directly. * * @author Arjen Poutsma * @see #setMessageFactory(WebServiceMessageFactory) @@ -57,15 +62,16 @@ public abstract class WebServiceGatewaySupport implements InitializingBean { private WebServiceTemplate webServiceTemplate; /** - * Creates a new instance of the {@code WebServiceGatewaySupport} class, with a default {@code WebServiceTemplate}. + * Creates a new instance of the {@code WebServiceGatewaySupport} class, with a + * default {@code WebServiceTemplate}. */ protected WebServiceGatewaySupport() { webServiceTemplate = new WebServiceTemplate(); } /** - * Creates a new {@code WebServiceGatewaySupport} instance based on the given message factory. - * + * Creates a new {@code WebServiceGatewaySupport} instance based on the given message + * factory. * @param messageFactory the message factory to use */ protected WebServiceGatewaySupport(WebServiceMessageFactory messageFactory) { @@ -125,10 +131,12 @@ public abstract class WebServiceGatewaySupport implements InitializingBean { /** * Sets the {@code WebServiceTemplate} to be used by the gateway. *

- * When using this property, the convenience setters ({@link #setMarshaller(Marshaller)}, - * {@link #setUnmarshaller(Unmarshaller)}, {@link #setMessageSender(WebServiceMessageSender)}, - * {@link #setMessageSenders(WebServiceMessageSender[])}, and {@link #setDefaultUri(String)}) should not be set on - * this class, but on the template directly. + * When using this property, the convenience setters + * ({@link #setMarshaller(Marshaller)}, {@link #setUnmarshaller(Unmarshaller)}, + * {@link #setMessageSender(WebServiceMessageSender)}, + * {@link #setMessageSenders(WebServiceMessageSender[])}, and + * {@link #setDefaultUri(String)}) should not be set on this class, but on the + * template directly. */ public final void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) { Assert.notNull(webServiceTemplate, "'webServiceTemplate' must not be null"); @@ -141,9 +149,9 @@ public abstract class WebServiceGatewaySupport implements InitializingBean { } /** - * Sets the {@code Marshaller} used by the gateway. Setting this property is only required if the marshalling - * functionality of {@code WebServiceTemplate} is to be used. - * + * Sets the {@code Marshaller} used by the gateway. Setting this property is only + * required if the marshalling functionality of {@code WebServiceTemplate} is to be + * used. * @see WebServiceTemplate#marshalSendAndReceive */ public final void setMarshaller(Marshaller marshaller) { @@ -156,9 +164,9 @@ public abstract class WebServiceGatewaySupport implements InitializingBean { } /** - * Sets the {@code Unmarshaller} used by the gateway. Setting this property is only required if the marshalling - * functionality of {@code WebServiceTemplate} is to be used. - * + * Sets the {@code Unmarshaller} used by the gateway. Setting this property is only + * required if the marshalling functionality of {@code WebServiceTemplate} is to be + * used. * @see WebServiceTemplate#marshalSendAndReceive */ public final void setUnmarshaller(Unmarshaller unmarshaller) { @@ -182,11 +190,11 @@ public abstract class WebServiceGatewaySupport implements InitializingBean { } /** - * Subclasses can override this for custom initialization behavior. Gets called after population of this instance's - * bean properties. - * + * Subclasses can override this for custom initialization behavior. Gets called after + * population of this instance's bean properties. * @throws java.lang.Exception if initialization fails */ - protected void initGateway() throws Exception {} + protected void initGateway() throws Exception { + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/WebServiceAccessor.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/WebServiceAccessor.java index 8529781e..8bd959f5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/WebServiceAccessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/WebServiceAccessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -28,10 +28,12 @@ import org.springframework.ws.transport.WebServiceMessageSender; import org.springframework.xml.transform.TransformerObjectSupport; /** - * Base class for {@code WebServiceTemplate} and other WS-accessing helpers. Defines common properties like the - * {@link WebServiceMessageFactory} and {@link WebServiceMessageSender}. + * Base class for {@code WebServiceTemplate} and other WS-accessing helpers. Defines + * common properties like the {@link WebServiceMessageFactory} and + * {@link WebServiceMessageSender}. *

- * Not intended to be used directly. See {@link org.springframework.ws.client.core.WebServiceTemplate}. + * Not intended to be used directly. See + * {@link org.springframework.ws.client.core.WebServiceTemplate}. * * @author Arjen Poutsma * @see org.springframework.ws.client.core.WebServiceTemplate @@ -61,8 +63,8 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem /** * Sets the single message sender used for sending messages. *

- * This message sender will be used to resolve an URI to a {@link WebServiceConnection}. - * + * This message sender will be used to resolve an URI to a + * {@link WebServiceConnection}. * @see #createConnection(URI) */ public void setMessageSender(WebServiceMessageSender messageSender) { @@ -73,8 +75,8 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem /** * Sets the message senders used for sending messages. *

- * These message senders will be used to resolve an URI to a {@link WebServiceConnection}. - * + * These message senders will be used to resolve an URI to a + * {@link WebServiceConnection}. * @see #createConnection(URI) */ public void setMessageSenders(WebServiceMessageSender[] messageSenders) { @@ -89,12 +91,13 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem } /** - * Creates a connection to the given URI, or throws an exception when it cannot be resolved. + * Creates a connection to the given URI, or throws an exception when it cannot be + * resolved. *

- * Default implementation iterates over all configured {@link WebServiceMessageSender} objects, and calls - * {@link WebServiceMessageSender#supports(URI)} for each of them. If the sender supports the parameter URI, it - * creates a connection using {@link WebServiceMessageSender#createConnection(URI)} . - * + * Default implementation iterates over all configured {@link WebServiceMessageSender} + * objects, and calls {@link WebServiceMessageSender#supports(URI)} for each of them. + * If the sender supports the parameter URI, it creates a connection using + * {@link WebServiceMessageSender#createConnection(URI)} . * @param uri the URI to open a connection to * @return the created connection * @throws IllegalArgumentException when the uri cannot be resolved @@ -109,7 +112,8 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem if (logger.isDebugEnabled()) { try { logger.debug("Opening [" + connection + "] to [" + connection.getUri() + "]"); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { // ignore } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/AbstractCachingDestinationProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/AbstractCachingDestinationProvider.java index c9fed4f5..a54a149e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/AbstractCachingDestinationProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/AbstractCachingDestinationProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,10 +22,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * Abstract base class for {@link DestinationProvider} implementations that cache destination URI. + * Abstract base class for {@link DestinationProvider} implementations that cache + * destination URI. *

- * Caching can be disabled by setting the {@link #setCache(boolean) cache} property to {@code false}; forcing a - * destination lookup for every call. + * Caching can be disabled by setting the {@link #setCache(boolean) cache} property to + * {@code false}; forcing a destination lookup for every call. * * @author Arjen Poutsma * @since 1.5.4 @@ -40,9 +41,9 @@ public abstract class AbstractCachingDestinationProvider implements DestinationP private boolean cache = true; /** - * Set whether to cache resolved destinations. Default is {@code true}. This flag can be turned off to re-lookup a - * destination for each operation, which allows for hot restarting of destinations. This is mainly useful during - * development. + * Set whether to cache resolved destinations. Default is {@code true}. This flag can + * be turned off to re-lookup a destination for each operation, which allows for hot + * restarting of destinations. This is mainly useful during development. */ public void setCache(boolean cache) { this.cache = cache; @@ -55,7 +56,8 @@ public abstract class AbstractCachingDestinationProvider implements DestinationP cachedUri = lookupDestination(); } return cachedUri; - } else { + } + else { return lookupDestination(); } } @@ -63,9 +65,10 @@ public abstract class AbstractCachingDestinationProvider implements DestinationP /** * Abstract template method that looks up the URI. *

- * If {@linkplain #setCache(boolean) caching} is enabled, this method will only be called once. - * + * If {@linkplain #setCache(boolean) caching} is enabled, this method will only be + * called once. * @return the destination URI */ protected abstract URI lookupDestination(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/DestinationProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/DestinationProvider.java index cf95afb0..74cebf3b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/DestinationProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/DestinationProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,11 +19,12 @@ package org.springframework.ws.client.support.destination; import java.net.URI; /** - * Strategy interface for providing a {@link org.springframework.ws.client.core.WebServiceTemplate} destination URI at + * Strategy interface for providing a + * {@link org.springframework.ws.client.core.WebServiceTemplate} destination URI at * runtime. *

- * Typically implemented by providers that use WSDL, a UDDI registry, or some other form to determine the destination - * URI. + * Typically implemented by providers that use WSDL, a UDDI registry, or some other form + * to determine the destination URI. * * @author Arjen Poutsma * @see org.springframework.ws.client.core.WebServiceTemplate#setDestinationProvider(DestinationProvider) @@ -33,7 +34,6 @@ public interface DestinationProvider { /** * Return the destination URI. - * * @return the destination URI */ URI getDestination(); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/DestinationProvisionException.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/DestinationProvisionException.java index cf5c3654..c7be31a8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/DestinationProvisionException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/DestinationProvisionException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public class DestinationProvisionException extends WebServiceClientException { public DestinationProvisionException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/Wsdl11DestinationProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/Wsdl11DestinationProvider.java index 786af275..04f6eeef 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/Wsdl11DestinationProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/destination/Wsdl11DestinationProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,6 +26,8 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; +import org.w3c.dom.Document; + import org.springframework.core.io.Resource; import org.springframework.util.Assert; import org.springframework.ws.client.WebServiceIOException; @@ -34,14 +36,15 @@ import org.springframework.xml.transform.ResourceSource; import org.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.xpath.XPathExpression; import org.springframework.xml.xpath.XPathExpressionFactory; -import org.w3c.dom.Document; /** - * Implementation of the {@link DestinationProvider} that resolves a destination URI from a WSDL file. + * Implementation of the {@link DestinationProvider} that resolves a destination URI from + * a WSDL file. *

* The extraction relies on an XPath expression to locate the URI. By default, the - * {@link #DEFAULT_WSDL_LOCATION_EXPRESSION} will be used, but this expression can be overridden by setting the - * {@link #setLocationExpression(String) locationExpression} property. + * {@link #DEFAULT_WSDL_LOCATION_EXPRESSION} will be used, but this expression can be + * overridden by setting the {@link #setLocationExpression(String) locationExpression} + * property. * * @author Tareq Abed Rabbo * @author Arjen Poutsma @@ -49,7 +52,10 @@ import org.w3c.dom.Document; */ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvider { - /** Default XPath expression used for extracting all {@code location} attributes from the WSDL definition. */ + /** + * Default XPath expression used for extracting all {@code location} attributes from + * the WSDL definition. + */ public static final String DEFAULT_WSDL_LOCATION_EXPRESSION = "/wsdl:definitions/wsdl:service/wsdl:port/soap:address/@location"; private static TransformerFactory transformerFactory = TransformerFactoryUtils.newInstance(); @@ -69,7 +75,10 @@ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvide expressionNamespaces); } - /** Sets a WSDL location from which the service destination {@code URI} will be resolved. */ + /** + * Sets a WSDL location from which the service destination {@code URI} will be + * resolved. + */ public void setWsdl(Resource wsdlResource) { Assert.notNull(wsdlResource, "'wsdl' must not be null"); Assert.isTrue(wsdlResource.exists(), wsdlResource + " does not exist"); @@ -77,7 +86,8 @@ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvide } /** - * Sets the XPath expression to use when extracting the service location {@code URI} from a WSDL. + * Sets the XPath expression to use when extracting the service location {@code URI} + * from a WSDL. *

* The expression can use the following bound prefixes:

* @@ -119,9 +129,11 @@ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvide logger.debug("Found location [" + location + "] in " + wsdlResource); } return location != null ? URI.create(location) : null; - } catch (IOException ex) { + } + catch (IOException ex) { throw new WebServiceIOException("Error extracting location from WSDL [" + wsdlResource + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new WebServiceTransformerException("Error extracting location from WSDL [" + wsdlResource + "]", ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/AbstractValidatingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/AbstractValidatingInterceptor.java index a0446f4a..bdb79a0e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/AbstractValidatingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/AbstractValidatingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,6 +20,8 @@ import java.io.IOException; import javax.xml.transform.Source; +import org.xml.sax.SAXParseException; + import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -34,15 +36,15 @@ import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.validation.XmlValidatorFactory; import org.springframework.xml.xsd.XsdSchema; import org.springframework.xml.xsd.XsdSchemaCollection; -import org.xml.sax.SAXParseException; /** - * Abstract base class for {@link ClientInterceptor} implementations that validate part of the message using a schema. - * The exact message part is determined by the {@link #getValidationRequestSource(WebServiceMessage)} and + * Abstract base class for {@link ClientInterceptor} implementations that validate part of + * the message using a schema. The exact message part is determined by the + * {@link #getValidationRequestSource(WebServiceMessage)} and * {@link #getValidationResponseSource(WebServiceMessage)} template methods. *

- * By default, only the request message is validated, but this behaviour can be changed using the - * {@code validateRequest} and {@code validateResponse} properties. + * By default, only the request message is validated, but this behaviour can be changed + * using the {@code validateRequest} and {@code validateResponse} properties. * * @author Arjen Poutsma * @see #getValidationRequestSource(WebServiceMessage) @@ -67,8 +69,8 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Sets the schema language. Default is the W3C XML Schema: {@code http://www.w3.org/2001/XMLSchema"}. - * + * Sets the schema language. Default is the W3C XML Schema: + * {@code http://www.w3.org/2001/XMLSchema"}. * @see XmlValidatorFactory#SCHEMA_W3C_XML * @see XmlValidatorFactory#SCHEMA_RELAX_NG */ @@ -83,8 +85,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** * Sets the schema resource to use for validation. Setting this property, - * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or - * {@link #setSchemas(Resource[]) schemas} is required. + * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, + * {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is + * required. */ public void setSchema(Resource schema) { setSchemas(schema); @@ -92,8 +95,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** * Sets the schema resources to use for validation. Setting this property, - * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or - * {@link #setSchemas(Resource[]) schemas} is required. + * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, + * {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is + * required. */ public void setSchemas(Resource... schemas) { Assert.notEmpty(schemas, "schemas must not be empty or null"); @@ -106,9 +110,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** * Sets the {@link XsdSchema} to use for validation. Setting this property, - * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or - * {@link #setSchemas(Resource[]) schemas} is required. - * + * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, + * {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is + * required. * @param schema the xsd schema to use * @throws java.io.IOException in case of I/O errors */ @@ -117,9 +121,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Sets the {@link XsdSchemaCollection} to use for validation. Setting this property, {@link #setXsdSchema(XsdSchema) - * xsdSchema}, {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is required. - * + * Sets the {@link XsdSchemaCollection} to use for validation. Setting this property, + * {@link #setXsdSchema(XsdSchema) xsdSchema}, {@link #setSchema(Resource) schema}, or + * {@link #setSchemas(Resource[]) schemas} is required. * @param schemaCollection the xsd schema collection to use * @throws java.io.IOException in case of I/O errors */ @@ -127,12 +131,18 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup this.validator = schemaCollection.createValidator(); } - /** Indicates whether the request should be validated against the schema. Default is {@code true}. */ + /** + * Indicates whether the request should be validated against the schema. Default is + * {@code true}. + */ public void setValidateRequest(boolean validateRequest) { this.validateRequest = validateRequest; } - /** Indicates whether the response should be validated against the schema. Default is {@code false}. */ + /** + * Indicates whether the response should be validated against the schema. Default is + * {@code false}. + */ public void setValidateResponse(boolean validateResponse) { this.validateResponse = validateResponse; } @@ -153,11 +163,11 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Validates the request message in the given message context. Validation only occurs if - * {@link #setValidateRequest(boolean) validateRequest} is set to {@code true}, which is the default. + * Validates the request message in the given message context. Validation only occurs + * if {@link #setValidateRequest(boolean) validateRequest} is set to {@code true}, + * which is the default. *

* Returns {@code true} if the request is valid, or {@code false} if it isn't. - * * @param messageContext the message context * @return {@code true} if the message is valid; {@code false} otherwise * @see #setValidateRequest(boolean) @@ -170,12 +180,14 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup SAXParseException[] errors; try { errors = validator.validate(requestSource); - } catch (IOException e) { + } + catch (IOException e) { throw new WebServiceIOException("Could not validate response: " + e.getMessage(), e); } if (!ObjectUtils.isEmpty(errors)) { return handleRequestValidationErrors(messageContext, errors); - } else if (logger.isDebugEnabled()) { + } + else if (logger.isDebugEnabled()) { logger.debug("Request message validated"); } } @@ -186,9 +198,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** * Template method that is called when the request message contains validation errors. *

- * Default implementation logs all errors, and throws a {@link WebServiceValidationException}. Subclasses can override - * this method to customize this behavior. - * + * Default implementation logs all errors, and throws a + * {@link WebServiceValidationException}. Subclasses can override this method to + * customize this behavior. * @param messageContext the message context * @param errors the validation errors * @return {@code true} to continue processing the request, {@code false} otherwise @@ -201,12 +213,11 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Validates the response message in the given message context. Validation only occurs if - * {@link #setValidateResponse(boolean) validateResponse} is set to {@code true}, which is not the - * default. + * Validates the response message in the given message context. Validation only occurs + * if {@link #setValidateResponse(boolean) validateResponse} is set to {@code true}, + * which is not the default. *

* Returns {@code true} if the request is valid, or {@code false} if it isn't. - * * @param messageContext the message context. * @return {@code true} if the response is valid; {@code false} otherwise * @see #setValidateResponse(boolean) @@ -219,12 +230,14 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup SAXParseException[] errors; try { errors = validator.validate(responseSource); - } catch (IOException e) { + } + catch (IOException e) { throw new WebServiceIOException("Could not validate response: " + e.getMessage(), e); } if (!ObjectUtils.isEmpty(errors)) { return handleResponseValidationErrors(messageContext, errors); - } else if (logger.isDebugEnabled()) { + } + else if (logger.isDebugEnabled()) { logger.debug("Response message validated"); } } @@ -233,14 +246,15 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Template method that is called when the response message contains validation errors. + * Template method that is called when the response message contains validation + * errors. *

- * Default implementation logs all errors, and returns {@code false}, i.e. do not cot continue to process the respone - * interceptor chain. - * + * Default implementation logs all errors, and returns {@code false}, i.e. do not cot + * continue to process the respone interceptor chain. * @param messageContext the message context * @param errors the validation errors - * @return {@code true} to continue the reponse interceptor chain, {@code false} (the default) otherwise + * @return {@code true} to continue the reponse interceptor chain, {@code false} (the + * default) otherwise */ protected boolean handleResponseValidationErrors(MessageContext messageContext, SAXParseException[] errors) throws WebServiceValidationException { @@ -258,21 +272,25 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** Does nothing by default. */ @Override - public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException {} + public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException { + } /** - * Abstract template method that returns the part of the request message that is to be validated. - * + * Abstract template method that returns the part of the request message that is to be + * validated. * @param request the request message - * @return the part of the message that is to validated, or {@code null} not to validate anything + * @return the part of the message that is to validated, or {@code null} not to + * validate anything */ protected abstract Source getValidationRequestSource(WebServiceMessage request); /** - * Abstract template method that returns the part of the response message that is to be validated. - * + * Abstract template method that returns the part of the response message that is to + * be validated. * @param response the response message - * @return the part of the message that is to validated, or {@code null} not to validate anything + * @return the part of the message that is to validated, or {@code null} not to + * validate anything */ protected abstract Source getValidationResponseSource(WebServiceMessage response); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/ClientInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/ClientInterceptor.java index d916df3b..58355b79 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/ClientInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/ClientInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,20 +22,24 @@ import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.transport.WebServiceConnection; /** - * Workflow interface that allows for customized client-side message interception. Applications can register any number - * of existing or custom interceptors on a {@link org.springframework.ws.client.core.WebServiceTemplate}, to add common - * pre- and postprocessing behavior without needing to modify payload handling code. + * Workflow interface that allows for customized client-side message interception. + * Applications can register any number of existing or custom interceptors on a + * {@link org.springframework.ws.client.core.WebServiceTemplate}, to add common pre- and + * postprocessing behavior without needing to modify payload handling code. *

* A {@code ClientInterceptor} gets called after payload creation (using - * {@link org.springframework.ws.client.core.WebServiceTemplate#marshalSendAndReceive(Object)} or similar methods, and - * after {@link org.springframework.ws.client.core.WebServiceMessageCallback callback} invocation, but before the - * message is sent over the {@link WebServiceConnection}. This mechanism can be used for a large field of preprocessing - * aspects, e.g. for authorization checks, or message header checks. Its main purpose is to allow for factoring out - * meta-data (i.e. {@link SoapHeader}) related code. + * {@link org.springframework.ws.client.core.WebServiceTemplate#marshalSendAndReceive(Object)} + * or similar methods, and after + * {@link org.springframework.ws.client.core.WebServiceMessageCallback callback} + * invocation, but before the message is sent over the {@link WebServiceConnection}. This + * mechanism can be used for a large field of preprocessing aspects, e.g. for + * authorization checks, or message header checks. Its main purpose is to allow for + * factoring out meta-data (i.e. {@link SoapHeader}) related code. *

- * Client interceptors are defined on a {@link org.springframework.ws.client.core.WebServiceTemplate}, using the - * {@link org.springframework.ws.client.core.WebServiceTemplate#setInterceptors(ClientInterceptor[]) interceptors} - * property. + * Client interceptors are defined on a + * {@link org.springframework.ws.client.core.WebServiceTemplate}, using the + * {@link org.springframework.ws.client.core.WebServiceTemplate#setInterceptors(ClientInterceptor[]) + * interceptors} property. * * @author Giovanni Cuccu * @author Arjen Poutsma @@ -45,40 +49,41 @@ import org.springframework.ws.transport.WebServiceConnection; public interface ClientInterceptor { /** - * Processes the outgoing request message. Called after payload creation and callback invocation, but before the - * message is sent. - * + * Processes the outgoing request message. Called after payload creation and callback + * invocation, but before the message is sent. * @param messageContext contains the outgoing request message - * @return {@code true} to continue processing of the request interceptors; {@code false} to indicate blocking of the - * request endpoint chain + * @return {@code true} to continue processing of the request interceptors; + * {@code false} to indicate blocking of the request endpoint chain * @throws WebServiceClientException in case of errors * @see MessageContext#getRequest() */ boolean handleRequest(MessageContext messageContext) throws WebServiceClientException; /** - * Processes the incoming response message. Called for non-fault response messages before payload handling in the + * Processes the incoming response message. Called for non-fault response messages + * before payload handling in the * {@link org.springframework.ws.client.core.WebServiceTemplate}. *

- * Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed. - * + * Note: Will only be called if this interceptor's {@link #handleRequest} method has + * successfully completed. * @param messageContext contains the outgoing request message - * @return {@code true} to continue processing of the request interceptors; {@code false} to indicate blocking of the - * response endpoint chain + * @return {@code true} to continue processing of the request interceptors; + * {@code false} to indicate blocking of the response endpoint chain * @throws WebServiceClientException in case of errors * @see MessageContext#getResponse() */ boolean handleResponse(MessageContext messageContext) throws WebServiceClientException; /** - * Processes the incoming response fault. Called for response fault messages before payload handling in the + * Processes the incoming response fault. Called for response fault messages before + * payload handling in the * {@link org.springframework.ws.client.core.WebServiceTemplate}. *

- * Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed. - * + * Note: Will only be called if this interceptor's {@link #handleRequest} method has + * successfully completed. * @param messageContext contains the outgoing request message - * @return {@code true} to continue processing of the request interceptors; {@code false} to indicate blocking of the - * request endpoint chain + * @return {@code true} to continue processing of the request interceptors; + * {@code false} to indicate blocking of the request endpoint chain * @throws WebServiceClientException in case of errors * @see MessageContext#getResponse() * @see org.springframework.ws.FaultAwareWebServiceMessage#hasFault() @@ -86,12 +91,13 @@ public interface ClientInterceptor { boolean handleFault(MessageContext messageContext) throws WebServiceClientException; /** - * Callback after completion of request and response (fault) processing. Will be called on any outcome, thus allows - * for proper resource cleanup. + * Callback after completion of request and response (fault) processing. Will be + * called on any outcome, thus allows for proper resource cleanup. *

- * Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed. - * - * @param messageContext contains both request and response messages, the response should contains a Fault + * Note: Will only be called if this interceptor's {@link #handleRequest} method has + * successfully completed. + * @param messageContext contains both request and response messages, the response + * should contains a Fault * @param ex exception thrown on handler execution, if any * @throws WebServiceClientException in case of errors * @since 2.2 diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/ClientInterceptorAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/ClientInterceptorAdapter.java index 59b11261..4ef9fe79 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/ClientInterceptorAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/ClientInterceptorAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,8 @@ import org.springframework.ws.client.WebServiceClientException; import org.springframework.ws.context.MessageContext; /** - * Default implementation of the {@code ClientInterceptor} interface, for simplified implementation of - * pre-only/post-only interceptors. + * Default implementation of the {@code ClientInterceptor} interface, for simplified + * implementation of pre-only/post-only interceptors. * * @author Marten Deinum * @since 2.2.5 @@ -56,4 +56,5 @@ public abstract class ClientInterceptorAdapter implements ClientInterceptor { public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException { } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/PayloadValidatingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/PayloadValidatingInterceptor.java index 07a64431..3e268b79 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/PayloadValidatingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/PayloadValidatingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,14 +21,16 @@ import javax.xml.transform.Source; import org.springframework.ws.WebServiceMessage; /** - * Client-side interceptor that validates the contents of {@code WebServiceMessage}s using a schema. Allows for both W3C - * XML and RELAX NG schemas. + * Client-side interceptor that validates the contents of {@code WebServiceMessage}s using + * a schema. Allows for both W3C XML and RELAX NG schemas. *

- * When the payload is invalid, this interceptor stops processing of the interceptor chain. + * When the payload is invalid, this interceptor stops processing of the interceptor + * chain. *

- * The schema to validate against is set with the {@code schema} property or {@code schemas} property. By default, only - * the request message is validated, but this behaviour can be changed using the {@code validateRequest} and - * {@code validateResponse} properties. Responses that contains faults are not validated. + * The schema to validate against is set with the {@code schema} property or + * {@code schemas} property. By default, only the request message is validated, but this + * behaviour can be changed using the {@code validateRequest} and {@code validateResponse} + * properties. Responses that contains faults are not validated. * * @author Stefan Schmidt * @author Arjen Poutsma @@ -42,9 +44,9 @@ public class PayloadValidatingInterceptor extends AbstractValidatingInterceptor /** * Returns the part of the request message that is to be validated. Default - * * @param request the request message - * @return the part of the message that is to validated, or {@code null} not to validate anything + * @return the part of the message that is to validated, or {@code null} not to + * validate anything */ @Override protected Source getValidationRequestSource(WebServiceMessage request) { @@ -53,12 +55,13 @@ public class PayloadValidatingInterceptor extends AbstractValidatingInterceptor /** * Returns the part of the response message that is to be validated. - * * @param response the response message - * @return the part of the message that is to validated, or {@code null} not to validate anything + * @return the part of the message that is to validated, or {@code null} not to + * validate anything */ @Override protected Source getValidationResponseSource(WebServiceMessage response) { return response.getPayloadSource(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/WebServiceValidationException.java b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/WebServiceValidationException.java index 5d511170..1fd25958 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/WebServiceValidationException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/client/support/interceptor/WebServiceValidationException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,10 @@ package org.springframework.ws.client.support.interceptor; -import org.springframework.ws.client.WebServiceClientException; import org.xml.sax.SAXParseException; +import org.springframework.ws.client.WebServiceClientException; + /** * Exception thrown whenever a validation error occurs on the client-side. * @@ -52,4 +53,5 @@ public class WebServiceValidationException extends WebServiceClientException { public SAXParseException[] getValidationErrors() { return validationErrors; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java b/spring-ws-core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java index d3db7cd0..448ace96 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,6 +16,8 @@ package org.springframework.ws.config; +import org.w3c.dom.Element; + import org.springframework.beans.BeanMetadataElement; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; @@ -46,10 +48,10 @@ import org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionR import org.springframework.ws.soap.server.endpoint.adapter.method.SoapHeaderElementMethodArgumentResolver; import org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver; import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping; -import org.w3c.dom.Element; /** - * {@link BeanDefinitionParser} that parses the {@code annotation-driven} element to configure a Spring WS application. + * {@link BeanDefinitionParser} that parses the {@code annotation-driven} element to + * configure a Spring WS application. * * @author Arjen Poutsma * @since 2.0 @@ -90,8 +92,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { } private void registerEndpointMappings(Object source, ParserContext parserContext) { - RootBeanDefinition payloadRootMappingDef = createBeanDefinition(PayloadRootAnnotationMethodEndpointMapping.class, - source); + RootBeanDefinition payloadRootMappingDef = createBeanDefinition( + PayloadRootAnnotationMethodEndpointMapping.class, source); payloadRootMappingDef.getPropertyValues().add("order", 0); parserContext.getReaderContext().registerWithGeneratedName(payloadRootMappingDef); @@ -135,18 +137,19 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { returnValueHandlers.add(dom4jProcessor); } if (jaxb2Present) { - RuntimeBeanReference xmlRootElementProcessor = createBeanReference(XmlRootElementPayloadMethodProcessor.class, - source, parserContext); + RuntimeBeanReference xmlRootElementProcessor = createBeanReference( + XmlRootElementPayloadMethodProcessor.class, source, parserContext); argumentResolvers.add(xmlRootElementProcessor); returnValueHandlers.add(xmlRootElementProcessor); - RuntimeBeanReference jaxbElementProcessor = createBeanReference(JaxbElementPayloadMethodProcessor.class, source, - parserContext); + RuntimeBeanReference jaxbElementProcessor = createBeanReference(JaxbElementPayloadMethodProcessor.class, + source, parserContext); argumentResolvers.add(jaxbElementProcessor); returnValueHandlers.add(jaxbElementProcessor); } if (jdomPresent) { - RuntimeBeanReference jdomProcessor = createBeanReference(JDomPayloadMethodProcessor.class, source, parserContext); + RuntimeBeanReference jdomProcessor = createBeanReference(JDomPayloadMethodProcessor.class, source, + parserContext); argumentResolvers.add(jdomProcessor); returnValueHandlers.add(jdomProcessor); } @@ -154,7 +157,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { argumentResolvers.add(createBeanDefinition(StaxPayloadMethodArgumentResolver.class, source)); } if (xomPresent) { - RuntimeBeanReference xomProcessor = createBeanReference(XomPayloadMethodProcessor.class, source, parserContext); + RuntimeBeanReference xomProcessor = createBeanReference(XomPayloadMethodProcessor.class, source, + parserContext); argumentResolvers.add(xomProcessor); returnValueHandlers.add(xomProcessor); } @@ -163,7 +167,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { RuntimeBeanReference unmarshallerReference; if (element.hasAttribute("unmarshaller")) { unmarshallerReference = new RuntimeBeanReference(element.getAttribute("unmarshaller")); - } else { + } + else { unmarshallerReference = marshallerReference; } @@ -182,7 +187,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { } private void registerEndpointExceptionResolvers(Object source, ParserContext parserContext) { - RootBeanDefinition annotationResolverDef = createBeanDefinition(SoapFaultAnnotationExceptionResolver.class, source); + RootBeanDefinition annotationResolverDef = createBeanDefinition(SoapFaultAnnotationExceptionResolver.class, + source); annotationResolverDef.getPropertyValues().add("order", 0); parserContext.getReaderContext().registerWithGeneratedName(annotationResolverDef); @@ -204,4 +210,5 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); return beanDefinition; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/DynamicWsdlBeanDefinitionParser.java b/spring-ws-core/src/main/java/org/springframework/ws/config/DynamicWsdlBeanDefinitionParser.java index 82917d7a..7636f01e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/DynamicWsdlBeanDefinitionParser.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/DynamicWsdlBeanDefinitionParser.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,6 +18,8 @@ package org.springframework.ws.config; import java.util.List; +import org.w3c.dom.Element; + import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; @@ -31,7 +33,6 @@ import org.springframework.util.xml.DomUtils; import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; import org.springframework.xml.xsd.SimpleXsdSchema; import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection; -import org.w3c.dom.Element; /** * Parser for the {@code <sws:dynamic-wsdl/>} element. @@ -75,10 +76,11 @@ class DynamicWsdlBeanDefinitionParser extends AbstractBeanDefinitionParser { collectionDef.getPropertyValues().addPropertyValue("xsds", xsds); String collectionName = parserContext.getReaderContext().registerWithGeneratedName(collectionDef); wsdlBuilder.addPropertyReference("schemaCollection", collectionName); - } else { + } + else { if (schemas.size() > 1) { - throw new IllegalArgumentException( - "Multiple elements requires Commons XMLSchema." + "Please put Commons XMLSchema on the classpath."); + throw new IllegalArgumentException("Multiple elements requires Commons XMLSchema." + + "Please put Commons XMLSchema on the classpath."); } RootBeanDefinition schemaDef = createBeanDefinition(SimpleXsdSchema.class, source); Element schema = schemas.iterator().next(); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/InterceptorsBeanDefinitionParser.java b/spring-ws-core/src/main/java/org/springframework/ws/config/InterceptorsBeanDefinitionParser.java index 5c56ea2c..0f34c7a8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/InterceptorsBeanDefinitionParser.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/InterceptorsBeanDefinitionParser.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,6 +18,8 @@ package org.springframework.ws.config; import java.util.List; +import org.w3c.dom.Element; + import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.config.BeanReference; @@ -33,7 +35,6 @@ import org.springframework.ws.server.SmartEndpointInterceptor; import org.springframework.ws.soap.server.endpoint.interceptor.DelegatingSmartSoapEndpointInterceptor; import org.springframework.ws.soap.server.endpoint.interceptor.PayloadRootSmartSoapEndpointInterceptor; import org.springframework.ws.soap.server.endpoint.interceptor.SoapActionSmartEndpointInterceptor; -import org.w3c.dom.Element; /** * Parser for the {@code <sws:interceptors/>} element. @@ -59,7 +60,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef); registerSmartInterceptor(parserContext, smartInterceptorDef); - } else if ("ref".equals(childElement.getLocalName())) { + } + else if ("ref".equals(childElement.getLocalName())) { RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( DelegatingSmartSoapEndpointInterceptor.class, childElement, parserContext); @@ -69,13 +71,15 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { registerSmartInterceptor(parserContext, smartInterceptorDef); - } else if ("payloadRoot".equals(childElement.getLocalName())) { + } + else if ("payloadRoot".equals(childElement.getLocalName())) { List payloadRootChildren = DomUtils.getChildElements(childElement); for (Element payloadRootChild : payloadRootChildren) { if ("bean".equals(payloadRootChild.getLocalName())) { RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( PayloadRootSmartSoapEndpointInterceptor.class, childElement, parserContext); - BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, payloadRootChild); + BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, + payloadRootChild); String namespaceUri = childElement.getAttribute("namespaceUri"); String localPart = childElement.getAttribute("localPart"); @@ -85,7 +89,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, localPart); registerSmartInterceptor(parserContext, smartInterceptorDef); - } else if ("ref".equals(payloadRootChild.getLocalName())) { + } + else if ("ref".equals(payloadRootChild.getLocalName())) { RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( PayloadRootSmartSoapEndpointInterceptor.class, childElement, parserContext); BeanReference interceptorRef = createInterceptorReference(parserContext, payloadRootChild); @@ -100,13 +105,15 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { registerSmartInterceptor(parserContext, smartInterceptorDef); } } - } else if ("soapAction".equals(childElement.getLocalName())) { + } + else if ("soapAction".equals(childElement.getLocalName())) { List soapActionChildren = DomUtils.getChildElements(childElement); for (Element soapActionChild : soapActionChildren) { if ("bean".equals(soapActionChild.getLocalName())) { RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( SoapActionSmartEndpointInterceptor.class, childElement, parserContext); - BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, soapActionChild); + BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, + soapActionChild); String soapAction = childElement.getAttribute("value"); @@ -114,7 +121,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, soapAction); registerSmartInterceptor(parserContext, smartInterceptorDef); - } else if ("ref".equals(soapActionChild.getLocalName())) { + } + else if ("ref".equals(soapActionChild.getLocalName())) { RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( SoapActionSmartEndpointInterceptor.class, childElement, parserContext); BeanReference interceptorRef = createInterceptorReference(parserContext, soapActionChild); @@ -176,4 +184,5 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { private void error(ParserContext parserContext, String message, Object source) { parserContext.getDelegate().getReaderContext().error(message, source); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java b/spring-ws-core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java index 187ecb53..138a27fe 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,21 @@ package org.springframework.ws.config; +import org.w3c.dom.Element; + import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; -import org.w3c.dom.Element; /** * Parser for the <sws:marshalling-endpoints/> element. * * @author Arjen Poutsma * @since 1.5.0 - * @deprecated as of Spring Web Services 2.0, in favor of {@link AnnotationDrivenBeanDefinitionParser} + * @deprecated as of Spring Web Services 2.0, in favor of + * {@link AnnotationDrivenBeanDefinitionParser} */ @Deprecated class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/WebServicesNamespaceHandler.java b/spring-ws-core/src/main/java/org/springframework/ws/config/WebServicesNamespaceHandler.java index 28ac79b1..f2a00dd9 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/WebServicesNamespaceHandler.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/WebServicesNamespaceHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -37,4 +37,5 @@ public class WebServicesNamespaceHandler extends NamespaceHandlerSupport { registerBeanDefinitionParser("marshalling-endpoints", new MarshallingEndpointsBeanDefinitionParser()); registerBeanDefinitionParser("xpath-endpoints", new XPathEndpointsBeanDefinitionParser()); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java b/spring-ws-core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java index 9e1dc11e..b7b5be0d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,18 +19,20 @@ package org.springframework.ws.config; import java.util.List; import java.util.Properties; +import org.w3c.dom.Element; + import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.util.xml.DomUtils; -import org.w3c.dom.Element; /** * Parser for the <sws:xpath-endpoints/> element. * * @author Arjen Poutsma * @since 1.5.0 - * @deprecated as of Spring Web Services 2.0, in favor of {@link AnnotationDrivenBeanDefinitionParser} + * @deprecated as of Spring Web Services 2.0, in favor of + * {@link AnnotationDrivenBeanDefinitionParser} */ @Deprecated class XPathEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/DelegatingWsConfiguration.java b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/DelegatingWsConfiguration.java index 74f93b61..d2116be6 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/DelegatingWsConfiguration.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/DelegatingWsConfiguration.java @@ -1,3 +1,19 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.config.annotation; import java.util.List; @@ -9,9 +25,10 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler; /** - * A sub-class of {@code WsConfigurationSupport} that detects and delegates to all beans of type {@link WsConfigurer} - * allowing them to customize the configuration provided by {@code WsConfigurationSupport}. This is the class actually - * imported by {@link EnableWs @EnableWs}. + * A sub-class of {@code WsConfigurationSupport} that detects and delegates to all beans + * of type {@link WsConfigurer} allowing them to customize the configuration provided by + * {@code WsConfigurationSupport}. This is the class actually imported by + * {@link EnableWs @EnableWs}. * * @author Arjen Poutsma * @since 2.2 @@ -42,4 +59,5 @@ public class DelegatingWsConfiguration extends WsConfigurationSupport { protected void addReturnValueHandlers(List returnValueHandlers) { this.configurers.addReturnValueHandlers(returnValueHandlers); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/EnableWs.java b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/EnableWs.java index 37ec0cad..fee584c7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/EnableWs.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/EnableWs.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,8 +26,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; /** - * Add this annotation to an {@link Configuration @Configuration} class to have the Spring Web Services configuration - * defined in {@link WsConfigurationSupport} imported. For instance: + * Add this annotation to an {@link Configuration @Configuration} class to have the Spring + * Web Services configuration defined in {@link WsConfigurationSupport} imported. For + * instance: * *

  * @Configuration
@@ -38,8 +39,9 @@ import org.springframework.context.annotation.Import;
  * }
  * 
*

- * Customize the imported configuration by implementing the {@link WsConfigurer} interface or more likely by extending - * the {@link WsConfigurerAdapter} base class and overriding individual methods: + * Customize the imported configuration by implementing the {@link WsConfigurer} interface + * or more likely by extending the {@link WsConfigurerAdapter} base class and overriding + * individual methods: * *

  * @Configuration
@@ -61,9 +63,9 @@ import org.springframework.context.annotation.Import;
  * }
  * 
*

- * If the customization options of {@link WsConfigurer} do not expose something you need to configure, consider removing - * the {@code @EnableWs} annotation and extending directly from {@link WsConfigurationSupport} overriding selected - * {@code @Bean} methods: + * If the customization options of {@link WsConfigurer} do not expose something you need + * to configure, consider removing the {@code @EnableWs} annotation and extending directly + * from {@link WsConfigurationSupport} overriding selected {@code @Bean} methods: * *

  * @Configuration
diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurationSupport.java b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurationSupport.java
index 64e5ff88..f8cc1d24 100644
--- a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurationSupport.java
+++ b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurationSupport.java
@@ -1,11 +1,11 @@
 /*
- * Copyright 2005-2022 the original author or authors.
+ * Copyright 2005-2025 the original author or authors.
  *
  * Licensed 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
+ *      https://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,
@@ -40,30 +40,34 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
 import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping;
 
 /**
- * This is the main class providing the configuration behind the Spring Web Services Java config. It is typically
- * imported by adding {@link EnableWs @EnableWs} to an application {@link Configuration @Configuration} class. An
- * alternative, more advanced option is to extend directly from this class and override methods as necessary remembering
- * to add {@link Configuration @Configuration} to the subclass and {@link Bean @Bean} to overridden {@link Bean @Bean}
- * methods. For more details see the Javadoc of {@link EnableWs @EnableWs}.
+ * This is the main class providing the configuration behind the Spring Web Services Java
+ * config. It is typically imported by adding {@link EnableWs @EnableWs} to an application
+ * {@link Configuration @Configuration} class. An alternative, more advanced option is to
+ * extend directly from this class and override methods as necessary remembering to add
+ * {@link Configuration @Configuration} to the subclass and {@link Bean @Bean} to
+ * overridden {@link Bean @Bean} methods. For more details see the Javadoc of
+ * {@link EnableWs @EnableWs}.
  * 

* This class registers the following {@link EndpointMapping}s: *

    - *
  • {@link PayloadRootAnnotationMethodEndpointMapping} ordered at 0 for mapping requests to - * {@link PayloadRoot @PayloadRoot} annotated controller methods. - *
  • {@link SoapActionAnnotationMethodEndpointMapping} ordered at 1 for mapping requests to - * {@link SoapAction @SoapAction} annotated controller methods. - *
  • {@link AnnotationActionEndpointMapping} ordered at 2 for mapping requests to {@link Action @Action} annotated - * controller methods. + *
  • {@link PayloadRootAnnotationMethodEndpointMapping} ordered at 0 for mapping + * requests to {@link PayloadRoot @PayloadRoot} annotated controller methods. + *
  • {@link SoapActionAnnotationMethodEndpointMapping} ordered at 1 for mapping requests + * to {@link SoapAction @SoapAction} annotated controller methods. + *
  • {@link AnnotationActionEndpointMapping} ordered at 2 for mapping requests to + * {@link Action @Action} annotated controller methods. *
*

* Registers one {@link EndpointAdapter}: *

    - *
  • {@link DefaultMethodEndpointAdapter} for processing requests with annotated endpoint methods. + *
  • {@link DefaultMethodEndpointAdapter} for processing requests with annotated + * endpoint methods. *
*

* Registers the following {@link EndpointExceptionResolver}s: *

    - *
  • {@link SoapFaultAnnotationExceptionResolver} for handling exceptions annotated with {@link SoapFault @SoapFault}. + *
  • {@link SoapFaultAnnotationExceptionResolver} for handling exceptions annotated with + * {@link SoapFault @SoapFault}. *
  • {@link SimpleSoapExceptionResolver} for creating default exceptions. *
* @@ -78,8 +82,8 @@ public class WsConfigurationSupport { private List interceptors; /** - * Returns a {@link PayloadRootAnnotationMethodEndpointMapping} ordered at 0 for mapping requests to annotated - * endpoints. + * Returns a {@link PayloadRootAnnotationMethodEndpointMapping} ordered at 0 for + * mapping requests to annotated endpoints. */ @Bean public PayloadRootAnnotationMethodEndpointMapping payloadRootAnnotationMethodEndpointMapping() { @@ -90,8 +94,8 @@ public class WsConfigurationSupport { } /** - * Returns a {@link SoapActionAnnotationMethodEndpointMapping} ordered at 1 for mapping requests to annotated - * endpoints. + * Returns a {@link SoapActionAnnotationMethodEndpointMapping} ordered at 1 for + * mapping requests to annotated endpoints. */ @Bean public SoapActionAnnotationMethodEndpointMapping soapActionAnnotationMethodEndpointMapping() { @@ -102,7 +106,8 @@ public class WsConfigurationSupport { } /** - * Returns a {@link AnnotationActionEndpointMapping} ordered at 2 for mapping requests to annotated endpoints. + * Returns a {@link AnnotationActionEndpointMapping} ordered at 2 for mapping requests + * to annotated endpoints. */ @Bean public AnnotationActionEndpointMapping annotationActionEndpointMapping() { @@ -113,8 +118,9 @@ public class WsConfigurationSupport { } /** - * Provide access to the shared handler interceptors used to configure {@link EndpointMapping} instances with. This - * method cannot be overridden, use {@link #addInterceptors(List)} instead. + * Provide access to the shared handler interceptors used to configure + * {@link EndpointMapping} instances with. This method cannot be overridden, use + * {@link #addInterceptors(List)} instead. */ protected final EndpointInterceptor[] getInterceptors() { if (interceptors == null) { @@ -125,14 +131,16 @@ public class WsConfigurationSupport { } /** - * Template method to add endpoint interceptors. Override this method to add Spring-WS interceptors for pre- and - * post-processing of endpoint invocation. + * Template method to add endpoint interceptors. Override this method to add Spring-WS + * interceptors for pre- and post-processing of endpoint invocation. */ - protected void addInterceptors(List interceptors) {} + protected void addInterceptors(List interceptors) { + } /** - * Returns a {@link DefaultMethodEndpointAdapter} for processing requests through annotated endpoint methods. Consider - * overriding one of these other more fine-grained methods: + * Returns a {@link DefaultMethodEndpointAdapter} for processing requests through + * annotated endpoint methods. Consider overriding one of these other more + * fine-grained methods: *
    *
  • {@link #addArgumentResolvers(List)} for adding custom argument resolvers. *
  • {@link #addReturnValueHandlers(List)} for adding custom return value handlers. @@ -154,21 +162,24 @@ public class WsConfigurationSupport { } /** - * Add custom {@link MethodArgumentResolver}s to use in addition to the ones registered by default. - * + * Add custom {@link MethodArgumentResolver}s to use in addition to the ones + * registered by default. * @param argumentResolvers the list of custom converters; initially an empty list. */ - protected void addArgumentResolvers(List argumentResolvers) {} + protected void addArgumentResolvers(List argumentResolvers) { + } /** - * Add custom {@link MethodReturnValueHandler}s in addition to the ones registered by default. - * + * Add custom {@link MethodReturnValueHandler}s in addition to the ones registered by + * default. * @param returnValueHandlers the list of custom handlers; initially an empty list. */ - protected void addReturnValueHandlers(List returnValueHandlers) {} + protected void addReturnValueHandlers(List returnValueHandlers) { + } /** - * Returns a {@link SoapFaultAnnotationExceptionResolver} ordered at 0 for handling endpoint exceptions. + * Returns a {@link SoapFaultAnnotationExceptionResolver} ordered at 0 for handling + * endpoint exceptions. */ @Bean public SoapFaultAnnotationExceptionResolver soapFaultAnnotationExceptionResolver() { @@ -179,8 +190,9 @@ public class WsConfigurationSupport { } /** - * Returns a {@link SimpleSoapExceptionResolver} ordered at {@linkplain Ordered#LOWEST_PRECEDENCE lowest precedence} - * for handling endpoint exceptions. + * Returns a {@link SimpleSoapExceptionResolver} ordered at + * {@linkplain Ordered#LOWEST_PRECEDENCE lowest precedence} for handling endpoint + * exceptions. */ @Bean public SimpleSoapExceptionResolver simpleSoapExceptionResolver() { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurer.java b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurer.java index 26e217e2..cfb67aba 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurer.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurer.java @@ -1,3 +1,19 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.config.annotation; import java.util.List; @@ -7,12 +23,13 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler; /** - * Defines callback methods to customize the Java-based configuration for Spring Web Services enabled via - * {@link EnableWs @EnableWs}. + * Defines callback methods to customize the Java-based configuration for Spring Web + * Services enabled via {@link EnableWs @EnableWs}. *

    - * {@code @EnableWs}-annotated configuration classes may implement this interface to be called back and given a chance - * to customize the default configuration. Consider extending {@link WsConfigurerAdapter}, which provides a stub - * implementation of all interface methods. + * {@code @EnableWs}-annotated configuration classes may implement this interface to be + * called back and given a chance to customize the default configuration. Consider + * extending {@link WsConfigurerAdapter}, which provides a stub implementation of all + * interface methods. * * @author Arjen Poutsma * @since 2.2 @@ -20,13 +37,13 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHa public interface WsConfigurer { /** - * Add {@link EndpointInterceptor}s for pre- and post-processing of endpoint method invocations. + * Add {@link EndpointInterceptor}s for pre- and post-processing of endpoint method + * invocations. */ void addInterceptors(List interceptors); /** * Add resolvers to support custom endpoint method argument types. - * * @param argumentResolvers initially an empty list */ void addArgumentResolvers(List argumentResolvers); @@ -34,10 +51,11 @@ public interface WsConfigurer { /** * Add handlers to support custom controller method return value types. *

    - * Using this option does not override the built-in support for handling return values. To customize the built-in - * support for handling return values, configure RequestMappingHandlerAdapter directly. - * + * Using this option does not override the built-in support for handling return + * values. To customize the built-in support for handling return values, configure + * RequestMappingHandlerAdapter directly. * @param returnValueHandlers initially an empty list */ void addReturnValueHandlers(List returnValueHandlers); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerAdapter.java index 9d1974d1..652ea143 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerAdapter.java @@ -1,3 +1,19 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.config.annotation; import java.util.List; @@ -7,8 +23,8 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler; /** - * An default implementation of {@link WsConfigurer} with empty methods allowing sub-classes to override only the - * methods they're interested in. + * An default implementation of {@link WsConfigurer} with empty methods allowing + * sub-classes to override only the methods they're interested in. * * @author Arjen Poutsma * @since 2.2 @@ -21,7 +37,8 @@ public class WsConfigurerAdapter implements WsConfigurer { * This implementation is empty. */ @Override - public void addInterceptors(List interceptors) {} + public void addInterceptors(List interceptors) { + } /** * {@inheritDoc} @@ -29,7 +46,8 @@ public class WsConfigurerAdapter implements WsConfigurer { * This implementation is empty. */ @Override - public void addArgumentResolvers(List argumentResolvers) {} + public void addArgumentResolvers(List argumentResolvers) { + } /** * {@inheritDoc} @@ -40,4 +58,5 @@ public class WsConfigurerAdapter implements WsConfigurer { public void addReturnValueHandlers(List returnValueHandlers) { } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerComposite.java b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerComposite.java index 04cca7c1..f41841bf 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerComposite.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerComposite.java @@ -1,3 +1,19 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.config.annotation; import java.util.ArrayList; @@ -8,7 +24,8 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler; /** - * An {@link WsConfigurer} implementation that delegates to other {@link WsConfigurer} instances. + * An {@link WsConfigurer} implementation that delegates to other {@link WsConfigurer} + * instances. * * @author Arjen Poutsma * @since 2.2 diff --git a/spring-ws-core/src/main/java/org/springframework/ws/context/AbstractMessageContext.java b/spring-ws-core/src/main/java/org/springframework/ws/context/AbstractMessageContext.java index 54d15374..a452a80d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/context/AbstractMessageContext.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/context/AbstractMessageContext.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,7 +30,8 @@ import org.springframework.util.StringUtils; public abstract class AbstractMessageContext implements MessageContext { /** - * Keys are {@code Strings}, values are {@code Objects}. Lazily initialized by {@code getProperties()}. + * Keys are {@code Strings}, values are {@code Objects}. Lazily initialized by + * {@code getProperties()}. */ private Map properties; @@ -65,4 +66,5 @@ public abstract class AbstractMessageContext implements MessageContext { } return properties; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/context/DefaultMessageContext.java b/spring-ws-core/src/main/java/org/springframework/ws/context/DefaultMessageContext.java index 6e4e2b15..2189648f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/context/DefaultMessageContext.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/context/DefaultMessageContext.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -37,13 +37,17 @@ public class DefaultMessageContext extends AbstractMessageContext { private WebServiceMessage response; - /** Construct a new, empty instance of the {@code DefaultMessageContext} with the given message factory. */ + /** + * Construct a new, empty instance of the {@code DefaultMessageContext} with the given + * message factory. + */ public DefaultMessageContext(WebServiceMessageFactory messageFactory) { this(messageFactory.createWebServiceMessage(), messageFactory); } /** - * Construct a new instance of the {@code DefaultMessageContext} with the given request message and message factory. + * Construct a new instance of the {@code DefaultMessageContext} with the given + * request message and message factory. */ public DefaultMessageContext(WebServiceMessage request, WebServiceMessageFactory messageFactory) { Assert.notNull(request, "request must not be null"); @@ -96,4 +100,5 @@ public class DefaultMessageContext extends AbstractMessageContext { throw new IllegalStateException("Response message already created"); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/context/MessageContext.java b/spring-ws-core/src/main/java/org/springframework/ws/context/MessageContext.java index f3968b02..47cbd3a8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/context/MessageContext.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/context/MessageContext.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,11 +25,11 @@ import org.springframework.ws.server.EndpointInterceptor; /** * Context holder for message requests. *

    - * Contains both the message request as well as the response. Response message are usually lazily created (but do not - * have to be). + * Contains both the message request as well as the response. Response message are usually + * lazily created (but do not have to be). *

    - * Also contains properties, which can be used to by {@link EndpointInterceptor interceptors} to pass information on to - * endpoints. + * Also contains properties, which can be used to by {@link EndpointInterceptor + * interceptors} to pass information on to endpoints. * * @author Arjen Poutsma * @since 1.0.0 @@ -38,21 +38,18 @@ public interface MessageContext { /** * Returns the request message. - * * @return the request message */ WebServiceMessage getRequest(); /** * Indicates whether this context has a response. - * * @return {@code true} if this context has a response; {@code false} otherwise */ boolean hasResponse(); /** * Returns the response message. Creates a new response if no response is present. - * * @return the response message * @see #hasResponse() */ @@ -60,7 +57,6 @@ public interface MessageContext { /** * Sets the response message. - * * @param response the response message * @throws IllegalStateException if a response has already been created * @since 1.5.0 @@ -76,7 +72,6 @@ public interface MessageContext { /** * Reads a response message from the given input stream. - * * @param inputStream the stream to read the response from * @throws IOException in case of I/O errors * @throws IllegalStateException if a response has already been created @@ -84,9 +79,9 @@ public interface MessageContext { void readResponse(InputStream inputStream) throws IOException; /** - * Sets the name and value of a property associated with the {@code MessageContext}. If the {@code MessageContext} - * contains a value of the same property, the old value is replaced. - * + * Sets the name and value of a property associated with the {@code MessageContext}. + * If the {@code MessageContext} contains a value of the same property, the old value + * is replaced. * @param name name of the property associated with the value * @param value value of the property */ @@ -94,7 +89,6 @@ public interface MessageContext { /** * Gets the value of a specific property from the {@code MessageContext}. - * * @param name name of the property whose value is to be retrieved * @return value of the property */ @@ -102,23 +96,22 @@ public interface MessageContext { /** * Removes a property from the {@code MessageContext}. - * * @param name name of the property to be removed */ void removeProperty(String name); /** * Check if this message context contains a property with the given name. - * * @param name the name of the property to look for - * @return {@code true} if the {@code MessageContext} contains the property; {@code false} otherwise + * @return {@code true} if the {@code MessageContext} contains the property; + * {@code false} otherwise */ boolean containsProperty(String name); /** * Return the names of all properties in this {@code MessageContext}. - * - * @return the names of all properties in this context, or an empty array if none defined + * @return the names of all properties in this context, or an empty array if none + * defined */ String[] getPropertyNames(); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/mime/AbstractMimeMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/mime/AbstractMimeMessage.java index 5a9958a0..0744703f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/mime/AbstractMimeMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/mime/AbstractMimeMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,22 @@ package org.springframework.ws.mime; -import jakarta.activation.DataHandler; -import jakarta.activation.DataSource; -import jakarta.activation.FileDataSource; - import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import jakarta.activation.DataHandler; +import jakarta.activation.DataSource; +import jakarta.activation.FileDataSource; + import org.springframework.core.io.InputStreamSource; import org.springframework.core.io.Resource; import org.springframework.util.Assert; /** - * Abstract implementation of the {@link MimeMessage} interface. Contains convenient default implementations. + * Abstract implementation of the {@link MimeMessage} interface. Contains convenient + * default implementations. * * @author Arjen Poutsma * @since 1.0.0 @@ -58,7 +59,8 @@ public abstract class AbstractMimeMessage implements MimeMessage { } /** - * Activation framework {@code DataSource} that wraps a Spring {@code InputStreamSource}. + * Activation framework {@code DataSource} that wraps a Spring + * {@code InputStreamSource}. * * @author Arjen Poutsma * @since 1.0.0 @@ -94,7 +96,8 @@ public abstract class AbstractMimeMessage implements MimeMessage { if (inputStreamSource instanceof Resource) { Resource resource = (Resource) inputStreamSource; return resource.getFilename(); - } else { + } + else { throw new UnsupportedOperationException("DataSource name not available"); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/mime/Attachment.java b/spring-ws-core/src/main/java/org/springframework/ws/mime/Attachment.java index 7a7d2e1e..9079c10c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/mime/Attachment.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/mime/Attachment.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,11 +16,11 @@ package org.springframework.ws.mime; -import jakarta.activation.DataHandler; - import java.io.IOException; import java.io.InputStream; +import jakarta.activation.DataHandler; + /** * Represents an attachment to a {@link org.springframework.ws.mime.MimeMessage} * @@ -33,38 +33,36 @@ public interface Attachment { /** * Returns the content identifier of the attachment. - * * @return the content id, or {@code null} if empty or not defined */ String getContentId(); /** * Returns the content type of the attachment. - * * @return the content type, or {@code null} if empty or not defined */ String getContentType(); /** - * Return an {@code InputStream} to read the contents of the attachment from. The user is responsible for closing the - * stream. - * + * Return an {@code InputStream} to read the contents of the attachment from. The user + * is responsible for closing the stream. * @return the contents of the file as stream, or an empty stream if empty * @throws IOException in case of access I/O errors */ InputStream getInputStream() throws IOException; /** - * Returns the size of the attachment in bytes. Returns {@code -1} if the size cannot be determined. - * - * @return the size of the attachment, {@code 0} if empty, or {@code -1} if the size cannot be determined + * Returns the size of the attachment in bytes. Returns {@code -1} if the size cannot + * be determined. + * @return the size of the attachment, {@code 0} if empty, or {@code -1} if the size + * cannot be determined */ long getSize(); /** * Returns the data handler of the attachment. - * * @return the data handler of the attachment */ DataHandler getDataHandler(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/mime/MimeMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/mime/MimeMessage.java index ce0f2663..fa2d708e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/mime/MimeMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/mime/MimeMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,17 @@ package org.springframework.ws.mime; -import jakarta.activation.DataHandler; - import java.io.File; import java.util.Iterator; +import jakarta.activation.DataHandler; + import org.springframework.core.io.InputStreamSource; import org.springframework.ws.WebServiceMessage; /** - * Represents a Web service message with MIME attachments. Attachments can be added as a file, an - * {@link InputStreamSource}, or a {@link DataHandler}. + * Represents a Web service message with MIME attachments. Attachments can be added as a + * file, an {@link InputStreamSource}, or a {@link DataHandler}. * * @author Arjen Poutsma * @see Attachment @@ -36,33 +36,33 @@ public interface MimeMessage extends WebServiceMessage { /** * Indicates whether this message is a XOP package. - * - * @return {@code true} when the constraints specified in - * Identifying XOP - * Documents are met. - * @see XOP Packages + * @return {@code true} when the constraints specified in Identifying + * XOP Documents are met. + * @see XOP + * Packages */ boolean isXopPackage(); /** * Turns this message into a XOP package. - * * @return {@code true} when the message is a XOP package - * @see XOP Packages + * @see XOP + * Packages */ boolean convertToXopPackage(); /** * Returns the {@link Attachment} with the specified content Id. - * - * @return the attachment with the specified content id; or {@code null} if it cannot be found + * @return the attachment with the specified content id; or {@code null} if it cannot + * be found * @throws AttachmentException in case of errors */ Attachment getAttachment(String contentId) throws AttachmentException; /** - * Returns an {@code Iterator} over all {@link Attachment} objects that are part of this message. - * + * Returns an {@code Iterator} over all {@link Attachment} objects that are part of + * this message. * @return an iterator over all attachments * @throws AttachmentException in case of errors * @see Attachment @@ -72,9 +72,9 @@ public interface MimeMessage extends WebServiceMessage { /** * Add an attachment to the message, taking the content from a {@link File}. *

    - * The content type will be determined by the name of the given content file. Do not use this for temporary files with - * arbitrary filenames (possibly ending in ".tmp" or the like)! - * + * The content type will be determined by the name of the given content file. Do not + * use this for temporary files with arbitrary filenames (possibly ending in ".tmp" or + * the like)! * @param contentId the content Id of the attachment * @param file the file to take the content from * @return the added attachment @@ -83,14 +83,15 @@ public interface MimeMessage extends WebServiceMessage { Attachment addAttachment(String contentId, File file) throws AttachmentException; /** - * Add an attachment to the message, taking the content from an {@link InputStreamSource}. + * Add an attachment to the message, taking the content from an + * {@link InputStreamSource}. *

    - * Note that the stream returned by the source needs to be a fresh one on each call, as underlying - * implementations can invoke {@link InputStreamSource#getInputStream()} multiple times. - * + * Note that the stream returned by the source needs to be a fresh one on each + * call, as underlying implementations can invoke + * {@link InputStreamSource#getInputStream()} multiple times. * @param contentId the content Id of the attachment - * @param inputStreamSource the resource to take the content from (all of Spring's Resource implementations can be - * passed in here) + * @param inputStreamSource the resource to take the content from (all of Spring's + * Resource implementations can be passed in here) * @param contentType the content type to use for the element * @return the added attachment * @throws AttachmentException in case of errors @@ -100,10 +101,10 @@ public interface MimeMessage extends WebServiceMessage { /** * Add an attachment to the message, taking the content from a {@link DataHandler}. - * * @param dataHandler the data handler to take the content from * @return the added attachment * @throws AttachmentException in case of errors */ Attachment addAttachment(String contentId, DataHandler dataHandler); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/pox/PoxMessageException.java b/spring-ws-core/src/main/java/org/springframework/ws/pox/PoxMessageException.java index e53b4741..cae67110 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/pox/PoxMessageException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/pox/PoxMessageException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public abstract class PoxMessageException extends WebServiceMessageException { public PoxMessageException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessage.java index b0817894..9422ae7e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,14 +27,15 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + import org.springframework.util.Assert; import org.springframework.ws.pox.PoxMessage; import org.springframework.ws.transport.TransportConstants; import org.springframework.ws.transport.TransportOutputStream; import org.springframework.xml.namespace.QNameUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; /** * Implementation of the {@code PoxMessage} interface that is based on a DOM Document. @@ -53,7 +54,6 @@ public class DomPoxMessage implements PoxMessage { /** * Constructs a new instance of the {@code DomPoxMessage} with the given document. - * * @param document the document to base the message on */ public DomPoxMessage(Document document, Transformer transformer, String contentType) { @@ -110,8 +110,10 @@ public class DomPoxMessage implements PoxMessage { transportOutputStream.addHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType); } transformer.transform(getPayloadSource(), new StreamResult(outputStream)); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new DomPoxMessageException("Could write document: " + ex.getMessage(), ex); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageException.java b/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageException.java index 0d1dbb2d..f1971c27 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public class DomPoxMessageException extends PoxMessageException { public DomPoxMessageException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageFactory.java b/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageFactory.java index a0e09e36..7a611b41 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageFactory.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,15 +24,17 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerConfigurationException; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessageFactory; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.TransformerObjectSupport; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; /** - * Implementation of the {@link WebServiceMessageFactory} interface that creates a {@link DomPoxMessage}. + * Implementation of the {@link WebServiceMessageFactory} interface that creates a + * {@link DomPoxMessage}. * * @author Arjen Poutsma * @see org.springframework.ws.pox.dom.DomPoxMessage @@ -56,7 +58,6 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We /** * Provide your own {@link DocumentBuilderFactory}. - * * @param documentBuilderFactory */ public DomPoxMessageFactory(DocumentBuilderFactory documentBuilderFactory) { @@ -73,7 +74,10 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We this.contentType = contentType; } - /** Set whether or not the XML parser should be XML namespace aware. Default is {@code true}. */ + /** + * Set whether or not the XML parser should be XML namespace aware. Default is + * {@code true}. + */ public void setNamespaceAware(boolean namespaceAware) { documentBuilderFactory.setNamespaceAware(namespaceAware); } @@ -84,7 +88,8 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We } /** - * Set if the XML parser should expand entity reference nodes. Default is {@code false}. + * Set if the XML parser should expand entity reference nodes. Default is + * {@code false}. */ public void setExpandEntityReferences(boolean expandEntityRef) { documentBuilderFactory.setExpandEntityReferences(expandEntityRef); @@ -96,9 +101,11 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document request = documentBuilder.newDocument(); return new DomPoxMessage(request, createTransformer(), contentType); - } catch (ParserConfigurationException ex) { + } + catch (ParserConfigurationException ex) { throw new DomPoxMessageException("Could not create message context", ex); - } catch (TransformerConfigurationException ex) { + } + catch (TransformerConfigurationException ex) { throw new DomPoxMessageException("Could not create transformer", ex); } } @@ -109,12 +116,16 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document request = documentBuilder.parse(inputStream); return new DomPoxMessage(request, createTransformer(), contentType); - } catch (ParserConfigurationException ex) { + } + catch (ParserConfigurationException ex) { throw new DomPoxMessageException("Could not create message context", ex); - } catch (SAXException ex) { + } + catch (SAXException ex) { throw new DomPoxMessageException("Could not parse request message", ex); - } catch (TransformerConfigurationException ex) { + } + catch (TransformerConfigurationException ex) { throw new DomPoxMessageException("Could not create transformer", ex); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointAdapter.java index f73eb3ea..bd0c577f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,12 +19,13 @@ package org.springframework.ws.server; import org.springframework.ws.context.MessageContext; /** - * Interface that must be implemented for each endpoint type to handle a message request. This interface is used to - * allow the {@code MessageDispatcher} to be indefinitely extensible. It accesses all installed endpoints through this - * interface, meaning that is does not contain code specific to any endpoint type. + * Interface that must be implemented for each endpoint type to handle a message request. + * This interface is used to allow the {@code MessageDispatcher} to be indefinitely + * extensible. It accesses all installed endpoints through this interface, meaning that is + * does not contain code specific to any endpoint type. *

    - * This interface is not intended for application developers. It is available for those who want to develop their own - * message flow. + * This interface is not intended for application developers. It is available for those + * who want to develop their own message flow. * * @author Arjen Poutsma * @see MessageDispatcher @@ -36,19 +37,20 @@ public interface EndpointAdapter { * Does this {@code EndpointAdapter} support the given {@code endpoint}? *

    * Typical {@code EndpointAdapters} will base the decision on the endpoint type. - * * @param endpoint endpoint object to check - * @return {@code true} if this {@code EndpointAdapter} supports the supplied {@code endpoint} + * @return {@code true} if this {@code EndpointAdapter} supports the supplied + * {@code endpoint} */ boolean supports(Object endpoint); /** * Use the given {@code endpoint} to handle the request. - * * @param messageContext the current message context - * @param endpoint the endpoint to use. This object must have previously been passed to the {@link #supports(Object)} - * method of this interface, which must have returned {@code true} + * @param endpoint the endpoint to use. This object must have previously been passed + * to the {@link #supports(Object)} method of this interface, which must have returned + * {@code true} * @throws Exception in case of errors */ void invoke(MessageContext messageContext, Object endpoint) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointExceptionResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointExceptionResolver.java index c935429d..a63879b6 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointExceptionResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointExceptionResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,7 +19,8 @@ package org.springframework.ws.server; import org.springframework.ws.context.MessageContext; /** - * Defines the interface for objects than can resolve exceptions thrown during endpoint execution. + * Defines the interface for objects than can resolve exceptions thrown during endpoint + * execution. * * @author Arjen Poutsma * @since 1.0.0 @@ -28,11 +29,12 @@ public interface EndpointExceptionResolver { /** * Try to resolve the given exception that got thrown during on endpoint execution. - * * @param messageContext current message context - * @param endpoint the executed endpoint, or null if none chosen at the time of the exception + * @param endpoint the executed endpoint, or null if none chosen at the time of the + * exception * @param ex the exception that got thrown during endpoint execution * @return {@code true} if resolved; {@code false} otherwise */ boolean resolveException(MessageContext messageContext, Object endpoint, Exception ex); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointInterceptor.java index f0b95f76..995d1339 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,18 +19,23 @@ package org.springframework.ws.server; import org.springframework.ws.context.MessageContext; /** - * Workflow interface that allows for customized endpoint invocation chains. Applications can register any number of - * existing or custom interceptors for certain groups of endpoints, to add common preprocessing behavior without needing - * to modify each endpoint implementation. + * Workflow interface that allows for customized endpoint invocation chains. Applications + * can register any number of existing or custom interceptors for certain groups of + * endpoints, to add common preprocessing behavior without needing to modify each endpoint + * implementation. *

    - * An {@code EndpointInterceptor} gets called before the appropriate {@link EndpointAdapter} triggers the invocation of - * the endpoint itself. This mechanism can be used for a large field of preprocessing aspects, e.g. for authorization - * checks, or message header checks. Its main purpose is to allow for factoring out repetitive endpoint code. + * An {@code EndpointInterceptor} gets called before the appropriate + * {@link EndpointAdapter} triggers the invocation of the endpoint itself. This mechanism + * can be used for a large field of preprocessing aspects, e.g. for authorization checks, + * or message header checks. Its main purpose is to allow for factoring out repetitive + * endpoint code. *

    - * Typically an interceptor chain is defined per {@link EndpointMapping} bean, sharing its granularity. To be able to - * apply a certain interceptor chain to a group of handlers, one needs to map the desired handlers via one - * {@code EndpointMapping} bean. The interceptors themselves are defined as beans in the application context, referenced - * by the mapping bean definition via its {@code interceptors} property (in XML: a <list> of <ref>). + * Typically an interceptor chain is defined per {@link EndpointMapping} bean, sharing its + * granularity. To be able to apply a certain interceptor chain to a group of handlers, + * one needs to map the desired handlers via one {@code EndpointMapping} bean. The + * interceptors themselves are defined as beans in the application context, referenced by + * the mapping bean definition via its {@code interceptors} property (in XML: a + * <list> of <ref>). * * @author Arjen Poutsma * @see EndpointInvocationChain#getInterceptors() @@ -41,36 +46,40 @@ import org.springframework.ws.context.MessageContext; public interface EndpointInterceptor { /** - * Processes the incoming request message. Called after {@link EndpointMapping} determined an appropriate endpoint - * object, but before {@link EndpointAdapter} invokes the endpoint. + * Processes the incoming request message. Called after {@link EndpointMapping} + * determined an appropriate endpoint object, but before {@link EndpointAdapter} + * invokes the endpoint. *

    - * {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors, - * with the endpoint itself at the end. With this method, each interceptor can decide to abort the chain, typically - * creating a custom response. - * + * {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting + * of any number of interceptors, with the endpoint itself at the end. With this + * method, each interceptor can decide to abort the chain, typically creating a custom + * response. * @param messageContext contains the incoming request message * @param endpoint chosen endpoint to invoke - * @return {@code true} to continue processing of the request interceptor chain; {@code false} to indicate blocking of - * the request endpoint chain, without invoking the endpoint + * @return {@code true} to continue processing of the request interceptor chain; + * {@code false} to indicate blocking of the request endpoint chain, without + * invoking the endpoint * @throws Exception in case of errors * @see MessageContext#getRequest() */ boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception; /** - * Processes the outgoing response message. Called after {@link EndpointAdapter} actually invoked the endpoint. Can - * manipulate the response, if any, by adding new headers, etc. + * Processes the outgoing response message. Called after {@link EndpointAdapter} + * actually invoked the endpoint. Can manipulate the response, if any, by adding new + * headers, etc. *

    - * {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors, - * with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting - * applied in inverse order of the execution chain. + * {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting + * of any number of interceptors, with the endpoint itself at the end. With this + * method, each interceptor can post-process an invocation, getting applied in inverse + * order of the execution chain. *

    - * Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed. - * + * Note: Will only be called if this interceptor's {@link #handleRequest} method has + * successfully completed. * @param messageContext contains both request and response messages * @param endpoint chosen endpoint to invoke - * @return {@code true} to continue processing of the response interceptor chain; {@code false} to indicate blocking - * of the response endpoint chain. + * @return {@code true} to continue processing of the response interceptor chain; + * {@code false} to indicate blocking of the response endpoint chain. * @throws Exception in case of errors * @see MessageContext#getRequest() * @see MessageContext#hasResponse() @@ -79,36 +88,43 @@ public interface EndpointInterceptor { boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception; /** - * Processes the outgoing response fault. Called after {@link EndpointAdapter} actually invoked the endpoint. Can - * manipulate the response, if any, by adding new headers, etc. + * Processes the outgoing response fault. Called after {@link EndpointAdapter} + * actually invoked the endpoint. Can manipulate the response, if any, by adding new + * headers, etc. *

    - * {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting of any number of interceptors, - * with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting - * applied in inverse order of the execution chain. + * {@link MessageDispatcher} processes an endpoint in an invocation chain, consisting + * of any number of interceptors, with the endpoint itself at the end. With this + * method, each interceptor can post-process an invocation, getting applied in inverse + * order of the execution chain. *

    - * Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed. - * - * @param messageContext contains both request and response messages, the response should contains a Fault + * Note: Will only be called if this interceptor's {@link #handleRequest} method has + * successfully completed. + * @param messageContext contains both request and response messages, the response + * should contains a Fault * @param endpoint chosen endpoint to invoke - * @return {@code true} to continue processing of the response interceptor chain; {@code false} to indicate blocking - * of the response handler chain. + * @return {@code true} to continue processing of the response interceptor chain; + * {@code false} to indicate blocking of the response handler chain. */ boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception; /** - * Callback after completion of request and response (fault) processing. Will be called on any outcome of endpoint - * invocation, thus allows for proper resource cleanup. + * Callback after completion of request and response (fault) processing. Will be + * called on any outcome of endpoint invocation, thus allows for proper resource + * cleanup. *

    - * Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed. + * Note: Will only be called if this interceptor's {@link #handleRequest} method has + * successfully completed. *

    - * As with the {@link #handleResponse} method, the method will be invoked on each interceptor in the chain in reverse - * order, so the first interceptor will be the last to be invoked. - * - * @param messageContext contains both request and response messages, the response should contains a Fault + * As with the {@link #handleResponse} method, the method will be invoked on each + * interceptor in the chain in reverse order, so the first interceptor will be the + * last to be invoked. + * @param messageContext contains both request and response messages, the response + * should contains a Fault * @param endpoint chosen endpoint to invoke * @param ex exception thrown on handler execution, if any * @throws Exception in case of errors * @since 2.0.2 */ void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointInvocationChain.java b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointInvocationChain.java index 64c9be07..4eb2c782 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointInvocationChain.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointInvocationChain.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -17,7 +17,8 @@ package org.springframework.ws.server; /** - * Endpoint invocation chain, consisting of an endpoint object and any preprocessing interceptors. + * Endpoint invocation chain, consisting of an endpoint object and any preprocessing + * interceptors. * * @author Arjen Poutsma * @see EndpointInterceptor @@ -31,7 +32,6 @@ public class EndpointInvocationChain { /** * Create new {@code EndpointInvocationChain}. - * * @param endpoint the endpoint object to invoke */ public EndpointInvocationChain(Object endpoint) { @@ -40,7 +40,6 @@ public class EndpointInvocationChain { /** * Create new {@code EndpointInvocationChain}. - * * @param endpoint the endpoint object to invoke * @param interceptors the array of interceptors to apply */ @@ -51,7 +50,6 @@ public class EndpointInvocationChain { /** * Returns the endpoint object to invoke. - * * @return the endpoint object */ public Object getEndpoint() { @@ -60,7 +58,6 @@ public class EndpointInvocationChain { /** * Returns the array of interceptors to apply before the handler executes. - * * @return the array of interceptors */ public EndpointInterceptor[] getInterceptors() { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointMapping.java index 590a1ecb..eea56930 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/EndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,13 +21,16 @@ import org.springframework.ws.context.MessageContext; /** * Defines a mapping between message requests and endpoint objects. *

    - * This class can be implemented by application developers, although this is not always necessary, as - * {@code PayloadRootQNameEndpointMapping} and {@code SoapActionEndpointMapping} are included. + * This class can be implemented by application developers, although this is not always + * necessary, as {@code PayloadRootQNameEndpointMapping} and + * {@code SoapActionEndpointMapping} are included. *

    - * HandlerMapping implementations can support mapped interceptors but do not have to. An endpoint will always be wrapped - * in a {@code EndpointExecutionChain} instance, optionally accompanied by some {@code EndpointInterceptor} instances. - * The {@code MessageDispacher} will first call each {@code EndpointInterceptor}'s {@code handlerRequest} method in the - * given order, finally invoking the endpoint itself if all {@code handlerRequest} methods have returned {@code true}. + * HandlerMapping implementations can support mapped interceptors but do not have to. An + * endpoint will always be wrapped in a {@code EndpointExecutionChain} instance, + * optionally accompanied by some {@code EndpointInterceptor} instances. The + * {@code MessageDispacher} will first call each {@code EndpointInterceptor}'s + * {@code handlerRequest} method in the given order, finally invoking the endpoint itself + * if all {@code handlerRequest} methods have returned {@code true}. * * @author Arjen Poutsma * @see org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping @@ -38,19 +41,20 @@ import org.springframework.ws.context.MessageContext; public interface EndpointMapping { /** - * Returns an endpoint and any interceptors for this message context. The choice may be made on message contents, - * transport request url, a routing table, or any factor the implementing class chooses. + * Returns an endpoint and any interceptors for this message context. The choice may + * be made on message contents, transport request url, a routing table, or any factor + * the implementing class chooses. *

    - * The returned {@code EndpointExecutionChain} contains an endpoint Object, rather than even a tag interface, so that - * endpoints are not constrained in any way. For example, a {@code EndpointAdapter} could be written to allow another - * framework's endpoint objects to be used. + * The returned {@code EndpointExecutionChain} contains an endpoint Object, rather + * than even a tag interface, so that endpoints are not constrained in any way. For + * example, a {@code EndpointAdapter} could be written to allow another framework's + * endpoint objects to be used. *

    - * Returns {@code null} if no match was found. This is by design. The {@code MessageDispatcher} will query all - * registered {@code EndpointMapping} beans to find a match, and only decide there is an error if none can find an - * endpoint. - * - * @return a HandlerExecutionChain instance containing endpoint object and any interceptors, or {@code null} if no - * mapping is found + * Returns {@code null} if no match was found. This is by design. The + * {@code MessageDispatcher} will query all registered {@code EndpointMapping} beans + * to find a match, and only decide there is an error if none can find an endpoint. + * @return a HandlerExecutionChain instance containing endpoint object and any + * interceptors, or {@code null} if no mapping is found * @throws Exception if there is an internal error */ EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/MessageDispatcher.java b/spring-ws-core/src/main/java/org/springframework/ws/server/MessageDispatcher.java index 6dc95f47..b02a3bcc 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/MessageDispatcher.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/MessageDispatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,6 +25,7 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanNameAware; @@ -47,24 +48,29 @@ import org.springframework.ws.support.DefaultStrategiesHelper; import org.springframework.ws.transport.WebServiceMessageReceiver; /** - * Central dispatcher for use within Spring-WS, dispatching Web service messages to registered endpoints. + * Central dispatcher for use within Spring-WS, dispatching Web service messages to + * registered endpoints. *

    - * This dispatcher is quite similar to Spring MVCs {@link DispatcherServlet}. Just like its counterpart, this dispatcher - * is very flexible. This class is SOAP agnostic; in typical SOAP Web Services, the {@link SoapMessageDispatcher} - * subclass is used. + * This dispatcher is quite similar to Spring MVCs {@link DispatcherServlet}. Just like + * its counterpart, this dispatcher is very flexible. This class is SOAP agnostic; in + * typical SOAP Web Services, the {@link SoapMessageDispatcher} subclass is used. *

      - *
    • It can use any {@link EndpointMapping} implementation - whether standard, or provided as part of an application - - * to control the routing of request messages to endpoint objects. Endpoint mappings can be registered using the + *
    • It can use any {@link EndpointMapping} implementation - whether standard, or + * provided as part of an application - to control the routing of request messages to + * endpoint objects. Endpoint mappings can be registered using the * {@link #setEndpointMappings(List) endpointMappings} property.
    • - *
    • It can use any {@link EndpointAdapter}; this allows one to use any endpoint interface or form. Defaults to the - * {@link MessageEndpointAdapter} and {@link PayloadEndpointAdapter}, for {@link MessageEndpoint} and + *
    • It can use any {@link EndpointAdapter}; this allows one to use any endpoint + * interface or form. Defaults to the {@link MessageEndpointAdapter} and + * {@link PayloadEndpointAdapter}, for {@link MessageEndpoint} and * {@link PayloadEndpoint}, respectively, and the - * {@link org.springframework.ws.server.endpoint.adapter.MessageMethodEndpointAdapter MessageMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.PayloadMethodEndpointAdapter PayloadMethodEndpointAdapter}. - * Additional endpoint adapters can be added through the {@link #setEndpointAdapters(List) endpointAdapters} - * property.
    • - *
    • Its exception resolution strategy can be specified via a {@link EndpointExceptionResolver}, for example mapping - * certain exceptions to SOAP Faults. Default is none. Additional exception resolvers can be added through the + * {@link org.springframework.ws.server.endpoint.adapter.MessageMethodEndpointAdapter + * MessageMethodEndpointAdapter} and + * {@link org.springframework.ws.server.endpoint.adapter.PayloadMethodEndpointAdapter + * PayloadMethodEndpointAdapter}. Additional endpoint adapters can be added through the + * {@link #setEndpointAdapters(List) endpointAdapters} property.
    • + *
    • Its exception resolution strategy can be specified via a + * {@link EndpointExceptionResolver}, for example mapping certain exceptions to SOAP + * Faults. Default is none. Additional exception resolvers can be added through the * {@link #setEndpointExceptionResolvers(List) endpointExceptionResolvers} property.
    • *
    * @@ -85,18 +91,18 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa /** Additional logger to use when no mapped endpoint is found for a request. */ protected static final Log endpointNotFoundLogger = LogFactory - .getLog(MessageDispatcher.ENDPOINT_NOT_FOUND_LOG_CATEGORY); + .getLog(MessageDispatcher.ENDPOINT_NOT_FOUND_LOG_CATEGORY); /** Log category to use for message tracing. */ public static final String MESSAGE_TRACING_LOG_CATEGORY = "org.springframework.ws.server.MessageTracing"; /** Additional logger to use for sent message tracing. */ protected static final Log sentMessageTracingLogger = LogFactory - .getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".sent"); + .getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".sent"); /** Additional logger to use for received message tracing. */ protected static final Log receivedMessageTracingLogger = LogFactory - .getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".received"); + .getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".received"); private final DefaultStrategiesHelper defaultStrategiesHelper; @@ -127,12 +133,18 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa this.endpointAdapters = endpointAdapters; } - /** Returns the {@code EndpointExceptionResolver}s to use by this {@code MessageDispatcher}. */ + /** + * Returns the {@code EndpointExceptionResolver}s to use by this + * {@code MessageDispatcher}. + */ public List getEndpointExceptionResolvers() { return endpointExceptionResolvers; } - /** Sets the {@code EndpointExceptionResolver}s to use by this {@code MessageDispatcher}. */ + /** + * Sets the {@code EndpointExceptionResolver}s to use by this + * {@code MessageDispatcher}. + */ public void setEndpointExceptionResolvers(List endpointExceptionResolvers) { this.endpointExceptionResolvers = endpointExceptionResolvers; } @@ -161,14 +173,16 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa @Override public void receive(MessageContext messageContext) throws Exception { - // Let's keep a reference to the request content as it came in, it might be changed by interceptors in dispatch() + // Let's keep a reference to the request content as it came in, it might be + // changed by interceptors in dispatch() String requestContent = ""; if (receivedMessageTracingLogger.isTraceEnabled() || sentMessageTracingLogger.isTraceEnabled()) { requestContent = getMessageContent(messageContext.getRequest()); } if (receivedMessageTracingLogger.isTraceEnabled()) { receivedMessageTracingLogger.trace("Received request [" + requestContent + "]"); - } else if (receivedMessageTracingLogger.isDebugEnabled()) { + } + else if (receivedMessageTracingLogger.isDebugEnabled()) { receivedMessageTracingLogger.debug("Received request [" + messageContext.getRequest() + "]"); } dispatch(messageContext); @@ -176,14 +190,17 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa WebServiceMessage response = messageContext.getResponse(); if (sentMessageTracingLogger.isTraceEnabled()) { String responseContent = getMessageContent(response); - sentMessageTracingLogger.trace("Sent response [" + responseContent + "] for request [" + requestContent + "]"); - } else if (sentMessageTracingLogger.isDebugEnabled()) { sentMessageTracingLogger - .debug("Sent response [" + response + "] for request [" + messageContext.getRequest() + "]"); + .trace("Sent response [" + responseContent + "] for request [" + requestContent + "]"); } - } else if (sentMessageTracingLogger.isDebugEnabled()) { - sentMessageTracingLogger.debug("MessageDispatcher with name '" + beanName + "' sends no response for request [" - + messageContext.getRequest() + "]"); + else if (sentMessageTracingLogger.isDebugEnabled()) { + sentMessageTracingLogger + .debug("Sent response [" + response + "] for request [" + messageContext.getRequest() + "]"); + } + } + else if (sentMessageTracingLogger.isDebugEnabled()) { + sentMessageTracingLogger.debug("MessageDispatcher with name '" + beanName + + "' sends no response for request [" + messageContext.getRequest() + "]"); } } @@ -195,10 +212,9 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa /** * Dispatches the request in the given MessageContext according to the configuration. - * * @param messageContext the message context - * @throws org.springframework.ws.NoEndpointFoundException thrown when an endpoint cannot be resolved for the incoming - * message + * @throws org.springframework.ws.NoEndpointFoundException thrown when an endpoint + * cannot be resolved for the incoming message */ protected final void dispatch(MessageContext messageContext) throws Exception { EndpointInvocationChain mappedEndpoint = null; @@ -231,21 +247,25 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa // Apply handleResponse methods of registered interceptors triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext); - } catch (NoEndpointFoundException ex) { + } + catch (NoEndpointFoundException ex) { // No triggering of interceptors if no endpoint is found if (endpointNotFoundLogger.isWarnEnabled()) { endpointNotFoundLogger.warn("No endpoint mapping found for [" + messageContext.getRequest() + "]"); } throw ex; - } catch (Exception ex) { + } + catch (Exception ex) { Object endpoint = mappedEndpoint != null ? mappedEndpoint.getEndpoint() : null; processEndpointException(messageContext, endpoint, ex); triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext); } triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, null); - } catch (NoEndpointFoundException ex) { + } + catch (NoEndpointFoundException ex) { throw ex; - } catch (Exception ex) { + } + catch (Exception ex) { // Trigger after-completion for thrown exception. triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, ex); throw ex; @@ -254,19 +274,20 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa /** * Returns the endpoint for this request. All endpoint mappings are tried, in order. - * - * @return the {@code EndpointInvocationChain}, or {@code null} if no endpoint could be found. + * @return the {@code EndpointInvocationChain}, or {@code null} if no endpoint could + * be found. */ protected EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception { for (EndpointMapping endpointMapping : getEndpointMappings()) { EndpointInvocationChain endpoint = endpointMapping.getEndpoint(messageContext); if (endpoint != null) { if (logger.isDebugEnabled()) { - logger.debug( - "Endpoint mapping [" + endpointMapping + "] maps request to endpoint [" + endpoint.getEndpoint() + "]"); + logger.debug("Endpoint mapping [" + endpointMapping + "] maps request to endpoint [" + + endpoint.getEndpoint() + "]"); } return endpoint; - } else if (logger.isDebugEnabled()) { + } + else if (logger.isDebugEnabled()) { logger.debug("Endpoint mapping [" + endpointMapping + "] has no mapping for request"); } } @@ -275,7 +296,6 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa /** * Returns the {@code EndpointAdapter} for the given endpoint. - * * @param endpoint the endpoint to find an adapter for * @return the adapter */ @@ -293,11 +313,10 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa } /** - * Callback for pre-processing of given invocation chain and message context. Gets called before invocation of - * {@code handleRequest} on the interceptors. + * Callback for pre-processing of given invocation chain and message context. Gets + * called before invocation of {@code handleRequest} on the interceptors. *

    * Default implementation does nothing, and returns {@code true}. - * * @param mappedEndpoint the mapped {@code EndpointInvocationChain} * @param messageContext the message context * @return {@code true} if processing should continue; {@code false} otherwise @@ -307,11 +326,12 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa } /** - * Determine an error {@code SOAPMessage} response via the registered {@code EndpointExceptionResolvers}. Most likely, - * the response contains a {@code SOAPFault}. If no suitable resolver was found, the exception is rethrown. - * + * Determine an error {@code SOAPMessage} response via the registered + * {@code EndpointExceptionResolvers}. Most likely, the response contains a + * {@code SOAPFault}. If no suitable resolver was found, the exception is rethrown. * @param messageContext current SOAPMessage request - * @param endpoint the executed endpoint, or null if none chosen at the time of the exception + * @param endpoint the executed endpoint, or null if none chosen at the time of the + * exception * @param ex the exception that got thrown during handler execution * @throws Exception if no suitable resolver is found */ @@ -332,10 +352,9 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa } /** - * Trigger handleResponse or handleFault on the mapped EndpointInterceptors. Will just invoke said method on all - * interceptors whose handleRequest invocation returned {@code true}, in addition to the last interceptor who returned - * {@code false}. - * + * Trigger handleResponse or handleFault on the mapped EndpointInterceptors. Will just + * invoke said method on all interceptors whose handleRequest invocation returned + * {@code true}, in addition to the last interceptor who returned {@code false}. * @param mappedEndpoint the mapped EndpointInvocationChain * @param interceptorIndex index of last interceptor that was called * @param messageContext the message context, whose request and response are filled @@ -356,7 +375,8 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa EndpointInterceptor interceptor = mappedEndpoint.getInterceptors()[i]; if (!hasFault) { resume = interceptor.handleResponse(messageContext, mappedEndpoint.getEndpoint()); - } else { + } + else { resume = interceptor.handleFault(messageContext, mappedEndpoint.getEndpoint()); } } @@ -364,10 +384,10 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa } /** - * Trigger afterCompletion callbacks on the mapped EndpointInterceptors. Will just invoke afterCompletion for all - * interceptors whose handleRequest invocation has successfully completed and returned true, in addition to the last - * interceptor who returned {@code false}. - * + * Trigger afterCompletion callbacks on the mapped EndpointInterceptors. Will just + * invoke afterCompletion for all interceptors whose handleRequest invocation has + * successfully completed and returned true, in addition to the last interceptor who + * returned {@code false}. * @param mappedEndpoint the mapped EndpointInvocationChain * @param interceptorIndex index of last interceptor that successfully completed * @param ex Exception thrown on handler execution, or {@code null} if none @@ -384,7 +404,8 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa EndpointInterceptor interceptor = interceptors[i]; try { interceptor.afterCompletion(messageContext, mappedEndpoint.getEndpoint(), ex); - } catch (Throwable ex2) { + } + catch (Throwable ex2) { logger.error("EndpointInterceptor.afterCompletion threw exception", ex2); } } @@ -393,20 +414,22 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa } /** - * Initialize the {@code EndpointAdapters} used by this class. If no adapter beans are explicitly set by using the - * {@code endpointAdapters} property, we use the default strategies. - * + * Initialize the {@code EndpointAdapters} used by this class. If no adapter beans are + * explicitly set by using the {@code endpointAdapters} property, we use the default + * strategies. * @see #setEndpointAdapters(java.util.List) */ private void initEndpointAdapters(ApplicationContext applicationContext) throws BeansException { if (endpointAdapters == null) { - Map matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, - EndpointAdapter.class, true, false); + Map matchingBeans = BeanFactoryUtils + .beansOfTypeIncludingAncestors(applicationContext, EndpointAdapter.class, true, false); if (!matchingBeans.isEmpty()) { endpointAdapters = new ArrayList<>(matchingBeans.values()); endpointAdapters.sort(new OrderComparator()); - } else { - endpointAdapters = defaultStrategiesHelper.getDefaultStrategies(EndpointAdapter.class, applicationContext); + } + else { + endpointAdapters = defaultStrategiesHelper.getDefaultStrategies(EndpointAdapter.class, + applicationContext); if (logger.isDebugEnabled()) { logger.debug("No EndpointAdapters found, using defaults"); } @@ -415,21 +438,22 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa } /** - * Initialize the {@code EndpointExceptionResolver} used by this class. If no resolver beans are explicitly set by - * using the {@code endpointExceptionResolvers} property, we use the default strategies. - * + * Initialize the {@code EndpointExceptionResolver} used by this class. If no resolver + * beans are explicitly set by using the {@code endpointExceptionResolvers} property, + * we use the default strategies. * @see #setEndpointExceptionResolvers(java.util.List) */ private void initEndpointExceptionResolvers(ApplicationContext applicationContext) throws BeansException { if (endpointExceptionResolvers == null) { Map matchingBeans = BeanFactoryUtils - .beansOfTypeIncludingAncestors(applicationContext, EndpointExceptionResolver.class, true, false); + .beansOfTypeIncludingAncestors(applicationContext, EndpointExceptionResolver.class, true, false); if (!matchingBeans.isEmpty()) { endpointExceptionResolvers = new ArrayList<>(matchingBeans.values()); endpointExceptionResolvers.sort(new OrderComparator()); - } else { - endpointExceptionResolvers = defaultStrategiesHelper.getDefaultStrategies(EndpointExceptionResolver.class, - applicationContext); + } + else { + endpointExceptionResolvers = defaultStrategiesHelper + .getDefaultStrategies(EndpointExceptionResolver.class, applicationContext); if (logger.isDebugEnabled()) { logger.debug("No EndpointExceptionResolvers found, using defaults"); } @@ -438,24 +462,27 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa } /** - * Initialize the {@code EndpointMappings} used by this class. If no mapping beans are explictely set by using the - * {@code endpointMappings} property, we use the default strategies. - * + * Initialize the {@code EndpointMappings} used by this class. If no mapping beans are + * explictely set by using the {@code endpointMappings} property, we use the default + * strategies. * @see #setEndpointMappings(java.util.List) */ private void initEndpointMappings(ApplicationContext applicationContext) throws BeansException { if (endpointMappings == null) { - Map matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, - EndpointMapping.class, true, false); + Map matchingBeans = BeanFactoryUtils + .beansOfTypeIncludingAncestors(applicationContext, EndpointMapping.class, true, false); if (!matchingBeans.isEmpty()) { endpointMappings = new ArrayList<>(matchingBeans.values()); endpointMappings.sort(new OrderComparator()); - } else { - endpointMappings = defaultStrategiesHelper.getDefaultStrategies(EndpointMapping.class, applicationContext); + } + else { + endpointMappings = defaultStrategiesHelper.getDefaultStrategies(EndpointMapping.class, + applicationContext); if (logger.isDebugEnabled()) { logger.debug("No EndpointMappings found, using defaults"); } } } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/SmartEndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/SmartEndpointInterceptor.java index 40d2b4db..ec3f71ed 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/SmartEndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/SmartEndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,8 @@ package org.springframework.ws.server; import org.springframework.ws.context.MessageContext; /** - * Extension of the {@link EndpointInterceptor} interface that adds a way to decide whether the interceptor should - * intercept a given message context. + * Extension of the {@link EndpointInterceptor} interface that adds a way to decide + * whether the interceptor should intercept a given message context. * * @author Arjen Poutsma * @since 2.0 @@ -29,10 +29,10 @@ public interface SmartEndpointInterceptor extends EndpointInterceptor { /** * Indicates whether this interceptor should intercept the given message context. - * * @param messageContext contains the incoming request message * @param endpoint chosen endpoint to invoke - * @return {@code true} to indicate that this interceptor applies; {@code false} otherwise + * @return {@code true} to indicate that this interceptor applies; {@code false} + * otherwise */ boolean shouldIntercept(MessageContext messageContext, Object endpoint); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDom4jPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDom4jPayloadEndpoint.java index 25989dbf..538e5840 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDom4jPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDom4jPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,15 +26,17 @@ import org.dom4j.Element; import org.dom4j.io.DOMReader; import org.dom4j.io.DocumentResult; import org.dom4j.io.DocumentSource; -import org.springframework.xml.transform.TransformerObjectSupport; import org.w3c.dom.Node; +import org.springframework.xml.transform.TransformerObjectSupport; + /** - * Abstract base class for endpoints that handle the message payload as dom4j elements. Offers the message payload as a - * dom4j {@code Element}, and allows subclasses to create a response by returning an {@code Element}. + * Abstract base class for endpoints that handle the message payload as dom4j elements. + * Offers the message payload as a dom4j {@code Element}, and allows subclasses to create + * a response by returning an {@code Element}. *

    - * An {@code AbstractDom4JPayloadEndpoint} only accept one payload element. Multiple payload elements are not in - * accordance with WS-I. + * An {@code AbstractDom4JPayloadEndpoint} only accept one payload element. Multiple + * payload elements are not in accordance with WS-I. * * @author Arjen Poutsma * @see org.dom4j.Element @@ -47,7 +49,8 @@ public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupp private boolean alwaysTransform = false; /** - * Set if the request {@link Source} should always be transformed into a new {@link DocumentResult}. + * Set if the request {@link Source} should always be transformed into a new + * {@link DocumentResult}. *

    * Default is {@code false}, which is faster. */ @@ -71,12 +74,13 @@ public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupp /** * Returns the payload element of the given source. *

    - * Default implementation checks whether the source is a {@link javax.xml.transform.dom.DOMSource}, and uses a - * {@link org.dom4j.io.DOMReader} to create a JDOM {@link org.dom4j.Element}. In all other cases, or when - * {@linkplain #setAlwaysTransform(boolean) alwaysTransform} is {@code true}, the source is transformed into a - * {@link org.dom4j.io.DocumentResult}, which is more expensive. If the passed source is {@code null}, {@code + * Default implementation checks whether the source is a + * {@link javax.xml.transform.dom.DOMSource}, and uses a + * {@link org.dom4j.io.DOMReader} to create a JDOM {@link org.dom4j.Element}. In all + * other cases, or when {@linkplain #setAlwaysTransform(boolean) alwaysTransform} is + * {@code true}, the source is transformed into a {@link org.dom4j.io.DocumentResult}, + * which is more expensive. If the passed source is {@code null}, {@code * null} is returned. - * * @param source the source to return the root element of; can be {@code null} * @return the document element * @throws javax.xml.transform.TransformerException in case of errors @@ -100,14 +104,15 @@ public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupp } /** - * Template method. Subclasses must implement this. Offers the request payload as a dom4j {@code Element}, and allows - * subclasses to return a response {@code Element}. + * Template method. Subclasses must implement this. Offers the request payload as a + * dom4j {@code Element}, and allows subclasses to return a response {@code Element}. *

    - * The given dom4j {@code Document} is to be used for constructing a response element, by using {@code addElement}. - * + * The given dom4j {@code Document} is to be used for constructing a response element, + * by using {@code addElement}. * @param requestElement the contents of the SOAP message as dom4j elements * @param responseDocument a dom4j document to be used for constructing a response * @return the response element. Can be {@code null} to specify no response. */ protected abstract Element invokeInternal(Element requestElement, Document responseDocument) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDomPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDomPayloadEndpoint.java index 304b0aa1..5ab66592 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDomPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractDomPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,20 +24,21 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; -import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.springframework.xml.transform.TransformerObjectSupport; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.transform.TransformerObjectSupport; + /** * Abstract base class for endpoints that handle the message payload as DOM elements. *

    - * Offers the message payload as a DOM {@code Element}, and allows subclasses to create a response by returning an - * {@code Element}. + * Offers the message payload as a DOM {@code Element}, and allows subclasses to create a + * response by returning an {@code Element}. *

    - * An {@code AbstractDomPayloadEndpoint} only accept one payload element. Multiple payload elements are not in - * accordance with WS-I. + * An {@code AbstractDomPayloadEndpoint} only accept one payload element. + * Multiple payload elements are not in accordance with WS-I. * * @author Arjen Poutsma * @author Alef Arendsen @@ -58,7 +59,10 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor private boolean alwaysTransform = false; - /** Set whether or not the XML parser should be XML namespace aware. Default is {@code true}. */ + /** + * Set whether or not the XML parser should be XML namespace aware. Default is + * {@code true}. + */ public void setNamespaceAware(boolean namespaceAware) { this.namespaceAware = namespaceAware; } @@ -69,14 +73,16 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor } /** - * Set if the XML parser should expand entity reference nodes. Default is {@code false}. + * Set if the XML parser should expand entity reference nodes. Default is + * {@code false}. */ public void setExpandEntityReferences(boolean expandEntityRef) { documentBuilderFactory.setExpandEntityReferences(expandEntityRef); } /** - * Set if the request {@link Source} should always be transformed into a new {@link DOMResult}. + * Set if the request {@link Source} should always be transformed into a new + * {@link DOMResult}. *

    * Default is {@code false}, which is faster. */ @@ -97,22 +103,24 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor } /** - * Create a {@code DocumentBuilder} that this endpoint will use for parsing XML documents. Can be overridden in - * subclasses, adding further initialization of the builder. - * - * @param factory the {@code DocumentBuilderFactory} that the DocumentBuilder should be created with + * Create a {@code DocumentBuilder} that this endpoint will use for parsing XML + * documents. Can be overridden in subclasses, adding further initialization of the + * builder. + * @param factory the {@code DocumentBuilderFactory} that the DocumentBuilder should + * be created with * @return the {@code DocumentBuilder} * @throws ParserConfigurationException if thrown by JAXP methods */ - protected DocumentBuilder createDocumentBuilder(DocumentBuilderFactory factory) throws ParserConfigurationException { + protected DocumentBuilder createDocumentBuilder(DocumentBuilderFactory factory) + throws ParserConfigurationException { return factory.newDocumentBuilder(); } /** - * Create a {@code DocumentBuilderFactory} that this endpoint will use for constructing XML documents. Can be - * overridden in subclasses, adding further initialization of the factory. The resulting - * {@code DocumentBuilderFactory} is cached, so this method will only be called once. - * + * Create a {@code DocumentBuilderFactory} that this endpoint will use for + * constructing XML documents. Can be overridden in subclasses, adding further + * initialization of the factory. The resulting {@code DocumentBuilderFactory} is + * cached, so this method will only be called once. * @return the DocumentBuilderFactory * @throws ParserConfigurationException if thrown by JAXP methods */ @@ -127,11 +135,11 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor /** * Returns the payload element of the given source. *

    - * Default implementation checks whether the source is a {@link DOMSource}, and returns the - * {@linkplain DOMSource#getNode() node} of that. In all other cases, or when {@linkplain #setAlwaysTransform(boolean) - * alwaysTransform} is {@code true}, the source is transformed into a {@link DOMResult}, which is more expensive. If - * the passed source is {@code null}, {@code null} is returned. - * + * Default implementation checks whether the source is a {@link DOMSource}, and + * returns the {@linkplain DOMSource#getNode() node} of that. In all other cases, or + * when {@linkplain #setAlwaysTransform(boolean) alwaysTransform} is {@code true}, the + * source is transformed into a {@link DOMResult}, which is more expensive. If the + * passed source is {@code null}, {@code null} is returned. * @param source the source to return the root element of; can be {@code null} * @param documentBuilder the document builder to be used for transformations * @return the document element @@ -145,7 +153,8 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor Node node = ((DOMSource) source).getNode(); if (node.getNodeType() == Node.ELEMENT_NODE) { return (Element) node; - } else if (node.getNodeType() == Node.DOCUMENT_NODE) { + } + else if (node.getNodeType() == Node.DOCUMENT_NODE) { return ((Document) node).getDocumentElement(); } } @@ -159,11 +168,11 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor /** * Template method that subclasses must implement to process the request. *

    - * Offers the request payload as a DOM {@code Element}, and allows subclasses to return a response {@code Element}. + * Offers the request payload as a DOM {@code Element}, and allows subclasses to + * return a response {@code Element}. *

    - * The given DOM {@code Document} is to be used for constructing {@code Node}s, by using the various {@code create} - * methods. - * + * The given DOM {@code Document} is to be used for constructing {@code Node}s, by + * using the various {@code create} methods. * @param requestElement the contents of the SOAP message as DOM elements * @param responseDocument a DOM document to be used for constructing {@code Node}s * @return the response element. Can be {@code null} to specify no response. diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractEndpointExceptionResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractEndpointExceptionResolver.java index c5055959..003889aa 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractEndpointExceptionResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractEndpointExceptionResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,6 +20,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.core.Ordered; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointExceptionResolver; @@ -47,23 +48,26 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep /** * Specify the set of endpoints that this exception resolver should map. *

    - * The exception mappings and the default fault will only apply to the specified endpoints. + * The exception mappings and the default fault will only apply to the specified + * endpoints. *

    - * If no endpoints are set, both the exception mappings and the default fault will apply to all handlers. This means - * that a specified default fault will be used as fallback for all exceptions; any further - * {@code EndpointExceptionResolvers} in the chain will be ignored in this case. + * If no endpoints are set, both the exception mappings and the default fault will + * apply to all handlers. This means that a specified default fault will be used as + * fallback for all exceptions; any further {@code EndpointExceptionResolvers} in the + * chain will be ignored in this case. */ public void setMappedEndpoints(Set mappedEndpoints) { this.mappedEndpoints = mappedEndpoints; } /** - * Set the log category for warn logging. The name will be passed to the underlying logger implementation through - * Commons Logging, getting interpreted as log category according to the logger's configuration. + * Set the log category for warn logging. The name will be passed to the underlying + * logger implementation through Commons Logging, getting interpreted as log category + * according to the logger's configuration. *

    - * Default is no warn logging. Specify this setting to activate warn logging into a specific category. Alternatively, - * override the {@link #logException} method for custom logging. - * + * Default is no warn logging. Specify this setting to activate warn logging into a + * specific category. Alternatively, override the {@link #logException} method for + * custom logging. * @see org.apache.commons.logging.LogFactory#getLog(String) * @see org.apache.log4j.Logger#getLogger(String) * @see java.util.logging.Logger#getLogger(String) @@ -76,7 +80,6 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep * Specify the order value for this mapping. *

    * Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered. - * * @see org.springframework.core.Ordered#getOrder() */ public final void setOrder(int order) { @@ -89,9 +92,8 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep } /** - * Default implementation that checks whether the given {@code endpoint} is in the set of {@link #setMappedEndpoints - * mapped endpoints}. - * + * Default implementation that checks whether the given {@code endpoint} is in the set + * of {@link #setMappedEndpoints mapped endpoints}. * @see #resolveExceptionInternal(MessageContext,Object,Exception) */ @Override @@ -109,12 +111,11 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep } /** - * Log the given exception at warn level, provided that warn logging has been activated through the - * {@link #setWarnLogCategory "warnLogCategory"} property. + * Log the given exception at warn level, provided that warn logging has been + * activated through the {@link #setWarnLogCategory "warnLogCategory"} property. *

    - * Calls {@link #buildLogMessage} in order to determine the concrete message to log. Always passes the full exception - * to the logger. - * + * Calls {@link #buildLogMessage} in order to determine the concrete message to log. + * Always passes the full exception to the logger. * @param ex the exception that got thrown during handler execution * @param messageContext current message context request * @see #setWarnLogCategory @@ -128,8 +129,8 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep } /** - * Build a log message for the given exception, occured during processing the given message context. - * + * Build a log message for the given exception, occured during processing the given + * message context. * @param ex the exception that got thrown during handler execution * @param messageContext the message context * @return the log message to use @@ -139,10 +140,11 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep } /** - * Template method for resolving exceptions that is called by {@link #resolveException}. - * + * Template method for resolving exceptions that is called by + * {@link #resolveException}. * @param messageContext current message context - * @param endpoint the executed endpoint, or {@code null} if none chosen at the time of the exception + * @param endpoint the executed endpoint, or {@code null} if none chosen at the time + * of the exception * @param ex the exception that got thrown during endpoint execution * @return {@code true} if resolved; {@code false} otherwise * @see #resolveException(MessageContext,Object,Exception) diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractJDomPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractJDomPayloadEndpoint.java index 96842650..5b52cd29 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractJDomPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractJDomPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,15 +25,17 @@ import org.jdom2.Element; import org.jdom2.input.DOMBuilder; import org.jdom2.transform.JDOMResult; import org.jdom2.transform.JDOMSource; -import org.springframework.xml.transform.TransformerObjectSupport; import org.w3c.dom.Node; +import org.springframework.xml.transform.TransformerObjectSupport; + /** * Abstract base class for endpoints that handle the message payload as JDOM elements. *

    - * Offers the message payload as a JDOM {@link Element}, and allows subclasses to create a response by returning an - * {@code Element}. one payload element. Multiple - * payload elements are not in accordance with WS-I. + * Offers the message payload as a JDOM {@link Element}, and allows subclasses to create a + * response by returning an {@code Element}. one payload element. Multiple payload elements are not in accordance + * with WS-I. * * @author Arjen Poutsma * @since 1.0.0 @@ -45,7 +47,8 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo private boolean alwaysTransform = false; /** - * Set if the request {@link Source} should always be transformed into a new {@link JDOMResult}. + * Set if the request {@link Source} should always be transformed into a new + * {@link JDOMResult}. *

    * Default is {@code false}, which is faster. */ @@ -63,11 +66,11 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo /** * Returns the payload element of the given source. *

    - * Default implementation checks whether the source is a {@link DOMSource}, and uses a {@link DOMBuilder} to create a - * JDOM {@link Element}. In all other cases, or when {@linkplain #setAlwaysTransform(boolean) alwaysTransform} is - * {@code true}, the source is transformed into a {@link JDOMResult}, which is more expensive. If the passed source is - * {@code null}, {@code null} is returned. - * + * Default implementation checks whether the source is a {@link DOMSource}, and uses a + * {@link DOMBuilder} to create a JDOM {@link Element}. In all other cases, or when + * {@linkplain #setAlwaysTransform(boolean) alwaysTransform} is {@code true}, the + * source is transformed into a {@link JDOMResult}, which is more expensive. If the + * passed source is {@code null}, {@code null} is returned. * @param source the source to return the root element of; can be {@code null} * @return the document element * @throws TransformerException in case of errors @@ -81,7 +84,8 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo DOMBuilder domBuilder = new DOMBuilder(); if (node.getNodeType() == Node.ELEMENT_NODE) { return domBuilder.build((org.w3c.dom.Element) node); - } else if (node.getNodeType() == Node.DOCUMENT_NODE) { + } + else if (node.getNodeType() == Node.DOCUMENT_NODE) { Document document = domBuilder.build((org.w3c.dom.Document) node); return document.getRootElement(); } @@ -93,11 +97,11 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo } /** - * Template method. Subclasses must implement this. Offers the request payload as a JDOM {@code Element}, and allows - * subclasses to return a response {@code Element}. - * + * Template method. Subclasses must implement this. Offers the request payload as a + * JDOM {@code Element}, and allows subclasses to return a response {@code Element}. * @param requestElement the contents of the SOAP message as JDOM element * @return the response element. Can be {@code null} to specify no response. */ protected abstract Element invokeInternal(Element requestElement) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractLoggingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractLoggingInterceptor.java index 9aa2b591..983cd0c3 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractLoggingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractLoggingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,15 +27,17 @@ import javax.xml.transform.stream.StreamResult; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; import org.springframework.xml.transform.TransformerObjectSupport; /** - * Abstract base class for {@code EndpointInterceptor} instances that log a part of a {@code WebServiceMessage}. By - * default, both request and response messages are logged, but this behaviour can be changed using the - * {@code logRequest} and {@code logResponse} properties. + * Abstract base class for {@code EndpointInterceptor} instances that log a part of a + * {@code WebServiceMessage}. By default, both request and response messages are logged, + * but this behaviour can be changed using the {@code logRequest} and {@code logResponse} + * properties. * * @author Arjen Poutsma * @since 1.0.0 @@ -43,8 +45,8 @@ import org.springframework.xml.transform.TransformerObjectSupport; public abstract class AbstractLoggingInterceptor extends TransformerObjectSupport implements EndpointInterceptor { /** - * The default {@code Log} instance used to write trace messages. This instance is mapped to the implementing - * {@code Class}. + * The default {@code Log} instance used to write trace messages. This instance is + * mapped to the implementing {@code Class}. */ protected transient Log logger = LogFactory.getLog(getClass()); @@ -63,11 +65,12 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor } /** - * Set the name of the logger to use. The name will be passed to the underlying logger implementation through Commons - * Logging, getting interpreted as log category according to the logger's configuration. + * Set the name of the logger to use. The name will be passed to the underlying logger + * implementation through Commons Logging, getting interpreted as log category + * according to the logger's configuration. *

    - * This can be specified to not log into the category of a class but rather into a specific named category. - * + * This can be specified to not log into the category of a class but rather into a + * specific named category. * @see org.apache.commons.logging.LogFactory#getLog(String) * @see org.apache.log4j.Logger#getLogger(String) * @see java.util.logging.Logger#getLogger(String) @@ -77,9 +80,8 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor } /** - * Logs the request message payload. Logging only occurs if {@code logRequest} is set to {@code true}, which is the - * default. - * + * Logs the request message payload. Logging only occurs if {@code logRequest} is set + * to {@code true}, which is the default. * @param messageContext the message context * @return {@code true} * @throws TransformerException when the payload cannot be transformed to a string @@ -93,9 +95,8 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor } /** - * Logs the response message payload. Logging only occurs if {@code logResponse} is set to {@code true}, which is the - * default. - * + * Logs the response message payload. Logging only occurs if {@code logResponse} is + * set to {@code true}, which is the default. * @param messageContext the message context * @return {@code true} * @throws TransformerException when the payload cannot be transformed to a string @@ -116,13 +117,14 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor /** Does nothing by default */ @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {} + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) { + } /** * Determine whether the {@link #logger} field is enabled. *

    - * Default is {@code true} when the "debug" level is enabled. Subclasses can override this to change the level under - * which logging occurs. + * Default is {@code true} when the "debug" level is enabled. Subclasses can override + * this to change the level under which logging occurs. */ protected boolean isLogEnabled() { return logger.isDebugEnabled(); @@ -136,11 +138,11 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor } /** - * Logs the given {@link Source source} to the {@link #logger}, using the message as a prefix. + * Logs the given {@link Source source} to the {@link #logger}, using the message as a + * prefix. *

    - * By default, this message creates a string representation of the given source, and delegates to - * {@link #logMessage(String)}. - * + * By default, this message creates a string representation of the given source, and + * delegates to {@link #logMessage(String)}. * @param logMessage the log message * @param source the source to be logged * @throws TransformerException in case of errors @@ -158,9 +160,8 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor /** * Logs the given string message. *

    - * By default, this method uses a "debug" level of logging. Subclasses can override this method to change the level of - * logging used by the logger. - * + * By default, this method uses a "debug" level of logging. Subclasses can override + * this method to change the level of logging used by the logger. * @param message the message */ protected void logMessage(String message) { @@ -168,10 +169,11 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor } /** - * Abstract template method that returns the {@code Source} for the given {@code WebServiceMessage}. - * + * Abstract template method that returns the {@code Source} for the given + * {@code WebServiceMessage}. * @param message the message * @return the source of the message */ protected abstract Source getSource(WebServiceMessage message); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java index d6dd7932..3b73a135 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,6 +20,7 @@ import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.InitializingBean; import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; @@ -29,9 +30,10 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.support.MarshallingUtils; /** - * Endpoint that unmarshals the request payload, and marshals the response object. This endpoint needs a - * {@code Marshaller} and {@code Unmarshaller}, both of which can be set using properties. An abstract template method - * is invoked using the request object as a parameter, and allows for a response object to be returned. + * Endpoint that unmarshals the request payload, and marshals the response object. This + * endpoint needs a {@code Marshaller} and {@code Unmarshaller}, both of which can be set + * using properties. An abstract template method is invoked using the request object as a + * parameter, and allows for a response object to be returned. * * @author Arjen Poutsma * @see #setMarshaller(org.springframework.oxm.Marshaller) @@ -53,24 +55,25 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo private Unmarshaller unmarshaller; /** - * Creates a new {@code AbstractMarshallingPayloadEndpoint}. The {@link Marshaller} and {@link Unmarshaller} must be - * injected using properties. - * + * Creates a new {@code AbstractMarshallingPayloadEndpoint}. The {@link Marshaller} + * and {@link Unmarshaller} must be injected using properties. * @see #setMarshaller(org.springframework.oxm.Marshaller) * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) */ - protected AbstractMarshallingPayloadEndpoint() {} + protected AbstractMarshallingPayloadEndpoint() { + } /** - * Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller. The given {@link Marshaller} - * should also implements the {@link Unmarshaller}, since it is used for both marshalling and unmarshalling. If it is - * not, an exception is thrown. + * Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller. + * The given {@link Marshaller} should also implements the {@link Unmarshaller}, since + * it is used for both marshalling and unmarshalling. If it is not, an exception is + * thrown. *

    - * Note that all {@link Marshaller} implementations in Spring-WS also implement the {@link Unmarshaller} interface, so - * that you can safely use this constructor. - * + * Note that all {@link Marshaller} implementations in Spring-WS also implement the + * {@link Unmarshaller} interface, so that you can safely use this constructor. * @param marshaller object used as marshaller and unmarshaller - * @throws IllegalArgumentException when {@code marshaller} does not implement the {@link Unmarshaller} interface + * @throws IllegalArgumentException when {@code marshaller} does not implement the + * {@link Unmarshaller} interface * @see #AbstractMarshallingPayloadEndpoint(Marshaller,Unmarshaller) */ protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller) { @@ -79,15 +82,16 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + "interface. Please set an Unmarshaller explicitly by using the " + "AbstractMarshallingPayloadEndpoint(Marshaller, Unmarshaller) constructor."); - } else { + } + else { setMarshaller(marshaller); setUnmarshaller((Unmarshaller) marshaller); } } /** - * Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller and unmarshaller. - * + * Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller + * and unmarshaller. * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use */ @@ -148,14 +152,15 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo } /** - * Callback for post-processing in terms of unmarshalling. Called on each message request, after standard - * unmarshalling. + * Callback for post-processing in terms of unmarshalling. Called on each message + * request, after standard unmarshalling. *

    * Default implementation returns {@code true}. - * * @param messageContext the message context - * @param requestObject the object unmarshalled from the {@link MessageContext#getRequest() request} - * @return {@code true} to continue and call {@link #invokeInternal(Object)}; {@code false} otherwise + * @param requestObject the object unmarshalled from the + * {@link MessageContext#getRequest() request} + * @return {@code true} to continue and call {@link #invokeInternal(Object)}; + * {@code false} otherwise */ protected boolean onUnmarshalRequest(MessageContext messageContext, Object requestObject) throws Exception { return true; @@ -171,36 +176,41 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo } /** - * Callback for post-processing in terms of marshalling. Called on each message request, after standard marshalling of - * the response. Only invoked when {@link #invokeInternal(Object)} returns an object. + * Callback for post-processing in terms of marshalling. Called on each message + * request, after standard marshalling of the response. Only invoked when + * {@link #invokeInternal(Object)} returns an object. *

    * Default implementation is empty. - * * @param messageContext the message context - * @param requestObject the object unmarshalled from the {@link MessageContext#getRequest() request} - * @param responseObject the object marshalled to the {@link MessageContext#getResponse()} request} + * @param requestObject the object unmarshalled from the + * {@link MessageContext#getRequest() request} + * @param responseObject the object marshalled to the + * {@link MessageContext#getResponse()} request} */ - protected void onMarshalResponse(MessageContext messageContext, Object requestObject, Object responseObject) {} + protected void onMarshalResponse(MessageContext messageContext, Object requestObject, Object responseObject) { + } /** - * Template method that gets called after the marshaller and unmarshaller have been set. + * Template method that gets called after the marshaller and unmarshaller have been + * set. *

    * The default implementation does nothing. - * - * @deprecated as of Spring Web Services 1.5: {@link #afterPropertiesSet()} is no longer final, so this can safely be - * overridden in subclasses + * @deprecated as of Spring Web Services 1.5: {@link #afterPropertiesSet()} is no + * longer final, so this can safely be overridden in subclasses */ @Deprecated - public void afterMarshallerSet() throws Exception {} + public void afterMarshallerSet() throws Exception { + } /** * Template method that subclasses must implement to process a request. *

    - * The unmarshalled request object is passed as a parameter, and the returned object is marshalled to a response. If - * no response is required, return {@code null}. - * + * The unmarshalled request object is passed as a parameter, and the returned object + * is marshalled to a response. If no response is required, return {@code null}. * @param requestObject the unmarshalled message payload as an object - * @return the object to be marshalled as response, or {@code null} if a response is not required + * @return the object to be marshalled as response, or {@code null} if a response is + * not required */ protected abstract Object invokeInternal(Object requestObject) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractSaxPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractSaxPayloadEndpoint.java index c7da5c34..4d77b618 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractSaxPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractSaxPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,16 +19,18 @@ package org.springframework.ws.server.endpoint; import javax.xml.transform.Source; import javax.xml.transform.sax.SAXResult; -import org.springframework.xml.transform.TransformerObjectSupport; import org.xml.sax.ContentHandler; +import org.springframework.xml.transform.TransformerObjectSupport; + /** - * Abstract base class for endpoints that handle the message payload with a SAX {@code ContentHandler}. Allows - * subclasses to create a response by returning a {@code Source}. + * Abstract base class for endpoints that handle the message payload with a SAX + * {@code ContentHandler}. Allows subclasses to create a response by returning a + * {@code Source}. *

    - * Implementations of this class should create a new handler for each call of {@code createContentHandler}, because of - * thread safety. The handlers is later passed on to {@code createResponse}, so it can be used for holding - * request-specific state. + * Implementations of this class should create a new handler for each call of + * {@code createContentHandler}, because of thread safety. The handlers is later passed on + * to {@code createResponse}, so it can be used for holding request-specific state. * * @author Arjen Poutsma * @see #createContentHandler() @@ -40,9 +42,8 @@ import org.xml.sax.ContentHandler; public abstract class AbstractSaxPayloadEndpoint extends TransformerObjectSupport implements PayloadEndpoint { /** - * Invokes the provided {@code ContentHandler} on the given request. After parsing has been done, the provided - * response is returned. - * + * Invokes the provided {@code ContentHandler} on the given request. After parsing has + * been done, the provided response is returned. * @see #createContentHandler() * @see #getResponse(org.xml.sax.ContentHandler) */ @@ -58,24 +59,25 @@ public abstract class AbstractSaxPayloadEndpoint extends TransformerObjectSuppor } /** - * Returns the SAX {@code ContentHandler} used to parse the incoming request payload. A new instance should be created - * for each call, because of thread-safety. The content handler can be used to hold request-specific state. + * Returns the SAX {@code ContentHandler} used to parse the incoming request payload. + * A new instance should be created for each call, because of thread-safety. The + * content handler can be used to hold request-specific state. *

    * If an incoming message does not contain a payload, this method will not be invoked. - * * @return a SAX content handler to be used for parsing */ protected abstract ContentHandler createContentHandler() throws Exception; /** - * Returns the response to be given, if any. This method is called after the request payload has been parsed using the - * SAX {@code ContentHandler}. The passed {@code ContentHandler} is created by {@link #createContentHandler()}: it can - * be used to hold request-specific state. + * Returns the response to be given, if any. This method is called after the request + * payload has been parsed using the SAX {@code ContentHandler}. The passed + * {@code ContentHandler} is created by {@link #createContentHandler()}: it can be + * used to hold request-specific state. *

    - * If an incoming message does not contain a payload, this method will be invoked with {@code null} as content - * handler. - * + * If an incoming message does not contain a payload, this method will be invoked with + * {@code null} as content handler. * @param contentHandler the content handler used to parse the request */ protected abstract Source getResponse(ContentHandler contentHandler) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxEventPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxEventPayloadEndpoint.java index 21b11746..0b9f1559 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxEventPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxEventPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,7 +20,11 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import javax.xml.namespace.NamespaceContext; -import javax.xml.stream.*; +import javax.xml.stream.XMLEventFactory; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; import javax.xml.stream.events.XMLEvent; import javax.xml.stream.util.XMLEventConsumer; import javax.xml.transform.Result; @@ -34,12 +38,13 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.context.MessageContext; /** - * Abstract base class for endpoints that handle the message payload with event-based StAX. Allows subclasses to read - * the request with a {@code XMLEventReader}, and to create a response using a {@code XMLEventWriter}. + * Abstract base class for endpoints that handle the message payload with event-based + * StAX. Allows subclasses to read the request with a {@code XMLEventReader}, and to + * create a response using a {@code XMLEventWriter}. * * @author Arjen Poutsma * @see #invokeInternal(javax.xml.stream.XMLEventReader,javax.xml.stream.util.XMLEventConsumer, - * javax.xml.stream.XMLEventFactory) + * javax.xml.stream.XMLEventFactory) * @see XMLEventReader * @see XMLEventWriter * @since 1.0.0 @@ -59,10 +64,10 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo } /** - * Create a {@code XMLEventFactory} that this endpoint will use to create {@code XMLEvent}s. Can be overridden in - * subclasses, adding further initialization of the factory. The resulting {@code XMLEventFactory} is cached, so this - * method will only be called once. - * + * Create a {@code XMLEventFactory} that this endpoint will use to create + * {@code XMLEvent}s. Can be overridden in subclasses, adding further initialization + * of the factory. The resulting {@code XMLEventFactory} is cached, so this method + * will only be called once. * @return the created {@code XMLEventFactory} */ protected XMLEventFactory createXmlEventFactory() { @@ -89,7 +94,8 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo if (streamReader != null) { try { eventReader = getInputFactory().createXMLEventReader(streamReader); - } catch (XMLStreamException ex) { + } + catch (XMLStreamException ex) { eventReader = null; } } @@ -98,7 +104,8 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo if (eventReader == null) { try { eventReader = getInputFactory().createXMLEventReader(source); - } catch (XMLStreamException | UnsupportedOperationException ex) { + } + catch (XMLStreamException | UnsupportedOperationException ex) { eventReader = null; } } @@ -120,7 +127,8 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo if (eventWriter == null) { try { eventWriter = getOutputFactory().createXMLEventWriter(result); - } catch (XMLStreamException ex) { + } + catch (XMLStreamException ex) { // ignore } } @@ -128,9 +136,9 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo } /** - * Template method. Subclasses must implement this. Offers the request payload as a {@code XMLEventReader}, and a - * {@code XMLEventWriter} to write the response payload to. - * + * Template method. Subclasses must implement this. Offers the request payload as a + * {@code XMLEventReader}, and a {@code XMLEventWriter} to write the response payload + * to. * @param eventReader the reader to read the payload events from * @param eventWriter the writer to write payload events to * @param eventFactory an {@code XMLEventFactory} that can be used to create events @@ -139,8 +147,9 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo XMLEventFactory eventFactory) throws Exception; /** - * Implementation of the {@code XMLEventWriter} interface that creates a response {@code WebServiceMessage} as soon as - * any method is called, thus lazily creating the response. + * Implementation of the {@code XMLEventWriter} interface that creates a response + * {@code WebServiceMessage} as soon as any method is called, thus lazily creating the + * response. */ private class ResponseCreatingEventWriter implements XMLEventWriter { @@ -180,11 +189,13 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo if (event.isEndDocument()) { if (os != null) { eventWriter.flush(); - // if we used an output stream cache, we have to transform it to the response again + // if we used an output stream cache, we have to transform it to the + // response again try { ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); transform(new StreamSource(is), messageContext.getResponse().getPayloadResult()); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XMLStreamException(ex); } } @@ -228,11 +239,14 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo WebServiceMessage response = messageContext.getResponse(); eventWriter = getEventWriter(response.getPayloadResult()); if (eventWriter == null) { - // as a final resort, use a stream, and transform that at endDocument() + // as a final resort, use a stream, and transform that at + // endDocument() os = new ByteArrayOutputStream(); eventWriter = getOutputFactory().createXMLEventWriter(os); } } } + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxPayloadEndpoint.java index e07e7585..12a0c416 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,7 +23,8 @@ import org.springframework.xml.XMLInputFactoryUtils; import org.springframework.xml.transform.TransformerObjectSupport; /** - * Abstract base class for endpoints use StAX. Provides an {@code XMLInputFactory} and an {@code XMLOutputFactory}. + * Abstract base class for endpoints use StAX. Provides an {@code XMLInputFactory} and an + * {@code XMLOutputFactory}. * * @author Arjen Poutsma * @see XMLInputFactory @@ -56,10 +57,10 @@ public abstract class AbstractStaxPayloadEndpoint extends TransformerObjectSuppo } /** - * Create a {@code XMLInputFactory} that this endpoint will use to create {@code XMLStreamReader}s or - * {@code XMLEventReader}. Can be overridden in subclasses, adding further initialization of the factory. The - * resulting {@code XMLInputFactory} is cached, so this method will only be called once. - * + * Create a {@code XMLInputFactory} that this endpoint will use to create + * {@code XMLStreamReader}s or {@code XMLEventReader}. Can be overridden in + * subclasses, adding further initialization of the factory. The resulting + * {@code XMLInputFactory} is cached, so this method will only be called once. * @return the created {@code XMLInputFactory} */ protected XMLInputFactory createXmlInputFactory() { @@ -67,13 +68,14 @@ public abstract class AbstractStaxPayloadEndpoint extends TransformerObjectSuppo } /** - * Create a {@code XMLOutputFactory} that this endpoint will use to create {@code XMLStreamWriters}s or - * {@code XMLEventWriters}. Can be overridden in subclasses, adding further initialization of the factory. The - * resulting {@code XMLOutputFactory} is cached, so this method will only be called once. - * + * Create a {@code XMLOutputFactory} that this endpoint will use to create + * {@code XMLStreamWriters}s or {@code XMLEventWriters}. Can be overridden in + * subclasses, adding further initialization of the factory. The resulting + * {@code XMLOutputFactory} is cached, so this method will only be called once. * @return the created {@code XMLOutputFactory} */ protected XMLOutputFactory createXmlOutputFactory() { return XMLOutputFactory.newInstance(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxStreamPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxStreamPayloadEndpoint.java index 387d4d9a..c482f93e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxStreamPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractStaxStreamPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -35,8 +35,9 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.context.MessageContext; /** - * Abstract base class for endpoints that handle the message payload with streaming StAX. Allows subclasses to read the - * request with a {@code XMLStreamReader}, and to create a response using a {@code XMLStreamWriter}. + * Abstract base class for endpoints that handle the message payload with streaming StAX. + * Allows subclasses to read the request with a {@code XMLStreamReader}, and to create a + * response using a {@code XMLStreamWriter}. * * @author Arjen Poutsma * @see #invokeInternal(javax.xml.stream.XMLStreamReader,javax.xml.stream.XMLStreamWriter) @@ -69,7 +70,8 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl if (eventReader != null) { try { streamReader = StaxUtils.createEventStreamReader(eventReader); - } catch (XMLStreamException ex) { + } + catch (XMLStreamException ex) { streamReader = null; } } @@ -79,7 +81,8 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl if (streamReader == null) { try { streamReader = getInputFactory().createXMLStreamReader(source); - } catch (XMLStreamException | UnsupportedOperationException ex) { + } + catch (XMLStreamException | UnsupportedOperationException ex) { // ignore } } @@ -101,7 +104,8 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl if (streamWriter == null) { try { streamWriter = getOutputFactory().createXMLStreamWriter(result); - } catch (XMLStreamException ex) { + } + catch (XMLStreamException ex) { // ignore } } @@ -109,17 +113,18 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl } /** - * Template method. Subclasses must implement this. Offers the request payload as a {@code XMLStreamReader}, and a - * {@code XMLStreamWriter} to write the response payload to. - * + * Template method. Subclasses must implement this. Offers the request payload as a + * {@code XMLStreamReader}, and a {@code XMLStreamWriter} to write the response + * payload to. * @param streamReader the reader to read the payload from * @param streamWriter the writer to write the payload to */ protected abstract void invokeInternal(XMLStreamReader streamReader, XMLStreamWriter streamWriter) throws Exception; /** - * Implementation of the {@code XMLStreamWriter} interface that creates a response {@code WebServiceMessage} as soon - * as any method is called, thus lazily creating the response. + * Implementation of the {@code XMLStreamWriter} interface that creates a response + * {@code WebServiceMessage} as soon as any method is called, thus lazily creating the + * response. */ private class ResponseCreatingStreamWriter implements XMLStreamWriter { @@ -150,12 +155,14 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl streamWriter.close(); if (os != null) { streamWriter.flush(); - // if we used an output stream cache, we have to transform it to the response again + // if we used an output stream cache, we have to transform it to the + // response again try { ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); transform(new StreamSource(is), messageContext.getResponse().getPayloadResult()); os = null; - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XMLStreamException(ex); } } @@ -344,11 +351,14 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl WebServiceMessage response = messageContext.getResponse(); streamWriter = getStreamWriter(response.getPayloadResult()); if (streamWriter == null) { - // as a final resort, use a stream, and transform that at endDocument() + // as a final resort, use a stream, and transform that at + // endDocument() os = new ByteArrayOutputStream(); streamWriter = getOutputFactory().createXMLStreamWriter(os); } } } + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractValidatingMarshallingPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractValidatingMarshallingPayloadEndpoint.java index 346c445d..82ab631f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractValidatingMarshallingPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractValidatingMarshallingPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,9 +23,9 @@ import org.springframework.validation.Validator; import org.springframework.ws.context.MessageContext; /** - * Extension of the {@link AbstractMarshallingPayloadEndpoint} which validates the request payload with - * {@link Validator}(s). The desired validators can be set using properties, and must - * {@link Validator#supports(Class) support} the request object. + * Extension of the {@link AbstractMarshallingPayloadEndpoint} which validates the request + * payload with {@link Validator}(s). The desired validators can be set using properties, + * and must {@link Validator#supports(Class) support} the request object. * * @author Arjen Poutsma * @since 1.0.2 @@ -58,9 +58,10 @@ public abstract class AbstractValidatingMarshallingPayloadEndpoint extends Abstr } /** - * Set the primary {@link Validator} for this endpoint. The {@link Validator} is must support the unmarshalled class. - * If there are one or more existing validators set already when this method is called, only the specified validator - * will be kept. Use {@link #setValidators(Validator[])} to set multiple validators. + * Set the primary {@link Validator} for this endpoint. The {@link Validator} is must + * support the unmarshalled class. If there are one or more existing validators set + * already when this method is called, only the specified validator will be kept. Use + * {@link #setValidators(Validator[])} to set multiple validators. */ public void setValidator(Validator validator) { this.validators = new Validator[] { validator }; @@ -71,7 +72,10 @@ public abstract class AbstractValidatingMarshallingPayloadEndpoint extends Abstr return validators; } - /** Set the Validators for this controller. The Validator must support the specified command class. */ + /** + * Set the Validators for this controller. The Validator must support the specified + * command class. + */ public void setValidators(Validator[] validators) { this.validators = validators; } @@ -92,12 +96,15 @@ public abstract class AbstractValidatingMarshallingPayloadEndpoint extends Abstr } /** - * Callback for post-processing validation errors. Called when validator(s) have been specified, and validation fails. - * + * Callback for post-processing validation errors. Called when validator(s) have been + * specified, and validation fails. * @param messageContext the message context - * @param requestObject the object unmarshalled from the {@link MessageContext#getRequest() request} + * @param requestObject the object unmarshalled from the + * {@link MessageContext#getRequest() request} * @param errors validation errors holder - * @return {@code true} to continue and call {@link #invokeInternal(Object)}; {@code false} otherwise + * @return {@code true} to continue and call {@link #invokeInternal(Object)}; + * {@code false} otherwise */ protected abstract boolean onValidationErrors(MessageContext messageContext, Object requestObject, Errors errors); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractXomPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractXomPayloadEndpoint.java index 740a6336..88309f13 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractXomPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/AbstractXomPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,12 @@ package org.springframework.ws.server.endpoint; -import nu.xom.*; -import nu.xom.converters.DOMConverter; - -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; import java.util.Locale; import javax.xml.stream.XMLEventReader; @@ -29,21 +31,32 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.springframework.core.NestedRuntimeException; -import org.springframework.xml.namespace.QNameUtils; -import org.springframework.xml.transform.TransformerObjectSupport; -import org.springframework.xml.transform.TraxUtils; +import nu.xom.Attribute; +import nu.xom.Builder; +import nu.xom.Document; +import nu.xom.Element; +import nu.xom.NodeFactory; +import nu.xom.ParentNode; +import nu.xom.ParsingException; +import nu.xom.Serializer; +import nu.xom.converters.DOMConverter; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; +import org.springframework.core.NestedRuntimeException; +import org.springframework.xml.namespace.QNameUtils; +import org.springframework.xml.transform.TransformerObjectSupport; +import org.springframework.xml.transform.TraxUtils; + /** - * Abstract base class for endpoints that handle the message payload as XOM elements. Offers the message payload as a - * XOM {@code Element}, and allows subclasses to create a response by returning an {@code Element}. + * Abstract base class for endpoints that handle the message payload as XOM elements. + * Offers the message payload as a XOM {@code Element}, and allows subclasses to create a + * response by returning an {@code Element}. *

    - * An {@code AbstractXomPayloadEndpoint} only accept one payload element. Multiple payload elements are not in - * accordance with WS-I. + * An {@code AbstractXomPayloadEndpoint} only accept one payload element. Multiple payload + * elements are not in accordance with WS-I. * * @author Arjen Poutsma * @see Element @@ -61,7 +74,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor XomSourceCallback sourceCallback = new XomSourceCallback(); try { TraxUtils.doWithSource(request, sourceCallback); - } catch (XomParsingException ex) { + } + catch (XomParsingException ex) { throw (ParsingException) ex.getCause(); } requestElement = sourceCallback.element; @@ -85,8 +99,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor /** * Creates a {@link Serializer} to be used for writing the response to. *

    - * Default implementation uses the UTF-8 encoding and does not set any options, but this may be changed in subclasses. - * + * Default implementation uses the UTF-8 encoding and does not set any options, but + * this may be changed in subclasses. * @param outputStream the output stream to serialize to * @return the serializer */ @@ -95,9 +109,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor } /** - * Template method. Subclasses must implement this. Offers the request payload as a XOM {@code Element}, and allows - * subclasses to return a response {@code Element}. - * + * Template method. Subclasses must implement this. Offers the request payload as a + * XOM {@code Element}, and allows subclasses to return a response {@code Element}. * @param requestElement the contents of the SOAP message as XOM element * @return the response element. Can be {@code null} to specify no response. */ @@ -111,10 +124,12 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor public void domSource(Node node) { if (node.getNodeType() == Node.ELEMENT_NODE) { element = DOMConverter.convert((org.w3c.dom.Element) node); - } else if (node.getNodeType() == Node.DOCUMENT_NODE) { + } + else if (node.getNodeType() == Node.DOCUMENT_NODE) { Document document = DOMConverter.convert((org.w3c.dom.Document) node); element = document.getRootElement(); - } else { + } + else { throw new IllegalArgumentException("DOMSource contains neither Document nor Element"); } } @@ -126,14 +141,17 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor Document document; if (inputSource.getByteStream() != null) { document = builder.build(inputSource.getByteStream()); - } else if (inputSource.getCharacterStream() != null) { + } + else if (inputSource.getCharacterStream() != null) { document = builder.build(inputSource.getCharacterStream()); - } else { + } + else { throw new IllegalArgumentException( "InputSource in SAXSource contains neither byte stream nor character stream"); } element = document.getRootElement(); - } catch (ParsingException e) { + } + catch (ParsingException e) { throw new XomParsingException(e); } } @@ -155,7 +173,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor Builder builder = new Builder(); Document document = builder.build(inputStream); element = document.getRootElement(); - } catch (ParsingException ex) { + } + catch (ParsingException ex) { throw new XomParsingException(ex); } } @@ -166,7 +185,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor Builder builder = new Builder(); Document document = builder.build(reader); element = document.getRootElement(); - } catch (ParsingException ex) { + } + catch (ParsingException ex) { throw new XomParsingException(ex); } } @@ -177,10 +197,12 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor Builder builder = new Builder(); Document document = builder.build(systemId); element = document.getRootElement(); - } catch (ParsingException ex) { + } + catch (ParsingException ex) { throw new XomParsingException(ex); } } + } @SuppressWarnings("serial") @@ -189,6 +211,7 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor private XomParsingException(ParsingException ex) { super(ex.getMessage(), ex); } + } private static class StaxStreamConverter { @@ -219,7 +242,8 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor if (element == null) { element = nodeFactory.makeRootElement(name, streamReader.getNamespaceURI()); document.setRootElement(element); - } else { + } + else { element = nodeFactory.startMakingElement(name, streamReader.getNamespaceURI()); parent.appendChild(element); } @@ -275,28 +299,39 @@ public abstract class AbstractXomPayloadEndpoint extends TransformerObjectSuppor type = type.toUpperCase(Locale.ENGLISH); if ("CDATA".equals(type)) { return Attribute.Type.CDATA; - } else if ("ENTITIES".equals(type)) { + } + else if ("ENTITIES".equals(type)) { return Attribute.Type.ENTITIES; - } else if ("ENTITY".equals(type)) { + } + else if ("ENTITY".equals(type)) { return Attribute.Type.ENTITY; - } else if ("ENUMERATION".equals(type)) { + } + else if ("ENUMERATION".equals(type)) { return Attribute.Type.ENUMERATION; - } else if ("ID".equals(type)) { + } + else if ("ID".equals(type)) { return Attribute.Type.ID; - } else if ("IDREF".equals(type)) { + } + else if ("IDREF".equals(type)) { return Attribute.Type.IDREF; - } else if ("IDREFS".equals(type)) { + } + else if ("IDREFS".equals(type)) { return Attribute.Type.IDREFS; - } else if ("NMTOKEN".equals(type)) { + } + else if ("NMTOKEN".equals(type)) { return Attribute.Type.NMTOKEN; - } else if ("NMTOKENS".equals(type)) { + } + else if ("NMTOKENS".equals(type)) { return Attribute.Type.NMTOKENS; - } else if ("NOTATION".equals(type)) { + } + else if ("NOTATION".equals(type)) { return Attribute.Type.NOTATION; - } else { + } + else { return Attribute.Type.UNDECLARED; } } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MessageEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MessageEndpoint.java index aa6169a0..19850255 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MessageEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MessageEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,9 @@ import org.springframework.ws.context.MessageContext; /** * Defines the basic contract for Web Services interested in the entire message payload. *

    - * The main entrypoint is {@link #invoke(MessageContext)}, which gets invoked with the message context. This context - * contains the {@link MessageContext#getRequest() request}, and can be used to create a response. + * The main entrypoint is {@link #invoke(MessageContext)}, which gets invoked with the + * message context. This context contains the {@link MessageContext#getRequest() request}, + * and can be used to create a response. * * @author Arjen Poutsma * @see org.springframework.ws.server.endpoint.PayloadEndpoint @@ -34,9 +35,9 @@ public interface MessageEndpoint { * Invokes an operation. *

    * The given {@code messageContext} can be used to create a response. - * * @param messageContext the message context * @throws Exception if an exception occurs */ void invoke(MessageContext messageContext) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java index 1951a3e3..771d0074 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,7 +25,8 @@ import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; /** - * Represents a bean method that will be invoked as part of an incoming Web service message. + * Represents a bean method that will be invoked as part of an incoming Web service + * message. *

    * Consists of a {@link Method}, and a bean {@link Object}. * @@ -42,7 +43,6 @@ public final class MethodEndpoint { /** * Constructs a new method endpoint with the given bean and method. - * * @param bean the object bean * @param method the method */ @@ -56,7 +56,6 @@ public final class MethodEndpoint { /** * Constructs a new method endpoint with the given bean, method name and parameters. - * * @param bean the object bean * @param methodName the method name * @param parameterTypes the method parameter types @@ -71,9 +70,8 @@ public final class MethodEndpoint { } /** - * Constructs a new method endpoint with the given bean name and method. The bean name will be lazily initialized when - * {@link #invoke(Object...)} is called. - * + * Constructs a new method endpoint with the given bean name and method. The bean name + * will be lazily initialized when {@link #invoke(Object...)} is called. * @param beanName the bean name * @param beanFactory the bean factory to use for bean initialization * @param method the method @@ -94,7 +92,8 @@ public final class MethodEndpoint { if (beanFactory != null && bean instanceof String) { String beanName = (String) bean; return beanFactory.getBean(beanName); - } else { + } + else { return bean; } } @@ -121,7 +120,6 @@ public final class MethodEndpoint { /** * Invokes this method endpoint with the given arguments. - * * @param args the arguments * @return the invocation result * @throws Exception when the method invocation results in an exception @@ -131,7 +129,8 @@ public final class MethodEndpoint { ReflectionUtils.makeAccessible(method); try { return method.invoke(endpoint, args); - } catch (InvocationTargetException ex) { + } + catch (InvocationTargetException ex) { handleInvocationTargetException(ex); throw new IllegalStateException("Unexpected exception thrown by method - " + ex.getTargetException().getClass().getName() + ": " + ex.getTargetException().getMessage()); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/PayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/PayloadEndpoint.java index 88ec7255..4def1d43 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/PayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/PayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,7 +21,8 @@ import javax.xml.transform.Source; /** * Defines the basic contract for Web Services interested in just the message payload. *

    - * The main entrypoint is {@link #invoke(Source)}, which gets invoked with the contents of the requesting message. + * The main entrypoint is {@link #invoke(Source)}, which gets invoked with the contents of + * the requesting message. * * @author Arjen Poutsma * @since 1.0.0 @@ -29,11 +30,13 @@ import javax.xml.transform.Source; public interface PayloadEndpoint { /** - * Invokes the endpoint with the given request payload, and possibly returns a response. - * + * Invokes the endpoint with the given request payload, and possibly returns a + * response. * @param request the payload of the request message, may be {@code null} - * @return the payload of the response message, may be {@code null} to indicate no response + * @return the payload of the response message, may be {@code null} to indicate no + * response * @throws Exception if an exception occurs */ Source invoke(Source request) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/AbstractMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/AbstractMethodEndpointAdapter.java index 8637e08a..ef412a82 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/AbstractMethodEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/AbstractMethodEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,8 +22,8 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.xml.transform.TransformerObjectSupport; /** - * Abstract base class for {@link EndpointAdapter} implementations that support {@link MethodEndpoint}s. Contains - * template methods for handling these method endpoints. + * Abstract base class for {@link EndpointAdapter} implementations that support + * {@link MethodEndpoint}s. Contains template methods for handling these method endpoints. * * @author Arjen Poutsma * @since 1.0.0 @@ -31,8 +31,8 @@ import org.springframework.xml.transform.TransformerObjectSupport; public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSupport implements EndpointAdapter { /** - * Delegates to {@link #supportsInternal(org.springframework.ws.server.endpoint.MethodEndpoint)}. - * + * Delegates to + * {@link #supportsInternal(org.springframework.ws.server.endpoint.MethodEndpoint)}. * @param endpoint endpoint object to check * @return whether or not this adapter can adapt the given endpoint */ @@ -42,11 +42,12 @@ public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSup } /** - * Delegates to {@link #invokeInternal(org.springframework.ws.context.MessageContext,MethodEndpoint)}. - * + * Delegates to + * {@link #invokeInternal(org.springframework.ws.context.MessageContext,MethodEndpoint)}. * @param messageContext the current message context - * @param endpoint the endpoint to use. This object must have previously been passed to the {@code supportsInternal} - * method of this interface, which must have returned {@code true} + * @param endpoint the endpoint to use. This object must have previously been passed + * to the {@code supportsInternal} method of this interface, which must have returned + * {@code true} * @throws Exception in case of errors */ @Override @@ -56,7 +57,6 @@ public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSup /** * Given a method endpoint, return whether or not this adapter can support it. - * * @param methodEndpoint method endpoint to check * @return whether or not this adapter can adapt the given method */ @@ -64,11 +64,11 @@ public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSup /** * Use the given method endpoint to handle the request. - * * @param messageContext the current message context * @param methodEndpoint the method endpoint to use * @throws Exception in case of errors */ - protected abstract void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception; + protected abstract void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint) + throws Exception; } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/DefaultMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/DefaultMethodEndpointAdapter.java index 17e06ccb..002b0370 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/DefaultMethodEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/DefaultMethodEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -43,8 +43,8 @@ import org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElement /** * Default extension of {@link AbstractMethodEndpointAdapter} with support for pluggable - * {@linkplain MethodArgumentResolver argument resolvers} and {@linkplain MethodReturnValueHandler return value - * handlers}. + * {@linkplain MethodArgumentResolver argument resolvers} and + * {@linkplain MethodReturnValueHandler return value handlers}. * * @author Arjen Poutsma * @since 2.0 @@ -98,8 +98,9 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter } /** - * Sets the custom handlers for method arguments. Custom handlers are ordered after built-in ones. To override the - * built-in support for return value handling use {@link #setMethodArgumentResolvers(List)}. + * Sets the custom handlers for method arguments. Custom handlers are ordered after + * built-in ones. To override the built-in support for return value handling use + * {@link #setMethodArgumentResolvers(List)}. */ public void setCustomMethodArgumentResolvers(List customMethodArgumentResolvers) { this.customMethodArgumentResolvers = customMethodArgumentResolvers; @@ -127,8 +128,9 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter } /** - * Sets the handlers for custom return value types. Custom handlers are ordered after built-in ones. To override the - * built-in support for return value handling use {@link #setMethodReturnValueHandlers(List)}. + * Sets the handlers for custom return value types. Custom handlers are ordered after + * built-in ones. To override the built-in support for return value handling use + * {@link #setMethodReturnValueHandlers(List)}. */ public void setCustomMethodReturnValueHandlers(List customMethodReturnValueHandlers) { this.customMethodReturnValueHandlers = customMethodReturnValueHandlers; @@ -190,16 +192,17 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter } /** - * Certain (SOAP-specific) {@code MethodArgumentResolver}s have to be instantiated by class name, in order to not - * introduce a cyclic dependency. + * Certain (SOAP-specific) {@code MethodArgumentResolver}s have to be instantiated by + * class name, in order to not introduce a cyclic dependency. */ @SuppressWarnings("unchecked") private void addMethodArgumentResolver(String className, List methodArgumentResolvers) { try { Class methodArgumentResolverClass = (Class) ClassUtils - .forName(className, getClassLoader()); + .forName(className, getClassLoader()); methodArgumentResolvers.add(BeanUtils.instantiateClass(methodArgumentResolverClass)); - } catch (ClassNotFoundException e) { + } + catch (ClassNotFoundException e) { logger.warn("Could not find \"" + className + "\" on the classpath"); } } @@ -297,15 +300,16 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter /** * Returns the argument array for the given method endpoint. *

    - * This implementation iterates over the set {@linkplain #setMethodArgumentResolvers(List) argument resolvers} to - * resolve each argument. - * + * This implementation iterates over the set + * {@linkplain #setMethodArgumentResolvers(List) argument resolvers} to resolve each + * argument. * @param messageContext the current message context * @param methodEndpoint the method endpoint to get arguments for * @return the arguments * @throws Exception in case of errors */ - protected Object[] getMethodArguments(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception { + protected Object[] getMethodArguments(MessageContext messageContext, MethodEndpoint methodEndpoint) + throws Exception { MethodParameter[] parameters = methodEndpoint.getMethodParameters(); Object[] args = new Object[parameters.length]; for (int i = 0; i < parameters.length; i++) { @@ -322,9 +326,9 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter /** * Handle the return value for the given method endpoint. *

    - * This implementation iterates over the set {@linkplain #setMethodReturnValueHandlers(java.util.List)} return value - * handlers} to resolve the return value. - * + * This implementation iterates over the set + * {@linkplain #setMethodReturnValueHandlers(java.util.List)} return value handlers} + * to resolve the return value. * @param messageContext the current message context * @param returnValue the return value * @param methodEndpoint the method endpoint to get arguments for @@ -339,6 +343,8 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter return; } } - throw new IllegalStateException("Return value [" + returnValue + "] not resolved by any MethodReturnValueHandler"); + throw new IllegalStateException( + "Return value [" + returnValue + "] not resolved by any MethodReturnValueHandler"); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapter.java index 1d20e561..b1f80113 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,49 +26,53 @@ import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.ws.server.endpoint.MethodEndpoint; /** - * Subclass of {@link MarshallingMethodEndpointAdapter} that supports {@link GenericMarshaller} and - * {@link GenericUnmarshaller}. More specifically, this adapter is aware of the - * {@link Method#getGenericParameterTypes()} and {@link Method#getGenericReturnType()}. + * Subclass of {@link MarshallingMethodEndpointAdapter} that supports + * {@link GenericMarshaller} and {@link GenericUnmarshaller}. More specifically, this + * adapter is aware of the {@link Method#getGenericParameterTypes()} and + * {@link Method#getGenericReturnType()}. *

    - * Prefer to use this adapter rather than the plain {@link MarshallingMethodEndpointAdapter} in combination with Java 5 - * marshallers, such as the {@link Jaxb2Marshaller}. + * Prefer to use this adapter rather than the plain + * {@link MarshallingMethodEndpointAdapter} in combination with Java 5 marshallers, such + * as the {@link Jaxb2Marshaller}. * * @author Arjen Poutsma * @since 1.0.2 - * @deprecated as of Spring Web Services 2.0, in favor of {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor - * MarshallingPayloadMethodProcessor}. + * @deprecated as of Spring Web Services 2.0, in favor of + * {@link DefaultMethodEndpointAdapter} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor + * MarshallingPayloadMethodProcessor}. */ @Deprecated public class GenericMarshallingMethodEndpointAdapter extends MarshallingMethodEndpointAdapter { /** - * Creates a new {@code GenericMarshallingMethodEndpointAdapter}. The {@link Marshaller} and {@link Unmarshaller} must - * be injected using properties. - * + * Creates a new {@code GenericMarshallingMethodEndpointAdapter}. The + * {@link Marshaller} and {@link Unmarshaller} must be injected using properties. * @see #setMarshaller(org.springframework.oxm.Marshaller) * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) */ - public GenericMarshallingMethodEndpointAdapter() {} + public GenericMarshallingMethodEndpointAdapter() { + } /** - * Creates a new {@code GenericMarshallingMethodEndpointAdapter} with the given marshaller. If the given - * {@link Marshaller} also implements the {@link Unmarshaller} interface, it is used for both marshalling and - * unmarshalling. Otherwise, an exception is thrown. + * Creates a new {@code GenericMarshallingMethodEndpointAdapter} with the given + * marshaller. If the given {@link Marshaller} also implements the + * {@link Unmarshaller} interface, it is used for both marshalling and unmarshalling. + * Otherwise, an exception is thrown. *

    - * Note that all {@link Marshaller} implementations in Spring-WS also implement the {@link Unmarshaller} interface, so - * that you can safely use this constructor. - * + * Note that all {@link Marshaller} implementations in Spring-WS also implement the + * {@link Unmarshaller} interface, so that you can safely use this constructor. * @param marshaller object used as marshaller and unmarshaller - * @throws IllegalArgumentException when {@code marshaller} does not implement the {@link Unmarshaller} interface + * @throws IllegalArgumentException when {@code marshaller} does not implement the + * {@link Unmarshaller} interface */ public GenericMarshallingMethodEndpointAdapter(Marshaller marshaller) { super(marshaller); } /** - * Creates a new {@code GenericMarshallingMethodEndpointAdapter} with the given marshaller and unmarshaller. - * + * Creates a new {@code GenericMarshallingMethodEndpointAdapter} with the given + * marshaller and unmarshaller. * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use */ @@ -85,10 +89,12 @@ public class GenericMarshallingMethodEndpointAdapter extends MarshallingMethodEn private boolean supportsReturnType(Method method) { if (Void.TYPE.equals(method.getReturnType())) { return true; - } else { + } + else { if (getMarshaller() instanceof GenericMarshaller) { return ((GenericMarshaller) getMarshaller()).supports(method.getGenericReturnType()); - } else { + } + else { return getMarshaller().supports(method.getReturnType()); } } @@ -97,11 +103,14 @@ public class GenericMarshallingMethodEndpointAdapter extends MarshallingMethodEn private boolean supportsParameters(Method method) { if (method.getParameterTypes().length != 1) { return false; - } else if (getUnmarshaller() instanceof GenericUnmarshaller) { + } + else if (getUnmarshaller() instanceof GenericUnmarshaller) { GenericUnmarshaller genericUnmarshaller = (GenericUnmarshaller) getUnmarshaller(); return genericUnmarshaller.supports(method.getGenericParameterTypes()[0]); - } else { + } + else { return getUnmarshaller().supports(method.getParameterTypes()[0]); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java index 569fc1f8..af25e29c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,7 +30,8 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.ws.support.MarshallingUtils; /** - * Adapter that supports endpoint methods that use marshalling. Supports methods with the following signature: + * Adapter that supports endpoint methods that use marshalling. Supports methods with the + * following signature: * *

      * void handleMyMessage(MyUnmarshalledType request);
    @@ -42,19 +43,22 @@ import org.springframework.ws.support.MarshallingUtils;
      * MyMarshalledType handleMyMessage(MyUnmarshalledType request);
      * 
    * - * I.e. methods that take a single parameter that {@link Unmarshaller#supports(Class) is supported} by the - * {@link Unmarshaller}, and return either {@code void} or a type {@link Marshaller#supports(Class) supported} by the - * {@link Marshaller}. The method can have any name, as long as it is mapped by an {@link EndpointMapping}. + * I.e. methods that take a single parameter that {@link Unmarshaller#supports(Class) is + * supported} by the {@link Unmarshaller}, and return either {@code void} or a type + * {@link Marshaller#supports(Class) supported} by the {@link Marshaller}. The method can + * have any name, as long as it is mapped by an {@link EndpointMapping}. *

    - * This endpoint needs a {@code Marshaller} and {@code Unmarshaller}, both of which can be set using properties. + * This endpoint needs a {@code Marshaller} and {@code Unmarshaller}, both of which can be + * set using properties. * * @author Arjen Poutsma * @see #setMarshaller(org.springframework.oxm.Marshaller) * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) * @since 1.0.0 - * @deprecated as of Spring Web Services 2.0, in favor of {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor - * MarshallingPayloadMethodProcessor}. + * @deprecated as of Spring Web Services 2.0, in favor of + * {@link DefaultMethodEndpointAdapter} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor + * MarshallingPayloadMethodProcessor}. */ @Deprecated public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdapter implements InitializingBean { @@ -64,24 +68,25 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap private Unmarshaller unmarshaller; /** - * Creates a new {@code MarshallingMethodEndpointAdapter}. The {@link Marshaller} and {@link Unmarshaller} must be - * injected using properties. - * + * Creates a new {@code MarshallingMethodEndpointAdapter}. The {@link Marshaller} and + * {@link Unmarshaller} must be injected using properties. * @see #setMarshaller(org.springframework.oxm.Marshaller) * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) */ - public MarshallingMethodEndpointAdapter() {} + public MarshallingMethodEndpointAdapter() { + } /** - * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller. If the given {@link Marshaller} - * also implements the {@link Unmarshaller} interface, it is used for both marshalling and unmarshalling. Otherwise, - * an exception is thrown. + * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller. + * If the given {@link Marshaller} also implements the {@link Unmarshaller} interface, + * it is used for both marshalling and unmarshalling. Otherwise, an exception is + * thrown. *

    - * Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, so - * that you can safely use this constructor. - * + * Note that all {@link Marshaller} implementations in Spring also implement the + * {@link Unmarshaller} interface, so that you can safely use this constructor. * @param marshaller object used as marshaller and unmarshaller - * @throws IllegalArgumentException when {@code marshaller} does not implement the {@link Unmarshaller} interface + * @throws IllegalArgumentException when {@code marshaller} does not implement the + * {@link Unmarshaller} interface */ public MarshallingMethodEndpointAdapter(Marshaller marshaller) { Assert.notNull(marshaller, "marshaller must not be null"); @@ -89,15 +94,16 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + "interface. Please set an Unmarshaller explicitly by using the " + "MarshallingMethodEndpointAdapter(Marshaller, Unmarshaller) constructor."); - } else { + } + else { this.setMarshaller(marshaller); this.setUnmarshaller((Unmarshaller) marshaller); } } /** - * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller and unmarshaller. - * + * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller + * and unmarshaller. * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use */ @@ -161,8 +167,8 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap } /** - * Supports a method with a single, unmarshallable parameter, and that return {@code void} or a marshallable type. - * + * Supports a method with a single, unmarshallable parameter, and that return + * {@code void} or a marshallable type. * @see Marshaller#supports(Class) * @see Unmarshaller#supports(Class) */ @@ -179,8 +185,10 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap private boolean supportsParameters(Method method) { if (method.getParameterTypes().length != 1) { return false; - } else { + } + else { return getUnmarshaller().supports(method.getParameterTypes()[0]); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageEndpointAdapter.java index 888524de..f40c9ae4 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,9 +23,11 @@ import org.springframework.ws.server.endpoint.MessageEndpoint; import org.springframework.ws.soap.server.SoapMessageDispatcher; /** - * Adapter to use a {@code MessageEndpoint} as the endpoint for a {@code EndpointInvocationChain}. + * Adapter to use a {@code MessageEndpoint} as the endpoint for a + * {@code EndpointInvocationChain}. *

    - * This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}. + * This adapter is registered by default by the {@link MessageDispatcher} and + * {@link SoapMessageDispatcher}. * * @author Arjen Poutsma * @see org.springframework.ws.server.EndpointInvocationChain @@ -42,4 +44,5 @@ public class MessageEndpointAdapter implements EndpointAdapter { public void invoke(MessageContext messageContext, Object endpoint) throws Exception { ((MessageEndpoint) endpoint).invoke(messageContext); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapter.java index 8667c009..b6fafae1 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,22 +24,26 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.ws.soap.server.SoapMessageDispatcher; /** - * Adapter that supports endpoint methods with message contexts. Supports methods with the following signature: + * Adapter that supports endpoint methods with message contexts. Supports methods with the + * following signature: * *

      * void handleMyMessage(MessageContext request);
      * 
    * - * I.e. methods that take a single {@link MessageContext} parameter, and return {@code void}. The method can have any - * name, as long as it is mapped by an {@link org.springframework.ws.server.EndpointMapping}. + * I.e. methods that take a single {@link MessageContext} parameter, and return + * {@code void}. The method can have any name, as long as it is mapped by an + * {@link org.springframework.ws.server.EndpointMapping}. *

    - * This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}. + * This adapter is registered by default by the {@link MessageDispatcher} and + * {@link SoapMessageDispatcher}. * * @author Arjen Poutsma * @since 1.0.0 - * @deprecated as of Spring Web Services 2.0, in favor of {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.MessageContextMethodArgumentResolver - * MessageContextMethodArgumentResolver}. + * @deprecated as of Spring Web Services 2.0, in favor of + * {@link DefaultMethodEndpointAdapter} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MessageContextMethodArgumentResolver + * MessageContextMethodArgumentResolver}. */ @Deprecated public class MessageMethodEndpointAdapter extends AbstractMethodEndpointAdapter { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadEndpointAdapter.java index 94d493c0..debe0bbf 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,9 +27,11 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher; import org.springframework.xml.transform.TransformerObjectSupport; /** - * Adapter to use a {@code PayloadEndpoint} as the endpoint for a {@code EndpointInvocationChain}. + * Adapter to use a {@code PayloadEndpoint} as the endpoint for a + * {@code EndpointInvocationChain}. *

    - * This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}. + * This adapter is registered by default by the {@link MessageDispatcher} and + * {@link SoapMessageDispatcher}. * * @author Arjen Poutsma * @see org.springframework.ws.server.endpoint.PayloadEndpoint @@ -53,4 +55,5 @@ public class PayloadEndpointAdapter extends TransformerObjectSupport implements transform(responseSource, response.getPayloadResult()); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapter.java index 19c43299..b537269a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,7 +27,8 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.ws.soap.server.SoapMessageDispatcher; /** - * Adapter that supports endpoint methods that use marshalling. Supports methods with the following signature: + * Adapter that supports endpoint methods that use marshalling. Supports methods with the + * following signature: * *

      * void handleMyMessage(Source request);
    @@ -39,16 +40,19 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher;
      * Source handleMyMessage(Source request);
      * 
    * - * I.e. methods that take a single {@link Source} parameter, and return either {@code void} or a {@link Source}. The - * method can have any name, as long as it is mapped by an {@link org.springframework.ws.server.EndpointMapping}. + * I.e. methods that take a single {@link Source} parameter, and return either + * {@code void} or a {@link Source}. The method can have any name, as long as it is mapped + * by an {@link org.springframework.ws.server.EndpointMapping}. *

    - * This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}. + * This adapter is registered by default by the {@link MessageDispatcher} and + * {@link SoapMessageDispatcher}. * * @author Arjen Poutsma * @since 1.0.0 - * @deprecated as of Spring Web Services 2.0, in favor of {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.SourcePayloadMethodProcessor - * SourcePayloadMethodProcessor}. + * @deprecated as of Spring Web Services 2.0, in favor of + * {@link DefaultMethodEndpointAdapter} and + * {@link org.springframework.ws.server.endpoint.adapter.method.SourcePayloadMethodProcessor + * SourcePayloadMethodProcessor}. */ @Deprecated public class PayloadMethodEndpointAdapter extends AbstractMethodEndpointAdapter { @@ -56,8 +60,9 @@ public class PayloadMethodEndpointAdapter extends AbstractMethodEndpointAdapter @Override protected boolean supportsInternal(MethodEndpoint methodEndpoint) { Method method = methodEndpoint.getMethod(); - return (Void.TYPE.isAssignableFrom(method.getReturnType()) || Source.class.isAssignableFrom(method.getReturnType())) - && method.getParameterTypes().length == 1 && Source.class.isAssignableFrom(method.getParameterTypes()[0]); + return (Void.TYPE.isAssignableFrom(method.getReturnType()) + || Source.class.isAssignableFrom(method.getReturnType())) && method.getParameterTypes().length == 1 + && Source.class.isAssignableFrom(method.getParameterTypes()[0]); } @@ -71,4 +76,5 @@ public class PayloadMethodEndpointAdapter extends AbstractMethodEndpointAdapter transform(responseSource, response.getPayloadResult()); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java index 163126b4..5a21e17d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,19 +29,21 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + import org.springframework.beans.factory.InitializingBean; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.ws.server.endpoint.annotation.XPathParam; import org.springframework.xml.namespace.SimpleNamespaceContext; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; /** - * Adapter that supports endpoint methods that use XPath expressions. Supports methods with the following signature: + * Adapter that supports endpoint methods that use XPath expressions. Supports methods + * with the following signature: * *

      * void handleMyMessage(@XPathParam("/root/child/text") String param);
    @@ -54,9 +56,9 @@ import org.w3c.dom.NodeList;
      * 		@XPathParam("/root/child/number") double param2);
      * 
    * - * I.e. methods that return either {@code void} or a {@link Source}, and have parameters annotated with - * {@link XPathParam} that specify the XPath expression that should be bound to that parameter. The parameter can be of - * the following types: + * I.e. methods that return either {@code void} or a {@link Source}, and have parameters + * annotated with {@link XPathParam} that specify the XPath expression that should be + * bound to that parameter. The parameter can be of the following types: *
      *
    • {@code boolean}, or {@link Boolean}
    • *
    • {@code double}, or {@link Double}
    • @@ -67,9 +69,10 @@ import org.w3c.dom.NodeList; * * @author Arjen Poutsma * @since 1.0.0 - * @deprecated as of Spring Web Services 2.0, in favor of {@link DefaultMethodEndpointAdapter} and - * {@link org.springframework.ws.server.endpoint.adapter.method.XPathParamMethodArgumentResolver - * XPathParamMethodArgumentResolver}. + * @deprecated as of Spring Web Services 2.0, in favor of + * {@link DefaultMethodEndpointAdapter} and + * {@link org.springframework.ws.server.endpoint.adapter.method.XPathParamMethodArgumentResolver + * XPathParamMethodArgumentResolver}. */ @Deprecated public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEndpointAdapter @@ -89,7 +92,10 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd xpathFactory = XPathFactory.newInstance(); } - /** Supports methods with @XPathParam parameters, and return either {@code Source} or nothing. */ + /** + * Supports methods with @XPathParam parameters, and return either {@code Source} or + * nothing. + */ @Override protected boolean supportsInternal(MethodEndpoint methodEndpoint) { Method method = methodEndpoint.getMethod(); @@ -142,15 +148,21 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd QName conversionType; if (Boolean.class.isAssignableFrom(parameterTypes[i]) || Boolean.TYPE.isAssignableFrom(parameterTypes[i])) { conversionType = XPathConstants.BOOLEAN; - } else if (Double.class.isAssignableFrom(parameterTypes[i]) || Double.TYPE.isAssignableFrom(parameterTypes[i])) { + } + else if (Double.class.isAssignableFrom(parameterTypes[i]) + || Double.TYPE.isAssignableFrom(parameterTypes[i])) { conversionType = XPathConstants.NUMBER; - } else if (Node.class.isAssignableFrom(parameterTypes[i])) { + } + else if (Node.class.isAssignableFrom(parameterTypes[i])) { conversionType = XPathConstants.NODE; - } else if (NodeList.class.isAssignableFrom(parameterTypes[i])) { + } + else if (NodeList.class.isAssignableFrom(parameterTypes[i])) { conversionType = XPathConstants.NODESET; - } else if (String.class.isAssignableFrom(parameterTypes[i])) { + } + else if (String.class.isAssignableFrom(parameterTypes[i])) { conversionType = XPathConstants.STRING; - } else { + } + else { throw new IllegalArgumentException("Invalid parameter type [" + parameterTypes[i] + "]. " + "Supported are: Boolean, Double, Node, NodeList, and String."); } @@ -171,7 +183,6 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd /** * Returns the root element of the given source. - * * @param source the source to get the root element from * @return the root element */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadMethodProcessor.java index 0517fc30..b61eee08 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,8 +30,9 @@ import org.springframework.ws.server.endpoint.annotation.ResponsePayload; import org.springframework.xml.transform.TransformerObjectSupport; /** - * Abstract base class for {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} implementations based on - * {@link RequestPayload} and {@link ResponsePayload} annotations. + * Abstract base class for {@link MethodArgumentResolver} and + * {@link MethodReturnValueHandler} implementations based on {@link RequestPayload} and + * {@link ResponsePayload} annotations. * * @author Arjen Poutsma * @since 2.0 @@ -44,25 +45,28 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu /** * {@inheritDoc} *

      - * This implementation gets checks if the given parameter is annotated with {@link RequestPayload}, and invokes - * {@link #supportsRequestPayloadParameter(org.springframework.core.MethodParameter)} afterwards. + * This implementation gets checks if the given parameter is annotated with + * {@link RequestPayload}, and invokes + * {@link #supportsRequestPayloadParameter(org.springframework.core.MethodParameter)} + * afterwards. */ @Override public final boolean supportsParameter(MethodParameter parameter) { Assert.isTrue(parameter.getParameterIndex() >= 0, "Parameter index smaller than 0"); if (parameter.getParameterAnnotation(RequestPayload.class) == null) { return false; - } else { + } + else { return supportsRequestPayloadParameter(parameter); } } /** - * Indicates whether the given {@linkplain MethodParameter method parameter}, annotated with {@link RequestPayload}, - * is supported by this resolver. - * + * Indicates whether the given {@linkplain MethodParameter method parameter}, + * annotated with {@link RequestPayload}, is supported by this resolver. * @param parameter the method parameter to check - * @return {@code true} if this resolver supports the supplied parameter; {@code false} otherwise + * @return {@code true} if this resolver supports the supplied parameter; + * {@code false} otherwise */ protected abstract boolean supportsRequestPayloadParameter(MethodParameter parameter); @@ -71,31 +75,33 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu /** * {@inheritDoc} *

      - * This implementation gets checks if the method of the given return type is annotated with {@link ResponsePayload}, - * and invokes {@link #supportsResponsePayloadReturnType(org.springframework.core.MethodParameter)} afterwards. + * This implementation gets checks if the method of the given return type is annotated + * with {@link ResponsePayload}, and invokes + * {@link #supportsResponsePayloadReturnType(org.springframework.core.MethodParameter)} + * afterwards. */ @Override public final boolean supportsReturnType(MethodParameter returnType) { Assert.isTrue(returnType.getParameterIndex() == -1, "Parameter index is not -1"); if (returnType.getMethodAnnotation(ResponsePayload.class) == null) { return false; - } else { + } + else { return supportsResponsePayloadReturnType(returnType); } } /** - * Indicates whether the given {@linkplain MethodParameter method return type}, annotated with - * {@link ResponsePayload}, is supported. - * + * Indicates whether the given {@linkplain MethodParameter method return type}, + * annotated with {@link ResponsePayload}, is supported. * @param returnType the method parameter to check - * @return {@code true} if this resolver supports the supplied return type; {@code false} otherwise + * @return {@code true} if this resolver supports the supplied return type; + * {@code false} otherwise */ protected abstract boolean supportsResponsePayloadReturnType(MethodParameter returnType); /** * Converts the given source to a byte array input stream. - * * @param source the source to convert * @return the input stream * @throws javax.xml.transform.TransformerException in case of transformation errors @@ -105,4 +111,5 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu transform(source, new StreamResult(bos)); return new ByteArrayInputStream(bos.toByteArray()); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadSourceMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadSourceMethodProcessor.java index dfc657dc..64f77fc2 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadSourceMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadSourceMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,8 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.RequestPayload; /** - * Abstract base class for {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} implementations based on - * {@link Source}s. + * Abstract base class for {@link MethodArgumentResolver} and + * {@link MethodReturnValueHandler} implementations based on {@link Source}s. * * @author Arjen Poutsma * @since 2.0 @@ -47,8 +47,8 @@ public abstract class AbstractPayloadSourceMethodProcessor extends AbstractPaylo } /** - * Resolves the given parameter, annotated with {@link RequestPayload}, into a method argument. - * + * Resolves the given parameter, annotated with {@link RequestPayload}, into a method + * argument. * @param parameter the parameter to resolve to an argument * @param requestPayload the request payload * @return the resolved argument. May be {@code null}. @@ -73,7 +73,6 @@ public abstract class AbstractPayloadSourceMethodProcessor extends AbstractPaylo /** * Creates a response payload for the given return value. - * * @param returnType the return type to handle * @param returnValue the return value to handle * @return the response payload diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MarshallingPayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MarshallingPayloadMethodProcessor.java index 41afd3a5..215e2cf4 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MarshallingPayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MarshallingPayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,8 +27,8 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.support.MarshallingUtils; /** - * Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} that uses {@link Marshaller} - * and {@link Unmarshaller} to support marshalled objects. + * Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} + * that uses {@link Marshaller} and {@link Unmarshaller} to support marshalled objects. * * @author Arjen Poutsma * @since 2.0 @@ -40,24 +40,25 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc private Unmarshaller unmarshaller; /** - * Creates a new {@code MarshallingPayloadMethodProcessor}. The {@link Marshaller} and {@link Unmarshaller} must be - * injected using properties. - * + * Creates a new {@code MarshallingPayloadMethodProcessor}. The {@link Marshaller} and + * {@link Unmarshaller} must be injected using properties. * @see #setMarshaller(Marshaller) * @see #setUnmarshaller(Unmarshaller) */ - public MarshallingPayloadMethodProcessor() {} + public MarshallingPayloadMethodProcessor() { + } /** - * Creates a new {@code MarshallingPayloadMethodProcessor} with the given marshaller. If the given {@link Marshaller} - * also implements the {@link Unmarshaller} interface, it is used for both marshalling and unmarshalling. Otherwise, - * an exception is thrown. + * Creates a new {@code MarshallingPayloadMethodProcessor} with the given marshaller. + * If the given {@link Marshaller} also implements the {@link Unmarshaller} interface, + * it is used for both marshalling and unmarshalling. Otherwise, an exception is + * thrown. *

      - * Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, so - * that you can safely use this constructor. - * + * Note that all {@link Marshaller} implementations in Spring also implement the + * {@link Unmarshaller} interface, so that you can safely use this constructor. * @param marshaller object used as marshaller and unmarshaller - * @throws IllegalArgumentException when {@code marshaller} does not implement the {@link Unmarshaller} interface + * @throws IllegalArgumentException when {@code marshaller} does not implement the + * {@link Unmarshaller} interface */ public MarshallingPayloadMethodProcessor(Marshaller marshaller) { Assert.notNull(marshaller, "marshaller must not be null"); @@ -67,8 +68,8 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc } /** - * Creates a new {@code MarshallingPayloadMethodProcessor} with the given marshaller and unmarshaller. - * + * Creates a new {@code MarshallingPayloadMethodProcessor} with the given marshaller + * and unmarshaller. * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use */ @@ -112,9 +113,11 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc Unmarshaller unmarshaller = getUnmarshaller(); if (unmarshaller == null) { return false; - } else if (unmarshaller instanceof GenericUnmarshaller) { + } + else if (unmarshaller instanceof GenericUnmarshaller) { return ((GenericUnmarshaller) unmarshaller).supports(parameter.getGenericParameterType()); - } else { + } + else { return unmarshaller.supports(parameter.getParameterType()); } } @@ -137,10 +140,12 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc Marshaller marshaller = getMarshaller(); if (marshaller == null) { return false; - } else if (marshaller instanceof GenericMarshaller) { + } + else if (marshaller instanceof GenericMarshaller) { GenericMarshaller genericMarshaller = (GenericMarshaller) marshaller; return genericMarshaller.supports(returnType.getGenericParameterType()); - } else { + } + else { return marshaller.supports(returnType.getParameterType()); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MessageContextMethodArgumentResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MessageContextMethodArgumentResolver.java index d43b7eb5..4582c9fe 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MessageContextMethodArgumentResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MessageContextMethodArgumentResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,7 +20,8 @@ import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; /** - * Implementation of {@link MethodArgumentResolver} that supports {@link MessageContext} arguments. + * Implementation of {@link MethodArgumentResolver} that supports {@link MessageContext} + * arguments. * * @author Arjen Poutsma * @since 2.0 @@ -36,4 +37,5 @@ public class MessageContextMethodArgumentResolver implements MethodArgumentResol public MessageContext resolveArgument(MessageContext messageContext, MethodParameter parameter) throws Exception { return messageContext; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodArgumentResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodArgumentResolver.java index 1c70ff24..f245b006 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodArgumentResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodArgumentResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,9 +20,10 @@ import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; /** - * Strategy interface used to resolve method parameters into arguments. This interface is used to allow the - * {@link org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter DefaultMethodEndpointAdapter} to - * be indefinitely extensible. + * Strategy interface used to resolve method parameters into arguments. This interface is + * used to allow the + * {@link org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter + * DefaultMethodEndpointAdapter} to be indefinitely extensible. * * @author Arjen Poutsma * @since 2.0 @@ -30,20 +31,20 @@ import org.springframework.ws.context.MessageContext; public interface MethodArgumentResolver { /** - * Indicates whether the given {@linkplain MethodParameter method parameter} is supported by this resolver. - * + * Indicates whether the given {@linkplain MethodParameter method parameter} is + * supported by this resolver. * @param parameter the method parameter to check - * @return {@code true} if this resolver supports the supplied parameter; {@code false} otherwise + * @return {@code true} if this resolver supports the supplied parameter; + * {@code false} otherwise */ boolean supportsParameter(MethodParameter parameter); /** * Resolves the given parameter into a method argument. - * * @param messageContext the current message context - * @param parameter the parameter to resolve to an argument. This parameter must have previously been passed to the - * {@link #supportsParameter(MethodParameter)} method of this interface, which must have returned - * {@code true}. + * @param parameter the parameter to resolve to an argument. This parameter must have + * previously been passed to the {@link #supportsParameter(MethodParameter)} method of + * this interface, which must have returned {@code true}. * @return the resolved argument. May be {@code null}. * @throws Exception in case of errors */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodReturnValueHandler.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodReturnValueHandler.java index 08cbc80d..3f108c8f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodReturnValueHandler.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodReturnValueHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,9 +20,9 @@ import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; /** - * Strategy interface used to handle method return values. This interface is used to allow the - * {@link org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter DefaultMethodEndpointAdapter} to - * be indefinitely extensible. + * Strategy interface used to handle method return values. This interface is used to allow + * the {@link org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter + * DefaultMethodEndpointAdapter} to be indefinitely extensible. * * @author Arjen Poutsma * @since 2.0 @@ -30,20 +30,20 @@ import org.springframework.ws.context.MessageContext; public interface MethodReturnValueHandler { /** - * Indicates whether the given {@linkplain MethodParameter method return type} is supported by this handler. - * + * Indicates whether the given {@linkplain MethodParameter method return type} is + * supported by this handler. * @param returnType the method return type to check - * @return {@code true} if this handler supports the supplied return type; {@code false} otherwise + * @return {@code true} if this handler supports the supplied return type; + * {@code false} otherwise */ boolean supportsReturnType(MethodParameter returnType); /** * Handles the given return value. - * * @param messageContext the current message context - * @param returnType the return type to handle. This type must have previously been passed to the - * {@link #supportsReturnType(MethodParameter)} method of this interface, which must have returned - * {@code true}. + * @param returnType the return type to handle. This type must have previously been + * passed to the {@link #supportsReturnType(MethodParameter)} method of this + * interface, which must have returned {@code true}. * @param returnValue the return value to handle * @throws Exception in case of errors */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/SourcePayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/SourcePayloadMethodProcessor.java index a2a981af..90e7f17a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/SourcePayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/SourcePayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,16 +30,17 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamSource; -import org.springframework.core.MethodParameter; -import org.springframework.xml.JaxpVersion; -import org.springframework.xml.XMLInputFactoryUtils; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.InputSource; +import org.springframework.core.MethodParameter; +import org.springframework.xml.JaxpVersion; +import org.springframework.xml.XMLInputFactoryUtils; + /** - * Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} that supports {@link Source} - * objects. + * Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} + * that supports {@link Source} objects. * * @author Arjen Poutsma * @since 2.0 @@ -67,21 +68,26 @@ public class SourcePayloadMethodProcessor extends AbstractPayloadSourceMethodPro Node node = domResult.getNode(); if (node.getNodeType() == Node.DOCUMENT_NODE) { return new DOMSource(((Document) node).getDocumentElement()); - } else { + } + else { return new DOMSource(domResult.getNode()); } - } else if (SAXSource.class.isAssignableFrom(parameterType)) { + } + else if (SAXSource.class.isAssignableFrom(parameterType)) { ByteArrayInputStream bis = convertToByteArrayInputStream(requestPayload); InputSource inputSource = new InputSource(bis); return new SAXSource(inputSource); - } else if (StreamSource.class.isAssignableFrom(parameterType)) { + } + else if (StreamSource.class.isAssignableFrom(parameterType)) { ByteArrayInputStream bis = convertToByteArrayInputStream(requestPayload); return new StreamSource(bis); - } else if (JaxpVersion.isAtLeastJaxp14() && Jaxp14StaxHandler.isStaxSource(parameterType)) { + } + else if (JaxpVersion.isAtLeastJaxp14() && Jaxp14StaxHandler.isStaxSource(parameterType)) { XMLStreamReader streamReader; try { streamReader = inputFactory.createXMLStreamReader(requestPayload); - } catch (UnsupportedOperationException | XMLStreamException ignored) { + } + catch (UnsupportedOperationException | XMLStreamException ignored) { streamReader = null; } if (streamReader == null) { @@ -110,12 +116,12 @@ public class SourcePayloadMethodProcessor extends AbstractPayloadSourceMethodPro } /** - * Create a {@code XMLInputFactory} that this resolver will use to create {@link javax.xml.stream.XMLStreamReader} and + * Create a {@code XMLInputFactory} that this resolver will use to create + * {@link javax.xml.stream.XMLStreamReader} and * {@link javax.xml.stream.XMLEventReader} objects. *

      - * Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so - * this method will only be called once. - * + * Can be overridden in subclasses, adding further initialization of the factory. The + * resulting factory is cached, so this method will only be called once. * @return the created factory */ protected XMLInputFactory createXmlInputFactory() { @@ -169,6 +175,7 @@ public class SourcePayloadMethodProcessor extends AbstractPayloadSourceMethodPro } }; } + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/StaxPayloadMethodArgumentResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/StaxPayloadMethodArgumentResolver.java index e8779768..6d8691c2 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/StaxPayloadMethodArgumentResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/StaxPayloadMethodArgumentResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -35,8 +35,8 @@ import org.springframework.xml.XMLInputFactoryUtils; import org.springframework.xml.transform.TransformerObjectSupport; /** - * Implementation of {@link MethodArgumentResolver} that supports StAX {@link XMLStreamReader} and - * {@link XMLEventReader} arguments. + * Implementation of {@link MethodArgumentResolver} that supports StAX + * {@link XMLStreamReader} and {@link XMLEventReader} arguments. * * @author Arjen Poutsma * @since 2.0 @@ -49,7 +49,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport public boolean supportsParameter(MethodParameter parameter) { if (parameter.getParameterAnnotation(RequestPayload.class) == null) { return false; - } else { + } + else { Class parameterType = parameter.getParameterType(); return XMLStreamReader.class.equals(parameterType) || XMLEventReader.class.equals(parameterType); } @@ -65,7 +66,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport Class parameterType = parameter.getParameterType(); if (XMLStreamReader.class.equals(parameterType)) { return resolveStreamReader(source); - } else if (XMLEventReader.class.equals(parameterType)) { + } + else if (XMLEventReader.class.equals(parameterType)) { return resolveEventReader(source); } throw new UnsupportedOperationException(); @@ -80,7 +82,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport if (eventReader != null) { try { streamReader = StaxUtils.createEventStreamReader(eventReader); - } catch (XMLStreamException ex) { + } + catch (XMLStreamException ex) { streamReader = null; } } @@ -89,7 +92,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport if (streamReader == null) { try { streamReader = inputFactory.createXMLStreamReader(requestSource); - } catch (XMLStreamException | UnsupportedOperationException ex) { + } + catch (XMLStreamException | UnsupportedOperationException ex) { streamReader = null; } } @@ -110,7 +114,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport if (streamReader != null) { try { eventReader = inputFactory.createXMLEventReader(streamReader); - } catch (XMLStreamException ex) { + } + catch (XMLStreamException ex) { eventReader = null; } } @@ -120,7 +125,8 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport if (eventReader == null) { try { eventReader = inputFactory.createXMLEventReader(requestSource); - } catch (XMLStreamException | UnsupportedOperationException ex) { + } + catch (XMLStreamException | UnsupportedOperationException ex) { eventReader = null; } } @@ -133,12 +139,11 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport } /** - * Create a {@code XMLInputFactory} that this resolver will use to create {@link XMLStreamReader} and - * {@link XMLEventReader} objects. + * Create a {@code XMLInputFactory} that this resolver will use to create + * {@link XMLStreamReader} and {@link XMLEventReader} objects. *

      - * Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so - * this method will only be called once. - * + * Can be overridden in subclasses, adding further initialization of the factory. The + * resulting factory is cached, so this method will only be called once. * @return the created factory */ protected XMLInputFactory createXmlInputFactory() { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolver.java index 59bd1aca..0a565e90 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,6 +25,11 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + import org.springframework.core.MethodParameter; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.support.ConversionServiceFactory; @@ -33,18 +38,17 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.XPathParam; import org.springframework.ws.server.endpoint.support.NamespaceUtils; import org.springframework.xml.transform.TransformerHelper; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; /** - * Implementation of {@link MethodArgumentResolver} that supports the {@link XPathParam @XPathParam} annotation. + * Implementation of {@link MethodArgumentResolver} that supports the + * {@link XPathParam @XPathParam} annotation. *

      - * This resolver supports parameters annotated with {@link XPathParam @XPathParam} that specifies the XPath expression - * that should be bound to that parameter. The parameter can either a "natively supported" XPath type ({@link Boolean - * boolean}, {@link Double double}, {@link String}, {@link Node}, or {@link NodeList}), or a type that is - * {@linkplain ConversionService#canConvert(Class, Class) supported} by the {@link ConversionService}. + * This resolver supports parameters annotated with {@link XPathParam @XPathParam} that + * specifies the XPath expression that should be bound to that parameter. The parameter + * can either a "natively supported" XPath type ({@link Boolean boolean}, {@link Double + * double}, {@link String}, {@link Node}, or {@link NodeList}), or a type that is + * {@linkplain ConversionService#canConvert(Class, Class) supported} by the + * {@link ConversionService}. * * @author Arjen Poutsma * @since 2.0 @@ -60,7 +64,9 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver /** * Sets the conversion service to use. *

      - * Defaults to the {@linkplain ConversionServiceFactory#createDefaultConversionService() default conversion service}. + * Defaults to the + * {@linkplain ConversionServiceFactory#createDefaultConversionService() default + * conversion service}. */ public void setConversionService(ConversionService conversionService) { this.conversionService = conversionService; @@ -76,11 +82,13 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver return false; } Class parameterType = parameter.getParameterType(); - if (Boolean.class.equals(parameterType) || Boolean.TYPE.equals(parameterType) || Double.class.equals(parameterType) - || Double.TYPE.equals(parameterType) || Node.class.isAssignableFrom(parameterType) - || NodeList.class.isAssignableFrom(parameterType) || String.class.isAssignableFrom(parameterType)) { + if (Boolean.class.equals(parameterType) || Boolean.TYPE.equals(parameterType) + || Double.class.equals(parameterType) || Double.TYPE.equals(parameterType) + || Node.class.isAssignableFrom(parameterType) || NodeList.class.isAssignableFrom(parameterType) + || String.class.isAssignableFrom(parameterType)) { return true; - } else { + } + else { return conversionService.canConvert(String.class, parameterType); } } @@ -108,15 +116,20 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver private QName getReturnType(Class parameterType) { if (Boolean.class.equals(parameterType) || Boolean.TYPE.equals(parameterType)) { return XPathConstants.BOOLEAN; - } else if (Double.class.equals(parameterType) || Double.TYPE.equals(parameterType)) { + } + else if (Double.class.equals(parameterType) || Double.TYPE.equals(parameterType)) { return XPathConstants.NUMBER; - } else if (Node.class.equals(parameterType)) { + } + else if (Node.class.equals(parameterType)) { return XPathConstants.NODE; - } else if (NodeList.class.equals(parameterType)) { + } + else if (NodeList.class.equals(parameterType)) { return XPathConstants.NODESET; - } else if (String.class.equals(parameterType)) { + } + else if (String.class.equals(parameterType)) { return XPathConstants.STRING; - } else { + } + else { return null; } } @@ -135,11 +148,11 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver } /** - * Create a {@code XPathFactory} that this resolver will use to create {@link XPath} objects. + * Create a {@code XPathFactory} that this resolver will use to create {@link XPath} + * objects. *

      - * Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so - * this method will only be called once. - * + * Can be overridden in subclasses, adding further initialization of the factory. The + * resulting factory is cached, so this method will only be called once. * @return the created factory */ protected XPathFactory createXPathFactory() { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/Dom4jPayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/Dom4jPayloadMethodProcessor.java index b04331bb..fa6f1b8c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/Dom4jPayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/Dom4jPayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,12 +25,15 @@ import org.dom4j.Element; import org.dom4j.io.DOMReader; import org.dom4j.io.DocumentResult; import org.dom4j.io.DocumentSource; + import org.springframework.core.MethodParameter; import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; /** - * Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver - * MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler + * Implementation of + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver + * MethodArgumentResolver} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler * MethodReturnValueHandler} that supports dom4j {@linkplain Element elements}. * * @author Arjen Poutsma diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/DomPayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/DomPayloadMethodProcessor.java index 6b1b4f08..68fb0564 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/DomPayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/DomPayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,15 +20,18 @@ import javax.xml.transform.Source; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; -import org.springframework.core.MethodParameter; -import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.springframework.core.MethodParameter; +import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; + /** - * Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver - * MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler + * Implementation of + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver + * MethodArgumentResolver} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler * MethodReturnValueHandler} that supports W3C DOM {@linkplain Element elements}. * * @author Arjen Poutsma @@ -47,7 +50,8 @@ public class DomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces protected Node resolveRequestPayloadArgument(MethodParameter parameter, Source requestPayload) throws Exception { if (requestPayload instanceof DOMSource) { return resolveArgumentDomSource(parameter, (DOMSource) requestPayload); - } else { + } + else { DOMResult domResult = new DOMResult(); transform(requestPayload, domResult); DOMSource domSource = new DOMSource(domResult.getNode()); @@ -60,7 +64,8 @@ public class DomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces Node requestNode = requestSource.getNode(); if (parameterType.isAssignableFrom(requestNode.getClass())) { return requestNode; - } else if (Element.class.equals(parameterType) && requestNode instanceof Document) { + } + else if (Element.class.equals(parameterType) && requestNode instanceof Document) { Document document = (Document) requestNode; return document.getDocumentElement(); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/JDomPayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/JDomPayloadMethodProcessor.java index 06a79c5e..5372e924 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/JDomPayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/JDomPayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,13 +24,16 @@ import org.jdom2.Element; import org.jdom2.input.DOMBuilder; import org.jdom2.transform.JDOMResult; import org.jdom2.transform.JDOMSource; -import org.springframework.core.MethodParameter; -import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; import org.w3c.dom.Node; +import org.springframework.core.MethodParameter; +import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; + /** - * Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver - * MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler + * Implementation of + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver + * MethodArgumentResolver} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler * MethodReturnValueHandler} that supports JDOM {@linkplain Element elements}. * * @author Arjen Poutsma @@ -50,7 +53,8 @@ public class JDomPayloadMethodProcessor extends AbstractPayloadSourceMethodProce DOMBuilder domBuilder = new DOMBuilder(); if (node.getNodeType() == Node.ELEMENT_NODE) { return domBuilder.build((org.w3c.dom.Element) node); - } else if (node.getNodeType() == Node.DOCUMENT_NODE) { + } + else if (node.getNodeType() == Node.DOCUMENT_NODE) { Document document = domBuilder.build((org.w3c.dom.Document) node); return document.getRootElement(); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/XomPayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/XomPayloadMethodProcessor.java index a830873f..2c75d037 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/XomPayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/dom/XomPayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,6 @@ package org.springframework.ws.server.endpoint.adapter.method.dom; -import nu.xom.Builder; -import nu.xom.Document; -import nu.xom.Element; -import nu.xom.ParsingException; -import nu.xom.converters.DOMConverter; - import java.io.ByteArrayInputStream; import java.io.IOException; @@ -32,14 +26,22 @@ import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; +import nu.xom.Builder; +import nu.xom.Document; +import nu.xom.Element; +import nu.xom.ParsingException; +import nu.xom.converters.DOMConverter; +import org.w3c.dom.DOMImplementation; + import org.springframework.core.MethodParameter; import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.w3c.dom.DOMImplementation; /** - * Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver - * MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler + * Implementation of + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver + * MethodArgumentResolver} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler * MethodReturnValueHandler} that supports XOM {@linkplain Element elements}. * * @author Arjen Poutsma @@ -61,7 +63,8 @@ public class XomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces org.w3c.dom.Node node = ((DOMSource) requestPayload).getNode(); if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) { return DOMConverter.convert((org.w3c.dom.Element) node); - } else if (node.getNodeType() == org.w3c.dom.Node.DOCUMENT_NODE) { + } + else if (node.getNodeType() == org.w3c.dom.Node.DOCUMENT_NODE) { Document document = DOMConverter.convert((org.w3c.dom.Document) node); return document.getRootElement(); } @@ -97,11 +100,11 @@ public class XomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces } /** - * Create a {@code DocumentBuilderFactory} that this resolver will use to create response payloads. + * Create a {@code DocumentBuilderFactory} that this resolver will use to create + * response payloads. *

      - * Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so - * this method will only be called once. - * + * Can be overridden in subclasses, adding further initialization of the factory. The + * resulting factory is cached, so this method will only be called once. * @return the created factory */ protected DocumentBuilderFactory createDocumentBuilderFactory() { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/AbstractJaxb2PayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/AbstractJaxb2PayloadMethodProcessor.java index f9ef9868..2f25e4cf 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/AbstractJaxb2PayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/AbstractJaxb2PayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,6 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb; -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBElement; -import jakarta.xml.bind.JAXBException; -import jakarta.xml.bind.JAXBIntrospector; -import jakarta.xml.bind.Marshaller; -import jakarta.xml.bind.Unmarshaller; -import jakarta.xml.bind.UnmarshallerHandler; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -45,6 +37,19 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.JAXBIntrospector; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.Unmarshaller; +import jakarta.xml.bind.UnmarshallerHandler; +import org.w3c.dom.Node; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; +import org.xml.sax.ext.LexicalHandler; + import org.springframework.core.MethodParameter; import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; @@ -53,19 +58,18 @@ import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadMeth import org.springframework.ws.stream.StreamingPayload; import org.springframework.ws.stream.StreamingWebServiceMessage; import org.springframework.xml.transform.TraxUtils; -import org.w3c.dom.Node; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; -import org.xml.sax.ext.LexicalHandler; /** - * Abstract base class for {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver - * MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler - * MethodReturnValueHandler} implementations that use JAXB2. Creates {@link JAXBContext} object lazily, and offers - * {@linkplain #marshalToResponsePayload(org.springframework.ws.context.MessageContext, Class, Object) marshalling} and - * {@linkplain #unmarshalFromRequestPayload(org.springframework.ws.context.MessageContext, Class) unmarshalling} - * methods. + * Abstract base class for + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver + * MethodArgumentResolver} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler + * MethodReturnValueHandler} implementations that use JAXB2. Creates {@link JAXBContext} + * object lazily, and offers + * {@linkplain #marshalToResponsePayload(org.springframework.ws.context.MessageContext, Class, Object) + * marshalling} and + * {@linkplain #unmarshalFromRequestPayload(org.springframework.ws.context.MessageContext, Class) + * unmarshalling} methods. * * @author Arjen Poutsma * @since 2.0 @@ -86,8 +90,8 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa Object returnValue) throws Exception; /** - * Marshals the given {@code jaxbElement} to the response payload of the given message context. - * + * Marshals the given {@code jaxbElement} to the response payload of the given message + * context. * @param messageContext the message context to marshal to * @param clazz the clazz to create a marshaller for * @param jaxbElement the object to be marshalled @@ -107,12 +111,14 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa StreamingPayload payload = new JaxbStreamingPayload(clazz, jaxbElement); streamingResponse.setStreamingPayload(payload); - } else { + } + else { Result responsePayload = response.getPayloadResult(); try { Jaxb2ResultCallback callback = new Jaxb2ResultCallback(clazz, jaxbElement); TraxUtils.doWithResult(responsePayload, callback); - } catch (Exception ex) { + } + catch (Exception ex) { throw convertToJaxbException(ex); } } @@ -120,7 +126,6 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa /** * Unmarshals the request payload of the given message context. - * * @param messageContext the message context to unmarshal from * @param clazz the class to unmarshal * @return the unmarshalled object, or {@code null} if the request has no payload @@ -139,14 +144,14 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa logger.debug("Unmarshalled payload request to [" + callback.result + "]"); } return callback.result; - } catch (Exception ex) { + } + catch (Exception ex) { throw convertToJaxbException(ex); } } /** * Unmarshals the request payload of the given message context as {@link JAXBElement}. - * * @param messageContext the message context to unmarshal from * @param clazz the class to unmarshal * @return the unmarshalled element, or {@code null} if the request has no payload @@ -165,7 +170,8 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa logger.debug("Unmarshalled payload request to [" + callback.result + "]"); } return callback.result; - } catch (Exception ex) { + } + catch (Exception ex) { throw convertToJaxbException(ex); } } @@ -178,16 +184,16 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa private JAXBException convertToJaxbException(Exception ex) { if (ex instanceof JAXBException) { return (JAXBException) ex; - } else { + } + else { return new JAXBException(ex); } } /** - * Creates a new {@link Marshaller} to be used for marshalling objects to XML. Defaults to - * {@link jakarta.xml.bind.JAXBContext#createMarshaller()}, but can be overridden in subclasses for further - * customization. - * + * Creates a new {@link Marshaller} to be used for marshalling objects to XML. + * Defaults to {@link jakarta.xml.bind.JAXBContext#createMarshaller()}, but can be + * overridden in subclasses for further customization. * @param jaxbContext the JAXB context to create a marshaller for * @return the marshaller * @throws JAXBException in case of JAXB errors @@ -201,10 +207,9 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa } /** - * Creates a new {@link Unmarshaller} to be used for unmarshalling XML to objects. Defaults to - * {@link jakarta.xml.bind.JAXBContext#createUnmarshaller()}, but can be overridden in subclasses for further - * customization. - * + * Creates a new {@link Unmarshaller} to be used for unmarshalling XML to objects. + * Defaults to {@link jakarta.xml.bind.JAXBContext#createUnmarshaller()}, but can be + * overridden in subclasses for further customization. * @param jaxbContext the JAXB context to create a unmarshaller for * @return the unmarshaller * @throws JAXBException in case of JAXB errors @@ -248,16 +253,20 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa public void saxSource(XMLReader reader, InputSource inputSource) throws Exception { if (inputSource.getByteStream() == null && inputSource.getCharacterStream() == null && inputSource.getSystemId() == null) { - // The InputSource neither has a stream nor a system ID set; this means that - // we are dealing with a custom SAXSource that is not backed by a SAX parser + // The InputSource neither has a stream nor a system ID set; this means + // that + // we are dealing with a custom SAXSource that is not backed by a SAX + // parser // but that generates a sequence of SAX events in some other way. - // In this case, we need to use a ContentHandler to feed the SAX events into + // In this case, we need to use a ContentHandler to feed the SAX events + // into // the unmarshaller. UnmarshallerHandler handler = unmarshaller.getUnmarshallerHandler(); reader.setContentHandler(handler); reader.parse(inputSource); result = handler.getResult(); - } else { + } + else { // If a stream or system ID is set, we assume that the SAXSource is backed // by a SAX parser and we only pass the InputSource to the unmarshaller. // This effectively ignores the SAX parser and lets the unmarshaller take @@ -290,6 +299,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa public void source(String systemId) throws Exception { result = unmarshaller.unmarshal(new URL(systemId)); } + } private class JaxbElementSourceCallback implements TraxUtils.SourceCallback { @@ -339,6 +349,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa public void source(String systemId) throws Exception { result = unmarshaller.unmarshal(new StreamSource(systemId), declaredType); } + } private class Jaxb2ResultCallback implements TraxUtils.ResultCallback { @@ -386,6 +397,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa public void result(String systemId) throws Exception { marshaller.marshal(jaxbElement, new StreamResult(systemId)); } + } private class JaxbStreamingPayload implements StreamingPayload { @@ -414,10 +426,12 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa public void writeTo(XMLStreamWriter streamWriter) throws XMLStreamException { try { marshaller.marshal(jaxbElement, streamWriter); - } catch (JAXBException ex) { + } + catch (JAXBException ex) { throw new XMLStreamException("Could not marshal [" + jaxbElement + "]: " + ex.getMessage(), ex); } } + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/JaxbElementPayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/JaxbElementPayloadMethodProcessor.java index 77b93a56..4ad127da 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/JaxbElementPayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/JaxbElementPayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,20 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb; -import jakarta.xml.bind.JAXBElement; -import jakarta.xml.bind.JAXBException; - import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.JAXBException; + import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; /** - * Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver - * MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler + * Implementation of + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver + * MethodArgumentResolver} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler * MethodReturnValueHandler} that supports {@link JAXBElement} objects. * * @author Arjen Poutsma @@ -43,7 +45,8 @@ public class JaxbElementPayloadMethodProcessor extends AbstractJaxb2PayloadMetho } @Override - public JAXBElement resolveArgument(MessageContext messageContext, MethodParameter parameter) throws JAXBException { + public JAXBElement resolveArgument(MessageContext messageContext, MethodParameter parameter) + throws JAXBException { ParameterizedType parameterizedType = (ParameterizedType) parameter.getGenericParameterType(); Class clazz = (Class) parameterizedType.getActualTypeArguments()[0]; return unmarshalElementFromRequestPayload(messageContext, clazz); @@ -61,4 +64,5 @@ public class JaxbElementPayloadMethodProcessor extends AbstractJaxb2PayloadMetho JAXBElement element = (JAXBElement) returnValue; marshalToResponsePayload(messageContext, element.getDeclaredType(), element); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/XmlRootElementPayloadMethodProcessor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/XmlRootElementPayloadMethodProcessor.java index 9461b962..eb7e484b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/XmlRootElementPayloadMethodProcessor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/XmlRootElementPayloadMethodProcessor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,10 +25,13 @@ import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; /** - * Implementation of {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver - * MethodArgumentResolver} and {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler - * MethodReturnValueHandler} that supports parameters annotated with {@link XmlRootElement @XmlRootElement} or - * {@link XmlType @XmlType}, and return values annotated with {@link XmlRootElement @XmlRootElement}. + * Implementation of + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver + * MethodArgumentResolver} and + * {@link org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler + * MethodReturnValueHandler} that supports parameters annotated with + * {@link XmlRootElement @XmlRootElement} or {@link XmlType @XmlType}, and return values + * annotated with {@link XmlRootElement @XmlRootElement}. * * @author Arjen Poutsma * @since 2.0 @@ -38,7 +41,8 @@ public class XmlRootElementPayloadMethodProcessor extends AbstractJaxb2PayloadMe @Override protected boolean supportsRequestPayloadParameter(MethodParameter parameter) { Class parameterType = parameter.getParameterType(); - return parameterType.isAnnotationPresent(XmlRootElement.class) || parameterType.isAnnotationPresent(XmlType.class); + return parameterType.isAnnotationPresent(XmlRootElement.class) + || parameterType.isAnnotationPresent(XmlType.class); } @Override @@ -47,7 +51,8 @@ public class XmlRootElementPayloadMethodProcessor extends AbstractJaxb2PayloadMe if (parameterType.isAnnotationPresent(XmlRootElement.class)) { return unmarshalFromRequestPayload(messageContext, parameterType); - } else { + } + else { JAXBElement element = unmarshalElementFromRequestPayload(messageContext, parameterType); return element != null ? element.getValue() : null; } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Endpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Endpoint.java index ceb4fa6c..3c39378b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Endpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Endpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,8 +29,9 @@ import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationM /** * Indicates that an annotated class is an "Endpoint" (e.g. a web service endpoint). *

      - * This annotation serves as a specialization of {@link Component @Component}, allowing for implementation classes to be - * autodetected through classpath scanning. Instances of this class are typically picked up by an + * This annotation serves as a specialization of {@link Component @Component}, allowing + * for implementation classes to be autodetected through classpath scanning. Instances of + * this class are typically picked up by an * {@link AbstractAnnotationMethodEndpointMapping} implementation, such as * {@link SoapActionAnnotationMethodEndpointMapping}. * @@ -45,9 +46,8 @@ import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationM public @interface Endpoint { /** - * The value may indicate a suggestion for a logical component name, to be turned into a Spring bean in case of an - * autodetected component. - * + * The value may indicate a suggestion for a logical component name, to be turned into + * a Spring bean in case of an autodetected component. * @return the suggested component name, if any */ String value() default ""; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Namespace.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Namespace.java index 62ace40a..e454e57e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Namespace.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Namespace.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,9 +25,11 @@ import java.lang.annotation.Target; import javax.xml.XMLConstants; /** - * Sets up a namespace to be used in an {@link Endpoint @Endpoint} method, class, or package. + * Sets up a namespace to be used in an {@link Endpoint @Endpoint} method, class, or + * package. *

      - * Typically used in combination with {@link XPathParam @XPathParam}, or {@link PayloadRoot @PayloadRoot}. + * Typically used in combination with {@link XPathParam @XPathParam}, or + * {@link PayloadRoot @PayloadRoot}. * * @author Arjen Poutsma * @see XPathParam @@ -41,14 +43,12 @@ public @interface Namespace { /** * Signifies the prefix of the namespace. - * * @see #uri() */ String prefix() default XMLConstants.DEFAULT_NS_PREFIX; /** * Signifies the URI of the namespace. - * * @see #prefix() */ String uri(); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Namespaces.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Namespaces.java index 13c59bc1..a945ed3d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Namespaces.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/Namespaces.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,7 +23,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Sets the namespaces to be used in an {@link Endpoint @Endpoint} method, class, or package. + * Sets the namespaces to be used in an {@link Endpoint @Endpoint} method, class, or + * package. * * @author Arjen Poutsma * @see Namespace @@ -35,4 +36,5 @@ import java.lang.annotation.Target; public @interface Namespaces { Namespace[] value(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/PayloadRoot.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/PayloadRoot.java index badcc4ea..e375e6d5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/PayloadRoot.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/PayloadRoot.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marks an endpoint method as the handler for an incoming request. The annotation values signify the request payload - * root element that is handled by the method. + * Marks an endpoint method as the handler for an incoming request. The annotation values + * signify the request payload root element that is handled by the method. * * @author Arjen Poutsma * @see org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping @@ -38,15 +38,15 @@ import java.lang.annotation.Target; public @interface PayloadRoot { /** - * Signifies the local part of the payload root element handled by the annotated method. - * + * Signifies the local part of the payload root element handled by the annotated + * method. * @see #namespace() */ String localPart(); /** - * Signifies the namespace of the payload root element handled by the annotated method. - * + * Signifies the namespace of the payload root element handled by the annotated + * method. * @see #localPart() */ String namespace() default ""; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/RequestPayload.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/RequestPayload.java index 6d5216e8..4ccba100 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/RequestPayload.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/RequestPayload.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,8 @@ import java.lang.annotation.Target; /** * Annotation which indicates that a method parameter should be bound to the - * {@linkplain org.springframework.ws.WebServiceMessage#getPayloadSource() request payload}. Supported for annotated - * endpoint methods. + * {@linkplain org.springframework.ws.WebServiceMessage#getPayloadSource() request + * payload}. Supported for annotated endpoint methods. * * @author Arjen Poutsma * @see ResponsePayload diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/ResponsePayload.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/ResponsePayload.java index e6c6f369..4f10655f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/ResponsePayload.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/ResponsePayload.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,8 @@ import java.lang.annotation.Target; /** * Annotation which indicates that a method return value should be bound to the - * {@linkplain org.springframework.ws.WebServiceMessage#getPayloadSource() response payload}. Supported for annotated - * endpoint methods. + * {@linkplain org.springframework.ws.WebServiceMessage#getPayloadSource() response + * payload}. Supported for annotated endpoint methods. * * @author Arjen Poutsma * @see RequestPayload diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/XPathParam.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/XPathParam.java index 7424474c..11408042 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/XPathParam.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/annotation/XPathParam.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Indicates that a method parameter should be bound to an XPath expression. The annotation value signifies the XPath - * expression to use. The parameter can be of the following types: + * Indicates that a method parameter should be bound to an XPath expression. The + * annotation value signifies the XPath expression to use. The parameter can be of the + * following types: *

        *
      • {@code boolean}, or {@link Boolean}
      • *
      • {@code double}, or {@link Double}
      • @@ -43,4 +44,5 @@ import java.lang.annotation.Target; public @interface XPathParam { String value(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/AbstractValidatingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/AbstractValidatingInterceptor.java index 4a99882e..bbdd4965 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/AbstractValidatingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/AbstractValidatingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,6 +21,9 @@ import java.io.IOException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -37,16 +40,15 @@ import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.validation.XmlValidatorFactory; import org.springframework.xml.xsd.XsdSchema; import org.springframework.xml.xsd.XsdSchemaCollection; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; /** - * Abstract base class for {@code EndpointInterceptor} implementations that validate part of the message using a schema. - * The exact message part is determined by the {@code getValidationRequestSource} and - * {@code getValidationResponseSource} template methods. + * Abstract base class for {@code EndpointInterceptor} implementations that validate part + * of the message using a schema. The exact message part is determined by the + * {@code getValidationRequestSource} and {@code getValidationResponseSource} template + * methods. *

        - * By default, only the request message is validated, but this behaviour can be changed using the - * {@code validateRequest} and {@code validateResponse} properties. + * By default, only the request message is validated, but this behaviour can be changed + * using the {@code validateRequest} and {@code validateResponse} properties. * * @author Arjen Poutsma * @see #getValidationRequestSource(org.springframework.ws.WebServiceMessage) @@ -73,8 +75,8 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Sets the schema language. Default is the W3C XML Schema: {@code http://www.w3.org/2001/XMLSchema"}. - * + * Sets the schema language. Default is the W3C XML Schema: + * {@code http://www.w3.org/2001/XMLSchema"}. * @see org.springframework.xml.validation.XmlValidatorFactory#SCHEMA_W3C_XML * @see org.springframework.xml.validation.XmlValidatorFactory#SCHEMA_RELAX_NG */ @@ -89,8 +91,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** * Sets the schema resource to use for validation. Setting this property, - * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or - * {@link #setSchemas(Resource[]) schemas} is required. + * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, + * {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is + * required. */ public void setSchema(Resource schema) { setSchemas(schema); @@ -98,8 +101,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** * Sets the schema resources to use for validation. Setting this property, - * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or - * {@link #setSchemas(Resource[]) schemas} is required. + * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, + * {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is + * required. */ public void setSchemas(Resource... schemas) { Assert.notEmpty(schemas, "schemas must not be empty or null"); @@ -112,9 +116,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** * Sets the {@link XsdSchema} to use for validation. Setting this property, - * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, {@link #setSchema(Resource) schema}, or - * {@link #setSchemas(Resource[]) schemas} is required. - * + * {@link #setXsdSchemaCollection(XsdSchemaCollection) xsdSchemaCollection}, + * {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is + * required. * @param schema the xsd schema to use * @throws IOException in case of I/O errors */ @@ -123,9 +127,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Sets the {@link XsdSchemaCollection} to use for validation. Setting this property, {@link #setXsdSchema(XsdSchema) - * xsdSchema}, {@link #setSchema(Resource) schema}, or {@link #setSchemas(Resource[]) schemas} is required. - * + * Sets the {@link XsdSchemaCollection} to use for validation. Setting this property, + * {@link #setXsdSchema(XsdSchema) xsdSchema}, {@link #setSchema(Resource) schema}, or + * {@link #setSchemas(Resource[]) schemas} is required. * @param schemaCollection the xsd schema collection to use * @throws IOException in case of I/O errors */ @@ -134,20 +138,26 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Sets the error handler to use for validation. If not set, a default error handler will be used. - * + * Sets the error handler to use for validation. If not set, a default error handler + * will be used. * @param errorHandler the error handler. */ public void setErrorHandler(ValidationErrorHandler errorHandler) { this.errorHandler = errorHandler; } - /** Indicates whether the request should be validated against the schema. Default is {@code true}. */ + /** + * Indicates whether the request should be validated against the schema. Default is + * {@code true}. + */ public void setValidateRequest(boolean validateRequest) { this.validateRequest = validateRequest; } - /** Indicates whether the response should be validated against the schema. Default is {@code false}. */ + /** + * Indicates whether the response should be validated against the schema. Default is + * {@code false}. + */ public void setValidateResponse(boolean validateResponse) { this.validateResponse = validateResponse; } @@ -168,12 +178,12 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Validates the request message in the given message context. Validation only occurs if {@code validateRequest} is - * set to {@code true}, which is the default. + * Validates the request message in the given message context. Validation only occurs + * if {@code validateRequest} is set to {@code true}, which is the default. *

        - * Returns {@code true} if the request is valid, or {@code false} if it isn't. Additionally, when the request message - * is a {@link SoapMessage}, a {@link SoapFault} is added as response. - * + * Returns {@code true} if the request is valid, or {@code false} if it isn't. + * Additionally, when the request message is a {@link SoapMessage}, a + * {@link SoapFault} is added as response. * @param messageContext the message context * @return {@code true} if the message is valid; {@code false} otherwise * @see #setValidateRequest(boolean) @@ -187,7 +197,8 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup SAXParseException[] errors = validator.validate(requestSource, errorHandler); if (!ObjectUtils.isEmpty(errors)) { return handleRequestValidationErrors(messageContext, errors); - } else if (logger.isDebugEnabled()) { + } + else if (logger.isDebugEnabled()) { logger.debug("Request message validated"); } } @@ -196,12 +207,13 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Template method that is called when the request message contains validation errors. Default implementation logs all - * errors, and returns {@code false}, i.e. do not process the request. - * + * Template method that is called when the request message contains validation errors. + * Default implementation logs all errors, and returns {@code false}, i.e. do not + * process the request. * @param messageContext the message context * @param errors the validation errors - * @return {@code true} to continue processing the request, {@code false} (the default) otherwise + * @return {@code true} to continue processing the request, {@code false} (the + * default) otherwise */ protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors) throws TransformerException { @@ -212,11 +224,11 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Validates the response message in the given message context. Validation only occurs if {@code validateResponse} is - * set to {@code true}, which is not the default. + * Validates the response message in the given message context. Validation only occurs + * if {@code validateResponse} is set to {@code true}, which is not + * the default. *

        * Returns {@code true} if the request is valid, or {@code false} if it isn't. - * * @param messageContext the message context. * @return {@code true} if the response is valid; {@code false} otherwise * @see #setValidateResponse(boolean) @@ -229,7 +241,8 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup SAXParseException[] errors = validator.validate(responseSource, errorHandler); if (!ObjectUtils.isEmpty(errors)) { return handleResponseValidationErrors(messageContext, errors); - } else if (logger.isDebugEnabled()) { + } + else if (logger.isDebugEnabled()) { logger.debug("Response message validated"); } } @@ -238,12 +251,13 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup } /** - * Template method that is called when the response message contains validation errors. Default implementation logs - * all errors, and returns {@code false}, i.e. do not cot continue to process the response interceptor chain. - * + * Template method that is called when the response message contains validation + * errors. Default implementation logs all errors, and returns {@code false}, i.e. do + * not cot continue to process the response interceptor chain. * @param messageContext the message context * @param errors the validation errors - * @return {@code true} to continue the response interceptor chain, {@code false} (the default) otherwise + * @return {@code true} to continue the response interceptor chain, {@code false} (the + * default) otherwise */ protected boolean handleResponseValidationErrors(MessageContext messageContext, SAXParseException[] errors) { for (SAXParseException error : errors) { @@ -260,21 +274,25 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup /** Does nothing by default. */ @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {} + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) { + } /** - * Abstract template method that returns the part of the request message that is to be validated. - * + * Abstract template method that returns the part of the request message that is to be + * validated. * @param request the request message - * @return the part of the message that is to validated, or {@code null} not to validate anything + * @return the part of the message that is to validated, or {@code null} not to + * validate anything */ protected abstract Source getValidationRequestSource(WebServiceMessage request); /** - * Abstract template method that returns the part of the response message that is to be validated. - * + * Abstract template method that returns the part of the response message that is to + * be validated. * @param response the response message - * @return the part of the message that is to validated, or {@code null} not to validate anything + * @return the part of the message that is to validated, or {@code null} not to + * validate anything */ protected abstract Source getValidationResponseSource(WebServiceMessage response); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/DelegatingSmartEndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/DelegatingSmartEndpointInterceptor.java index e64f197c..b9c2d495 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/DelegatingSmartEndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/DelegatingSmartEndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,8 @@ import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.server.SmartEndpointInterceptor; /** - * Implementation of the {@link SmartEndpointInterceptor} interface that delegates to a delegate - * {@link EndpointInterceptor}. + * Implementation of the {@link SmartEndpointInterceptor} interface that delegates to a + * delegate {@link EndpointInterceptor}. * * @author Arjen Poutsma * @since 2.0 @@ -34,8 +34,8 @@ public class DelegatingSmartEndpointInterceptor implements SmartEndpointIntercep private final EndpointInterceptor delegate; /** - * Creates a new instance of the {@code DelegatingSmartEndpointInterceptor} with the given delegate. - * + * Creates a new instance of the {@code DelegatingSmartEndpointInterceptor} with the + * given delegate. * @param delegate the endpoint interceptor to delegate to. */ public DelegatingSmartEndpointInterceptor(EndpointInterceptor delegate) { @@ -45,7 +45,6 @@ public class DelegatingSmartEndpointInterceptor implements SmartEndpointIntercep /** * Returns the delegate. - * * @return the delegate */ public EndpointInterceptor getDelegate() { @@ -55,7 +54,8 @@ public class DelegatingSmartEndpointInterceptor implements SmartEndpointIntercep /** * {@inheritDoc} *

        - * This implementation delegates to {@link #shouldIntercept(WebServiceMessage, Object)}. + * This implementation delegates to + * {@link #shouldIntercept(WebServiceMessage, Object)}. */ @Override public boolean shouldIntercept(MessageContext messageContext, Object endpoint) { @@ -67,10 +67,10 @@ public class DelegatingSmartEndpointInterceptor implements SmartEndpointIntercep * Indicates whether this interceptor should intercept the given request message. *

        * This implementation always returns {@code true}. - * * @param request the request message * @param endpoint chosen endpoint to invoke - * @return {@code true} to indicate that this interceptor applies; {@code false} otherwise + * @return {@code true} to indicate that this interceptor applies; {@code false} + * otherwise */ protected boolean shouldIntercept(WebServiceMessage request, Object endpoint) { return true; @@ -95,4 +95,5 @@ public class DelegatingSmartEndpointInterceptor implements SmartEndpointIntercep public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception { getDelegate().afterCompletion(messageContext, endpoint, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/EndpointInterceptorAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/EndpointInterceptorAdapter.java index 76b36d2c..69aa4cfc 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/EndpointInterceptorAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/EndpointInterceptorAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,13 +18,14 @@ package org.springframework.ws.server.endpoint.interceptor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.EndpointInterceptor; import org.w3c.dom.Element; +import org.springframework.ws.context.MessageContext; +import org.springframework.ws.server.EndpointInterceptor; + /** - * Default implementation of the {@code EndpointInterceptor} interface, for simplified implementation of - * pre-only/post-only interceptors. + * Default implementation of the {@code EndpointInterceptor} interface, for simplified + * implementation of pre-only/post-only interceptors. * * @author Arjen Poutsma * @since 1.0.0 @@ -41,7 +42,6 @@ public class EndpointInterceptorAdapter implements EndpointInterceptor { /** * Returns {@code true}. - * * @return {@code true} */ @Override @@ -51,7 +51,6 @@ public class EndpointInterceptorAdapter implements EndpointInterceptor { /** * Returns {@code true}. - * * @return {@code true} */ @Override @@ -61,7 +60,6 @@ public class EndpointInterceptorAdapter implements EndpointInterceptor { /** * Returns {@code true}. - * * @return {@code true} */ @Override @@ -73,5 +71,7 @@ public class EndpointInterceptorAdapter implements EndpointInterceptor { * Does nothing by default. */ @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception {} + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception { + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadLoggingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadLoggingInterceptor.java index 1da995b0..d91d3245 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadLoggingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadLoggingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,11 +22,11 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.server.endpoint.AbstractLoggingInterceptor; /** - * Simple {@link org.springframework.ws.server.EndpointInterceptor EndpointInterceptor} that logs the payload of request - * and response messages. + * Simple {@link org.springframework.ws.server.EndpointInterceptor EndpointInterceptor} + * that logs the payload of request and response messages. *

        - * By default, both request and response messages are logged, but this behaviour can be changed using the - * {@link #logRequest} and {@link #logResponse} properties. + * By default, both request and response messages are logged, but this behaviour can be + * changed using the {@link #logRequest} and {@link #logResponse} properties. * * @author Arjen Poutsma * @see #setLogRequest(boolean) diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptor.java index f83ac8f8..30863a56 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,6 +29,9 @@ import javax.xml.transform.stream.StreamSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -37,16 +40,16 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; import org.springframework.xml.transform.ResourceSource; import org.springframework.xml.transform.TransformerObjectSupport; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; /** - * Interceptor that transforms the payload of {@code WebServiceMessage}s using XSLT stylesheet. Allows for seperate - * stylesheets for request and response. This interceptor is especially useful when supporting with multiple version of - * a Web service: you can transform the older message format to the new format. + * Interceptor that transforms the payload of {@code WebServiceMessage}s using XSLT + * stylesheet. Allows for seperate stylesheets for request and response. This interceptor + * is especially useful when supporting with multiple version of a Web service: you can + * transform the older message format to the new format. *

        - * The stylesheets to use can be set using the {@code requestXslt} and {@code responseXslt} properties. Both of these - * are optional: if not set, the message is simply not transformed. Setting one of the two is required, though. + * The stylesheets to use can be set using the {@code requestXslt} and + * {@code responseXslt} properties. Both of these are optional: if not set, the message is + * simply not transformed. Setting one of the two is required, though. * * @author Arjen Poutsma * @see #setRequestXslt(org.springframework.core.io.Resource) @@ -77,9 +80,8 @@ public class PayloadTransformingInterceptor extends TransformerObjectSupport } /** - * Transforms the request message in the given message context using a provided stylesheet. Transformation only occurs - * if the {@code requestXslt} has been set. - * + * Transforms the request message in the given message context using a provided + * stylesheet. Transformation only occurs if the {@code requestXslt} has been set. * @param messageContext the message context * @return always returns {@code true} * @see #setRequestXslt(org.springframework.core.io.Resource) @@ -96,9 +98,8 @@ public class PayloadTransformingInterceptor extends TransformerObjectSupport } /** - * Transforms the response message in the given message context using a stylesheet. Transformation only occurs if the - * {@code responseXslt} has been set. - * + * Transforms the response message in the given message context using a stylesheet. + * Transformation only occurs if the {@code responseXslt} has been set. * @param messageContext the message context * @return always returns {@code true} * @see #setResponseXslt(org.springframework.core.io.Resource) @@ -129,7 +130,8 @@ public class PayloadTransformingInterceptor extends TransformerObjectSupport /** Does nothing by default. */ @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {} + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) { + } @Override public void afterPropertiesSet() throws Exception { @@ -156,4 +158,5 @@ public class PayloadTransformingInterceptor extends TransformerObjectSupport responseTemplates = transformerFactory.newTemplates(responseSource); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractAnnotationMethodEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractAnnotationMethodEndpointMapping.java index d2fff3a0..a84b1fb5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractAnnotationMethodEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractAnnotationMethodEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,10 +24,12 @@ import org.springframework.core.annotation.AnnotationUtils; import org.springframework.ws.server.endpoint.annotation.Endpoint; /** - * Abstract base for {@link org.springframework.ws.server.EndpointMapping} implementations that map classes tagged with - * an annotation. By default the annotation is {@link Endpoint}, but this can be overriden in subclasses. + * Abstract base for {@link org.springframework.ws.server.EndpointMapping} implementations + * that map classes tagged with an annotation. By default the annotation is + * {@link Endpoint}, but this can be overriden in subclasses. *

        - * The methods of each bean carrying @Endpoint will be registered using {@link #registerMethods(String)}. + * The methods of each bean carrying @Endpoint will be registered using + * {@link #registerMethods(String)}. * * @author Arjen Poutsma * @since 1.0.0 @@ -39,11 +41,12 @@ public abstract class AbstractAnnotationMethodEndpointMapping extends Abstrac /** * Set whether to detect endpoint beans in ancestor ApplicationContexts. *

        - * Default is "false": Only endpoint beans in the current ApplicationContext will be detected, i.e. only in the - * context that this EndpointMapping itself is defined in (typically the current MessageDispatcherServlet's context). + * Default is "false": Only endpoint beans in the current ApplicationContext will be + * detected, i.e. only in the context that this EndpointMapping itself is defined in + * (typically the current MessageDispatcherServlet's context). *

        - * Switch this flag on to detect endpoint beans in ancestor contexts (typically the Spring root WebApplicationContext) - * as well. + * Switch this flag on to detect endpoint beans in ancestor contexts (typically the + * Spring root WebApplicationContext) as well. */ public void setDetectEndpointsInAncestorContexts(boolean detectEndpointsInAncestorContexts) { this.detectEndpointsInAncestorContexts = detectEndpointsInAncestorContexts; @@ -66,7 +69,8 @@ public abstract class AbstractAnnotationMethodEndpointMapping extends Abstrac for (String beanName : beanNames) { Class endpointClass = getApplicationContext().getType(beanName); - if (endpointClass != null && AnnotationUtils.findAnnotation(endpointClass, getEndpointAnnotationType()) != null) { + if (endpointClass != null + && AnnotationUtils.findAnnotation(endpointClass, getEndpointAnnotationType()) != null) { registerMethods(beanName); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractEndpointMapping.java index d0ca2d2f..3c06d032 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,7 +32,8 @@ import org.springframework.ws.server.EndpointMapping; import org.springframework.ws.server.SmartEndpointInterceptor; /** - * Abstract base class for EndpointMapping implementations. Supports a default endpoint, and endpoint interceptors. + * Abstract base class for EndpointMapping implementations. Supports a default endpoint, + * and endpoint interceptors. * * @author Arjen Poutsma * @see #getEndpointInternal(org.springframework.ws.context.MessageContext) @@ -50,8 +51,8 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i private SmartEndpointInterceptor[] smartInterceptors; /** - * Returns the endpoint interceptors to apply to all endpoints mapped by this endpoint mapping. - * + * Returns the endpoint interceptors to apply to all endpoints mapped by this endpoint + * mapping. * @return array of endpoint interceptors, or {@code null} if none */ public EndpointInterceptor[] getInterceptors() { @@ -59,8 +60,8 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i } /** - * Sets the endpoint interceptors to apply to all endpoints mapped by this endpoint mapping. - * + * Sets the endpoint interceptors to apply to all endpoints mapped by this endpoint + * mapping. * @param interceptors array of endpoint interceptors, or {@code null} if none */ public final void setInterceptors(EndpointInterceptor[] interceptors) { @@ -76,7 +77,6 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i * Specify the order value for this mapping. *

        * Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered. - * * @see org.springframework.core.Ordered#getOrder() */ public final void setOrder(int order) { @@ -85,7 +85,6 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i /** * Initializes the interceptors. - * * @see #initInterceptors() */ @Override @@ -95,22 +94,20 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i /** * Initialize the specified interceptors, adapting them where necessary. - * * @see #setInterceptors */ protected void initInterceptors() { Map smartInterceptors = BeanFactoryUtils - .beansOfTypeIncludingAncestors(getApplicationContext(), SmartEndpointInterceptor.class, true, false); + .beansOfTypeIncludingAncestors(getApplicationContext(), SmartEndpointInterceptor.class, true, false); if (!smartInterceptors.isEmpty()) { this.smartInterceptors = smartInterceptors.values() - .toArray(new SmartEndpointInterceptor[smartInterceptors.size()]); + .toArray(new SmartEndpointInterceptor[smartInterceptors.size()]); } } /** - * Look up an endpoint for the given message context, falling back to the default endpoint if no specific one is - * found. - * + * Look up an endpoint for the given message context, falling back to the default + * endpoint if no specific one is found. * @return the looked up endpoint instance, or the default endpoint * @see #getEndpointInternal(org.springframework.ws.context.MessageContext) */ @@ -149,9 +146,9 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i } /** - * Creates a new {@code EndpointInvocationChain} based on the given message context, endpoint, and interceptors. - * Default implementation creates a simple {@code EndpointInvocationChain} based on the set interceptors. - * + * Creates a new {@code EndpointInvocationChain} based on the given message context, + * endpoint, and interceptors. Default implementation creates a simple + * {@code EndpointInvocationChain} based on the set interceptors. * @param endpoint the endpoint * @param interceptors the endpoint interceptors * @return the created invocation chain @@ -164,7 +161,6 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i /** * Returns the default endpoint for this endpoint mapping. - * * @return the default endpoint mapping, or null if none */ protected final Object getDefaultEndpoint() { @@ -172,11 +168,10 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i } /** - * Sets the default endpoint for this endpoint mapping. This endpoint will be returned if no specific mapping was - * found. + * Sets the default endpoint for this endpoint mapping. This endpoint will be returned + * if no specific mapping was found. *

        * Default is {@code null}, indicating no default endpoint. - * * @param defaultEndpoint the default endpoint, or null if none */ public final void setDefaultEndpoint(Object defaultEndpoint) { @@ -184,28 +179,31 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i } /** - * Resolves an endpoint string. If the given string can is a bean name, it is resolved using the application context. - * + * Resolves an endpoint string. If the given string can is a bean name, it is resolved + * using the application context. * @param endpointName the endpoint name * @return the resolved endpoint, or {@code null} if the name could not be resolved */ protected Object resolveStringEndpoint(String endpointName) { if (getApplicationContext().containsBean(endpointName)) { return getApplicationContext().getBean(endpointName); - } else { + } + else { return null; } } /** - * Lookup an endpoint for the given request, returning {@code null} if no specific one is found. This template method - * is called by getEndpoint, a {@code null} return value will lead to the default handler, if one is set. + * Lookup an endpoint for the given request, returning {@code null} if no specific one + * is found. This template method is called by getEndpoint, a {@code null} return + * value will lead to the default handler, if one is set. *

        - * The returned endpoint can be a string, in which case it is resolved as a bean name. Also, it can take the form - * {@code beanName#method}, in which case the method is resolved. - * + * The returned endpoint can be a string, in which case it is resolved as a bean name. + * Also, it can take the form {@code beanName#method}, in which case the method is + * resolved. * @return the looked up endpoint instance, or null * @throws Exception if there is an error */ protected abstract Object getEndpointInternal(MessageContext messageContext) throws Exception; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMapBasedEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMapBasedEndpointMapping.java index a32e9093..2129fe8c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMapBasedEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMapBasedEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,11 +26,12 @@ import org.springframework.util.StringUtils; import org.springframework.ws.context.MessageContext; /** - * Abstract base class for endpoint mapping that are based on a {@code Map}. Provides mappings of application context - * beans as well as a settable map. + * Abstract base class for endpoint mapping that are based on a {@code Map}. Provides + * mappings of application context beans as well as a settable map. *

        - * Subclasses determine the exact nature of the key in the enpoint map; this can be a qualified name, a SOAP Header, the - * result of a XPath validation. The values are always endpoint objects, or bean names of endpoint objects. + * Subclasses determine the exact nature of the key in the enpoint map; this can be a + * qualified name, a SOAP Header, the result of a XPath validation. The values are always + * endpoint objects, or bean names of endpoint objects. * * @author Arjen Poutsma * @since 1.0.0 @@ -47,30 +48,32 @@ public abstract class AbstractMapBasedEndpointMapping extends AbstractEndpointMa private Map temporaryEndpointMap = new HashMap(); /** - * Set whether to lazily initialize endpoints. Only applicable to singleton endpoints, as prototypes are always lazily - * initialized. Default is {@code false}, as eager initialization allows for more efficiency through referencing the - * controller objects directly. + * Set whether to lazily initialize endpoints. Only applicable to singleton endpoints, + * as prototypes are always lazily initialized. Default is {@code false}, as eager + * initialization allows for more efficiency through referencing the controller + * objects directly. *

        - * If you want to allow your endpoints to be lazily initialized, make them "lazy-init" and set this flag to - * {@code true}. Just making them "lazy-init" will not work, as they are initialized through the references from the - * endpoint mapping in this case. + * If you want to allow your endpoints to be lazily initialized, make them "lazy-init" + * and set this flag to {@code true}. Just making them "lazy-init" will not work, as + * they are initialized through the references from the endpoint mapping in this case. */ public void setLazyInitEndpoints(boolean lazyInitEndpoints) { this.lazyInitEndpoints = lazyInitEndpoints; } /** - * Set whether to register bean names found in the application context. Setting this to {@code true} will register all - * beans found in the application context under their name. Default is {@code false}. + * Set whether to register bean names found in the application context. Setting this + * to {@code true} will register all beans found in the application context under + * their name. Default is {@code false}. */ public final void setRegisterBeanNames(boolean registerBeanNames) { this.registerBeanNames = registerBeanNames; } /** - * Sets a Map with keys and endpoint beans as values. The nature of the keys in the given map depends on the exact - * subclass used. They can be qualified names, for instance, or mime headers. - * + * Sets a Map with keys and endpoint beans as values. The nature of the keys in the + * given map depends on the exact subclass used. They can be qualified names, for + * instance, or mime headers. * @throws IllegalArgumentException if the endpoint is invalid */ public final void setEndpointMap(Map endpointMap) { @@ -78,8 +81,8 @@ public abstract class AbstractMapBasedEndpointMapping extends AbstractEndpointMa } /** - * Maps keys to endpoint bean names. The nature of the property names depends on the exact subclass used. They can be - * qualified names, for instance, or mime headers. + * Maps keys to endpoint bean names. The nature of the property names depends on the + * exact subclass used. They can be qualified names, for instance, or mime headers. */ public void setMappings(Properties mappings) { for (Map.Entry entry : mappings.entrySet()) { @@ -89,19 +92,22 @@ public abstract class AbstractMapBasedEndpointMapping extends AbstractEndpointMa } } - /** Validates the given endpoint key. Should return {@code true} is the given string is valid. */ + /** + * Validates the given endpoint key. Should return {@code true} is the given string is + * valid. + */ protected abstract boolean validateLookupKey(String key); /** - * Returns the endpoint key for the given message context. Returns {@code null} if a key cannot be found. - * + * Returns the endpoint key for the given message context. Returns {@code null} if a + * key cannot be found. * @return the registration key; or {@code null} */ protected abstract String getLookupKeyForMessage(MessageContext messageContext) throws Exception; /** - * Lookup an endpoint for the given message. The extraction of the endpoint key is delegated to the concrete subclass. - * + * Lookup an endpoint for the given message. The extraction of the endpoint key is + * delegated to the concrete subclass. * @return the looked up endpoint, or {@code null} */ @Override @@ -118,7 +124,6 @@ public abstract class AbstractMapBasedEndpointMapping extends AbstractEndpointMa /** * Looks up an endpoint instance for the given keys. All keys are tried in order. - * * @param key key the beans are mapped to * @return the associated endpoint instance, or {@code null} if not found */ @@ -128,10 +133,10 @@ public abstract class AbstractMapBasedEndpointMapping extends AbstractEndpointMa /** * Register the given endpoint instance under the registration key. - * * @param key the string representation of the registration key * @param endpoint the endpoint instance - * @throws org.springframework.beans.BeansException if the endpoint could not be registered + * @throws org.springframework.beans.BeansException if the endpoint could not be + * registered */ protected void registerEndpoint(String key, Object endpoint) throws BeansException { Object mappedEndpoint = endpointMap.get(key); @@ -153,12 +158,11 @@ public abstract class AbstractMapBasedEndpointMapping extends AbstractEndpointMa } /** - * Registers annd checks the set endpoints. Checks the beans set through {@code setEndpointMap} and - * {@code setMappings}, and registers the bean names found in the application context, if {@code registerBeanNames} is - * set to {@code true}. - * - * @throws ApplicationContextException if either of the endpoints defined via {@code setEndpointMap} or - * {@code setMappings} is invalid + * Registers annd checks the set endpoints. Checks the beans set through + * {@code setEndpointMap} and {@code setMappings}, and registers the bean names found + * in the application context, if {@code registerBeanNames} is set to {@code true}. + * @throws ApplicationContextException if either of the endpoints defined via + * {@code setEndpointMap} or {@code setMappings} is invalid * @see #setEndpointMap(java.util.Map) * @see #setMappings(java.util.Properties) * @see #setRegisterBeanNames(boolean) diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMethodEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMethodEndpointMapping.java index d60b57f6..ecf3de32 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMethodEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMethodEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -39,9 +39,10 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; /** * Abstract base class for {@link MethodEndpoint} mappings. *

        - * Subclasses typically implement {@link org.springframework.beans.factory.config.BeanPostProcessor} to look for beans - * that qualify as endpoint. The methods of this bean are then registered under a specific key with - * {@link #registerEndpoint(Object, MethodEndpoint)}. + * Subclasses typically implement + * {@link org.springframework.beans.factory.config.BeanPostProcessor} to look for beans + * that qualify as endpoint. The methods of this bean are then registered under a specific + * key with {@link #registerEndpoint(Object, MethodEndpoint)}. * * @author Arjen Poutsma * @since 1.0.0 @@ -51,8 +52,8 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM private final Map endpointMap = new HashMap(); /** - * Lookup an endpoint for the given message. The extraction of the endpoint key is delegated to the concrete subclass. - * + * Lookup an endpoint for the given message. The extraction of the endpoint key is + * delegated to the concrete subclass. * @return the looked up endpoint, or {@code null} * @see #getLookupKeyForMessage(MessageContext) */ @@ -70,14 +71,12 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM /** * Returns the endpoint keys for the given message context. - * * @return the registration keys */ protected abstract T getLookupKeyForMessage(MessageContext messageContext) throws Exception; /** * Looks up an endpoint instance for the given keys. All keys are tried in order. - * * @param key key the beans are mapped to * @return the associated endpoint instance, or {@code null} if not found */ @@ -87,7 +86,6 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM /** * Register the given endpoint instance under the key. - * * @param key the lookup key * @param endpoint the method endpoint instance * @throws BeansException if the endpoint could not be registered @@ -108,10 +106,10 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM } /** - * Helper method that registers the methods of the given bean. This method iterates over the methods of the bean, and - * calls {@link #getLookupKeyForMethod(Method)} for each. If this returns a string, the method is registered using + * Helper method that registers the methods of the given bean. This method iterates + * over the methods of the bean, and calls {@link #getLookupKeyForMethod(Method)} for + * each. If this returns a string, the method is registered using * {@link #registerEndpoint(Object, MethodEndpoint)}. - * * @see #getLookupKeyForMethod(Method) */ protected void registerMethods(final Object endpoint) { @@ -129,10 +127,10 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM } /** - * Helper method that registers the methods of the given class. This method iterates over the methods of the class, - * and calls {@link #getLookupKeyForMethod(Method)} for each. If this returns a string, the method is registered using + * Helper method that registers the methods of the given class. This method iterates + * over the methods of the class, and calls {@link #getLookupKeyForMethod(Method)} for + * each. If this returns a string, the method is registered using * {@link #registerEndpoint(Object, MethodEndpoint)}. - * * @see #getLookupKeyForMethod(Method) * @see #getLookupKeysForMethod(Method) */ @@ -183,9 +181,8 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM } /** - * Returns the endpoint key for the given method. Returns {@code null} if the method is not to be registered, which is - * the default. - * + * Returns the endpoint key for the given method. Returns {@code null} if the method + * is not to be registered, which is the default. * @param method the method * @return a registration key, or {@code null} if the method is not to be registered * @see #getLookupKeysForMethod(Method) @@ -195,33 +192,33 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM } /** - * Returns the endpoint keys for the given method. Should return an empty array if the method is not to be registered. - * The default delegates to {@link #getLookupKeysForMethod(Method)}. - * + * Returns the endpoint keys for the given method. Should return an empty array if the + * method is not to be registered. The default delegates to + * {@link #getLookupKeysForMethod(Method)}. * @param method the method * @return a list of registration keys * @since 2.2 */ protected List getLookupKeysForMethod(Method method) { T key = getLookupKeyForMethod(method); - return key != null ? Collections.singletonList(key) : Collections. emptyList(); + return key != null ? Collections.singletonList(key) : Collections.emptyList(); } /** * Return the class or interface to use for method reflection. *

        * Default implementation delegates to {@link AopUtils#getTargetClass(Object)}. - * * @param endpoint the bean instance (might be an AOP proxy) * @return the bean class to expose */ protected Class getEndpointClass(Object endpoint) { if (AopUtils.isJdkDynamicProxy(endpoint)) { - throw new IllegalArgumentException( - ClassUtils.getShortName(getClass()) + " does not work with JDK Dynamic Proxies. " - + "Please use CGLIB proxies, by setting proxy-target-class=\"true\" on the aop:aspectj-autoproxy " - + "or aop:config element."); + throw new IllegalArgumentException(ClassUtils.getShortName(getClass()) + + " does not work with JDK Dynamic Proxies. " + + "Please use CGLIB proxies, by setting proxy-target-class=\"true\" on the aop:aspectj-autoproxy " + + "or aop:config element."); } return AopUtils.getTargetClass(endpoint); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractQNameEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractQNameEndpointMapping.java index c7cbafa7..28f3376c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractQNameEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractQNameEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,7 +22,8 @@ import org.springframework.ws.context.MessageContext; import org.springframework.xml.namespace.QNameUtils; /** - * Abstract base class for {@code EndpointMapping}s that resolve qualified names as registration keys. + * Abstract base class for {@code EndpointMapping}s that resolve qualified names as + * registration keys. * * @author Arjen Poutsma * @since 1.0.0 @@ -37,7 +38,6 @@ public abstract class AbstractQNameEndpointMapping extends AbstractMapBasedEndpo /** * Template method that resolves the qualified names from the given SOAP message. - * * @return an array of qualified names that serve as registration keys */ protected abstract QName resolveQName(MessageContext messageContext) throws Exception; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMapping.java index c9247327..cac54a76 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,8 +33,8 @@ import org.springframework.ws.server.endpoint.support.PayloadRootUtils; import org.springframework.xml.transform.TransformerFactoryUtils; /** - * Implementation of the {@link EndpointMapping} interface that uses the {@link PayloadRoot} annotation to map methods - * to request payload root elements. + * Implementation of the {@link EndpointMapping} interface that uses the + * {@link PayloadRoot} annotation to map methods to request payload root elements. *

        * Endpoints typically have the following form: * @@ -62,7 +62,6 @@ public class PayloadRootAnnotationMethodEndpointMapping extends AbstractAnnotati /** * Override the default {@link TransformerFactory}. - * * @param transformerFactory */ public static void setTransformerFactory(TransformerFactory transformerFactory) { @@ -83,7 +82,8 @@ public class PayloadRootAnnotationMethodEndpointMapping extends AbstractAnnotati for (PayloadRoot payloadRoot : payloadRoots.value()) { result.add(getQNameFromAnnotation(payloadRoot)); } - } else { + } + else { PayloadRoot payloadRoot = AnnotationUtils.findAnnotation(method, PayloadRoot.class); if (payloadRoot != null) { result.add(getQNameFromAnnotation(payloadRoot)); @@ -96,7 +96,8 @@ public class PayloadRootAnnotationMethodEndpointMapping extends AbstractAnnotati private QName getQNameFromAnnotation(PayloadRoot payloadRoot) { if (StringUtils.hasLength(payloadRoot.localPart()) && StringUtils.hasLength(payloadRoot.namespace())) { return new QName(payloadRoot.namespace(), payloadRoot.localPart()); - } else { + } + else { return new QName(payloadRoot.localPart()); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootQNameEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootQNameEndpointMapping.java index 831c21a7..ab381036 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootQNameEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootQNameEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,22 +25,23 @@ import org.springframework.ws.server.endpoint.support.PayloadRootUtils; import org.springframework.xml.transform.TransformerFactoryUtils; /** - * Implementation of the {@code EndpointMapping} interface to map from the qualified name of the request payload root - * element. Supports both mapping to bean instances and mapping to bean names: the latter is required for prototype - * endpoints. + * Implementation of the {@code EndpointMapping} interface to map from the qualified name + * of the request payload root element. Supports both mapping to bean instances and + * mapping to bean names: the latter is required for prototype endpoints. *

        - * The {@code endpointMap} property is suitable for populating the endpoint map with bean references, e.g. via the map - * element in XML bean definitions. + * The {@code endpointMap} property is suitable for populating the endpoint map with bean + * references, e.g. via the map element in XML bean definitions. *

        - * Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the - * {@code java.util.Properties} class, like as follows: + * Mappings to bean names can be set via the {@code mappings} property, in a form accepted + * by the {@code java.util.Properties} class, like as follows: * *

          * {http://www.springframework.org/spring-ws/samples/airline/schemas}BookFlight=bookFlightEndpoint
          * {http://www.springframework.org/spring-ws/samples/airline/schemas}GetFlights=getFlightsEndpoint
          * 
        * - * The syntax is QNAME=ENDPOINT_BEAN_NAME. Qualified names are parsed using the syntax described in {@code QNameEditor}. + * The syntax is QNAME=ENDPOINT_BEAN_NAME. Qualified names are parsed using the syntax + * described in {@code QNameEditor}. * * @author Arjen Poutsma * @see org.springframework.xml.namespace.QNameEditor @@ -56,7 +57,6 @@ public class PayloadRootQNameEndpointMapping extends AbstractQNameEndpointMappin /** * Override the default {@link TransformerFactory}. - * * @param transformerFactory */ public static void setTransformerFactory(TransformerFactory transformerFactory) { @@ -67,4 +67,5 @@ public class PayloadRootQNameEndpointMapping extends AbstractQNameEndpointMappin protected QName resolveQName(MessageContext messageContext) throws TransformerException { return PayloadRootUtils.getPayloadRootQName(messageContext.getRequest().getPayloadSource(), transformerFactory); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMapping.java index a5dc1acc..0a25dbb7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,9 +30,10 @@ import org.springframework.ws.server.endpoint.support.PayloadRootUtils; import org.springframework.xml.transform.TransformerFactoryUtils; /** - * Simple subclass of {@link AbstractMethodEndpointMapping} that maps from the local name of the request payload to - * methods. Endpoint beans are registered using the {@code endpoints} property; the endpoint methods that start with - * {@code methodPrefix} and end with {@code methodSuffix} will be registered. + * Simple subclass of {@link AbstractMethodEndpointMapping} that maps from the local name + * of the request payload to methods. Endpoint beans are registered using the + * {@code endpoints} property; the endpoint methods that start with {@code methodPrefix} + * and end with {@code methodSuffix} will be registered. *

        * Endpoints typically have the following form: * @@ -45,7 +46,8 @@ import org.springframework.xml.transform.TransformerFactoryUtils; * } *

* - * This method will handle any message that has the {@code MyMessage} as a payload root local name. + * This method will handle any message that has the {@code MyMessage} as a payload root + * local name. * * @author Arjen Poutsma * @see #setEndpoints(Object[]) @@ -72,8 +74,8 @@ public class SimpleMethodEndpointMapping extends AbstractMethodEndpointMapping - * When the {@link #setUsePath(boolean) usePath} property is enabled, the mapping will be based on the URI path rather - * than the full URI. + * When the {@link #setUsePath(boolean) usePath} property is enabled, the mapping will be + * based on the URI path rather than the full URI. *

- * The {@code endpointMap} property is suitable for populating the endpoint map with bean references, e.g. via the map - * element in XML bean definitions. + * The {@code endpointMap} property is suitable for populating the endpoint map with bean + * references, e.g. via the map element in XML bean definitions. *

- * Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the {@code + * Mappings to bean names can be set via the {@code mappings} property, in a form accepted + * by the {@code * java.util.Properties} class, like as follows: * *

@@ -52,9 +53,11 @@ import org.springframework.ws.transport.context.TransportContextHolder;
  *
  * The syntax is [URI|PATH]=ENDPOINT_BEAN_NAME.
  * 

- * This endpoint mapping does not read from the request message, and therefore is more suitable for message factories - * which directly read from the transport request (such as the {@link SaajSoapMessageFactory} with the {@code - * payloadCaching} disabled). However, this endpoint mapping obviously is transport specific. + * This endpoint mapping does not read from the request message, and therefore is more + * suitable for message factories which directly read from the transport request (such as + * the {@link SaajSoapMessageFactory} with the {@code + * payloadCaching} disabled). However, this endpoint mapping obviously is transport + * specific. * * @author Arjen Poutsma * @since 1.5.0 @@ -64,8 +67,8 @@ public class UriEndpointMapping extends AbstractMapBasedEndpointMapping { private boolean usePath = false; /** - * Indicates whether the path should be used instead of the full URI. Default is {@code false}. - * + * Indicates whether the path should be used instead of the full URI. Default is + * {@code false}. * @since 2.1.1 */ public void setUsePath(boolean usePath) { @@ -77,7 +80,8 @@ public class UriEndpointMapping extends AbstractMapBasedEndpointMapping { try { new URI(key); return true; - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { return false; } } @@ -91,11 +95,13 @@ public class UriEndpointMapping extends AbstractMapBasedEndpointMapping { URI connectionUri = connection.getUri(); if (usePath) { return connectionUri.getPath(); - } else { + } + else { return connectionUri.toString(); } } } return null; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMapping.java index c22fafc0..b778bc60 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,6 +23,8 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; +import org.w3c.dom.Element; + import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -31,29 +33,29 @@ import org.springframework.ws.context.MessageContext; import org.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.xpath.XPathExpression; import org.springframework.xml.xpath.XPathExpressionFactory; -import org.w3c.dom.Element; /** - * Implementation of the {@code EndpointMapping} interface that maps to endpoint using an XPath expression. Supports - * both mapping to bean instances and mapping to bean names: the latter is required for prototype endpoints. + * Implementation of the {@code EndpointMapping} interface that maps to endpoint using an + * XPath expression. Supports both mapping to bean instances and mapping to bean names: + * the latter is required for prototype endpoints. *

- * The XPath expression can be set using the {@code expression} property. Setting this property is required. There is - * also an optional {@code namespaces} property, which defines to set namespace bindings that are used in the - * expression. + * The XPath expression can be set using the {@code expression} property. Setting this + * property is required. There is also an optional {@code namespaces} property, which + * defines to set namespace bindings that are used in the expression. *

- * The {@code endpointMap} property is suitable for populating the endpoint map with bean references, e.g. via the map - * element in XML bean definitions. + * The {@code endpointMap} property is suitable for populating the endpoint map with bean + * references, e.g. via the map element in XML bean definitions. *

- * Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the - * {@code java.util.Properties} class, like as follows: + * Mappings to bean names can be set via the {@code mappings} property, in a form accepted + * by the {@code java.util.Properties} class, like as follows: * *

  * BookFlight=bookFlightEndpoint
  * GetFlights=getFlightsEndpoint
  * 
* - * The syntax is XPATH_EVALUATION=ENDPOINT_BEAN_NAME. The key is the evaluation of the XPath expression for the incoming - * message, the value is the name of the endpoint. + * The syntax is XPATH_EVALUATION=ENDPOINT_BEAN_NAME. The key is the evaluation of the + * XPath expression for the incoming message, the value is the name of the endpoint. * * @author Arjen Poutsma * @see #setExpression(String) @@ -75,7 +77,10 @@ public class XPathPayloadEndpointMapping extends AbstractMapBasedEndpointMapping expressionString = expression; } - /** Sets the namespaces bindings used in the expression. Keys are prefixes, values are namespaces. */ + /** + * Sets the namespaces bindings used in the expression. Keys are prefixes, values are + * namespaces. + */ public void setNamespaces(Map namespaces) { this.namespaces = namespaces; } @@ -85,7 +90,8 @@ public class XPathPayloadEndpointMapping extends AbstractMapBasedEndpointMapping Assert.notNull(expressionString, "expression is required"); if (namespaces == null) { expression = XPathExpressionFactory.createXPathExpression(expressionString); - } else { + } + else { expression = XPathExpressionFactory.createXPathExpression(expressionString, namespaces); } transformerFactory = TransformerFactoryUtils.newInstance(); @@ -108,4 +114,5 @@ public class XPathPayloadEndpointMapping extends AbstractMapBasedEndpointMapping protected boolean validateLookupKey(String key) { return StringUtils.hasLength(key); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/jaxb/XmlRootElementEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/jaxb/XmlRootElementEndpointMapping.java index 4ff5cd17..070efdc9 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/jaxb/XmlRootElementEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/jaxb/XmlRootElementEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,15 @@ package org.springframework.ws.server.endpoint.mapping.jaxb; +import java.lang.reflect.Method; + +import javax.xml.namespace.QName; + import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBIntrospector; import jakarta.xml.bind.annotation.XmlRootElement; -import java.lang.reflect.Method; - -import javax.xml.namespace.QName; - import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.mapping.AbstractAnnotationMethodEndpointMapping; @@ -32,8 +32,9 @@ import org.springframework.ws.server.endpoint.support.PayloadRootUtils; import org.springframework.xml.transform.TransformerHelper; /** - * Implementation of the {@link org.springframework.ws.server.EndpointMapping EndpointMapping} interface that uses the - * JAXB2 {@link XmlRootElement} annotation to map methods to request payload root elements. + * Implementation of the {@link org.springframework.ws.server.EndpointMapping + * EndpointMapping} interface that uses the JAXB2 {@link XmlRootElement} annotation to map + * methods to request payload root elements. *

* Endpoints typically have the following form: * @@ -90,7 +91,8 @@ public class XmlRootElementEndpointMapping extends AbstractAnnotationMethodEndpo if (result != null) { return result; } - } catch (InstantiationException | IllegalAccessException e) { + } + catch (InstantiationException | IllegalAccessException e) { // ignore } return null; @@ -101,7 +103,8 @@ public class XmlRootElementEndpointMapping extends AbstractAnnotationMethodEndpo JAXBContext context = JAXBContext.newInstance(parameterType); JAXBIntrospector introspector = context.createJAXBIntrospector(); return introspector.getElementName(param); - } catch (JAXBException ex) { + } + catch (JAXBException ex) { return null; } } @@ -110,4 +113,5 @@ public class XmlRootElementEndpointMapping extends AbstractAnnotationMethodEndpo protected QName getLookupKeyForMessage(MessageContext messageContext) throws Exception { return PayloadRootUtils.getPayloadRootQName(messageContext.getRequest().getPayloadSource(), transformerHelper); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/support/NamespaceUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/support/NamespaceUtils.java index 6ff89b79..7f8da528 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/support/NamespaceUtils.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/support/NamespaceUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,16 +34,17 @@ import org.springframework.xml.namespace.SimpleNamespaceContext; */ public abstract class NamespaceUtils { - private NamespaceUtils() {} + private NamespaceUtils() { + } /** - * Creates a {@code NamespaceContext} for the specified method, based on {@link Namespaces @Namespaces} and - * {@link Namespace @Namespace} annotations. + * Creates a {@code NamespaceContext} for the specified method, based on + * {@link Namespaces @Namespaces} and {@link Namespace @Namespace} annotations. *

- * This method will search for {@link Namespaces @Namespaces} and {@link Namespace @Namespace} annotation in the given - * method, its class, and its package, in reverse order. That is: package-level annotations are overridden by + * This method will search for {@link Namespaces @Namespaces} and + * {@link Namespace @Namespace} annotation in the given method, its class, and its + * package, in reverse order. That is: package-level annotations are overridden by * class-level annotations, which again are overridden by method-level annotations. - * * @param method the method to create the namespace context for * @return the namespace context */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/support/PayloadRootUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/support/PayloadRootUtils.java index 0ce300f8..d7f70c63 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/support/PayloadRootUtils.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/support/PayloadRootUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,14 +30,15 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; -import org.springframework.xml.namespace.QNameUtils; -import org.springframework.xml.transform.TransformerHelper; -import org.springframework.xml.transform.TraxUtils; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; +import org.springframework.xml.namespace.QNameUtils; +import org.springframework.xml.transform.TransformerHelper; +import org.springframework.xml.transform.TraxUtils; + /** * Helper class for determining the root qualified name of a Web Service payload. * @@ -46,13 +47,14 @@ import org.xml.sax.XMLReader; */ public abstract class PayloadRootUtils { - private PayloadRootUtils() {} + private PayloadRootUtils() { + } /** * Returns the root qualified name of the given source, transforming it if necessary. - * * @param source the source to get the root element from - * @param transformerFactory a transformer factory, necessary if the given source is not a {@code DOMSource} + * @param transformerFactory a transformer factory, necessary if the given source is + * not a {@code DOMSource} * @return the root element, or {@code null} if {@code source} is {@code null} */ public static QName getPayloadRootQName(Source source, TransformerFactory transformerFactory) @@ -70,16 +72,19 @@ public abstract class PayloadRootUtils { TraxUtils.doWithSource(source, callback); if (callback.result != null) { return callback.result; - } else { + } + else { // we have no other option than to transform DOMResult domResult = new DOMResult(); transformerHelper.transform(source, domResult); Document document = (Document) domResult.getNode(); return QNameUtils.getQNameForNode(document.getDocumentElement()); } - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw ex; - } catch (Exception ex) { + } + catch (Exception ex) { return null; } } @@ -92,7 +97,8 @@ public abstract class PayloadRootUtils { public void domSource(Node node) throws Exception { if (node.getNodeType() == Node.ELEMENT_NODE) { result = QNameUtils.getQNameForNode(node); - } else if (node.getNodeType() == Node.DOCUMENT_NODE) { + } + else if (node.getNodeType() == Node.DOCUMENT_NODE) { Document document = (Document) node; result = QNameUtils.getQNameForNode(document.getDocumentElement()); } @@ -107,7 +113,8 @@ public abstract class PayloadRootUtils { if (event != null) { if (event.isStartElement()) { result = event.asStartElement().getName(); - } else if (event.isEndElement()) { + } + else if (event.isEndElement()) { result = event.asEndElement().getName(); } } @@ -118,7 +125,8 @@ public abstract class PayloadRootUtils { if (streamReader.getEventType() == XMLStreamConstants.START_DOCUMENT) { try { streamReader.nextTag(); - } catch (XMLStreamException ex) { + } + catch (XMLStreamException ex) { throw new IllegalStateException("Could not read next tag: " + ex.getMessage(), ex); } } @@ -147,6 +155,7 @@ public abstract class PayloadRootUtils { public void source(String systemId) throws Exception { // Do nothing } + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/AbstractSoapMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/AbstractSoapMessage.java index 1f8de5bc..9ceef05c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/AbstractSoapMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/AbstractSoapMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,7 +23,8 @@ import javax.xml.transform.Source; import org.springframework.ws.mime.AbstractMimeMessage; /** - * Abstract implementation of the {@link SoapMessage} interface. Contains convenient default implementations. + * Abstract implementation of the {@link SoapMessage} interface. Contains convenient + * default implementations. * * @author Arjen Poutsma * @since 1.0.0 @@ -67,7 +68,8 @@ public abstract class AbstractSoapMessage extends AbstractMimeMessage implements public final QName getFaultCode() { if (hasFault()) { return getSoapBody().getFault().getFaultCode(); - } else { + } + else { return null; } } @@ -77,7 +79,8 @@ public abstract class AbstractSoapMessage extends AbstractMimeMessage implements public final String getFaultReason() { if (hasFault()) { return getSoapBody().getFault().getFaultStringOrReason(); - } else { + } + else { return null; } } @@ -88,13 +91,16 @@ public abstract class AbstractSoapMessage extends AbstractMimeMessage implements String envelopeNamespace = getEnvelope().getName().getNamespaceURI(); if (SoapVersion.SOAP_11.getEnvelopeNamespaceUri().equals(envelopeNamespace)) { version = SoapVersion.SOAP_11; - } else if (SoapVersion.SOAP_12.getEnvelopeNamespaceUri().equals(envelopeNamespace)) { + } + else if (SoapVersion.SOAP_12.getEnvelopeNamespaceUri().equals(envelopeNamespace)) { version = SoapVersion.SOAP_12; - } else { + } + else { throw new IllegalStateException( "Unknown Envelope namespace uri '" + envelopeNamespace + "'. " + "Cannot deduce SoapVersion."); } } return version; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapBody.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapBody.java index cc7c4bd9..1555ba02 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapBody.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapBody.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,11 +24,12 @@ import javax.xml.transform.Source; import org.springframework.ws.WebServiceMessage; /** - * Represents the {@code Body} element in a SOAP message. A SOAP body contains the payload of the - * message. This payload can be custom XML, or a {@code SoapFault} (but not both). + * Represents the {@code Body} element in a SOAP message. A SOAP body contains the + * payload of the message. This payload can be custom XML, or a + * {@code SoapFault} (but not both). *

- * Note that the source returned by {@code getSource()} includes the SOAP Body element itself. For the contents of the - * body, use {@code getPayloadSource()}. + * Note that the source returned by {@code getSource()} includes the SOAP Body element + * itself. For the contents of the body, use {@code getPayloadSource()}. * * @author Arjen Poutsma * @see SoapEnvelope#getBody() @@ -41,7 +42,6 @@ public interface SoapBody extends SoapElement { /** * Returns a {@code Source} that represents the contents of the body. - * * @return the message contents * @see WebServiceMessage#getPayloadSource() */ @@ -51,18 +51,17 @@ public interface SoapBody extends SoapElement { * Returns a {@code Result} that represents the contents of the body. *

* Calling this method removes the current content of the body. - * * @return the message contents * @see WebServiceMessage#getPayloadResult() */ Result getPayloadResult(); /** - * Adds a {@code MustUnderstand} fault to the body. A {@code MustUnderstand} is returned when a SOAP header with a - * {@code MustUnderstand} attribute is not understood. + * Adds a {@code MustUnderstand} fault to the body. A {@code MustUnderstand} is + * returned when a SOAP header with a {@code MustUnderstand} attribute is not + * understood. *

* Adding a fault removes the current content of the body. - * * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @return the created {@code SoapFault} @@ -70,11 +69,11 @@ public interface SoapBody extends SoapElement { SoapFault addMustUnderstandFault(String faultStringOrReason, Locale locale) throws SoapFaultException; /** - * Adds a {@code Client}/{@code Sender} fault to the body. For SOAP 1.1, this adds a fault with a {@code Client} fault - * code. For SOAP 1.2, this adds a fault with a {@code Sender} code. + * Adds a {@code Client}/{@code Sender} fault to the body. For SOAP 1.1, this adds a + * fault with a {@code Client} fault code. For SOAP 1.2, this adds a fault with a + * {@code Sender} code. *

* Adding a fault removes the current content of the body. - * * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @return the created {@code SoapFault} @@ -82,11 +81,11 @@ public interface SoapBody extends SoapElement { SoapFault addClientOrSenderFault(String faultStringOrReason, Locale locale) throws SoapFaultException; /** - * Adds a {@code Server}/{@code Receiver} fault to the body. For SOAP 1.1, this adds a fault with a {@code Server} - * fault code. For SOAP 1.2, this adds a fault with a {@code Receiver} code. + * Adds a {@code Server}/{@code Receiver} fault to the body. For SOAP 1.1, this adds a + * fault with a {@code Server} fault code. For SOAP 1.2, this adds a fault with a + * {@code Receiver} code. *

* Adding a fault removes the current content of the body. - * * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @return the created {@code SoapFault} @@ -97,7 +96,6 @@ public interface SoapBody extends SoapElement { * Adds a {@code VersionMismatch} fault to the body. *

* Adding a fault removes the current content of the body. - * * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @return the created {@code SoapFault} @@ -106,15 +104,14 @@ public interface SoapBody extends SoapElement { /** * Indicates whether this body has a {@code SoapFault}. - * * @return {@code true} if the body has a fault; {@code false} otherwise */ boolean hasFault(); /** * Returns the {@code SoapFault} of this body. - * * @return the {@code SoapFault}, or {@code null} if none is present */ SoapFault getFault(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapElement.java index 03242ea7..86db4dec 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapElement.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,22 +32,19 @@ public interface SoapElement { /** * Returns the qualified name of this element. - * * @return the qualified name of this element */ QName getName(); /** - * Returns the {@code Source} of this element. This includes the element itself, i.e. {@code SoapEnvelope.getSource()} - * will include the {@code Envelope} tag. - * + * Returns the {@code Source} of this element. This includes the element itself, i.e. + * {@code SoapEnvelope.getSource()} will include the {@code Envelope} tag. * @return the {@code Source} of this element */ Source getSource(); /** * Adds an attribute with the specified qualified name and value to this element. - * * @param name the qualified name of the attribute * @param value the value of the attribute */ @@ -55,30 +52,28 @@ public interface SoapElement { /** * Removes the attribute with the specified name. - * * @param name the qualified name of the attribute to remove */ void removeAttribute(QName name); /** * Returns the value of the attribute with the specified qualified name. - * * @param name the qualified name * @return the value, or {@code null} if there is no such attribute */ String getAttributeValue(QName name); /** - * Returns an {@code Iterator} over all of the attributes in element as {@link QName qualified names}. - * + * Returns an {@code Iterator} over all of the attributes in element as {@link QName + * qualified names}. * @return an iterator over all the attribute names */ Iterator getAllAttributes(); /** * Adds a namespace declaration with the specified prefix and URI to this element. - * - * @param prefix the namespace prefix. Can be empty or null to declare the default namespace + * @param prefix the namespace prefix. Can be empty or null to declare the default + * namespace * @param namespaceUri the namespace uri * @throws SoapElementException in case of errors */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapEnvelope.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapEnvelope.java index 20c243d2..b5e54062 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapEnvelope.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapEnvelope.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -17,8 +17,8 @@ package org.springframework.ws.soap; /** - * Represents the {@code Envelope} element in a SOAP message. The header contains the optional {@code SoapHeader} and - * {@code SoapBody}. + * Represents the {@code Envelope} element in a SOAP message. The header contains the + * optional {@code SoapHeader} and {@code SoapBody}. * * @author Arjen Poutsma * @since 1.0.0 @@ -27,7 +27,6 @@ public interface SoapEnvelope extends SoapElement { /** * Returns the {@code SoapHeader}. Returns {@code null} if no header is present. - * * @return the {@code SoapHeader}, or {@code null} * @throws SoapHeaderException if the header cannot be returned */ @@ -35,7 +34,6 @@ public interface SoapEnvelope extends SoapElement { /** * Returns the {@code SoapBody}. - * * @return the {@code SoapBody} * @throws SoapBodyException if the header cannot be returned */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFault.java index 2ace5f2e..785060b5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFault.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,8 @@ import javax.xml.namespace.QName; /** * Represents the {@code Fault} element in the body of a SOAP message. *

- * A fault consists of a {@link #getFaultCode() fault code}, {@link #getFaultActorOrRole fault string/reason}, and - * {@link #getFaultActorOrRole() role}. + * A fault consists of a {@link #getFaultCode() fault code}, {@link #getFaultActorOrRole + * fault string/reason}, and {@link #getFaultActorOrRole() role}. * * @author Arjen Poutsma * @since 1.0.0 @@ -33,28 +33,33 @@ public interface SoapFault extends SoapElement { QName getFaultCode(); /** - * Returns the fault string or reason. For SOAP 1.1, this returns the fault string. For SOAP 1.2, this returns the - * fault reason for the default locale. + * Returns the fault string or reason. For SOAP 1.1, this returns the fault string. + * For SOAP 1.2, this returns the fault reason for the default locale. */ String getFaultStringOrReason(); - /** Returns the fault actor or role. For SOAP 1.1, this returns the actor. For SOAP 1.2, this returns the role. */ + /** + * Returns the fault actor or role. For SOAP 1.1, this returns the actor. For SOAP + * 1.2, this returns the role. + */ String getFaultActorOrRole(); - /** Sets the fault actor. For SOAP 1.1, this sets the actor. For SOAP 1.2, this sets the role. */ + /** + * Sets the fault actor. For SOAP 1.1, this sets the actor. For SOAP 1.2, this sets + * the role. + */ void setFaultActorOrRole(String faultActor); /** * Returns the optional detail element for this {@code SoapFault}. - * * @return a fault detail */ SoapFaultDetail getFaultDetail(); /** * Creates an optional {@code SoapFaultDetail} object and assigns it to this fault. - * * @return the created detail */ SoapFaultDetail addFaultDetail(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFaultDetail.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFaultDetail.java index b0b4fa2f..61b3d7b2 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFaultDetail.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFaultDetail.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,8 +22,8 @@ import javax.xml.namespace.QName; import javax.xml.transform.Result; /** - * Represents the {@code detail} element in a SOAP fault. A detail contains {@code SoapFaultDetailElement}s, which - * represent the individual details. + * Represents the {@code detail} element in a SOAP fault. A detail contains + * {@code SoapFaultDetailElement}s, which represent the individual details. * * @author Arjen Poutsma * @see SoapFaultDetailElement @@ -32,8 +32,8 @@ import javax.xml.transform.Result; public interface SoapFaultDetail extends SoapElement { /** - * Adds a new {@code SoapFaultDetailElement} with the specified qualified name to this detail. - * + * Adds a new {@code SoapFaultDetailElement} with the specified qualified name to this + * detail. * @param name the qualified name of the new detail element * @return the created {@code SoapFaultDetailElement} */ @@ -43,14 +43,12 @@ public interface SoapFaultDetail extends SoapElement { * Returns a {@code Result} that represents the concents of the detail. *

* The result can be used for marshalling. - * * @return the {@code Result} of this element */ Result getResult(); /** * Gets an iterator over all of the {@code SoapFaultDetailElement}s in this detail. - * * @return an iterator over all the {@code SoapFaultDetailElement}s * @see SoapFaultDetailElement */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFaultDetailElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFaultDetailElement.java index 99582a2a..267ecc35 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFaultDetailElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapFaultDetailElement.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,8 @@ package org.springframework.ws.soap; import javax.xml.transform.Result; /** - * Represents the content for an individual SOAP detail entry in a SOAP Message. All {@code SoapFaultDetailElement}s are - * contained in a {@code SoapDetail}. + * Represents the content for an individual SOAP detail entry in a SOAP Message. All + * {@code SoapFaultDetailElement}s are contained in a {@code SoapDetail}. * * @author Arjen Poutsma * @see SoapFaultDetail @@ -28,9 +28,13 @@ import javax.xml.transform.Result; */ public interface SoapFaultDetailElement extends SoapElement { - /** Returns a {@code Result} that allows for writing to the contents of the detail element. */ + /** + * Returns a {@code Result} that allows for writing to the contents + * of the detail element. + */ Result getResult(); /** Adds a new text node to this element. */ void addText(String text); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapHeader.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapHeader.java index d74a4704..29c40149 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapHeader.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapHeader.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,8 +22,8 @@ import javax.xml.namespace.QName; import javax.xml.transform.Result; /** - * Represents the {@code Header} element in a SOAP message. A SOAP header contains {@code SoapHeaderElement}s, which - * represent the individual headers. + * Represents the {@code Header} element in a SOAP message. A SOAP header contains + * {@code SoapHeaderElement}s, which represent the individual headers. * * @author Arjen Poutsma * @see SoapHeaderElement @@ -36,14 +36,13 @@ public interface SoapHeader extends SoapElement { * Returns a {@code Result} that represents the contents of the header. *

* The result can be used for marshalling. - * * @return the {@code Result} of this element */ Result getResult(); /** - * Adds a new {@code SoapHeaderElement} with the specified qualified name to this header. - * + * Adds a new {@code SoapHeaderElement} with the specified qualified name to this + * header. * @param name the qualified name of the new header element * @return the created {@code SoapHeaderElement} * @throws SoapHeaderException if the header cannot be created @@ -51,23 +50,23 @@ public interface SoapHeader extends SoapElement { SoapHeaderElement addHeaderElement(QName name) throws SoapHeaderException; /** - * Removes the {@code SoapHeaderElement} with the specified qualified name from this header. + * Removes the {@code SoapHeaderElement} with the specified qualified name from this + * header. *

- * This method will only remove the first child element with the specified name. If no element is found with the - * specified name, this method has no effect. - * + * This method will only remove the first child element with the specified name. If no + * element is found with the specified name, this method has no effect. * @param name the qualified name of the header element to be removed * @throws SoapHeaderException if the header cannot be removed */ void removeHeaderElement(QName name) throws SoapHeaderException; /** - * Returns an {@code Iterator} over all the {@code SoapHeaderElement}s that have the specified actor or role and that - * have a {@code MustUnderstand} attribute whose value is equivalent to {@code true}. - * + * Returns an {@code Iterator} over all the {@code SoapHeaderElement}s that have the + * specified actor or role and that have a {@code MustUnderstand} attribute whose + * value is equivalent to {@code true}. * @param actorOrRole the actor (SOAP 1.1) or role (SOAP 1.2) for which to search - * @return an iterator over all the header elements that contain the specified actor/role and are marked as - * {@code MustUnderstand} + * @return an iterator over all the header elements that contain the specified + * actor/role and are marked as {@code MustUnderstand} * @throws SoapHeaderException if the headers cannot be returned * @see SoapHeaderElement */ @@ -75,7 +74,6 @@ public interface SoapHeader extends SoapElement { /** * Returns an {@code Iterator} over all the {@code SoapHeaderElement}s in this header. - * * @return an iterator over all the header elements * @throws SoapHeaderException if the header cannot be returned * @see SoapHeaderElement @@ -83,8 +81,8 @@ public interface SoapHeader extends SoapElement { Iterator examineAllHeaderElements() throws SoapHeaderException; /** - * Returns an {@code Iterator} over all the {@code SoapHeaderElement}s with the given qualified name in this header. - * + * Returns an {@code Iterator} over all the {@code SoapHeaderElement}s with the given + * qualified name in this header. * @param name the qualified name for which to search * @return an iterator over all the header elements * @throws SoapHeaderException if the header cannot be returned diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapHeaderElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapHeaderElement.java index 3aaf981d..aeb4fce3 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapHeaderElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapHeaderElement.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,8 @@ package org.springframework.ws.soap; import javax.xml.transform.Result; /** - * Represents the contents of an individual SOAP header in the a SOAP message. All {@code SoapHeaderElement}s are - * contained in a {@code SoapHeader}. + * Represents the contents of an individual SOAP header in the a SOAP message. All + * {@code SoapHeaderElement}s are contained in a {@code SoapHeader}. * * @author Arjen Poutsma * @see SoapHeader @@ -29,50 +29,53 @@ import javax.xml.transform.Result; public interface SoapHeaderElement extends SoapElement { /** - * Returns the actor or role for this header element. In a SOAP 1.1 compliant message, this will read the - * {@code actor} attribute; in SOAP 1.2, the {@code role} attribute. - * + * Returns the actor or role for this header element. In a SOAP 1.1 compliant message, + * this will read the {@code actor} attribute; in SOAP 1.2, the {@code role} + * attribute. * @return the role of the header */ String getActorOrRole() throws SoapHeaderException; /** - * Sets the actor or role for this header element. In a SOAP 1.1 compliant message, this will result in an - * {@code actor} attribute being set; in SOAP 1.2, a {@code actorOrRole} attribute. - * + * Sets the actor or role for this header element. In a SOAP 1.1 compliant message, + * this will result in an {@code actor} attribute being set; in SOAP 1.2, a + * {@code actorOrRole} attribute. * @param actorOrRole the actorOrRole value */ void setActorOrRole(String actorOrRole) throws SoapHeaderException; /** - * Indicates whether the {@code mustUnderstand} attribute for this header element is set. - * - * @return {@code true} if the {@code mustUnderstand} attribute is set; {@code false} otherwise + * Indicates whether the {@code mustUnderstand} attribute for this header element is + * set. + * @return {@code true} if the {@code mustUnderstand} attribute is set; {@code false} + * otherwise */ boolean getMustUnderstand() throws SoapHeaderException; /** - * Sets the {@code mustUnderstand} attribute for this header element. If the attribute is on, the role who receives - * the header must process it. - * - * @param mustUnderstand {@code true} to set the {@code mustUnderstand} attribute on; {@code false} to turn it off + * Sets the {@code mustUnderstand} attribute for this header element. If the attribute + * is on, the role who receives the header must process it. + * @param mustUnderstand {@code true} to set the {@code mustUnderstand} attribute on; + * {@code false} to turn it off */ void setMustUnderstand(boolean mustUnderstand) throws SoapHeaderException; - /** Returns a {@code Result} that allows for writing to the contents of the header element. */ + /** + * Returns a {@code Result} that allows for writing to the contents + * of the header element. + */ Result getResult() throws SoapHeaderException; /** * Returns the text content of this header element, if any. - * * @return the text content of this header element */ String getText(); /** * Sets the text content of this header element. - * * @param content the new text content of this header element */ void setText(String content); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessage.java index 8721091b..a9b54aac 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,16 @@ package org.springframework.ws.soap; -import org.springframework.ws.FaultAwareWebServiceMessage; -import org.springframework.ws.mime.MimeMessage; import org.w3c.dom.Document; +import org.springframework.ws.FaultAwareWebServiceMessage; +import org.springframework.ws.mime.MimeMessage; + /** - * Represents an abstraction for SOAP messages, providing access to a SOAP Envelope. The contents of the SOAP body can - * be retrieved by {@code getPayloadSource()} and {@code getPayloadResult()} on {@code WebServiceMessage}, the - * super-interface of this interface. + * Represents an abstraction for SOAP messages, providing access to a SOAP Envelope. The + * contents of the SOAP body can be retrieved by {@code getPayloadSource()} and + * {@code getPayloadResult()} on {@code WebServiceMessage}, the super-interface of this + * interface. * * @author Arjen Poutsma * @see #getPayloadSource() @@ -38,37 +40,32 @@ public interface SoapMessage extends MimeMessage, FaultAwareWebServiceMessage { /** * Get the SOAP Action for this message, or {@code null} if not present. - * * @return the SOAP Action. */ String getSoapAction(); /** * Sets the SOAP Action for this message. - * * @param soapAction the SOAP Action. */ void setSoapAction(String soapAction); /** - * Returns the {@code SoapBody} associated with this {@code SoapMessage}. This is a convenience method for - * {@code getEnvelope().getBody()}. - * + * Returns the {@code SoapBody} associated with this {@code SoapMessage}. This is a + * convenience method for {@code getEnvelope().getBody()}. * @see SoapEnvelope#getBody() */ SoapBody getSoapBody() throws SoapBodyException; /** - * Returns the {@code SoapHeader} associated with this {@code SoapMessage}. This is a convenience method for - * {@code getEnvelope().getHeader()}. - * + * Returns the {@code SoapHeader} associated with this {@code SoapMessage}. This is a + * convenience method for {@code getEnvelope().getHeader()}. * @see SoapEnvelope#getHeader() */ SoapHeader getSoapHeader() throws SoapHeaderException; /** * Returns the SOAP version of this message. This can be either SOAP 1.1 or SOAP 1.2. - * * @return the SOAP version * @see SoapVersion#SOAP_11 * @see SoapVersion#SOAP_12 @@ -76,16 +73,14 @@ public interface SoapMessage extends MimeMessage, FaultAwareWebServiceMessage { SoapVersion getVersion(); /** - * Returns this message as a {@link Document}. Depending on the underlying implementation, this Document may be 'live' - * or not. - * + * Returns this message as a {@link Document}. Depending on the underlying + * implementation, this Document may be 'live' or not. * @return this soap message as a DOM document */ Document getDocument(); /** * Sets the contents of the message to the given {@link Document}. - * * @param document the soap message as a DOM document */ void setDocument(Document document); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageCreationException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageCreationException.java index c0483611..3cc3215a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageCreationException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageCreationException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public class SoapMessageCreationException extends SoapMessageException { public SoapMessageCreationException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageException.java index 7b951320..96f81cf2 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,4 +36,5 @@ public abstract class SoapMessageException extends WebServiceMessageException { public SoapMessageException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageFactory.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageFactory.java index 0faea106..5a255234 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageFactory.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapMessageFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,10 +22,11 @@ import java.io.InputStream; import org.springframework.ws.WebServiceMessageFactory; /** - * Sub-interface of {@link WebServiceMessageFactory} which contains SOAP-specific properties and methods. + * Sub-interface of {@link WebServiceMessageFactory} which contains SOAP-specific + * properties and methods. *

- * The {@code soapVersion} property can be used to indicate the SOAP version of the factory. By default, the version is - * {@link SoapVersion#SOAP_11}. + * The {@code soapVersion} property can be used to indicate the SOAP version of the + * factory. By default, the version is {@link SoapVersion#SOAP_11}. * * @author Arjen Poutsma * @since 1.0.0 @@ -34,7 +35,6 @@ public interface SoapMessageFactory extends WebServiceMessageFactory { /** * Sets the SOAP Version used by this factory. - * * @param version the version constant * @see SoapVersion#SOAP_11 * @see SoapVersion#SOAP_12 @@ -43,7 +43,6 @@ public interface SoapMessageFactory extends WebServiceMessageFactory { /** * Creates a new, empty {@code SoapMessage}. - * * @return the empty message */ @Override @@ -52,9 +51,9 @@ public interface SoapMessageFactory extends WebServiceMessageFactory { /** * Reads a {@link SoapMessage} from the given input stream. *

- * If the given stream is an instance of {@link org.springframework.ws.transport.TransportInputStream - * TransportInputStream}, the headers will be read from the request. - * + * If the given stream is an instance of + * {@link org.springframework.ws.transport.TransportInputStream TransportInputStream}, + * the headers will be read from the request. * @param inputStream the input stream to read the message from * @return the created message * @throws java.io.IOException if an I/O exception occurs diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapVersion.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapVersion.java index a5800fab..00019ee9 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapVersion.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/SoapVersion.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,8 @@ package org.springframework.ws.soap; import javax.xml.namespace.QName; /** - * Interface that defines a specific version of the SOAP specification. Contains properties for elements that make up a - * soap envelope. + * Interface that defines a specific version of the SOAP specification. Contains + * properties for elements that make up a soap envelope. * * @author Arjen Poutsma * @see #SOAP_11 @@ -31,8 +31,8 @@ public interface SoapVersion { /** * Represents version 1.1 of the SOAP specification. - * - * @see SOAP 1.1 specification + * @see SOAP 1.1 + * specification */ SoapVersion SOAP_11 = new SoapVersion() { @@ -129,7 +129,6 @@ public interface SoapVersion { /** * Represents version 1.2 of the SOAP specification. - * * @see SOAP 1.2 specification */ SoapVersion SOAP_12 = new SoapVersion() { @@ -252,12 +251,15 @@ public interface SoapVersion { QName getMustUnderstandAttributeName(); /** - * Returns the URI indicating that a header element is intended for the next SOAP application that processes the - * message. + * Returns the URI indicating that a header element is intended for the next SOAP + * application that processes the message. */ String getNextActorOrRoleUri(); - /** Returns the URI indicating that a header element should never be directly processed. */ + /** + * Returns the URI indicating that a header element should never be directly + * processed. + */ String getNoneActorOrRoleUri(); /** Returns the qualified name of the {@code MustUnderstand} SOAP Fault value. */ @@ -276,8 +278,9 @@ public interface SoapVersion { QName getClientOrSenderFaultName(); /** - * Returns the URI indicating that a header element should only be processed by nodes acting as the ultimate receiver - * of a message. + * Returns the URI indicating that a header element should only be processed by nodes + * acting as the ultimate receiver of a message. */ String getUltimateReceiverRoleUri(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/AddressingException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/AddressingException.java index 8c1ff1c4..c2210688 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/AddressingException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/AddressingException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public class AddressingException extends WebServiceException { public AddressingException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/client/ActionCallback.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/client/ActionCallback.java index b8125658..74c6ed89 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/client/ActionCallback.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/client/ActionCallback.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,7 +36,8 @@ import org.springframework.ws.transport.context.TransportContext; import org.springframework.ws.transport.context.TransportContextHolder; /** - * {@link WebServiceMessageCallback} implementation that sets the WS-Addressing {@code Action} header on the message. + * {@link WebServiceMessageCallback} implementation that sets the WS-Addressing + * {@code Action} header on the message. *

* A usage example with {@link org.springframework.ws.client.core.WebServiceTemplate}: * @@ -73,10 +74,10 @@ public class ActionCallback implements WebServiceMessageCallback { * Create a new {@code ActionCallback} with the given {@code Action}. *

* The {@code To} header of the outgoing message will reflect the - * {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI}. + * {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection + * URI}. *

* The {@link AddressingVersion} is set to {@link Addressing10}. - * * @param action the value of the action property to set */ public ActionCallback(String action) throws URISyntaxException { @@ -87,10 +88,10 @@ public class ActionCallback implements WebServiceMessageCallback { * Create a new {@code ActionCallback} with the given {@code Action}. *

* The {@code To} header of the outgoing message will reflect the - * {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI}. + * {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection + * URI}. *

* The {@link AddressingVersion} is set to {@link Addressing10}. - * * @param action the value of the action property to set */ public ActionCallback(URI action) { @@ -101,8 +102,8 @@ public class ActionCallback implements WebServiceMessageCallback { * Create a new {@code ActionCallback} with the given version and {@code Action}. *

* The {@code To} header of the outgoing message will reflect the - * {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI}. - * + * {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection + * URI}. * @param action the value of the action property to set * @param version the WS-Addressing version to use */ @@ -111,8 +112,8 @@ public class ActionCallback implements WebServiceMessageCallback { } /** - * Create a new {@code ActionCallback} with the given version, {@code Action}, and optional {@code To}. - * + * Create a new {@code ActionCallback} with the given version, {@code Action}, and + * optional {@code To}. * @param action the value of the action property * @param version the WS-Addressing version to use * @param to the value of the destination property @@ -154,7 +155,6 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code Action}. - * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getAction() */ public URI getAction() { @@ -163,7 +163,6 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code From}. - * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getFrom() */ public EndpointReference getFrom() { @@ -172,7 +171,6 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Sets the {@code From}. - * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getFrom() */ public void setFrom(EndpointReference from) { @@ -181,7 +179,6 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code ReplyTo}. - * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getReplyTo() */ public EndpointReference getReplyTo() { @@ -190,7 +187,6 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Sets the {@code ReplyTo}. - * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getReplyTo() */ public void setReplyTo(EndpointReference replyTo) { @@ -199,7 +195,6 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code FaultTo}. - * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getFaultTo() */ public EndpointReference getFaultTo() { @@ -208,7 +203,6 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Sets the {@code FaultTo}. - * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getFaultTo() */ public void setFaultTo(EndpointReference faultTo) { @@ -218,8 +212,9 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code Destination} for outgoing messages. *

- * Defaults to the {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI} if no - * destination was set. + * Defaults to the + * {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection + * URI} if no destination was set. */ protected URI getTo() { if (to == null && (isToHeaderRequired() || shouldInitializeTo)) { @@ -227,12 +222,14 @@ public class ActionCallback implements WebServiceMessageCallback { if (transportContext != null && transportContext.getConnection() != null) { try { return transportContext.getConnection().getUri(); - } catch (URISyntaxException ex) { + } + catch (URISyntaxException ex) { // ignore } } throw new IllegalStateException("Could not obtain connection URI from Transport Context"); - } else { + } + else { return to; } } @@ -254,8 +251,9 @@ public class ActionCallback implements WebServiceMessageCallback { Assert.isInstanceOf(SoapMessage.class, message); SoapMessage soapMessage = (SoapMessage) message; URI messageId = getMessageIdStrategy().newMessageId(soapMessage); - MessageAddressingProperties map = new MessageAddressingProperties(getTo(), getFrom(), getReplyTo(), getFaultTo(), - getAction(), messageId); + MessageAddressingProperties map = new MessageAddressingProperties(getTo(), getFrom(), getReplyTo(), + getFaultTo(), getAction(), messageId); version.addAddressingHeaders(soapMessage, map); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/EndpointReference.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/EndpointReference.java index d929f4e6..1c5f8889 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/EndpointReference.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/EndpointReference.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,9 +21,10 @@ import java.net.URI; import java.util.Collections; import java.util.List; -import org.springframework.util.Assert; import org.w3c.dom.Node; +import org.springframework.util.Assert; + /** * Represents an Endpoint Reference, as defined in the WS-Addressing specification. * @@ -42,9 +43,8 @@ public final class EndpointReference implements Serializable { private final List referenceParameters; /** - * Creates a new instance of the {@link EndpointReference} class with the given address. The reference parameters and - * properties are empty. - * + * Creates a new instance of the {@link EndpointReference} class with the given + * address. The reference parameters and properties are empty. * @param address the endpoint address */ public EndpointReference(URI address) { @@ -55,9 +55,8 @@ public final class EndpointReference implements Serializable { } /** - * Creates a new instance of the {@link EndpointReference} class with the given address, reference properties, and - * reference parameters. - * + * Creates a new instance of the {@link EndpointReference} class with the given + * address, reference properties, and reference parameters. * @param address the endpoint address * @param referenceProperties the reference properties, as a list of {@link Node} * @param referenceParameters the reference parameters, as a list of {@link Node} @@ -76,12 +75,18 @@ public final class EndpointReference implements Serializable { return address; } - /** Returns the reference properties of the endpoint, as a list of {@link Node} objects. */ + /** + * Returns the reference properties of the endpoint, as a list of {@link Node} + * objects. + */ public List getReferenceProperties() { return referenceProperties; } - /** Returns the reference parameters of the endpoint, as a list of {@link Node} objects. */ + /** + * Returns the reference parameters of the endpoint, as a list of {@link Node} + * objects. + */ public List getReferenceParameters() { return referenceParameters; } @@ -103,4 +108,5 @@ public final class EndpointReference implements Serializable { public String toString() { return address.toString(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/MessageAddressingProperties.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/MessageAddressingProperties.java index 183d98c9..8be43c0e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/MessageAddressingProperties.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/MessageAddressingProperties.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,12 +24,15 @@ import java.util.List; import org.w3c.dom.Node; /** - * Represents a set of Message Addressing Properties, as defined in the WS-Addressing specification. + * Represents a set of Message Addressing Properties, as defined in the WS-Addressing + * specification. *

- * In earlier versions of the spec, these properties were called Message Information Headers. + * In earlier versions of the spec, these properties were called Message Information + * Headers. * * @author Arjen Poutsma - * @see Message Addressing Properties + * @see Message Addressing + * Properties * @since 1.5.0 */ public final class MessageAddressingProperties implements Serializable { @@ -56,7 +59,6 @@ public final class MessageAddressingProperties implements Serializable { /** * Constructs a new {@link MessageAddressingProperties} with the given parameters. - * * @param to the value of the destination property * @param from the value of the source endpoint property * @param replyTo the value of the reply endpoint property @@ -78,8 +80,8 @@ public final class MessageAddressingProperties implements Serializable { } /** - * Constructs a new {@link MessageAddressingProperties} that forms a reply to the given EPR. - * + * Constructs a new {@link MessageAddressingProperties} that forms a reply to the + * given EPR. * @param epr the endpoint reference to create a reply for * @param action the value of the action property * @param messageId the value of the message id property @@ -143,16 +145,17 @@ public final class MessageAddressingProperties implements Serializable { } /** - * Creates a {@link MessageAddressingProperties} that can be used for creating a reply to the given - * {@link EndpointReference}. The {@link #getTo() destination} property will be populated with the - * {@link EndpointReference#getAddress() address} of the given EPR, and the {@link #getRelatesTo() relationship} - * property will be set to the {@link #getMessageId() message id} property of this instance. the action is specified, - * the - * + * Creates a {@link MessageAddressingProperties} that can be used for creating a reply + * to the given {@link EndpointReference}. The {@link #getTo() destination} property + * will be populated with the {@link EndpointReference#getAddress() address} of the + * given EPR, and the {@link #getRelatesTo() relationship} property will be set to the + * {@link #getMessageId() message id} property of this instance. the action is + * specified, the * @param epr the endpoint reference to create a reply to * @param action the action */ public MessageAddressingProperties getReplyProperties(EndpointReference epr, URI action, URI messageId) { return new MessageAddressingProperties(epr, action, messageId, this.messageId); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/messageid/MessageIdStrategy.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/messageid/MessageIdStrategy.java index 965715b0..e72ae7af 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/messageid/MessageIdStrategy.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/messageid/MessageIdStrategy.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,7 +21,8 @@ import java.net.URI; import org.springframework.ws.soap.SoapMessage; /** - * Strategy interface that encapsulates the creation and validation of WS-Addressing {@code MessageID}s. + * Strategy interface that encapsulates the creation and validation of WS-Addressing + * {@code MessageID}s. * * @author Arjen Poutsma * @since 1.5.0 @@ -30,7 +31,6 @@ public interface MessageIdStrategy { /** * Indicates whether the given {@code MessageID} value is a duplicate or not - * * @param messageId the message id * @return {@code true} if a duplicate; {@code false} otherwise */ @@ -38,7 +38,6 @@ public interface MessageIdStrategy { /** * Returns a new WS-Addressing {@code MessageID} for the given {@link SoapMessage}. - * * @param message the message to create an id for * @return the new message id */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategy.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategy.java index 4052475c..bc0b7276 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategy.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategy.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,8 +22,8 @@ import java.util.UUID; import org.springframework.ws.soap.SoapMessage; /** - * Implementation of the {@link MessageIdStrategy} interface that uses a {@link UUID} to generate a Message Id. The UUID - * is prefixed by {@code urn:uuid:}. + * Implementation of the {@link MessageIdStrategy} interface that uses a {@link UUID} to + * generate a Message Id. The UUID is prefixed by {@code urn:uuid:}. *

* Note that the {@link UUID} class is only available on Java 5 and above. * @@ -44,4 +44,5 @@ public class UuidMessageIdStrategy implements MessageIdStrategy { public URI newMessageId(SoapMessage message) { return URI.create(PREFIX + UUID.randomUUID().toString()); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionEndpointMapping.java index 5d3a44ba..89d30378 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,12 +25,14 @@ import org.springframework.util.Assert; import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; /** - * Abstract base class for WS-Addressing {@code Action}-mapped {@link org.springframework.ws.server.EndpointMapping} - * implementations. Provides infrastructure for mapping endpoints to actions. + * Abstract base class for WS-Addressing {@code Action}-mapped + * {@link org.springframework.ws.server.EndpointMapping} implementations. Provides + * infrastructure for mapping endpoints to actions. *

- * By default, this mapping creates a {@code Action} for reply messages based on the request message, plus the extra - * {@link #setOutputActionSuffix(String) suffix}, and a * By default, this mapping creates a {@code Action} for reply - * messages based on the request message, plus the extra {@link #setOutputActionSuffix(String) suffix}. + * By default, this mapping creates a {@code Action} for reply messages based on the + * request message, plus the extra {@link #setOutputActionSuffix(String) suffix}, and a * + * By default, this mapping creates a {@code Action} for reply messages based on the + * request message, plus the extra {@link #setOutputActionSuffix(String) suffix}. * * @author Arjen Poutsma * @since 1.5.0 @@ -57,7 +59,6 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn /** * Sets the suffix to add to request {@code Action}s for reply messages. - * * @see #DEFAULT_OUTPUT_ACTION_SUFFIX */ public void setOutputActionSuffix(String outputActionSuffix) { @@ -72,7 +73,6 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn /** * Sets the suffix to add to request {@code Action}s for reply fault messages. - * * @see #DEFAULT_FAULT_ACTION_SUFFIX */ public void setFaultActionSuffix(String faultActionSuffix) { @@ -97,10 +97,9 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn } /** - * Returns the address property of the given endpoint. The value of this property should match the - * {@link MessageAddressingProperties#getTo() destination} of incoming messages. May return {@code null} to ignore the - * destination. - * + * Returns the address property of the given endpoint. The value of this property + * should match the {@link MessageAddressingProperties#getTo() destination} of + * incoming messages. May return {@code null} to ignore the destination. * @param endpoint the endpoint to return the address for * @return the endpoint address; or {@code null} to ignore the destination property */ @@ -108,7 +107,6 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn /** * Looks up an endpoint instance for the given action. All keys are tried in order. - * * @param action the action URI * @return the associated endpoint instance, or {@code null} if not found */ @@ -118,11 +116,11 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn /** * Register the specified endpoint for the given action URI. - * * @param action the action the bean should be mapped to - * @param endpoint the endpoint instance or endpoint bean name String (a bean name will automatically be resolved into - * the corresponding endpoint bean) - * @throws org.springframework.beans.BeansException if the endpoint couldn't be registered + * @param endpoint the endpoint instance or endpoint bean name String (a bean name + * will automatically be resolved into the corresponding endpoint bean) + * @throws org.springframework.beans.BeansException if the endpoint couldn't be + * registered * @throws IllegalStateException if there is a conflicting endpoint registered */ protected void registerEndpoint(URI action, Object endpoint) throws BeansException, IllegalStateException { @@ -142,7 +140,8 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn throw new IllegalStateException("Cannot map endpoint [" + endpoint + "] to action [" + action + "]: There is already endpoint [" + resolvedEndpoint + "] mapped."); } - } else { + } + else { this.endpointMap.put(action, resolvedEndpoint); if (logger.isDebugEnabled()) { logger.debug("Mapped Action [" + action + "] onto endpoint [" + resolvedEndpoint + "]"); @@ -155,7 +154,8 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn URI requestAction = requestMap.getAction(); if (requestAction != null) { return URI.create(requestAction.toString() + getOutputActionSuffix()); - } else { + } + else { return null; } } @@ -165,7 +165,8 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn URI requestAction = requestMap.getAction(); if (requestAction != null) { return URI.create(requestAction.toString() + getFaultActionSuffix()); - } else { + } + else { return null; } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionMethodEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionMethodEndpointMapping.java index a93eced6..6d6c9a9f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionMethodEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionMethodEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,10 @@ import org.springframework.util.Assert; import org.springframework.ws.server.endpoint.MethodEndpoint; /** - * Abstract base class for WS-Addressing {@code Action}-mapped {@link org.springframework.ws.server.EndpointMapping} - * implementations that map to {@link MethodEndpoint}s. Provides infrastructure for mapping endpoint methods to actions. + * Abstract base class for WS-Addressing {@code Action}-mapped + * {@link org.springframework.ws.server.EndpointMapping} implementations that map to + * {@link MethodEndpoint}s. Provides infrastructure for mapping endpoint methods to + * actions. * * @author Arjen Poutsma * @since 1.5.0 @@ -33,10 +35,11 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; public abstract class AbstractActionMethodEndpointMapping extends AbstractActionEndpointMapping { /** - * Helper method that registers the methods of the given bean. This method iterates over the methods of the bean, and - * calls {@link #getActionForMethod(java.lang.reflect.Method)} for each. If this returns a URI, the method is - * registered using {@link #registerEndpoint(java.net.URI, Object)}. - * + * Helper method that registers the methods of the given bean. This method iterates + * over the methods of the bean, and calls + * {@link #getActionForMethod(java.lang.reflect.Method)} for each. If this returns a + * URI, the method is registered using + * {@link #registerEndpoint(java.net.URI, Object)}. * @see #getActionForMethod (java.lang.reflect.Method) */ protected void registerMethods(Object endpoint) { @@ -60,7 +63,6 @@ public abstract class AbstractActionMethodEndpointMapping extends AbstractAction * Return the class or interface to use for method reflection. *

* Default implementation delegates to {@link AopUtils#getTargetClass(Object)}. - * * @param endpoint the bean instance (might be an AOP proxy) * @return the bean class to expose */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java index 0dbd74bf..acba20b2 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -52,24 +52,30 @@ import org.springframework.ws.transport.WebServiceMessageSender; import org.springframework.xml.transform.TransformerObjectSupport; /** - * Abstract base class for {@link EndpointMapping} implementations that handle WS-Addressing. Besides the normal - * {@link SoapEndpointMapping} properties, this mapping has a - * {@link #setVersions(org.springframework.ws.soap.addressing.version.AddressingVersion[]) versions} property, which - * defines the WS-Addressing specifications supported. By default, these are + * Abstract base class for {@link EndpointMapping} implementations that handle + * WS-Addressing. Besides the normal {@link SoapEndpointMapping} properties, this mapping + * has a + * {@link #setVersions(org.springframework.ws.soap.addressing.version.AddressingVersion[]) + * versions} property, which defines the WS-Addressing specifications supported. By + * default, these are * {@link org.springframework.ws.soap.addressing.version.Addressing200408} and * {@link org.springframework.ws.soap.addressing.version.Addressing10}. *

- * The {@link #setMessageIdStrategy(MessageIdStrategy) messageIdStrategy} property defines the strategy to use for - * creating reply {@code MessageIDs}. By default, this is the {@link UuidMessageIdStrategy}. + * The {@link #setMessageIdStrategy(MessageIdStrategy) messageIdStrategy} property defines + * the strategy to use for creating reply {@code MessageIDs}. By default, this is the + * {@link UuidMessageIdStrategy}. *

- * The {@link #setMessageSenders(WebServiceMessageSender[]) messageSenders} are used to send out-of-band reply messages. - * If a request messages defines a non-anonymous reply address, these senders will be used to send the message. + * The {@link #setMessageSenders(WebServiceMessageSender[]) messageSenders} are used to + * send out-of-band reply messages. If a request messages defines a non-anonymous reply + * address, these senders will be used to send the message. *

- * This mapping (and all subclasses) uses an implicit WS-Addressing {@link EndpointInterceptor}, which is added in every - * {@link EndpointInvocationChain} produced. As such, this mapping does not have the standard {@code interceptors} - * property, but rather a {@link #setPreInterceptors(EndpointInterceptor[]) preInterceptors} and - * {@link #setPostInterceptors(EndpointInterceptor[]) postInterceptors} property, which are added before and after the - * implicit WS-Addressing interceptor, respectively. + * This mapping (and all subclasses) uses an implicit WS-Addressing + * {@link EndpointInterceptor}, which is added in every {@link EndpointInvocationChain} + * produced. As such, this mapping does not have the standard {@code interceptors} + * property, but rather a {@link #setPreInterceptors(EndpointInterceptor[]) + * preInterceptors} and {@link #setPostInterceptors(EndpointInterceptor[]) + * postInterceptors} property, which are added before and after the implicit WS-Addressing + * interceptor, respectively. * * @author Arjen Poutsma * @author Nate Stoddard @@ -106,8 +112,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec /** * Initializes the default implementation for this mapping's strategies: the * {@link org.springframework.ws.soap.addressing.version.Addressing200408} and - * {@link org.springframework.ws.soap.addressing.version.Addressing10} versions of the specification, and the - * {@link UuidMessageIdStrategy}. + * {@link org.springframework.ws.soap.addressing.version.Addressing10} versions of the + * specification, and the {@link UuidMessageIdStrategy}. */ protected void initDefaultStrategies() { this.versions = new AddressingVersion[] { new Addressing200408(), new Addressing10() }; @@ -149,7 +155,6 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec * Specify the order value for this mapping. *

* Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered. - * * @see org.springframework.core.Ordered#getOrder() */ public final void setOrder(int order) { @@ -157,8 +162,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } /** - * Set additional interceptors to be applied before the implicit WS-Addressing interceptor, e.g. - * {@code XwsSecurityInterceptor}. + * Set additional interceptors to be applied before the implicit WS-Addressing + * interceptor, e.g. {@code XwsSecurityInterceptor}. */ public final void setPreInterceptors(EndpointInterceptor[] preInterceptors) { Assert.notNull(preInterceptors, "'preInterceptors' must not be null"); @@ -166,8 +171,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } /** - * Set additional interceptors to be applied after the implicit WS-Addressing interceptor, e.g. - * {@code PayloadLoggingInterceptor}. + * Set additional interceptors to be applied after the implicit WS-Addressing + * interceptor, e.g. {@code PayloadLoggingInterceptor}. */ public final void setPostInterceptors(EndpointInterceptor[] postInterceptors) { Assert.notNull(postInterceptors, "'postInterceptors' must not be null"); @@ -192,9 +197,9 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } /** - * Sets a single message senders, which is used to send out-of-band reply messages. If a request messages defines a - * non-anonymous reply address, this senders will be used to send the message. - * + * Sets a single message senders, which is used to send out-of-band reply messages. If + * a request messages defines a non-anonymous reply address, this senders will be used + * to send the message. * @param messageSender the message sender */ public final void setMessageSender(WebServiceMessageSender messageSender) { @@ -203,9 +208,9 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } /** - * Sets the message senders, which are used to send out-of-band reply messages. If a request messages defines a - * non-anonymous reply address, these senders will be used to send the message. - * + * Sets the message senders, which are used to send out-of-band reply messages. If a + * request messages defines a non-anonymous reply address, these senders will be used + * to send the message. * @param messageSenders the message senders */ public final void setMessageSenders(WebServiceMessageSender[] messageSenders) { @@ -215,7 +220,6 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec /** * Returns the message senders, which are used to send out-of-band reply messages. - * * @return the message sender */ public final WebServiceMessageSender[] getMessageSenders() { @@ -225,9 +229,10 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec /** * Sets the WS-Addressing versions to be supported by this mapping. *

- * By default, this array is set to support {@link org.springframework.ws.soap.addressing.version.Addressing200408 the - * August 2004} and the {@link org.springframework.ws.soap.addressing.version.Addressing10 May 2006} versions of the - * specification. + * By default, this array is set to support + * {@link org.springframework.ws.soap.addressing.version.Addressing200408 the August + * 2004} and the {@link org.springframework.ws.soap.addressing.version.Addressing10 + * May 2006} versions of the specification. */ public final void setVersions(AddressingVersion[] versions) { this.versions = versions; @@ -240,10 +245,10 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } if (getApplicationContext() != null) { Map smartInterceptors = BeanFactoryUtils - .beansOfTypeIncludingAncestors(getApplicationContext(), SmartEndpointInterceptor.class, true, false); + .beansOfTypeIncludingAncestors(getApplicationContext(), SmartEndpointInterceptor.class, true, false); if (!smartInterceptors.isEmpty()) { this.smartInterceptors = smartInterceptors.values() - .toArray(new SmartEndpointInterceptor[smartInterceptors.size()]); + .toArray(new SmartEndpointInterceptor[smartInterceptors.size()]); } } } @@ -286,8 +291,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec List interceptors = new ArrayList(); interceptors.addAll(Arrays.asList(preInterceptors)); - AddressingEndpointInterceptor addressingInterceptor = new AddressingEndpointInterceptor(version, messageIdStrategy, - messageSenders, responseAction, faultAction); + AddressingEndpointInterceptor addressingInterceptor = new AddressingEndpointInterceptor(version, + messageIdStrategy, messageSenders, responseAction, faultAction); interceptors.add(addressingInterceptor); interceptors.addAll(Arrays.asList(postInterceptors)); @@ -299,8 +304,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } } - return new SoapEndpointInvocationChain(endpoint, interceptors.toArray(new EndpointInterceptor[interceptors.size()]), - actorsOrRoles, isUltimateReceiver); + return new SoapEndpointInvocationChain(endpoint, + interceptors.toArray(new EndpointInterceptor[interceptors.size()]), actorsOrRoles, isUltimateReceiver); } private boolean supports(AddressingVersion version, SoapMessage request) { @@ -317,8 +322,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } /** - * Returns the message senders for the given endpoint. Default implementation returns {@link #getMessageSenders()} - * + * Returns the message senders for the given endpoint. Default implementation returns + * {@link #getMessageSenders()} * @param endpoint the endpoint * @return the message senders for the given endpoint */ @@ -327,9 +332,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } /** - * Returns the message ID strategy for the given endpoint. Default implementation returns - * {@link #getMessageIdStrategy()} - * + * Returns the message ID strategy for the given endpoint. Default implementation + * returns {@link #getMessageIdStrategy()} * @param endpoint the endpoint * @return the message ID strategy for the given endpoint */ @@ -338,18 +342,17 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } /** - * Lookup an endpoint for the given {@link MessageAddressingProperties}, returning {@code null} if no specific one is - * found. This template method is called by {@link #getEndpoint(MessageContext)}. - * + * Lookup an endpoint for the given {@link MessageAddressingProperties}, returning + * {@code null} if no specific one is found. This template method is called by + * {@link #getEndpoint(MessageContext)}. * @param map the message addressing properties * @return the endpoint, or {@code null} */ protected abstract Object getEndpointInternal(MessageAddressingProperties map); /** - * Provides the WS-Addressing Action for response messages, given the endpoint, and request Message Addressing - * Properties. - * + * Provides the WS-Addressing Action for response messages, given the endpoint, and + * request Message Addressing Properties. * @param endpoint the mapped endpoint * @param requestMap the MAP for the request * @return the response Action @@ -357,9 +360,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec protected abstract URI getResponseAction(Object endpoint, MessageAddressingProperties requestMap); /** - * Provides the WS-Addressing Action for response fault messages, given the endpoint, and request Message Addressing - * Properties. - * + * Provides the WS-Addressing Action for response fault messages, given the endpoint, + * and request Message Addressing Properties. * @param endpoint the mapped endpoint * @param requestMap the MAP for the request * @return the response Action diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java index b99879d9..7e68cdb8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,6 +21,7 @@ import java.net.URI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.util.Assert; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapHeaderElement; @@ -34,8 +35,8 @@ import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.WebServiceMessageSender; /** - * {@link SoapEndpointInterceptor} implementation that deals with WS-Addressing headers. Stateful, and instantiated by - * the {@link AbstractAddressingEndpointMapping}. + * {@link SoapEndpointInterceptor} implementation that deals with WS-Addressing headers. + * Stateful, and instantiated by the {@link AbstractAddressingEndpointMapping}. * * @author Arjen Poutsma * @since 1.5.0 @@ -96,7 +97,7 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { Assert.isInstanceOf(SoapMessage.class, messageContext.getRequest()); Assert.isInstanceOf(SoapMessage.class, messageContext.getResponse()); MessageAddressingProperties requestMap = version - .getMessageAddressingProperties((SoapMessage) messageContext.getRequest()); + .getMessageAddressingProperties((SoapMessage) messageContext.getRequest()); EndpointReference replyEpr = !isFault ? requestMap.getReplyTo() : requestMap.getFaultTo(); if (handleNoneAddress(messageContext, replyEpr)) { return false; @@ -108,7 +109,8 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { version.addAddressingHeaders(reply, replyMap); if (handleAnonymousAddress(messageContext, replyEpr)) { return true; - } else { + } + else { sendOutOfBand(messageContext, replyEpr); return false; } @@ -117,8 +119,8 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { private boolean handleNoneAddress(MessageContext messageContext, EndpointReference replyEpr) { if (replyEpr == null || version.hasNoneAddress(replyEpr)) { if (logger.isDebugEnabled()) { - logger.debug("Request [" + messageContext.getRequest() + "] has [" + replyEpr + "] reply address; reply [" - + messageContext.getResponse() + "] discarded"); + logger.debug("Request [" + messageContext.getRequest() + "] has [" + replyEpr + + "] reply address; reply [" + messageContext.getResponse() + "] discarded"); } messageContext.clearResponse(); return true; @@ -150,7 +152,8 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { try (WebServiceConnection connection = messageSender.createConnection(replyEpr.getAddress())) { connection.send(messageContext.getResponse()); break; - } finally { + } + finally { messageContext.clearResponse(); } } @@ -170,10 +173,12 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { } @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {} + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) { + } @Override public boolean understands(SoapHeaderElement header) { return version.understands(header); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java index f9905c5c..6547b24a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,8 +31,9 @@ import org.springframework.ws.soap.addressing.server.annotation.Action; import org.springframework.ws.soap.addressing.server.annotation.Address; /** - * Implementation of the {@link org.springframework.ws.server.EndpointMapping} interface that uses the - * {@link Action @Action} annotation to map methods to a WS-Addressing {@code Action} header. + * Implementation of the {@link org.springframework.ws.server.EndpointMapping} interface + * that uses the {@link Action @Action} annotation to map methods to a WS-Addressing + * {@code Action} header. *

* Endpoints typically have the following form: * @@ -47,9 +48,10 @@ import org.springframework.ws.soap.addressing.server.annotation.Address; * } *

*

- * If set, the {@link Address @Address} annotation on the endpoint class should be equal to the - * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() destination} property of the - * incoming message. + * If set, the {@link Address @Address} annotation on the endpoint class should be equal + * to the + * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() + * destination} property of the incoming message. * * @author Arjen Poutsma * @author Corneil du Plessis (with thanks to Chris Bono) @@ -57,7 +59,8 @@ import org.springframework.ws.soap.addressing.server.annotation.Address; * @see Address * @since 1.5.0 */ -public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpointMapping implements SmartInitializingSingleton { +public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpointMapping + implements SmartInitializingSingleton { /** Returns the 'endpoint' annotation type. Default is {@link Endpoint}. */ protected Class getEndpointAnnotationType() { @@ -65,8 +68,8 @@ public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpoin } /** - * Returns the action value for the specified method. Default implementation looks for the {@link Action} annotation - * value. + * Returns the action value for the specified method. Default implementation looks for + * the {@link Action} annotation value. */ @Override protected URI getActionForMethod(Method method) { @@ -74,19 +77,21 @@ public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpoin if (action != null && StringUtils.hasText(action.value())) { try { return new URI(action.value()); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Invalid Action annotation [" + action.value() + "] on [" + method + "]"); + } + catch (URISyntaxException e) { + throw new IllegalArgumentException( + "Invalid Action annotation [" + action.value() + "] on [" + method + "]"); } } return null; } /** - * Returns the address property of the given {@link MethodEndpoint}, by looking for the {@link Address} annotation. - * The value of this property should match the - * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() destination} of incoming - * messages. Returns {@code null} if the anotation is not present, thus ignoring the destination property. - * + * Returns the address property of the given {@link MethodEndpoint}, by looking for + * the {@link Address} annotation. The value of this property should match the + * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() + * destination} of incoming messages. Returns {@code null} if the anotation is not + * present, thus ignoring the destination property. * @param endpoint the method endpoint to return the address for * @return the endpoint address; or {@code null} to ignore the destination property */ @@ -97,7 +102,8 @@ public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpoin Address address = AnnotationUtils.findAnnotation(endpointClass, Address.class); if (address != null && StringUtils.hasText(address.value())) { return getActionUri(address.value(), methodEndpoint); - } else { + } + else { return null; } } @@ -108,7 +114,8 @@ public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpoin Action action = methodEndpoint.getMethod().getAnnotation(Action.class); if (action != null && StringUtils.hasText(action.output())) { return getActionUri(action.output(), methodEndpoint); - } else { + } + else { return super.getResponseAction(endpoint, map); } } @@ -119,7 +126,8 @@ public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpoin Action action = methodEndpoint.getMethod().getAnnotation(Action.class); if (action != null && StringUtils.hasText(action.fault())) { return getActionUri(action.fault(), methodEndpoint); - } else { + } + else { return super.getResponseAction(endpoint, map); } } @@ -127,13 +135,18 @@ public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpoin private URI getActionUri(String action, MethodEndpoint methodEndpoint) { try { return new URI(action); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Invalid Action annotation [" + action + "] on [" + methodEndpoint + "]"); + } + catch (URISyntaxException e) { + throw new IllegalArgumentException( + "Invalid Action annotation [" + action + "] on [" + methodEndpoint + "]"); } } public void afterSingletonsInstantiated() { - this.getApplicationContext().getBeansWithAnnotation(this.getEndpointAnnotationType()) - .values().forEach(this::registerMethods); + this.getApplicationContext() + .getBeansWithAnnotation(this.getEndpointAnnotationType()) + .values() + .forEach(this::registerMethods); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/SimpleActionEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/SimpleActionEndpointMapping.java index 60f7b12c..a9007693 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/SimpleActionEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/SimpleActionEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,14 +25,15 @@ import java.util.Properties; import org.springframework.beans.BeansException; /** - * Implementation of the {@code EndpointMapping} interface to map from WS-Addressing {@code Action} Message Addressing - * Property to endpoint beans. Supports both mapping to bean instances and mapping to bean names. + * Implementation of the {@code EndpointMapping} interface to map from WS-Addressing + * {@code Action} Message Addressing Property to endpoint beans. Supports both mapping to + * bean instances and mapping to bean names. *

- * The {@code endpointMap} property is suitable for populating the endpoint map with bean references, e.g. via the map - * element in XML bean definitions. + * The {@code endpointMap} property is suitable for populating the endpoint map with bean + * references, e.g. via the map element in XML bean definitions. *

- * Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the - * {@code java.util.Properties} class, like as follows: + * Mappings to bean names can be set via the {@code mappings} property, in a form accepted + * by the {@code java.util.Properties} class, like as follows: * *

  * http://www.springframework.org/spring-ws/samples/airline/BookFlight=bookFlightEndpoint
@@ -42,9 +43,10 @@ import org.springframework.beans.BeansException;
  * The syntax is WS_ADDRESSING_ACTION=ENDPOINT_BEAN_NAME.
  * 

* If set, the {@link #setAddress(URI) address} property should be equal to the - * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() destination} property of the - * incominging message. As such, it can be used to create multiple Endpoint References, by defining multiple - * {@code SimpleActionEndpointMapping} bean definitions with different {@code address} property values. + * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() + * destination} property of the incominging message. As such, it can be used to create + * multiple Endpoint References, by defining multiple {@code SimpleActionEndpointMapping} + * bean definitions with different {@code address} property values. * * @author Arjen Poutsma * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getAction() @@ -58,8 +60,8 @@ public class SimpleActionEndpointMapping extends AbstractActionEndpointMapping { private URI address; /** - * Map action URIs to endpoint bean names. This is the typical way of configuring this EndpointMapping. - * + * Map action URIs to endpoint bean names. This is the typical way of configuring this + * EndpointMapping. * @param mappings properties with URLs as keys and bean names as values * @see #setActionMap(java.util.Map) */ @@ -68,9 +70,8 @@ public class SimpleActionEndpointMapping extends AbstractActionEndpointMapping { } /** - * Set a Map with action URIs as keys and handler beans (or handler bean names) as values. Convenient for population - * with bean references. - * + * Set a Map with action URIs as keys and handler beans (or handler bean names) as + * values. Convenient for population with bean references. * @param actionMap map with action URIs as keys and beans as values * @see #setMappings */ @@ -79,9 +80,11 @@ public class SimpleActionEndpointMapping extends AbstractActionEndpointMapping { URI action; if (entry.getKey() instanceof String) { action = new URI((String) entry.getKey()); - } else if (entry.getKey() instanceof URI) { + } + else if (entry.getKey() instanceof URI) { action = (URI) entry.getKey(); - } else { + } + else { throw new IllegalArgumentException("Invalid key [" + entry.getKey() + "]; expected String or URI"); } this.actionMap.put(action, entry.getValue()); @@ -90,9 +93,8 @@ public class SimpleActionEndpointMapping extends AbstractActionEndpointMapping { /** * Set the address property. If set, value of this property is compared to the - * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() destination} property of the - * incominging message. - * + * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() + * destination} property of the incominging message. * @param address the address URI */ public void setAddress(URI address) { @@ -107,15 +109,16 @@ public class SimpleActionEndpointMapping extends AbstractActionEndpointMapping { /** * Register all endpoints specified in the action map. - * - * @param actionMap Map with action URIs as keys and endppint beans or bean names as values + * @param actionMap Map with action URIs as keys and endppint beans or bean names as + * values * @throws BeansException if an endpoint couldn't be registered * @throws IllegalStateException if there is a conflicting endpoint registered */ protected void registerEndpoints(Map actionMap) throws BeansException { if (actionMap.isEmpty()) { logger.warn("Neither 'actionMap' nor 'mappings' set on SimpleActionEndpointMapping"); - } else { + } + else { for (Map.Entry entry : actionMap.entrySet()) { URI action = entry.getKey(); Object endpoint = entry.getValue(); @@ -132,4 +135,5 @@ public class SimpleActionEndpointMapping extends AbstractActionEndpointMapping { protected URI getEndpointAddress(Object endpoint) { return address; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Action.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Action.java index 5c1b1bc6..79d8f183 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Action.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Action.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marks an endpoint method as the handler for an incoming request. The annotation value signifies the value for the - * request WS-Addressing {@code Action} header that is handled by the method. + * Marks an endpoint method as the handler for an incoming request. The annotation value + * signifies the value for the request WS-Addressing {@code Action} header that is handled + * by the method. * * @author Arjen Poutsma * @since 1.5.0 @@ -35,17 +36,20 @@ import java.lang.annotation.Target; public @interface Action { /** - * Signifies the value for the request WS-Addressing {@code Action} header that is handled by the method. + * Signifies the value for the request WS-Addressing {@code Action} header that is + * handled by the method. */ String value(); /** - * Signifies the value for the response WS-Addressing {@code Action} header that is provided by the method. + * Signifies the value for the response WS-Addressing {@code Action} header that is + * provided by the method. */ String output() default ""; /** - * Signifies the value for the fault response WS-Addressing {@code Action} header that is provided by the method. + * Signifies the value for the fault response WS-Addressing {@code Action} header that + * is provided by the method. */ String fault() default ""; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Address.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Address.java index bde1cb9e..11f2e681 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Address.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Address.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marks an endpoint with a WS-Addressing {@code Address}. If this annotation is applied, the {@linkplain #value() - * value} is compared to the {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() + * Marks an endpoint with a WS-Addressing {@code Address}. If this annotation is applied, + * the {@linkplain #value() value} is compared to the + * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() * destination} property of the incoming message. * * @author Arjen Poutsma @@ -36,7 +37,8 @@ import java.lang.annotation.Target; public @interface Address { /** - * Signifies the value for the request WS-Addressing destination that is handled by the class. + * Signifies the value for the request WS-Addressing destination that is handled by + * the class. */ String value(); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/AbstractAddressingVersion.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/AbstractAddressingVersion.java index 76279fc8..9bcbefab 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/AbstractAddressingVersion.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/AbstractAddressingVersion.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,6 +34,10 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + import org.springframework.util.StringUtils; import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapHeader; @@ -50,13 +54,10 @@ import org.springframework.xml.namespace.QNameUtils; import org.springframework.xml.transform.TransformerObjectSupport; import org.springframework.xml.xpath.XPathExpression; import org.springframework.xml.xpath.XPathExpressionFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; /** - * Abstract base class for {@link AddressingVersion} implementations. Uses {@link XPathExpression}s to retrieve - * addressing information. + * Abstract base class for {@link AddressingVersion} implementations. Uses + * {@link XPathExpression}s to retrieve addressing information. * * @author Arjen Poutsma * @since 1.5.0 @@ -95,12 +96,14 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport addressExpression = createNormalizedExpression(getAddressName(), namespaces); if (getReferencePropertiesName() != null) { referencePropertiesExpression = createChildrenExpression(getReferencePropertiesName(), namespaces); - } else { + } + else { referencePropertiesExpression = null; } if (getReferenceParametersName() != null) { referenceParametersExpression = createChildrenExpression(getReferenceParametersName(), namespaces); - } else { + } + else { referenceParametersExpression = null; } } @@ -148,7 +151,8 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport } try { return new URI(messageId); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { return null; } } @@ -166,7 +170,8 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport transform(source, domResult); Document document = (Document) domResult.getNode(); return document.getDocumentElement(); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new AddressingException("Could not transform SoapHeader to Document", ex); } } @@ -181,11 +186,9 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport return null; } List referenceProperties = referencePropertiesExpression != null - ? referencePropertiesExpression.evaluateAsNodeList(node) - : Collections.emptyList(); + ? referencePropertiesExpression.evaluateAsNodeList(node) : Collections.emptyList(); List referenceParameters = referenceParametersExpression != null - ? referenceParametersExpression.evaluateAsNodeList(node) - : Collections.emptyList(); + ? referenceParametersExpression.evaluateAsNodeList(node) : Collections.emptyList(); return new EndpointReference(address, referenceProperties, referenceParameters); } @@ -258,9 +261,11 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport addReferenceNodes(new DOMResult(referenceProps), epr.getReferenceProperties()); transform(new DOMSource(referenceProps), headerElement.getResult()); } - } catch (ParserConfigurationException ex) { + } + catch (ParserConfigurationException ex) { throw new AddressingException("Could not add Endpoint Reference [" + epr + "] to header element", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new AddressingException("Could not add reference properties/parameters to message", ex); } } @@ -271,7 +276,8 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport DOMSource source = new DOMSource(node); transform(source, result); } - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new AddressingException("Could not add reference properties/parameters to message", ex); } } @@ -292,7 +298,8 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport if (message.getSoapBody() instanceof Soap11Body) { Soap11Body soapBody = (Soap11Body) message.getSoapBody(); return soapBody.addFault(subcode, reason, Locale.ENGLISH); - } else if (message.getSoapBody() instanceof Soap12Body) { + } + else if (message.getSoapBody() instanceof Soap12Body) { Soap12Body soapBody = (Soap12Body) message.getSoapBody(); Soap12Fault soapFault = soapBody.addClientOrSenderFault(reason, Locale.ENGLISH); soapFault.addFaultSubcode(subcode); @@ -301,9 +308,7 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport return null; } - /* - * Address URIs - */ + // Address URIs @Override public final boolean hasAnonymousAddress(EndpointReference epr) { @@ -317,7 +322,10 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport return none != null && none.equals(epr.getAddress()); } - /** Returns the prefix associated with the WS-Addressing namespace handled by this specification. */ + /** + * Returns the prefix associated with the WS-Addressing namespace handled by this + * specification. + */ protected String getNamespacePrefix() { return "wsa"; } @@ -370,16 +378,18 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport } /** - * Returns the qualified name of the {@code ReferenceProperties} in the endpoint reference. Returns {@code null} when - * reference properties are not supported by this version of the spec. + * Returns the qualified name of the {@code ReferenceProperties} in the endpoint + * reference. Returns {@code null} when reference properties are not supported by this + * version of the spec. */ protected QName getReferencePropertiesName() { return new QName(getNamespaceUri(), "ReferenceProperties", getNamespacePrefix()); } /** - * Returns the qualified name of the {@code ReferenceParameters} in the endpoint reference. Returns {@code null} when - * reference parameters are not supported by this version of the spec. + * Returns the qualified name of the {@code ReferenceParameters} in the endpoint + * reference. Returns {@code null} when reference parameters are not supported by this + * version of the spec. */ protected QName getReferenceParametersName() { return new QName(getNamespaceUri(), "ReferenceParameters", getNamespacePrefix()); @@ -397,7 +407,10 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport /** Returns the default To URI. */ protected abstract URI getDefaultTo(); - /** Returns the default ReplyTo EPR. Can be based on the From EPR, or the anonymous URI. */ + /** + * Returns the default ReplyTo EPR. Can be based on the From EPR, or the anonymous + * URI. + */ protected abstract EndpointReference getDefaultReplyTo(EndpointReference from); /* @@ -414,15 +427,22 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport * Faults */ - /** Returns the qualified name of the fault subcode that indicates that a header is missing. */ + /** + * Returns the qualified name of the fault subcode that indicates that a header is + * missing. + */ protected abstract QName getMessageAddressingHeaderRequiredFaultSubcode(); /** Returns the reason of the fault that indicates that a header is missing. */ protected abstract String getMessageAddressingHeaderRequiredFaultReason(); - /** Returns the qualified name of the fault subcode that indicates that a header is invalid. */ + /** + * Returns the qualified name of the fault subcode that indicates that a header is + * invalid. + */ protected abstract QName getInvalidAddressingHeaderFaultSubcode(); /** Returns the reason of the fault that indicates that a header is invalid. */ protected abstract String getInvalidAddressingHeaderFaultReason(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/Addressing10.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/Addressing10.java index bc07d2d8..fac84db2 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/Addressing10.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/Addressing10.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,12 +26,13 @@ import org.springframework.ws.soap.addressing.core.EndpointReference; import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; /** - * Implements WS-Addressing 1.0 (May 2006). This version of the specification is used by Microsoft's Windows - * Communication Foundation (WCF), and supported by Axis 1 and 2. + * Implements WS-Addressing 1.0 (May 2006). This version of the specification is used by + * Microsoft's Windows Communication Foundation (WCF), and supported by Axis 1 and 2. * * @author Arjen Poutsma * @author Leandro Quiroga - * @see Web Services Addressing 1.0, May 2006 + * @see Web Services + * Addressing 1.0, May 2006 * @since 1.5.0 */ @@ -115,4 +116,5 @@ public class Addressing10 extends AbstractAddressingVersion { public String toString() { return "WS-Addressing 1.0"; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/Addressing200408.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/Addressing200408.java index d545bdec..f3550bbc 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/Addressing200408.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/Addressing200408.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,13 +26,14 @@ import org.springframework.ws.soap.addressing.core.EndpointReference; import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; /** - * Implements the August 2004 edition of the WS-Addressing specification. This version of the specification is used by - * Microsoft's Web Services Enhancements (WSE) 3.0, and supported by Axis 1 and 2, and XFire. + * Implements the August 2004 edition of the WS-Addressing specification. This version of + * the specification is used by Microsoft's Web Services Enhancements (WSE) 3.0, and + * supported by Axis 1 and 2, and XFire. * * @author Arjen Poutsma * @author Leandro Quiroga - * @see Web Services Addressing, August - * 2004 + * @see Web + * Services Addressing, August 2004 * @since 1.5.0 */ public class Addressing200408 extends AbstractAddressingVersion { @@ -113,4 +114,5 @@ public class Addressing200408 extends AbstractAddressingVersion { public String toString() { return "WS-Addressing August 2004"; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/AddressingVersion.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/AddressingVersion.java index 6a80b655..57cbf0b2 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/AddressingVersion.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/version/AddressingVersion.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,81 +32,79 @@ import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; public interface AddressingVersion { /** - * Returns the {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties} for the given message. - * + * Returns the + * {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties} for + * the given message. * @param message the message to find the map for * @return the message addressing properties - * @see Message Addressing Properties + * @see Message Addressing + * Properties */ MessageAddressingProperties getMessageAddressingProperties(SoapMessage message); /** - * Adds addressing SOAP headers to the given message, using the given {@link MessageAddressingProperties}. - * + * Adds addressing SOAP headers to the given message, using the given + * {@link MessageAddressingProperties}. * @param message the message to add the headers to * @param map the message addressing properties */ void addAddressingHeaders(SoapMessage message, MessageAddressingProperties map); /** - * Given a {@code SoapHeaderElement}, return whether or not this version understands it. - * + * Given a {@code SoapHeaderElement}, return whether or not this version understands + * it. * @param headerElement the header * @return {@code true} if understood, {@code false} otherwise */ boolean understands(SoapHeaderElement headerElement); /** - * Indicates whether the given {@link MessageAddressingProperties} has all required properties. - * - * @return {@code true} if the to and action properties have been set, and - if a reply or fault endpoint has been set - * - also checks for the message id + * Indicates whether the given {@link MessageAddressingProperties} has all required + * properties. + * @return {@code true} if the to and action properties have been set, and - if a + * reply or fault endpoint has been set - also checks for the message id */ boolean hasRequiredProperties(MessageAddressingProperties map); /** * Indicates whether the {@literal wsa:To} header is {@literal REQUIRED} or not. - * - * @return {@code true} if the wsa:To header of the {@link AddressingVersion} is REQUIRED. + * @return {@code true} if the wsa:To header of the {@link AddressingVersion} is + * REQUIRED. * @since 4.0 */ boolean isToHeaderRequired(); - /* - * Address URIs - */ + // Address URIs /** - * Indicates whether the given endpoint reference has a Anonymous address. This address is used to indicate that a - * message should be sent in-band. - * - * @see Formulating a Reply Message + * Indicates whether the given endpoint reference has a Anonymous address. This + * address is used to indicate that a message should be sent in-band. + * @see Formulating a Reply + * Message */ boolean hasAnonymousAddress(EndpointReference epr); /** - * Indicates whether the given endpoint reference has a None address. Messages to be sent to this address will not be - * sent. - * - * @see Sending a Message to an EPR + * Indicates whether the given endpoint reference has a None address. Messages to be + * sent to this address will not be sent. + * @see Sending a Message to + * an EPR */ boolean hasNoneAddress(EndpointReference epr); - /* - * Faults - */ + // Faults /** * Adds a Invalid Addressing Header fault to the given message. - * - * @see Invalid Addressing Header + * @see Invalid + * Addressing Header */ SoapFault addInvalidAddressingHeaderFault(SoapMessage message); /** * Adds a Message Addressing Header Required fault to the given message. - * - * @see Message Addressing Header Required + * @see Message + * Addressing Header Required */ SoapFault addMessageAddressingHeaderRequiredFault(SoapMessage message); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/client/SoapFaultClientException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/client/SoapFaultClientException.java index 0ba93c4c..12e6ccf1 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/client/SoapFaultClientException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/client/SoapFaultClientException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,7 +36,6 @@ public class SoapFaultClientException extends WebServiceFaultException { /** * Create a new instance of the {@code SoapFaultClientException} class. - * * @param faultMessage the fault message */ public SoapFaultClientException(SoapMessage faultMessage) { @@ -56,8 +55,8 @@ public class SoapFaultClientException extends WebServiceFaultException { } /** - * Returns the fault string or reason. For SOAP 1.1, this returns the fault string. For SOAP 1.2, this returns the - * fault reason for the default locale. + * Returns the fault string or reason. For SOAP 1.1, this returns the fault string. + * For SOAP 1.2, this returns the fault reason for the default locale. *

* Note that this message returns the same as {@link #getMessage()}. */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/client/core/SoapActionCallback.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/client/core/SoapActionCallback.java index b8a202f7..7f304fc4 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/client/core/SoapActionCallback.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/client/core/SoapActionCallback.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,7 +25,8 @@ import org.springframework.ws.client.core.WebServiceMessageCallback; import org.springframework.ws.soap.SoapMessage; /** - * {@link WebServiceMessageCallback} implementation that sets the SOAP Action header on the message. + * {@link WebServiceMessageCallback} implementation that sets the SOAP Action header on + * the message. *

* A usage example with {@link org.springframework.ws.client.core.WebServiceTemplate}: * diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/client/core/SoapFaultMessageResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/client/core/SoapFaultMessageResolver.java index d4311393..bfa9666e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/client/core/SoapFaultMessageResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/client/core/SoapFaultMessageResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,7 +24,8 @@ import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.client.SoapFaultClientException; /** - * Simple fault resolver that simply throws a {@link SoapFaultClientException} when a fault occurs. + * Simple fault resolver that simply throws a {@link SoapFaultClientException} when a + * fault occurs. * * @author Arjen Poutsma * @see SoapFaultClientException @@ -37,4 +38,5 @@ public class SoapFaultMessageResolver implements FaultMessageResolver { SoapMessage soapMessage = (SoapMessage) message; throw new SoapFaultClientException(soapMessage); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajAttachment.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajAttachment.java index 02f1a68d..2dbb7da5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajAttachment.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajAttachment.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,19 @@ package org.springframework.ws.soap.saaj; +import java.io.IOException; +import java.io.InputStream; + import jakarta.activation.DataHandler; import jakarta.xml.soap.AttachmentPart; import jakarta.xml.soap.SOAPException; -import java.io.IOException; -import java.io.InputStream; - import org.springframework.util.Assert; import org.springframework.ws.mime.Attachment; /** - * SAAJ-specific implementation of the {@code Attachment} interface. Wraps a {@link jakarta.xml.soap.AttachmentPart}. + * SAAJ-specific implementation of the {@code Attachment} interface. Wraps a + * {@link jakarta.xml.soap.AttachmentPart}. * * @author Arjen Poutsma * @since 1.0.0 @@ -55,7 +56,8 @@ class SaajAttachment implements Attachment { public InputStream getInputStream() throws IOException { try { return saajAttachment.getDataHandler().getInputStream(); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } @@ -64,7 +66,8 @@ class SaajAttachment implements Attachment { public long getSize() { try { return saajAttachment.getSize(); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } @@ -73,8 +76,10 @@ class SaajAttachment implements Attachment { public DataHandler getDataHandler() { try { return saajAttachment.getDataHandler(); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajAttachmentException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajAttachmentException.java index bb33bb69..87f563c1 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajAttachmentException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajAttachmentException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,7 +18,9 @@ package org.springframework.ws.soap.saaj; import org.springframework.ws.mime.AttachmentException; -/** @author Arjen Poutsma */ +/** + * @author Arjen Poutsma + */ @SuppressWarnings("serial") public class SaajAttachmentException extends AttachmentException { @@ -33,4 +35,5 @@ public class SaajAttachmentException extends AttachmentException { public SaajAttachmentException(Throwable ex) { super(ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java index 2c1748c8..b11b70d7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,22 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.SOAPBody; -import jakarta.xml.soap.SOAPException; -import jakarta.xml.soap.SOAPFault; - import java.util.Locale; import javax.xml.namespace.QName; +import jakarta.xml.soap.SOAPBody; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPFault; + import org.springframework.util.Assert; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.soap11.Soap11Body; import org.springframework.ws.soap.soap11.Soap11Fault; /** - * SAAJ-specific implementation of the {@code Soap11Body} interface. Wraps a {@link jakarta.xml.soap.SOAPBody}. + * SAAJ-specific implementation of the {@code Soap11Body} interface. Wraps a + * {@link jakarta.xml.soap.SOAPBody}. * * @author Arjen Poutsma * @since 1.0.0 @@ -65,12 +66,14 @@ class SaajSoap11Body extends SaajSoapBody implements Soap11Body { SOAPFault result; if (faultStringLocale == null) { result = body.addFault(faultCode, faultString); - } else { + } + else { result = body.addFault(faultCode, faultString, faultStringLocale); } SOAPFault saajFault = result; return new SaajSoap11Fault(saajFault); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Fault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Fault.java index a930509e..652d099a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Fault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Fault.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,16 @@ package org.springframework.ws.soap.saaj; +import java.util.Locale; + import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPFault; -import java.util.Locale; - import org.springframework.ws.soap.soap11.Soap11Fault; /** - * SAAJ-specific implementation of the {@code Soap11Fault} interface. Wraps a {@link jakarta.xml.soap.SOAPFault}. + * SAAJ-specific implementation of the {@code Soap11Fault} interface. Wraps a + * {@link jakarta.xml.soap.SOAPFault}. * * @author Arjen Poutsma * @since 1.0.0 @@ -44,7 +45,8 @@ class SaajSoap11Fault extends SaajSoapFault implements Soap11Fault { public void setFaultActorOrRole(String faultActor) { try { getSaajFault().setFaultActor(faultActor); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } @@ -58,4 +60,5 @@ class SaajSoap11Fault extends SaajSoapFault implements Soap11Fault { public Locale getFaultStringLocale() { return getSaajFault().getFaultStringLocale(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Header.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Header.java index 9c61e203..db68692a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Header.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Header.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,22 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPHeader; -import jakarta.xml.soap.SOAPHeaderElement; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPHeader; +import jakarta.xml.soap.SOAPHeaderElement; + import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.soap11.Soap11Header; /** - * SAAJ-specific implementation of the {@code Soap11Header} interface. Wraps a {@link jakarta.xml.soap.SOAPHeader}. + * SAAJ-specific implementation of the {@code Soap11Header} interface. Wraps a + * {@link jakarta.xml.soap.SOAPHeader}. * * @author Arjen Poutsma * @since 1.0.0 @@ -72,4 +73,5 @@ class SaajSoap11Header extends SaajSoapHeader implements Soap11Header { } return false; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java index 7772416b..6011c058 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Body.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,22 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.SOAPBody; -import jakarta.xml.soap.SOAPException; -import jakarta.xml.soap.SOAPFault; - import java.util.Locale; import javax.xml.namespace.QName; +import jakarta.xml.soap.SOAPBody; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPFault; + import org.springframework.util.Assert; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.soap12.Soap12Body; import org.springframework.ws.soap.soap12.Soap12Fault; /** - * SAAJ-specific implementation of the {@code Soap12Body} interface. Wraps a {@link jakarta.xml.soap.SOAPBody}. + * SAAJ-specific implementation of the {@code Soap12Body} interface. Wraps a + * {@link jakarta.xml.soap.SOAPBody}. * * @author Arjen Poutsma * @since 1.0.0 @@ -88,12 +89,14 @@ class SaajSoap12Body extends SaajSoapBody implements Soap12Body { SOAPFault result; if (faultStringLocale == null) { result = body.addFault(faultCode, faultString); - } else { + } + else { result = body.addFault(faultCode, faultString, faultStringLocale); } SOAPFault saajFault = result; return new SaajSoap12Fault(saajFault); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Fault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Fault.java index ee84818d..66ef0c8a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Fault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Fault.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,14 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.SOAPException; -import jakarta.xml.soap.SOAPFault; - import java.util.Iterator; import java.util.Locale; import javax.xml.namespace.QName; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPFault; + import org.springframework.ws.soap.soap12.Soap12Fault; /** @@ -45,7 +45,8 @@ class SaajSoap12Fault extends SaajSoapFault implements Soap12Fault { public void setFaultActorOrRole(String faultRole) { try { getSaajFault().setFaultRole(faultRole); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } @@ -60,7 +61,8 @@ class SaajSoap12Fault extends SaajSoapFault implements Soap12Fault { public void addFaultSubcode(QName subcode) { try { getSaajFault().appendFaultSubcode(subcode); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } @@ -74,7 +76,8 @@ class SaajSoap12Fault extends SaajSoapFault implements Soap12Fault { public void setFaultNode(String uri) { try { getSaajFault().setFaultNode(uri); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } @@ -84,7 +87,8 @@ class SaajSoap12Fault extends SaajSoapFault implements Soap12Fault { public void setFaultReasonText(Locale locale, String text) { try { getSaajFault().addFaultReasonText(text, locale); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } @@ -94,7 +98,8 @@ class SaajSoap12Fault extends SaajSoapFault implements Soap12Fault { public String getFaultReasonText(Locale locale) { try { return getSaajFault().getFaultReasonText(locale); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } @@ -103,4 +108,5 @@ class SaajSoap12Fault extends SaajSoapFault implements Soap12Fault { public String getFaultStringOrReason() { return getSaajFault().getFaultString(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Header.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Header.java index 6282a10e..45534adb 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Header.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap12Header.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,17 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPException; -import jakarta.xml.soap.SOAPHeader; -import jakarta.xml.soap.SOAPHeaderElement; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.xml.namespace.QName; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPHeader; +import jakarta.xml.soap.SOAPHeaderElement; + import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import org.springframework.ws.soap.SoapHeaderElement; @@ -34,7 +34,8 @@ import org.springframework.ws.soap.SoapHeaderException; import org.springframework.ws.soap.soap12.Soap12Header; /** - * SAAJ-specific implementation of the {@code Soap12Header} interface. Wraps a {@link jakarta.xml.soap.SOAPHeader}. + * SAAJ-specific implementation of the {@code Soap12Header} interface. Wraps a + * {@link jakarta.xml.soap.SOAPHeader}. * * @author Arjen Poutsma * @since 1.0.0 @@ -50,7 +51,8 @@ class SaajSoap12Header extends SaajSoapHeader implements Soap12Header { try { SOAPHeaderElement headerElement = getSaajHeader().addNotUnderstoodHeaderElement(headerName); return new SaajSoapHeaderElement(headerElement); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapHeaderException(ex); } } @@ -60,7 +62,8 @@ class SaajSoap12Header extends SaajSoapHeader implements Soap12Header { try { SOAPHeaderElement headerElement = getSaajHeader().addUpgradeHeaderElement(supportedSoapUris); return new SaajSoapHeaderElement(headerElement); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapHeaderException(ex); } } @@ -104,4 +107,5 @@ class SaajSoap12Header extends SaajSoapHeader implements Soap12Header { } return false; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java index a81311cc..84257092 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBody.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,20 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.SOAPBody; -import jakarta.xml.soap.SOAPElement; - import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; +import jakarta.xml.soap.SOAPBody; +import jakarta.xml.soap.SOAPElement; + import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.saaj.support.SaajUtils; /** - * SAAJ-specific abstract base class of the {@code SoapBody} interface. Wraps a {@link jakarta.xml.soap.SOAPBody}. + * SAAJ-specific abstract base class of the {@code SoapBody} interface. Wraps a + * {@link jakarta.xml.soap.SOAPBody}. * * @author Arjen Poutsma * @since 1.0.0 diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBodyException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBodyException.java index 3c800b5c..0ed4ecb8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBodyException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapBodyException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,7 +18,9 @@ package org.springframework.ws.soap.saaj; import org.springframework.ws.soap.SoapBodyException; -/** @author Arjen Poutsma */ +/** + * @author Arjen Poutsma + */ @SuppressWarnings("serial") public class SaajSoapBodyException extends SoapBodyException { @@ -33,4 +35,5 @@ public class SaajSoapBodyException extends SoapBodyException { public SaajSoapBodyException(Throwable ex) { super(ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElement.java index 2b61f65b..af1daa24 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElement.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,20 +16,21 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.SOAPElement; -import jakarta.xml.soap.SOAPException; - import java.util.Iterator; import javax.xml.namespace.QName; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; +import jakarta.xml.soap.SOAPElement; +import jakarta.xml.soap.SOAPException; + import org.springframework.util.Assert; import org.springframework.ws.soap.SoapElement; /** - * SAAJ-specific implementation of the {@code SoapElement} interface. Wraps a {@link jakarta.xml.soap.SOAPElement}. + * SAAJ-specific implementation of the {@code SoapElement} interface. Wraps a + * {@link jakarta.xml.soap.SOAPElement}. * * @author Arjen Poutsma * @since 1.0.0 @@ -57,7 +58,8 @@ class SaajSoapElement implements SoapElement { public void addAttribute(QName name, String value) { try { element.addAttribute(name, value); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapElementException(ex); } } @@ -82,7 +84,8 @@ class SaajSoapElement implements SoapElement { public void addNamespaceDeclaration(String prefix, String namespaceUri) { try { element.addNamespaceDeclaration(prefix, namespaceUri); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapElementException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElementException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElementException.java index 8f740055..56458267 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElementException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapElementException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,7 +18,9 @@ package org.springframework.ws.soap.saaj; import org.springframework.ws.soap.SoapElementException; -/** @author Arjen Poutsma */ +/** + * @author Arjen Poutsma + */ @SuppressWarnings("serial") public class SaajSoapElementException extends SoapElementException { @@ -33,4 +35,5 @@ public class SaajSoapElementException extends SoapElementException { public SaajSoapElementException(Throwable ex) { super(ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java index 5c368e64..d23e0f38 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,7 +27,8 @@ import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapVersion; /** - * SAAJ-specific implementation of the {@code SoapEnvelope} interface. Wraps a {@link jakarta.xml.soap.SOAPEnvelope}. + * SAAJ-specific implementation of the {@code SoapEnvelope} interface. Wraps a + * {@link jakarta.xml.soap.SOAPEnvelope}. * * @author Arjen Poutsma * @since 1.0.0 @@ -53,12 +54,16 @@ class SaajSoapEnvelope extends SaajSoapElement implements SoapEnve if (saajBody == null) { throw new SaajSoapBodyException("SAAJ SOAP message has no body"); } - if (saajBody.getElementQName().getNamespaceURI().equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) { + if (saajBody.getElementQName() + .getNamespaceURI() + .equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) { body = new SaajSoap11Body(saajBody, langAttributeOnSoap11FaultString); - } else { + } + else { body = new SaajSoap12Body(saajBody); } - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapBodyException(ex); } } @@ -71,15 +76,20 @@ class SaajSoapEnvelope extends SaajSoapElement implements SoapEnve try { SOAPHeader saajHeader = getSaajEnvelope().getHeader(); if (saajHeader != null) { - if (saajHeader.getElementQName().getNamespaceURI().equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) { + if (saajHeader.getElementQName() + .getNamespaceURI() + .equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) { header = new SaajSoap11Header(saajHeader); - } else { + } + else { header = new SaajSoap12Header(saajHeader); } - } else { + } + else { header = null; } - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapHeaderException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelopeException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelopeException.java index 1789795a..4ce49bba 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelopeException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelopeException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,4 +36,5 @@ public class SaajSoapEnvelopeException extends SoapEnvelopeException { public SaajSoapEnvelopeException(Throwable ex) { super(ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java index 33cff23f..7b749121 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,18 @@ package org.springframework.ws.soap.saaj; +import javax.xml.namespace.QName; + import jakarta.xml.soap.Detail; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPFault; -import javax.xml.namespace.QName; - import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapFaultDetail; /** - * SAAJ-specific abstract base class of the {@code SoapFault} interface. Wraps a {@link jakarta.xml.soap.SOAPFault}. + * SAAJ-specific abstract base class of the {@code SoapFault} interface. Wraps a + * {@link jakarta.xml.soap.SOAPFault}. * * @author Arjen Poutsma * @since 1.0.0 @@ -57,8 +58,10 @@ abstract class SaajSoapFault extends SaajSoapElement implements SoapF try { Detail saajDetail = getSaajFault().addDetail(); return new SaajSoapFaultDetail(saajDetail); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java index e0b5b868..04b9f36a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetail.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,17 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.Detail; -import jakarta.xml.soap.DetailEntry; -import jakarta.xml.soap.SOAPException; -import jakarta.xml.soap.SOAPFaultElement; - import java.util.Iterator; import javax.xml.namespace.QName; import javax.xml.transform.Result; import javax.xml.transform.dom.DOMResult; +import jakarta.xml.soap.Detail; +import jakarta.xml.soap.DetailEntry; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPFaultElement; + import org.springframework.util.Assert; import org.springframework.ws.soap.SoapFaultDetail; import org.springframework.ws.soap.SoapFaultDetailElement; @@ -54,7 +54,8 @@ class SaajSoapFaultDetail extends SaajSoapElement implements S try { DetailEntry detailEntry = getSaajDetail().addDetailEntry(name); return new SaajSoapFaultDetailElement(detailEntry); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } @@ -94,6 +95,7 @@ class SaajSoapFaultDetail extends SaajSoapElement implements S public void remove() { iterator.remove(); } + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetailElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetailElement.java index 4648bbc2..73777f9d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetailElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultDetailElement.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.DetailEntry; -import jakarta.xml.soap.SOAPException; - import javax.xml.transform.Result; import javax.xml.transform.dom.DOMResult; +import jakarta.xml.soap.DetailEntry; +import jakarta.xml.soap.SOAPException; + import org.springframework.ws.soap.SoapFaultDetailElement; /** @@ -46,7 +46,8 @@ class SaajSoapFaultDetailElement extends SaajSoapElement implements public void addText(String text) { try { getSaajDetailEntry().addTextNode(text); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapFaultException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultException.java index 39de2d79..89b96372 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFaultException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,4 +36,5 @@ public class SaajSoapFaultException extends SoapFaultException { public SaajSoapFaultException(Throwable ex) { super(ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java index 34ff8f75..874da796 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,24 +16,25 @@ package org.springframework.ws.soap.saaj; -import jakarta.xml.soap.Node; -import jakarta.xml.soap.SOAPException; -import jakarta.xml.soap.SOAPHeader; -import jakarta.xml.soap.SOAPHeaderElement; - import java.util.Iterator; import javax.xml.namespace.QName; import javax.xml.transform.Result; import javax.xml.transform.dom.DOMResult; +import jakarta.xml.soap.Node; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPHeader; +import jakarta.xml.soap.SOAPHeaderElement; + import org.springframework.util.Assert; import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapHeaderException; /** - * SAAJ-specific implementation of the {@code SoapHeader} interface. Wraps a {@link jakarta.xml.soap.SOAPHeader}. + * SAAJ-specific implementation of the {@code SoapHeader} interface. Wraps a + * {@link jakarta.xml.soap.SOAPHeader}. * * @author Arjen Poutsma * @since 1.0.0 @@ -71,7 +72,8 @@ abstract class SaajSoapHeader extends SaajSoapElement implements Soa try { SOAPHeaderElement headerElement = getSaajHeader().addHeaderElement(name); return new SaajSoapHeaderElement(headerElement); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapHeaderException(ex); } } @@ -114,7 +116,8 @@ abstract class SaajSoapHeader extends SaajSoapElement implements Soa Node saajHeaderElement = iterator.next(); if (saajHeaderElement instanceof SOAPHeaderElement) { return new SaajSoapHeaderElement((SOAPHeaderElement) saajHeaderElement); - } else { + } + else { throw new RuntimeException("saajHeaderElement is not an instance of SOAPHeaderElement"); } } @@ -123,6 +126,7 @@ abstract class SaajSoapHeader extends SaajSoapElement implements Soa public void remove() { iterator.remove(); } + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderException.java index d8a8b25a..a16bb8b8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,4 +36,5 @@ public class SaajSoapHeaderException extends SoapHeaderException { public SaajSoapHeaderException(Throwable ex) { super(ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java index 32a10df0..76dbbbcb 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,29 @@ package org.springframework.ws.soap.saaj; -import jakarta.activation.DataHandler; -import jakarta.xml.soap.*; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; +import jakarta.activation.DataHandler; +import jakarta.xml.soap.AttachmentPart; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.MimeHeader; +import jakarta.xml.soap.MimeHeaders; +import jakarta.xml.soap.SOAPBody; +import jakarta.xml.soap.SOAPElement; +import jakarta.xml.soap.SOAPEnvelope; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPMessage; +import jakarta.xml.soap.SOAPPart; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.ls.DOMImplementationLS; +import org.w3c.dom.ls.LSOutput; +import org.w3c.dom.ls.LSSerializer; + import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.ws.mime.Attachment; @@ -37,15 +51,10 @@ import org.springframework.ws.soap.saaj.support.SaajUtils; import org.springframework.ws.soap.support.SoapUtils; import org.springframework.ws.transport.TransportConstants; import org.springframework.ws.transport.TransportOutputStream; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.ls.DOMImplementationLS; -import org.w3c.dom.ls.LSOutput; -import org.w3c.dom.ls.LSSerializer; /** - * SAAJ-specific implementation of the {@link SoapMessage} interface. Created via the {@link SaajSoapMessageFactory}, - * wraps a {@link SOAPMessage}. + * SAAJ-specific implementation of the {@link SoapMessage} interface. Created via the + * {@link SaajSoapMessageFactory}, wraps a {@link SOAPMessage}. * * @author Arjen Poutsma * @author Greg Turnquist @@ -66,7 +75,6 @@ public class SaajSoapMessage extends AbstractSoapMessage { /** * Create a new {@code SaajSoapMessage} based on the given SAAJ {@code SOAPMessage}. - * * @param soapMessage the SAAJ SOAPMessage */ public SaajSoapMessage(SOAPMessage soapMessage) { @@ -75,7 +83,6 @@ public class SaajSoapMessage extends AbstractSoapMessage { /** * Create a new {@code SaajSoapMessage} based on the given SAAJ {@code SOAPMessage}. - * * @param soapMessage the SAAJ SOAPMessage * @param messageFactory the SAAJ message factory */ @@ -85,10 +92,9 @@ public class SaajSoapMessage extends AbstractSoapMessage { /** * Create a new {@code SaajSoapMessage} based on the given SAAJ {@code SOAPMessage}. - * * @param soapMessage the SAAJ SOAPMessage - * @param langAttributeOnSoap11FaultString whether a {@code xml:lang} attribute is allowed on SOAP 1.1 - * {@code } elements + * @param langAttributeOnSoap11FaultString whether a {@code xml:lang} attribute is + * allowed on SOAP 1.1 {@code } elements */ public SaajSoapMessage(SOAPMessage soapMessage, boolean langAttributeOnSoap11FaultString) { this(soapMessage, langAttributeOnSoap11FaultString, null); @@ -96,10 +102,9 @@ public class SaajSoapMessage extends AbstractSoapMessage { /** * Create a new {@code SaajSoapMessage} based on the given SAAJ {@code SOAPMessage}. - * * @param soapMessage the SAAJ SOAPMessage - * @param langAttributeOnSoap11FaultString whether a {@code xml:lang} attribute is allowed on SOAP 1.1 - * {@code } elements + * @param langAttributeOnSoap11FaultString whether a {@code xml:lang} attribute is + * allowed on SOAP 1.1 {@code } elements * @param messageFactory the message factory */ public SaajSoapMessage(SOAPMessage soapMessage, boolean langAttributeOnSoap11FaultString, @@ -110,12 +115,16 @@ public class SaajSoapMessage extends AbstractSoapMessage { this.messageFactory = messageFactory; } - /** Return the SAAJ {@code SOAPMessage} that this {@code SaajSoapMessage} is based on. */ + /** + * Return the SAAJ {@code SOAPMessage} that this {@code SaajSoapMessage} is based on. + */ public SOAPMessage getSaajMessage() { return saajMessage; } - /** Sets the SAAJ {@code SOAPMessage} that this {@code SaajSoapMessage} is based on. */ + /** + * Sets the SAAJ {@code SOAPMessage} that this {@code SaajSoapMessage} is based on. + */ public void setSaajMessage(SOAPMessage soapMessage) { Assert.notNull(soapMessage, "soapMessage must not be null"); saajMessage = soapMessage; @@ -128,7 +137,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { try { SOAPEnvelope saajEnvelope = getSaajMessage().getSOAPPart().getEnvelope(); envelope = new SaajSoapEnvelope(saajEnvelope, langAttributeOnSoap11FaultString); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapEnvelopeException(ex); } } @@ -141,11 +151,13 @@ public class SaajSoapMessage extends AbstractSoapMessage { if (SoapVersion.SOAP_11 == getVersion()) { String[] actions = mimeHeaders.getHeader(TransportConstants.HEADER_SOAP_ACTION); return ObjectUtils.isEmpty(actions) ? TransportConstants.EMPTY_SOAP_ACTION : actions[0]; - } else if (SoapVersion.SOAP_12 == getVersion()) { + } + else if (SoapVersion.SOAP_12 == getVersion()) { String[] contentTypes = mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE); return !ObjectUtils.isEmpty(contentTypes) ? SoapUtils.extractActionFromContentType(contentTypes[0]) : TransportConstants.EMPTY_SOAP_ACTION; - } else { + } + else { throw new IllegalStateException("Unsupported SOAP version: " + getVersion()); } } @@ -156,11 +168,13 @@ public class SaajSoapMessage extends AbstractSoapMessage { soapAction = SoapUtils.escapeAction(soapAction); if (SoapVersion.SOAP_11 == getVersion()) { mimeHeaders.setHeader(TransportConstants.HEADER_SOAP_ACTION, soapAction); - } else if (SoapVersion.SOAP_12 == getVersion()) { + } + else if (SoapVersion.SOAP_12 == getVersion()) { // force save of Content Type header try { saajMessage.saveChanges(); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapMessageException("Could not save message", ex); } String[] contentTypes = mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE); @@ -168,7 +182,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { contentType = SoapUtils.setActionInContentType(contentType, soapAction); mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType); mimeHeaders.removeHeader(TransportConstants.HEADER_SOAP_ACTION); - } else { + } + else { throw new IllegalStateException("Unsupported SOAP version: " + getVersion()); } @@ -177,7 +192,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { @Override public Document getDocument() { Assert.state(messageFactory != null, "Could find message factory to use"); - // return saajSoapMessage.getSaajMessage().getSOAPPart(); // does not work, see SWS-345 + // return saajSoapMessage.getSaajMessage().getSOAPPart(); // does not work, see + // SWS-345 try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); getSaajMessage().writeTo(bos); @@ -185,7 +201,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { SOAPMessage saajMessage = messageFactory.createMessage(getSaajMessage().getMimeHeaders(), bis); setSaajMessage(saajMessage); return saajMessage.getSOAPPart(); - } catch (SOAPException | IOException ex) { + } + catch (SOAPException | IOException ex) { throw new SaajSoapMessageException("Could not save changes", ex); } } @@ -210,7 +227,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { this.saajMessage = messageFactory.createMessage(saajMessage.getMimeHeaders(), bis); - } catch (SOAPException | IOException ex) { + } + catch (SOAPException | IOException ex) { throw new SaajSoapMessageException("Could not read input stream", ex); } } @@ -227,13 +245,17 @@ public class SaajSoapMessage extends AbstractSoapMessage { message.saveChanges(); if (outputStream instanceof TransportOutputStream) { TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream; - // some SAAJ implementations (Axis 1) do not have a Content-Type header by default + // some SAAJ implementations (Axis 1) do not have a Content-Type header by + // default MimeHeaders headers = message.getMimeHeaders(); if (ObjectUtils.isEmpty(headers.getHeader(TransportConstants.HEADER_CONTENT_TYPE))) { SOAPEnvelope envelope1 = message.getSOAPPart().getEnvelope(); - if (envelope1.getElementQName().getNamespaceURI().equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) { + if (envelope1.getElementQName() + .getNamespaceURI() + .equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) { headers.addHeader(TransportConstants.HEADER_CONTENT_TYPE, SoapVersion.SOAP_11.getContentType()); - } else { + } + else { headers.addHeader(TransportConstants.HEADER_CONTENT_TYPE, SoapVersion.SOAP_12.getContentType()); } message.saveChanges(); @@ -246,7 +268,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { message.writeTo(outputStream); outputStream.flush(); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SaajSoapMessageException("Could not write message to OutputStream: " + ex.getMessage(), ex); } } @@ -273,7 +296,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { private void convertMessageToXop() { MimeHeaders mimeHeaders = saajMessage.getMimeHeaders(); String[] oldContentTypes = mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE); - String oldContentType = !ObjectUtils.isEmpty(oldContentTypes) ? oldContentTypes[0] : getVersion().getContentType(); + String oldContentType = !ObjectUtils.isEmpty(oldContentTypes) ? oldContentTypes[0] + : getVersion().getContentType(); mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, CONTENT_TYPE_XOP + ";type=" + '"' + oldContentType + '"'); } @@ -281,7 +305,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { private void convertPartToXop() { SOAPPart saajPart = saajMessage.getSOAPPart(); String[] oldContentTypes = saajPart.getMimeHeader(TransportConstants.HEADER_CONTENT_TYPE); - String oldContentType = !ObjectUtils.isEmpty(oldContentTypes) ? oldContentTypes[0] : getVersion().getContentType(); + String oldContentType = !ObjectUtils.isEmpty(oldContentTypes) ? oldContentTypes[0] + : getVersion().getContentType(); saajPart.setMimeHeader(TransportConstants.HEADER_CONTENT_TYPE, CONTENT_TYPE_XOP + ";type=" + '"' + oldContentType + '"'); } @@ -333,7 +358,8 @@ public class SaajSoapMessage extends AbstractSoapMessage { } } } - } catch (SOAPException ex) { + } + catch (SOAPException ex) { // ignore } return builder.toString(); @@ -362,6 +388,7 @@ public class SaajSoapMessage extends AbstractSoapMessage { public void remove() { saajIterator.remove(); } + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageCreationException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageCreationException.java index eaeccb1c..dabaa5bb 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageCreationException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageCreationException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,4 +32,5 @@ public class SaajSoapMessageCreationException extends SoapMessageCreationExcepti public SaajSoapMessageCreationException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageException.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageException.java index 5cead1b6..8e2fd465 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,4 +32,5 @@ public class SaajSoapMessageException extends SoapMessageException { public SaajSoapMessageException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageFactory.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageFactory.java index 25e79e26..7cfd3c10 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageFactory.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessageFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -46,12 +46,16 @@ import org.springframework.ws.transport.TransportConstants; import org.springframework.ws.transport.TransportInputStream; /** - * SAAJ-specific implementation of the {@link org.springframework.ws.WebServiceMessageFactory WebServiceMessageFactory}. - * Wraps a SAAJ {@link MessageFactory}. This factory will use SAAJ 1.3 when found, or fall back to SAAJ 1.2 or even 1.1. + * SAAJ-specific implementation of the + * {@link org.springframework.ws.WebServiceMessageFactory WebServiceMessageFactory}. Wraps + * a SAAJ {@link MessageFactory}. This factory will use SAAJ 1.3 when found, or fall back + * to SAAJ 1.2 or even 1.1. *

- * A SAAJ {@link MessageFactory} can be injected to the {@link #SaajSoapMessageFactory(jakarta.xml.soap.MessageFactory) - * constructor}, or by the {@link #setMessageFactory(jakarta.xml.soap.MessageFactory)} property. When a SAAJ message - * factory is injected, the {@link #setSoapVersion(org.springframework.ws.soap.SoapVersion)} property is ignored. + * A SAAJ {@link MessageFactory} can be injected to the + * {@link #SaajSoapMessageFactory(jakarta.xml.soap.MessageFactory) constructor}, or by the + * {@link #setMessageFactory(jakarta.xml.soap.MessageFactory)} property. When a SAAJ + * message factory is injected, the + * {@link #setSoapVersion(org.springframework.ws.soap.SoapVersion)} property is ignored. * * @author Arjen Poutsma * @author Greg Turnquist @@ -72,7 +76,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB private Map messageProperties; /** Default, empty constructor. */ - public SaajSoapMessageFactory() {} + public SaajSoapMessageFactory() { + } /** Constructor that takes a message factory as an argument. */ public SaajSoapMessageFactory(MessageFactory messageFactory) { @@ -91,7 +96,6 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB /** * Sets the SAAJ message properties. These properties will be set on created messages. - * * @see jakarta.xml.soap.SOAPMessage#setProperty(String, Object) */ public void setMessageProperties(Map messageProperties) { @@ -99,12 +103,14 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB } /** - * Defines whether a {@code xml:lang} attribute should be set on SOAP 1.1 {@code } elements. + * Defines whether a {@code xml:lang} attribute should be set on SOAP 1.1 + * {@code } elements. *

- * The default is {@code true}, to comply with WS-I, but this flag can be set to {@code false} to the older W3C SOAP - * 1.1 specification. - * - * @see WS-I Basic Profile 1.1 + * The default is {@code true}, to comply with WS-I, but this flag can be set to + * {@code false} to the older W3C SOAP 1.1 specification. + * @see WS-I Basic + * Profile 1.1 */ public void setLangAttributeOnSoap11FaultString(boolean langAttributeOnSoap11FaultString) { this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString; @@ -115,13 +121,16 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB if (SaajUtils.getSaajVersion() >= SaajUtils.SAAJ_13) { if (SoapVersion.SOAP_11 == version) { messageFactoryProtocol = SOAPConstants.SOAP_1_1_PROTOCOL; - } else if (SoapVersion.SOAP_12 == version) { + } + else if (SoapVersion.SOAP_12 == version) { messageFactoryProtocol = SOAPConstants.SOAP_1_2_PROTOCOL; - } else { + } + else { throw new IllegalArgumentException( "Invalid version [" + version + "]. Expected the SOAP_11 or SOAP_12 constant"); } - } else if (SoapVersion.SOAP_11 != version) { + } + else if (SoapVersion.SOAP_11 != version) { throw new IllegalArgumentException("SAAJ 1.1 and 1.2 only support SOAP 1.1"); } } @@ -138,22 +147,28 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB logger.info("Creating SAAJ 1.3 MessageFactory with " + messageFactoryProtocol); } messageFactory = MessageFactory.newInstance(messageFactoryProtocol); - } else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) { + } + else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) { logger.info("Creating SAAJ 1.2 MessageFactory"); messageFactory = MessageFactory.newInstance(); - } else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_11) { + } + else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_11) { logger.info("Creating SAAJ 1.1 MessageFactory"); messageFactory = MessageFactory.newInstance(); - } else { + } + else { throw new IllegalStateException( "SaajSoapMessageFactory requires SAAJ 1.1, which was not found on the classpath"); } - } catch (NoSuchMethodError ex) { + } + catch (NoSuchMethodError ex) { throw new SoapMessageCreationException( "Could not create SAAJ MessageFactory. Is the version of the SAAJ specification interfaces [" - + SaajUtils.getSaajVersionString() + "] the same as the version supported by the application server?", + + SaajUtils.getSaajVersionString() + + "] the same as the version supported by the application server?", ex); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SoapMessageCreationException("Could not create SAAJ MessageFactory: " + ex.getMessage(), ex); } } @@ -168,7 +183,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB SOAPMessage saajMessage = messageFactory.createMessage(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SoapMessageCreationException("Could not create empty message: " + ex.getMessage(), ex); } } @@ -182,11 +198,13 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB saajMessage.getSOAPPart().getEnvelope(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); - } catch (SOAPException ex) { - // SAAJ 1.3 RI has a issue with handling multipart XOP content types which contain "startinfo" rather than + } + catch (SOAPException ex) { + // SAAJ 1.3 RI has a issue with handling multipart XOP content types which + // contain "startinfo" rather than // "start-info", so let's try and do something about it String contentType = StringUtils - .arrayToCommaDelimitedString(mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE)); + .arrayToCommaDelimitedString(mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE)); if (contentType.contains("startinfo")) { contentType = contentType.replace("startinfo", "start-info"); mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType); @@ -194,15 +212,18 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString); - } catch (SOAPException e) { + } + catch (SOAPException e) { // fall-through } } SAXParseException parseException = getSAXParseException(ex); if (parseException != null) { throw new InvalidXmlException("Could not parse XML", parseException); - } else { - throw new SoapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(), ex); + } + else { + throw new SoapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(), + ex); } } } @@ -210,9 +231,11 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB private SAXParseException getSAXParseException(Throwable ex) { if (ex instanceof SAXParseException) { return (SAXParseException) ex; - } else if (ex.getCause() != null) { + } + else if (ex.getCause() != null) { return getSAXParseException(ex.getCause()); - } else { + } + else { return null; } } @@ -223,14 +246,16 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB TransportInputStream transportInputStream = (TransportInputStream) inputStream; for (Iterator headerNames = transportInputStream.getHeaderNames(); headerNames.hasNext();) { String headerName = headerNames.next(); - for (Iterator headerValues = transportInputStream.getHeaders(headerName); headerValues.hasNext(); ) { + for (Iterator headerValues = transportInputStream.getHeaders(headerName); headerValues + .hasNext();) { String headerValue = headerValues.next(); if (isMimeHeader(headerName)) { StringTokenizer tokenizer = new StringTokenizer(headerValue, ","); while (tokenizer.hasMoreTokens()) { mimeHeaders.addHeader(headerName, tokenizer.nextToken().trim()); } - } else { + } + else { mimeHeaders.addHeader(headerName, headerValue); } } @@ -245,8 +270,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB } /** - * Checks for the UTF-8 Byte Order Mark, and removes it if present. The SAAJ RI cannot cope with these BOMs. - * + * Checks for the UTF-8 Byte Order Mark, and removes it if present. The SAAJ RI cannot + * cope with these BOMs. * @see SWS-393 * @see UTF-8 BOMs */ @@ -258,7 +283,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB int n = pushbackInputStream.read(bytes, bytesRead, bytes.length - bytesRead); if (n > 0) { bytesRead += n; - } else { + } + else { break; } } @@ -278,8 +304,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB /** * Template method that allows for post-processing of the given {@link SOAPMessage}. *

- * Default implementation sets {@linkplain SOAPMessage#setProperty(String, Object) message properties}, if any. - * + * Default implementation sets {@linkplain SOAPMessage#setProperty(String, Object) + * message properties}, if any. * @param soapMessage the message to post process * @see #setMessageProperties(java.util.Map) */ @@ -308,4 +334,5 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB builder.append(']'); return builder.toString(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajContentHandler.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajContentHandler.java index e116e690..477abe39 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajContentHandler.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajContentHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,24 +16,24 @@ package org.springframework.ws.soap.saaj.support; +import java.util.LinkedHashMap; +import java.util.Map; + import jakarta.xml.soap.Name; import jakarta.xml.soap.SOAPElement; import jakarta.xml.soap.SOAPEnvelope; import jakarta.xml.soap.SOAPException; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + /** - * SAX {@code ContentHandler} that transforms callback calls to the creation of SAAJ {@code Node}s and - * {@code SOAPElement}s. + * SAX {@code ContentHandler} that transforms callback calls to the creation of SAAJ + * {@code Node}s and {@code SOAPElement}s. * * @author Arjen Poutsma * @see jakarta.xml.soap.Node @@ -49,15 +49,16 @@ public class SaajContentHandler implements ContentHandler { private Map namespaces = new LinkedHashMap(); /** - * Constructs a new instance of the {@code SaajContentHandler} that creates children of the given {@code SOAPElement}. - * + * Constructs a new instance of the {@code SaajContentHandler} that creates children + * of the given {@code SOAPElement}. * @param element the element to write to */ public SaajContentHandler(SOAPElement element) { Assert.notNull(element, "element must not be null"); if (element instanceof SOAPEnvelope) { envelope = (SOAPEnvelope) element; - } else { + } + else { envelope = SaajUtils.getEnvelope(element); } this.element = element; @@ -68,7 +69,8 @@ public class SaajContentHandler implements ContentHandler { try { String text = new String(ch, start, length); element.addTextNode(text); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SAXException(ex); } } @@ -94,7 +96,8 @@ public class SaajContentHandler implements ContentHandler { } } element = child; - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new SAXException(ex); } } @@ -103,13 +106,15 @@ public class SaajContentHandler implements ContentHandler { String result = element.getNamespaceURI(prefix); if (namespaceUri.equals(result)) { return true; - } else { + } + else { try { SOAPElement parent = element.getParentElement(); if (parent != null) { return findParentNamespaceDeclaration(parent, prefix, namespaceUri); } - } catch (UnsupportedOperationException ex) { + } + catch (UnsupportedOperationException ex) { // ignore } return false; @@ -134,29 +139,37 @@ public class SaajContentHandler implements ContentHandler { } @Override - public void setDocumentLocator(Locator locator) {} + public void setDocumentLocator(Locator locator) { + } @Override - public void startDocument() throws SAXException {} + public void startDocument() throws SAXException { + } @Override - public void endDocument() throws SAXException {} + public void endDocument() throws SAXException { + } @Override - public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {} + public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { + } @Override - public void processingInstruction(String target, String data) throws SAXException {} + public void processingInstruction(String target, String data) throws SAXException { + } @Override - public void skippedEntity(String name) throws SAXException {} + public void skippedEntity(String name) throws SAXException { + } private String getPrefix(String qName) { int idx = qName.indexOf(':'); if (idx != -1) { return qName.substring(0, idx); - } else { + } + else { return null; } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java index de0de8d5..879e1901 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,22 +16,29 @@ package org.springframework.ws.soap.saaj.support; -import jakarta.xml.soap.*; - import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import javax.xml.namespace.QName; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.MimeHeaders; +import jakarta.xml.soap.Name; +import jakarta.xml.soap.SOAPBody; +import jakarta.xml.soap.SOAPElement; +import jakarta.xml.soap.SOAPEnvelope; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPMessage; + import org.springframework.core.io.Resource; import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.ws.transport.TransportConstants; /** - * Collection of generic utility methods to work with SAAJ. Includes conversion from SAAJ {@link Name} objects to - * {@link QName}s and vice-versa, and SAAJ version checking. + * Collection of generic utility methods to work with SAAJ. Includes conversion from SAAJ + * {@link Name} objects to {@link QName}s and vice-versa, and SAAJ version checking. * * @author Arjen Poutsma * @see Name @@ -50,7 +57,6 @@ public abstract class SaajUtils { /** * Gets the SAAJ version. Returns {@link #SAAJ_13} as of Spring-WS 2.2. - * * @return a code comparable to the SAAJ_XX codes in this class */ public static int getSaajVersion() { @@ -58,8 +64,8 @@ public abstract class SaajUtils { } /** - * Gets the SAAJ version for the specified {@link SOAPMessage}. Returns {@link #SAAJ_13} as of Spring-WS 2.2. - * + * Gets the SAAJ version for the specified {@link SOAPMessage}. Returns + * {@link #SAAJ_13} as of Spring-WS 2.2. * @return a code comparable to the SAAJ_XX codes in this class * @see #SAAJ_11 * @see #SAAJ_12 @@ -72,9 +78,8 @@ public abstract class SaajUtils { } /** - * Gets the SAAJ version for the specified {@link jakarta.xml.soap.SOAPElement}. Returns {@link #SAAJ_13} as of - * Spring-WS 2.2. - * + * Gets the SAAJ version for the specified {@link jakarta.xml.soap.SOAPElement}. + * Returns {@link #SAAJ_13} as of Spring-WS 2.2. * @return a code comparable to the SAAJ_XX codes in this class * @see #SAAJ_11 * @see #SAAJ_12 @@ -85,9 +90,9 @@ public abstract class SaajUtils { } /** - * Returns the SAAJ version as a String. The returned string will be "{@code SAAJ 1.3}", "{@code SAAJ + * Returns the SAAJ version as a String. The returned string will be + * "{@code SAAJ 1.3}", "{@code SAAJ * 1.2}", or "{@code SAAJ 1.1}". - * * @return a string representation of the SAAJ version * @see #getSaajVersion() */ @@ -98,18 +103,21 @@ public abstract class SaajUtils { private static String getSaajVersionString(int saajVersion) { if (saajVersion >= SaajUtils.SAAJ_13) { return "SAAJ 1.3"; - } else if (saajVersion == SaajUtils.SAAJ_12) { + } + else if (saajVersion == SaajUtils.SAAJ_12) { return "SAAJ 1.2"; - } else if (saajVersion == SaajUtils.SAAJ_11) { + } + else if (saajVersion == SaajUtils.SAAJ_11) { return "SAAJ 1.1"; - } else { + } + else { return ""; } } /** - * Converts a {@link QName} to a {@link Name}. A {@link SOAPElement} is required to resolve namespaces. - * + * Converts a {@link QName} to a {@link Name}. A {@link SOAPElement} is required to + * resolve namespaces. * @param qName the {@code QName} to convert * @param resolveElement a {@code SOAPElement} used to resolve namespaces to prefixes * @return the converted SAAJ Name @@ -121,11 +129,13 @@ public abstract class SaajUtils { SOAPEnvelope envelope = getEnvelope(resolveElement); if (StringUtils.hasLength(qName.getNamespaceURI()) && StringUtils.hasLength(qNamePrefix)) { return envelope.createName(qName.getLocalPart(), qNamePrefix, qName.getNamespaceURI()); - } else if (StringUtils.hasLength(qName.getNamespaceURI())) { + } + else if (StringUtils.hasLength(qName.getNamespaceURI())) { Iterator prefixes; if (getSaajVersion(resolveElement) == SAAJ_11) { prefixes = resolveElement.getNamespacePrefixes(); - } else { + } + else { prefixes = resolveElement.getVisibleNamespacePrefixes(); } while (prefixes.hasNext()) { @@ -135,30 +145,32 @@ public abstract class SaajUtils { } } return envelope.createName(qName.getLocalPart(), "", qName.getNamespaceURI()); - } else { + } + else { return envelope.createName(qName.getLocalPart()); } } /** * Converts a {@code jakarta.xml.soap.Name} to a {@code javax.xml.namespace.QName}. - * * @param name the {@code Name} to convert * @return the converted {@code QName} */ public static QName toQName(Name name) { if (StringUtils.hasLength(name.getURI()) && StringUtils.hasLength(name.getPrefix())) { return new QName(name.getURI(), name.getLocalName(), name.getPrefix()); - } else if (StringUtils.hasLength(name.getURI())) { + } + else if (StringUtils.hasLength(name.getURI())) { return new QName(name.getURI(), name.getLocalName()); - } else { + } + else { return new QName(name.getLocalName()); } } /** - * Loads a SAAJ {@code SOAPMessage} from the given resource with a given message factory. - * + * Loads a SAAJ {@code SOAPMessage} from the given resource with a given message + * factory. * @param resource the resource to read from * @param messageFactory SAAJ message factory used to construct the message * @return the loaded SAAJ message @@ -177,7 +189,6 @@ public abstract class SaajUtils { /** * Returns the SAAJ {@code SOAPEnvelope} for the given element. - * * @param element the element to return the envelope from * @return the envelope, or {@code null} if not found */ @@ -188,7 +199,8 @@ public abstract class SaajUtils { return (SOAPEnvelope) element; } element = element.getParentElement(); - } while (element != null); + } + while (element != null); return null; } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajXmlReader.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajXmlReader.java index a8e4de68..726b1299 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajXmlReader.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/support/SaajXmlReader.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,12 @@ package org.springframework.ws.soap.saaj.support; +import java.util.Iterator; + import jakarta.xml.soap.Name; import jakarta.xml.soap.Node; import jakarta.xml.soap.SOAPElement; import jakarta.xml.soap.Text; - -import java.util.Iterator; - -import org.springframework.util.StringUtils; -import org.springframework.xml.sax.AbstractXmlReader; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -32,9 +29,13 @@ import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; import org.xml.sax.helpers.AttributesImpl; +import org.springframework.util.StringUtils; +import org.springframework.xml.sax.AbstractXmlReader; + /** - * SAX {@code XMLReader} that reads from a SAAJ {@code Node}. Consumes {@code XMLEvents} from an {@code XMLEventReader}, - * and calls the corresponding methods on the SAX callback interfaces. + * SAX {@code XMLReader} that reads from a SAAJ {@code Node}. Consumes {@code XMLEvents} + * from an {@code XMLEventReader}, and calls the corresponding methods on the SAX callback + * interfaces. * * @author Arjen Poutsma * @see jakarta.xml.soap.Node @@ -54,8 +55,8 @@ public class SaajXmlReader extends AbstractXmlReader { private boolean namespacePrefixesFeature = false; /** - * Constructs a new instance of the {@code SaajXmlReader} that reads from the given {@code Node}. - * + * Constructs a new instance of the {@code SaajXmlReader} that reads from the given + * {@code Node}. * @param startNode the SAAJ {@code Node} to read from */ public SaajXmlReader(Node startNode) { @@ -66,9 +67,11 @@ public class SaajXmlReader extends AbstractXmlReader { public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException { if (NAMESPACES_FEATURE_NAME.equals(name)) { return namespacesFeature; - } else if (NAMESPACE_PREFIXES_FEATURE_NAME.equals(name)) { + } + else if (NAMESPACE_PREFIXES_FEATURE_NAME.equals(name)) { return namespacePrefixesFeature; - } else { + } + else { return super.getFeature(name); } } @@ -77,9 +80,11 @@ public class SaajXmlReader extends AbstractXmlReader { public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { if (NAMESPACES_FEATURE_NAME.equals(name)) { this.namespacesFeature = value; - } else if (NAMESPACE_PREFIXES_FEATURE_NAME.equals(name)) { + } + else if (NAMESPACE_PREFIXES_FEATURE_NAME.equals(name)) { this.namespacePrefixesFeature = value; - } else { + } + else { super.setFeature(name, value); } } @@ -88,9 +93,9 @@ public class SaajXmlReader extends AbstractXmlReader { * Parses the StAX XML reader passed at construction-time. *

* Note that the given {@code InputSource} is not read, but ignored. - * * @param ignored is ignored - * @throws org.xml.sax.SAXException A SAX exception, possibly wrapping a {@code XMLStreamException} + * @throws org.xml.sax.SAXException A SAX exception, possibly wrapping a + * {@code XMLStreamException} */ @Override public final void parse(InputSource ignored) throws SAXException { @@ -101,9 +106,9 @@ public class SaajXmlReader extends AbstractXmlReader { * Parses the StAX XML reader passed at construction-time. *

* Note that the given system identifier is not read, but ignored. - * * @param ignored is ignored - * @throws SAXException A SAX exception, possibly wrapping a {@code XMLStreamException} + * @throws SAXException A SAX exception, possibly wrapping a + * {@code XMLStreamException} */ @Override public final void parse(String ignored) throws SAXException { @@ -123,7 +128,8 @@ public class SaajXmlReader extends AbstractXmlReader { private void handleNode(Node node) throws SAXException { if (node instanceof SOAPElement) { handleElement((SOAPElement) node); - } else if (node instanceof Text) { + } + else if (node instanceof Text) { Text text = (Text) node; handleText(text); } @@ -140,7 +146,8 @@ public class SaajXmlReader extends AbstractXmlReader { } getContentHandler().startElement(elementName.getURI(), elementName.getLocalName(), elementName.getQualifiedName(), getAttributes(element)); - } else { + } + else { getContentHandler().startElement("", "", elementName.getQualifiedName(), getAttributes(element)); } } @@ -156,7 +163,8 @@ public class SaajXmlReader extends AbstractXmlReader { String prefix = (String) iterator.next(); getContentHandler().endPrefixMapping(prefix); } - } else { + } + else { getContentHandler().endElement("", "", elementName.getQualifiedName()); } } @@ -189,7 +197,8 @@ public class SaajXmlReader extends AbstractXmlReader { String qName; if (StringUtils.hasLength(prefix)) { qName = "xmlns:" + prefix; - } else { + } + else { qName = "xmlns"; } attributes.addAttribute("", "", qName, "CDATA", namespaceUri); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SmartSoapEndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SmartSoapEndpointInterceptor.java index 58b83632..a74c3116 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SmartSoapEndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SmartSoapEndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,7 +19,8 @@ package org.springframework.ws.soap.server; import org.springframework.ws.server.SmartEndpointInterceptor; /** - * SOAP-specific extension of the {@link org.springframework.ws.server.SmartEndpointInterceptor} interface. Allows for + * SOAP-specific extension of the + * {@link org.springframework.ws.server.SmartEndpointInterceptor} interface. Allows for * handling of SOAP faults, which are considered different from regular responses. * * @author Arjen Poutsma diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInterceptor.java index 4dc11c2a..08f2db52 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,8 +20,8 @@ import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.soap.SoapHeaderElement; /** - * SOAP-specific extension of the {@link EndpointInterceptor} interface. Allows for handling of SOAP faults, which are - * considered different from regular responses. + * SOAP-specific extension of the {@link EndpointInterceptor} interface. Allows for + * handling of SOAP faults, which are considered different from regular responses. * * @author Arjen Poutsma * @since 1.0.0 @@ -29,8 +29,8 @@ import org.springframework.ws.soap.SoapHeaderElement; public interface SoapEndpointInterceptor extends EndpointInterceptor { /** - * Given a {@link SoapHeaderElement}, return whether or not this {@link SoapEndpointInterceptor} understands it. - * + * Given a {@link SoapHeaderElement}, return whether or not this + * {@link SoapEndpointInterceptor} understands it. * @param header the header * @return {@code true} if understood, {@code false} otherwise */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInvocationChain.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInvocationChain.java index 48cf7092..6f34c11c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInvocationChain.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInvocationChain.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,8 +20,9 @@ import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.server.EndpointInvocationChain; /** - * SOAP-specific subclass of the {@code EndpointInvocationChain}. Adds associated actors (SOAP 1.1) or roles (SOAP 1.2). - * Used by the {@code SoapMessageDispatcher} to determine the MustUnderstand headers for particular endpoint. + * SOAP-specific subclass of the {@code EndpointInvocationChain}. Adds associated actors + * (SOAP 1.1) or roles (SOAP 1.2). Used by the {@code SoapMessageDispatcher} to determine + * the MustUnderstand headers for particular endpoint. * * @author Arjen Poutsma * @see #getActorsOrRoles() @@ -36,7 +37,6 @@ public class SoapEndpointInvocationChain extends EndpointInvocationChain { /** * Create new {@code SoapEndpointInvocationChain}. - * * @param endpoint the endpoint object to invoke */ public SoapEndpointInvocationChain(Object endpoint) { @@ -45,7 +45,6 @@ public class SoapEndpointInvocationChain extends EndpointInvocationChain { /** * Create new {@code SoapEndpointInvocationChain}. - * * @param endpoint the endpoint object to invoke * @param interceptors the array of interceptors to apply */ @@ -55,11 +54,11 @@ public class SoapEndpointInvocationChain extends EndpointInvocationChain { /** * Create new {@code EndpointInvocationChain}. - * * @param endpoint the endpoint object to invoke * @param interceptors the array of interceptors to apply * @param actorsOrRoles the array of actorsOrRoles to set - * @param isUltimateReceiver whether this chain fullfils the SOAP 1.2 Ultimate receiver role + * @param isUltimateReceiver whether this chain fullfils the SOAP 1.2 Ultimate + * receiver role */ public SoapEndpointInvocationChain(Object endpoint, EndpointInterceptor[] interceptors, String[] actorsOrRoles, boolean isUltimateReceiver) { @@ -69,17 +68,20 @@ public class SoapEndpointInvocationChain extends EndpointInvocationChain { } /** - * Gets the actors (SOAP 1.1) or roles (SOAP 1.2) associated with an invocation of this chain and its contained - * interceptors and endpoint. - * + * Gets the actors (SOAP 1.1) or roles (SOAP 1.2) associated with an invocation of + * this chain and its contained interceptors and endpoint. * @return a string array of URIs for SOAP actors/roles */ public String[] getActorsOrRoles() { return actorsOrRoles; } - /** Indicates whether this chain fulfills the SOAP 1.2 Ultimate Receiver role. Default is {@code true}. */ + /** + * Indicates whether this chain fulfills the SOAP 1.2 Ultimate Receiver role. Default + * is {@code true}. + */ public boolean isUltimateReceiver() { return isUltimateReceiver; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointMapping.java index 68398fb2..de4b8a4a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,23 +19,34 @@ package org.springframework.ws.soap.server; import org.springframework.ws.server.EndpointMapping; /** - * SOAP-specific sub-interface of the {@code EndpointMapping}. Adds associated actors (SOAP 1.1) or roles (SOAP 1.2). - * Used by the {@code SoapMessageDispatcher} to determine the MustUnderstand headers for particular endpoint. + * SOAP-specific sub-interface of the {@code EndpointMapping}. Adds associated actors + * (SOAP 1.1) or roles (SOAP 1.2). Used by the {@code SoapMessageDispatcher} to determine + * the MustUnderstand headers for particular endpoint. *

- * The main purpose for this interface is to add consitency between all SOAP-specific {@code EndpointMappings}. The - * {@code SoapMessageDispatcher} does not require all endpoint mappings to implement this interface. + * The main purpose for this interface is to add consitency between all SOAP-specific + * {@code EndpointMappings}. The {@code SoapMessageDispatcher} does not require all + * endpoint mappings to implement this interface. * * @author Arjen Poutsma * @since 1.0.0 */ public interface SoapEndpointMapping extends EndpointMapping { - /** Sets a single SOAP actor/actorOrRole to apply to all endpoints mapped by the delegate endpoint mapping. */ + /** + * Sets a single SOAP actor/actorOrRole to apply to all endpoints mapped by the + * delegate endpoint mapping. + */ void setActorOrRole(String actorOrRole); - /** Sets the array of SOAP actors/actorsOrRoles to apply to all endpoints mapped by the delegate endpoint mapping. */ + /** + * Sets the array of SOAP actors/actorsOrRoles to apply to all endpoints mapped by the + * delegate endpoint mapping. + */ void setActorsOrRoles(String[] actorsOrRoles); - /** Indicates whether this the endpoint fulfills the SOAP 1.2 Ultimate Receiver role. */ + /** + * Indicates whether this the endpoint fulfills the SOAP 1.2 Ultimate Receiver role. + */ void setUltimateReceiver(boolean ultimateReceiver); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapMessageDispatcher.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapMessageDispatcher.java index 147957c1..7f3ccf50 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapMessageDispatcher.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapMessageDispatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -38,8 +38,9 @@ import org.springframework.ws.soap.soap11.Soap11Header; import org.springframework.ws.soap.soap12.Soap12Header; /** - * SOAP-specific subclass of the {@link MessageDispatcher}. Adds functionality for adding actor roles to a endpoint - * invocation chain, and endpoint interception using {@link SoapEndpointInterceptor} objects. + * SOAP-specific subclass of the {@link MessageDispatcher}. Adds functionality for adding + * actor roles to a endpoint invocation chain, and endpoint interception using + * {@link SoapEndpointInterceptor} objects. * * @author Arjen Poutsma * @see org.springframework.ws.soap.SoapMessage @@ -56,26 +57,31 @@ public class SoapMessageDispatcher extends MessageDispatcher { private Locale mustUnderstandFaultStringLocale = Locale.ENGLISH; /** - * Sets the message used for {@code MustUnderstand} fault. Default to {@link #DEFAULT_MUST_UNDERSTAND_FAULT_STRING}. + * Sets the message used for {@code MustUnderstand} fault. Default to + * {@link #DEFAULT_MUST_UNDERSTAND_FAULT_STRING}. */ public void setMustUnderstandFaultString(String mustUnderstandFaultString) { this.mustUnderstandFaultString = mustUnderstandFaultString; } - /** Sets the locale of the message used for {@code MustUnderstand} fault. Default to {@link Locale#ENGLISH}. */ + /** + * Sets the locale of the message used for {@code MustUnderstand} fault. Default to + * {@link Locale#ENGLISH}. + */ public void setMustUnderstandFaultStringLocale(Locale mustUnderstandFaultStringLocale) { this.mustUnderstandFaultStringLocale = mustUnderstandFaultStringLocale; } /** - * Process the headers targeted at the actor or role fullfilled by the endpoint. Also processed the - * {@code MustUnderstand} headers in the incoming SOAP request message. Iterates over all SOAP headers which should be - * understood for this role, and determines whether these are supported. Generates a SOAP MustUnderstand fault if a + * Process the headers targeted at the actor or role fullfilled by the endpoint. Also + * processed the {@code MustUnderstand} headers in the incoming SOAP request message. + * Iterates over all SOAP headers which should be understood for this role, and + * determines whether these are supported. Generates a SOAP MustUnderstand fault if a * header is not understood. - * * @param mappedEndpoint the mapped EndpointInvocationChain * @param messageContext the message context - * @return {@code true} if all necessary headers are understood; {@code false} otherwise + * @return {@code true} if all necessary headers are understood; {@code false} + * otherwise * @see SoapEndpointInvocationChain#getActorsOrRoles() * @see org.springframework.ws.soap.SoapHeader#examineMustUnderstandHeaderElements(String) */ @@ -104,8 +110,10 @@ public class SoapMessageDispatcher extends MessageDispatcher { Iterator headerIterator; if (soapHeader instanceof Soap11Header) { headerIterator = ((Soap11Header) soapHeader).examineHeaderElementsToProcess(actorsOrRoles); - } else { - headerIterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(actorsOrRoles, isUltimateReceiver); + } + else { + headerIterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(actorsOrRoles, + isUltimateReceiver); } List notUnderstoodHeaderNames = new ArrayList(); while (headerIterator.hasNext()) { @@ -120,7 +128,8 @@ public class SoapMessageDispatcher extends MessageDispatcher { } if (notUnderstoodHeaderNames.isEmpty()) { return true; - } else { + } + else { SoapMessage response = (SoapMessage) messageContext.getResponse(); createMustUnderstandFault(response, notUnderstoodHeaderNames, actorsOrRoles); return false; @@ -128,11 +137,11 @@ public class SoapMessageDispatcher extends MessageDispatcher { } /** - * Handles the request for a single SOAP actor/role. Iterates over all {@code MustUnderstand} headers for a specific - * SOAP 1.1 actor or SOAP 1.2 role, and determines whether these are understood by any of the registered - * {@code SoapEndpointInterceptor}. If they are, returns {@code true}. If they are not, a SOAP fault is created, and - * false is returned. - * + * Handles the request for a single SOAP actor/role. Iterates over all + * {@code MustUnderstand} headers for a specific SOAP 1.1 actor or SOAP 1.2 role, and + * determines whether these are understood by any of the registered + * {@code SoapEndpointInterceptor}. If they are, returns {@code true}. If they are + * not, a SOAP fault is created, and false is returned. * @see SoapEndpointInterceptor#understands(org.springframework.ws.soap.SoapHeaderElement) */ private boolean headerUnderstood(EndpointInvocationChain mappedEndpoint, SoapHeaderElement headerElement) { @@ -156,7 +165,8 @@ public class SoapMessageDispatcher extends MessageDispatcher { + StringUtils.collectionToCommaDelimitedString(notUnderstoodHeaderNames) + ". Returning fault"); } SoapBody responseBody = soapResponse.getSoapBody(); - SoapFault fault = responseBody.addMustUnderstandFault(mustUnderstandFaultString, mustUnderstandFaultStringLocale); + SoapFault fault = responseBody.addMustUnderstandFault(mustUnderstandFaultString, + mustUnderstandFaultStringLocale); if (!ObjectUtils.isEmpty(actorsOrRoles)) { fault.setFaultActorOrRole(actorsOrRoles[0]); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/AbstractFaultCreatingValidatingMarshallingPayloadEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/AbstractFaultCreatingValidatingMarshallingPayloadEndpoint.java index 49adf67f..efb23397 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/AbstractFaultCreatingValidatingMarshallingPayloadEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/AbstractFaultCreatingValidatingMarshallingPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,13 +33,16 @@ import org.springframework.ws.soap.SoapFaultDetailElement; import org.springframework.ws.soap.SoapMessage; /** - * Extension of the {@link org.springframework.ws.server.endpoint.AbstractValidatingMarshallingPayloadEndpoint} which - * validates the request payload with {@link Validator}(s), and creates a SOAP Fault whenever the request message cannot - * be validated. The desired validators can be set using properties, and must - * {@link Validator#supports(Class) support} the request object. + * Extension of the + * {@link org.springframework.ws.server.endpoint.AbstractValidatingMarshallingPayloadEndpoint} + * which validates the request payload with {@link Validator}(s), and creates a SOAP Fault + * whenever the request message cannot be validated. The desired validators can be set + * using properties, and must {@link Validator#supports(Class) support} + * the request object. *

- * The contents of the SOAP Fault can be specified by setting the {@link #setAddValidationErrorDetail(boolean) - * addValidationErrorDetail}, {@link #setFaultStringOrReason(String) faultStringOrReason}, or + * The contents of the SOAP Fault can be specified by setting the + * {@link #setAddValidationErrorDetail(boolean) addValidationErrorDetail}, + * {@link #setFaultStringOrReason(String) faultStringOrReason}, or * {@link #setDetailElementName(QName) detailElementName} properties. * * @author Arjen Poutsma @@ -47,12 +50,13 @@ import org.springframework.ws.soap.SoapMessage; * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints */ @Deprecated -public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint extends - org.springframework.ws.server.endpoint.AbstractValidatingMarshallingPayloadEndpoint implements MessageSourceAware { +public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint + extends org.springframework.ws.server.endpoint.AbstractValidatingMarshallingPayloadEndpoint + implements MessageSourceAware { /** - * Default SOAP Fault Detail name used when a global validation error occur on the request. - * + * Default SOAP Fault Detail name used when a global validation error occur on the + * request. * @see #setDetailElementName(javax.xml.namespace.QName) */ public static final QName DEFAULT_DETAIL_ELEMENT_NAME = new QName("http://springframework.org/spring-ws", @@ -60,7 +64,6 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint /** * Default SOAP Fault string used when a validation errors occur on the request. - * * @see #setFaultStringOrReason(String) */ public static final String DEFAULT_FAULTSTRING_OR_REASON = "Validation error"; @@ -76,10 +79,10 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint private MessageSource messageSource; /** - * Returns whether a SOAP Fault detail element should be created when a validation error occurs. This detail element - * will contain the exact validation errors. It is only added when the underlying message is a {@code SoapMessage}. - * Defaults to {@code true}. - * + * Returns whether a SOAP Fault detail element should be created when a validation + * error occurs. This detail element will contain the exact validation errors. It is + * only added when the underlying message is a {@code SoapMessage}. Defaults to + * {@code true}. * @see org.springframework.ws.soap.SoapFault#addFaultDetail() */ public boolean getAddValidationErrorDetail() { @@ -87,40 +90,44 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint } /** - * Indicates whether a SOAP Fault detail element should be created when a validation error occurs. This detail element - * will contain the exact validation errors. It is only added when the underlying message is a {@code SoapMessage}. - * Defaults to {@code true}. - * + * Indicates whether a SOAP Fault detail element should be created when a validation + * error occurs. This detail element will contain the exact validation errors. It is + * only added when the underlying message is a {@code SoapMessage}. Defaults to + * {@code true}. * @see org.springframework.ws.soap.SoapFault#addFaultDetail() */ public void setAddValidationErrorDetail(boolean addValidationErrorDetail) { this.addValidationErrorDetail = addValidationErrorDetail; } - /** Returns the fault detail element name when validation errors occur on the request. */ + /** + * Returns the fault detail element name when validation errors occur on the request. + */ public QName getDetailElementName() { return detailElementName; } /** - * Sets the fault detail element name when validation errors occur on the request. Defaults to - * {@code DEFAULT_DETAIL_ELEMENT_NAME}. - * + * Sets the fault detail element name when validation errors occur on the request. + * Defaults to {@code DEFAULT_DETAIL_ELEMENT_NAME}. * @see #DEFAULT_DETAIL_ELEMENT_NAME */ public void setDetailElementName(QName detailElementName) { this.detailElementName = detailElementName; } - /** Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors occur on the request. */ + /** + * Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors + * occur on the request. + */ public String getFaultStringOrReason() { return faultStringOrReason; } /** - * Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors occur on the request. It is only - * added when the underlying message is a {@code SoapMessage}. Defaults to {@code DEFAULT_FAULTSTRING_OR_REASON}. - * + * Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors + * occur on the request. It is only added when the underlying message is a + * {@code SoapMessage}. Defaults to {@code DEFAULT_FAULTSTRING_OR_REASON}. * @see #DEFAULT_FAULTSTRING_OR_REASON */ public void setFaultStringOrReason(String faultStringOrReason) { @@ -133,9 +140,8 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint } /** - * Sets the locale for SOAP fault reason and validation messages. It is only added when the underlying message is a - * {@code SoapMessage}. Defaults to English. - * + * Sets the locale for SOAP fault reason and validation messages. It is only added + * when the underlying message is a {@code SoapMessage}. Defaults to English. * @see java.util.Locale#ENGLISH */ public void setFaultStringOrReasonLocale(Locale faultStringOrReasonLocale) { @@ -149,12 +155,13 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint /** * This implementation logs all errors, returns {@code false}, and creates a - * {@link SoapBody#addClientOrSenderFault(String,Locale) client or sender} {@link SoapFault}, adding a - * {@link SoapFaultDetail} with all errors if the {@code addValidationErrorDetail} property is {@code true}. - * + * {@link SoapBody#addClientOrSenderFault(String,Locale) client or sender} + * {@link SoapFault}, adding a {@link SoapFaultDetail} with all errors if the + * {@code addValidationErrorDetail} property is {@code true}. * @param messageContext the message context * @param errors the validation errors - * @return {@code true} to continue processing the request, {@code false} (the default) otherwise + * @return {@code true} to continue processing the request, {@code false} (the + * default) otherwise * @see Errors#getAllErrors() */ @Override @@ -178,4 +185,5 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint } return false; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/AbstractSoapFaultDefinitionExceptionResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/AbstractSoapFaultDefinitionExceptionResolver.java index 727b94c6..e3fa6448 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/AbstractSoapFaultDefinitionExceptionResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/AbstractSoapFaultDefinitionExceptionResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,9 +29,9 @@ import org.springframework.ws.soap.soap12.Soap12Body; import org.springframework.ws.soap.soap12.Soap12Fault; /** - * Abstract base class for SOAP-based {@link EndpointExceptionResolver} implementations that depend on - * {@link SoapFaultDefinition}. Provides a default endpoint property, and a template method that provides the definition - * for a given exception. + * Abstract base class for SOAP-based {@link EndpointExceptionResolver} implementations + * that depend on {@link SoapFaultDefinition}. Provides a default endpoint property, and a + * template method that provides the definition for a given exception. * * @author Arjen Poutsma * @see #setDefaultFault(SoapFaultDefinition) @@ -42,15 +42,19 @@ public abstract class AbstractSoapFaultDefinitionExceptionResolver extends Abstr private SoapFaultDefinition defaultFault; - /** Set the default fault. This fault will be returned if no specific mapping was found. */ + /** + * Set the default fault. This fault will be returned if no specific mapping was + * found. + */ public void setDefaultFault(SoapFaultDefinition defaultFault) { this.defaultFault = defaultFault; } /** - * Template method that returns the {@link SoapFaultDefinition} for the given exception. - * - * @param endpoint the executed endpoint, or {@code null} if none chosen at the time of the exception + * Template method that returns the {@link SoapFaultDefinition} for the given + * exception. + * @param endpoint the executed endpoint, or {@code null} if none chosen at the time + * of the exception * @param ex the exception to be handled * @return the definition mapped to the exception, or {@code null} if none is found. */ @@ -79,19 +83,24 @@ public abstract class AbstractSoapFaultDefinitionExceptionResolver extends Abstr if (SoapFaultDefinition.SERVER.equals(definition.getFaultCode()) || SoapFaultDefinition.RECEIVER.equals(definition.getFaultCode())) { fault = soapBody.addServerOrReceiverFault(faultStringOrReason, definition.getLocale()); - } else if (SoapFaultDefinition.CLIENT.equals(definition.getFaultCode()) + } + else if (SoapFaultDefinition.CLIENT.equals(definition.getFaultCode()) || SoapFaultDefinition.SENDER.equals(definition.getFaultCode())) { fault = soapBody.addClientOrSenderFault(faultStringOrReason, definition.getLocale()); - } else { + } + else { if (soapBody instanceof Soap11Body) { Soap11Body soap11Body = (Soap11Body) soapBody; fault = soap11Body.addFault(definition.getFaultCode(), faultStringOrReason, definition.getLocale()); - } else if (soapBody instanceof Soap12Body) { + } + else if (soapBody instanceof Soap12Body) { Soap12Body soap12Body = (Soap12Body) soapBody; - Soap12Fault soap12Fault = soap12Body.addServerOrReceiverFault(faultStringOrReason, definition.getLocale()); + Soap12Fault soap12Fault = soap12Body.addServerOrReceiverFault(faultStringOrReason, + definition.getLocale()); soap12Fault.addFaultSubcode(definition.getFaultCode()); fault = soap12Fault; - } else { + } + else { throw new IllegalStateException("This class only supports SOAP 1.1 and SOAP 1.2."); } } @@ -102,15 +111,17 @@ public abstract class AbstractSoapFaultDefinitionExceptionResolver extends Abstr } /** - * Customize the {@link SoapFault} created by this resolver. Called for each created fault + * Customize the {@link SoapFault} created by this resolver. Called for each created + * fault *

- * The default implementation is empty. Can be overridden in subclasses to customize the properties of the fault, such - * as adding details, etc. - * - * @param endpoint the executed endpoint, or {@code null} if none chosen at the time of the exception + * The default implementation is empty. Can be overridden in subclasses to customize + * the properties of the fault, such as adding details, etc. + * @param endpoint the executed endpoint, or {@code null} if none chosen at the time + * of the exception * @param ex the exception to be handled * @param fault the created fault */ - protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) {} + protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) { + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolver.java index bbda8a1d..d12c9993 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,8 +27,9 @@ import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapMessage; /** - * Simple, SOAP-specific {@link org.springframework.ws.server.EndpointExceptionResolver EndpointExceptionResolver} - * implementation that stores the exception's message as the fault string. + * Simple, SOAP-specific {@link org.springframework.ws.server.EndpointExceptionResolver + * EndpointExceptionResolver} implementation that stores the exception's message as the + * fault string. *

* The fault code is always set to a Server (in SOAP 1.1) or Receiver (SOAP 1.2). * @@ -71,13 +72,16 @@ public class SimpleSoapExceptionResolver extends AbstractEndpointExceptionResolv } /** - * Empty template method to allow subclasses an opportunity to customize the given {@link SoapFault}. Called from + * Empty template method to allow subclasses an opportunity to customize the given + * {@link SoapFault}. Called from * {@link #resolveExceptionInternal(MessageContext,Object,Exception)}. - * * @param messageContext current message context - * @param endpoint the executed endpoint, or {@code null} if none chosen at the time of the exception + * @param endpoint the executed endpoint, or {@code null} if none chosen at the time + * of the exception * @param ex the exception that got thrown during endpoint execution * @param fault the SOAP fault to be customized. */ - protected void customizeFault(MessageContext messageContext, Object endpoint, Exception ex, SoapFault fault) {} + protected void customizeFault(MessageContext messageContext, Object endpoint, Exception ex, SoapFault fault) { + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolver.java index c33d39aa..f1a60a94 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,8 @@ import org.springframework.ws.soap.server.endpoint.annotation.FaultCode; import org.springframework.ws.soap.server.endpoint.annotation.SoapFault; /** - * Implementation of the {@link org.springframework.ws.server.EndpointExceptionResolver} interface that uses the - * {@link SoapFault} annotation to map exceptions to SOAP Faults. + * Implementation of the {@link org.springframework.ws.server.EndpointExceptionResolver} + * interface that uses the {@link SoapFault} annotation to map exceptions to SOAP Faults. * * @author Arjen Poutsma * @since 1.0.0 @@ -38,14 +38,17 @@ public class SoapFaultAnnotationExceptionResolver extends AbstractSoapFaultDefin SoapFaultDefinition definition = new SoapFaultDefinition(); if (faultAnnotation.faultCode() != FaultCode.CUSTOM) { definition.setFaultCode(faultAnnotation.faultCode().value()); - } else if (StringUtils.hasLength(faultAnnotation.customFaultCode())) { + } + else if (StringUtils.hasLength(faultAnnotation.customFaultCode())) { definition.setFaultCode(QName.valueOf(faultAnnotation.customFaultCode())); } definition.setFaultStringOrReason(faultAnnotation.faultStringOrReason()); definition.setLocale(StringUtils.parseLocaleString(faultAnnotation.locale())); return definition; - } else { + } + else { return null; } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinition.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinition.java index c4c35d6d..154fe3f4 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinition.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinition.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,8 @@ import java.util.Locale; import javax.xml.namespace.QName; /** - * Defines properties for a SOAP Fault. Used by the {@code SoapFaultDefinitionEditor} and the - * {@code SoapFaultMappingExceptionResolver}. + * Defines properties for a SOAP Fault. Used by the {@code SoapFaultDefinitionEditor} and + * the {@code SoapFaultMappingExceptionResolver}. * * @author Arjen Poutsma * @see SoapFaultDefinitionEditor @@ -32,29 +32,29 @@ import javax.xml.namespace.QName; public class SoapFaultDefinition { /** - * Constant {@code QName} used to indicate that a {@code Client} fault must be created. - * + * Constant {@code QName} used to indicate that a {@code Client} fault must be + * created. * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String,java.util.Locale) */ public static final QName CLIENT = new QName("CLIENT"); /** - * Constant {@code QName} used to indicate that a {@code Receiver} fault must be created. - * + * Constant {@code QName} used to indicate that a {@code Receiver} fault must be + * created. * @see org.springframework.ws.soap.SoapBody#addServerOrReceiverFault(String,java.util.Locale) */ public static final QName RECEIVER = new QName("RECEIVER"); /** - * Constant {@code QName} used to indicate that a {@code Sender} fault must be created. - * + * Constant {@code QName} used to indicate that a {@code Sender} fault must be + * created. * @see org.springframework.ws.soap.SoapBody#addServerOrReceiverFault(String,java.util.Locale) */ public static final QName SENDER = new QName("SENDER"); /** - * Constant {@code QName} used to indicate that a {@code Server} fault must be created. - * + * Constant {@code QName} used to indicate that a {@code Server} fault must be + * created. * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String,java.util.Locale) */ public static final QName SERVER = new QName("SERVER"); @@ -75,19 +75,24 @@ public class SoapFaultDefinition { this.faultCode = faultCode; } - /** Returns the fault string or reason text. By default, it is set to the exception message. */ + /** + * Returns the fault string or reason text. By default, it is set to the exception + * message. + */ public String getFaultStringOrReason() { return faultStringOrReason; } - /** Sets the fault string or reason text. By default, it is set to the exception message. */ + /** + * Sets the fault string or reason text. By default, it is set to the exception + * message. + */ public void setFaultStringOrReason(String faultStringOrReason) { this.faultStringOrReason = faultStringOrReason; } /** * Gets the fault string locale. By default, it is English. - * * @see Locale#ENGLISH */ public Locale getLocale() { @@ -96,10 +101,10 @@ public class SoapFaultDefinition { /** * Sets the fault string locale. By default, it is English. - * * @see Locale#ENGLISH */ public void setLocale(Locale locale) { this.locale = locale; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditor.java index ef4041f0..506d80c9 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,13 +32,15 @@ import org.springframework.xml.namespace.QNameEditor; * faultCode,faultString,locale *

* - * where {@code faultCode} is the string representation of a {@code QName}, {@code faultStringOrReason} is the optional - * fault string, and {@code locale} is the optional string representations for the {@code faultStringOrReason}language. - * By default, the language is set to English, and the fault string set to the exception message. + * where {@code faultCode} is the string representation of a {@code QName}, + * {@code faultStringOrReason} is the optional fault string, and {@code locale} is the + * optional string representations for the {@code faultStringOrReason}language. By + * default, the language is set to English, and the fault string set to the exception + * message. *

- * Instead of supplying a custom fault code, you can use the constants {@code SERVER} or {@code RECEIVER} indicate a - * {@code Server}/{@code Receiver} fault, or {@code CLIENT} or {@code SENDER} to{@code Client}/{@code Sender} fault - * respectively. + * Instead of supplying a custom fault code, you can use the constants {@code SERVER} or + * {@code RECEIVER} indicate a {@code Server}/{@code Receiver} fault, or {@code CLIENT} or + * {@code SENDER} to{@code Client}/{@code Sender} fault respectively. *

* For example: * @@ -80,7 +82,8 @@ public class SoapFaultDefinitionEditor extends PropertyEditorSupport { public void setAsText(String text) throws IllegalArgumentException { if (!StringUtils.hasLength(text)) { setValue(null); - } else { + } + else { String[] tokens = StringUtils.commaDelimitedListToStringArray(text); if (tokens.length < FAULT_STRING_INDEX) { throw new IllegalArgumentException("Invalid amount of comma delimited values in [" + text diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultMappingExceptionResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultMappingExceptionResolver.java index 33410139..d2f84ff7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultMappingExceptionResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/SoapFaultMappingExceptionResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,9 @@ import java.util.Properties; import org.springframework.util.CollectionUtils; /** - * Exception resolver that allows for mapping exception class names to SOAP Faults. The mappings are set using the - * {@code exceptionMappings} property, the format of which is documented in {@link SoapFaultDefinitionEditor}. + * Exception resolver that allows for mapping exception class names to SOAP Faults. The + * mappings are set using the {@code exceptionMappings} property, the format of which is + * documented in {@link SoapFaultDefinitionEditor}. * * @author Arjen Poutsma * @since 1.0.0 @@ -34,15 +35,15 @@ public class SoapFaultMappingExceptionResolver extends AbstractSoapFaultDefiniti private Map exceptionMappings = new LinkedHashMap(); /** - * Set the mappings between exception class names and SOAP Faults. The exception class name can be a substring, with - * no wildcard support at present. + * Set the mappings between exception class names and SOAP Faults. The exception class + * name can be a substring, with no wildcard support at present. *

- * The values of the given properties object should use the format described in {@code SoapFaultDefinitionEditor}. + * The values of the given properties object should use the format described in + * {@code SoapFaultDefinitionEditor}. *

* Follows the same matching algorithm as {@code SimpleMappingExceptionResolver}. - * - * @param mappings exception patterns (can also be fully qualified class names) as keys, fault definition texts as - * values + * @param mappings exception patterns (can also be fully qualified class names) as + * keys, fault definition texts as values * @see SoapFaultDefinitionEditor */ public void setExceptionMappings(Properties mappings) { @@ -75,10 +76,12 @@ public class SoapFaultMappingExceptionResolver extends AbstractSoapFaultDefiniti } /** - * Return the depth to the superclass matching. {@code 0} means ex matches exactly. Returns {@code -1} if there's no - * match. Otherwise, returns depth. Lowest depth wins. + * Return the depth to the superclass matching. {@code 0} means ex matches exactly. + * Returns {@code -1} if there's no match. Otherwise, returns depth. Lowest depth + * wins. *

- * Follows the same algorithm as RollbackRuleAttribute, and SimpleMappingExceptionResolver + * Follows the same algorithm as RollbackRuleAttribute, and + * SimpleMappingExceptionResolver */ protected int getDepth(String exceptionMapping, Exception ex) { return getDepth(exceptionMapping, ex.getClass(), 0); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapHeaderElementMethodArgumentResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapHeaderElementMethodArgumentResolver.java index 92493a2f..c1d6f34f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapHeaderElementMethodArgumentResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapHeaderElementMethodArgumentResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,10 +34,11 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapHeader; import org.springframework.xml.namespace.QNameUtils; /** - * Implementation of {@link MethodArgumentResolver} that supports resolving {@link SoapHeaderElement} parameters. Target - * method parameters must be annotated with {@link SoapHeader} to indicate the SOAP header to resolve. This resolver - * supports simple {@link SoapHeaderElement} parameters and {@link List} parameters for elements that appear multiple - * times in the same SOAP header. + * Implementation of {@link MethodArgumentResolver} that supports resolving + * {@link SoapHeaderElement} parameters. Target method parameters must be annotated with + * {@link SoapHeader} to indicate the SOAP header to resolve. This resolver supports + * simple {@link SoapHeaderElement} parameters and {@link List} parameters for elements + * that appear multiple times in the same SOAP header. *

* The following snippet shows an example of supported declarations. * @@ -46,8 +47,7 @@ import org.springframework.xml.namespace.QNameUtils; * public void soapHeaderElement(@SoapHeader("{http://springframework.org/ws}header") SoapHeaderElement element) * * public void soapHeaderElementList(@SoapHeader("{http://springframework.org/ws}header") List<SoapHeaderElement> elements) - *
- * + *
* * @author Tareq Abedrabbo * @author Arjen Poutsma @@ -92,8 +92,8 @@ public class SoapHeaderElementMethodArgumentResolver implements MethodArgumentRe String paramValue = parameter.getParameterAnnotation(SoapHeader.class).value(); - Assert.isTrue(QNameUtils.validateQName(paramValue), - "Invalid header qualified name [" + paramValue + "]. " + "QName must be of the form '{namespace}localPart'."); + Assert.isTrue(QNameUtils.validateQName(paramValue), "Invalid header qualified name [" + paramValue + "]. " + + "QName must be of the form '{namespace}localPart'."); QName qname = QName.valueOf(paramValue); @@ -101,7 +101,8 @@ public class SoapHeaderElementMethodArgumentResolver implements MethodArgumentRe if (SoapHeaderElement.class.equals(parameterType)) { return extractSoapHeader(qname, soapHeader); - } else if (List.class.equals(parameterType)) { + } + else if (List.class.equals(parameterType)) { return extractSoapHeaderList(qname, soapHeader); } // should not happen @@ -131,4 +132,5 @@ public class SoapHeaderElementMethodArgumentResolver implements MethodArgumentRe } return result; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapMethodArgumentResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapMethodArgumentResolver.java index cf7588f8..be811cf3 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapMethodArgumentResolver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapMethodArgumentResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,8 +26,8 @@ import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapMessage; /** - * Implementation of {@link MethodArgumentResolver} that supports {@link SoapMessage}, {@link SoapBody}, - * {@link SoapEnvelope}, and {@link SoapHeader}. + * Implementation of {@link MethodArgumentResolver} that supports {@link SoapMessage}, + * {@link SoapBody}, {@link SoapEnvelope}, and {@link SoapHeader}. * * @author Arjen Poutsma * @since 2.0 @@ -50,14 +50,18 @@ public class SoapMethodArgumentResolver implements MethodArgumentResolver { if (SoapMessage.class.equals(parameterType)) { return request; - } else if (SoapBody.class.equals(parameterType)) { + } + else if (SoapBody.class.equals(parameterType)) { return request.getSoapBody(); - } else if (SoapEnvelope.class.equals(parameterType)) { + } + else if (SoapEnvelope.class.equals(parameterType)) { return request.getEnvelope(); - } else if (SoapHeader.class.equals(parameterType)) { + } + else if (SoapHeader.class.equals(parameterType)) { return request.getSoapHeader(); } // should not happen throw new UnsupportedOperationException(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/FaultCode.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/FaultCode.java index a3277fd0..ccd2d3db 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/FaultCode.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/FaultCode.java @@ -1,18 +1,18 @@ /* -* Copyright 2005-2022 the original author or authors. -* -* Licensed 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. -*/ + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ package org.springframework.ws.soap.server.endpoint.annotation; @@ -22,7 +22,8 @@ import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.soap11.Soap11Body; /** - * Enumeration that represents the standard SOAP Fault codes for use with the JDK 1.5+ {@link SoapFault} annotation. + * Enumeration that represents the standard SOAP Fault codes for use with the JDK 1.5+ + * {@link SoapFault} annotation. * * @author Arjen Poutsma * @since 1.0.0 @@ -30,11 +31,11 @@ import org.springframework.ws.soap.soap11.Soap11Body; public enum FaultCode { /** - * Constant used to indicate that a fault must be created with a custom fault code. When this value is used, the - * {@code customFaultCode} string property must be used on {@link SoapFault}. + * Constant used to indicate that a fault must be created with a custom fault code. + * When this value is used, the {@code customFaultCode} string property must be used + * on {@link SoapFault}. *

* Note that custom Fault Codes are only supported on SOAP 1.1. - * * @see SoapFault#customFaultCode() * @see Soap11Body#addFault(javax.xml.namespace.QName,String,java.util.Locale) */ @@ -42,28 +43,27 @@ public enum FaultCode { /** * Constant used to indicate that a {@code Client} fault must be created. - * * @see SoapBody#addClientOrSenderFault(String,java.util.Locale) */ CLIENT(new QName("CLIENT")), /** - * Constant {@code QName} used to indicate that a {@code Receiver} fault must be created. - * + * Constant {@code QName} used to indicate that a {@code Receiver} fault must be + * created. * @see SoapBody#addServerOrReceiverFault(String,java.util.Locale) */ RECEIVER(new QName("RECEIVER")), /** - * Constant {@code QName} used to indicate that a {@code Sender} fault must be created. - * + * Constant {@code QName} used to indicate that a {@code Sender} fault must be + * created. * @see SoapBody#addServerOrReceiverFault(String,java.util.Locale) */ SENDER(new QName("SENDER")), /** - * Constant {@code QName} used to indicate that a {@code Server} fault must be created. - * + * Constant {@code QName} used to indicate that a {@code Server} fault must be + * created. * @see SoapBody#addClientOrSenderFault(String,java.util.Locale) */ SERVER(new QName("SERVER")); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapAction.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapAction.java index efe6d424..1e3b4238 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapAction.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapAction.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marks an endpoint method as the handler for an incoming request. The annotation value signifies the value for the - * request {@code SOAPAction} header that is handled by the method. + * Marks an endpoint method as the handler for an incoming request. The annotation value + * signifies the value for the request {@code SOAPAction} header that is handled by the + * method. * * @author Arjen Poutsma * @see org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping @@ -37,7 +38,10 @@ import java.lang.annotation.Target; @Repeatable(SoapActions.class) public @interface SoapAction { - /** Signifies the value for the request {@code SOAPAction} header that is handled by the method. */ + /** + * Signifies the value for the request {@code SOAPAction} header that is handled by + * the method. + */ String value(); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapFault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapFault.java index 41be0ef2..30eb36be 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapFault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapFault.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,7 +26,8 @@ import java.lang.annotation.Target; import javax.xml.namespace.QName; /** - * Marks an exception class with the fault elements that should be returned whenever this exception is thrown. + * Marks an exception class with the fault elements that should be returned whenever this + * exception is thrown. * * @author Arjen Poutsma * @see org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver @@ -42,16 +43,19 @@ public @interface SoapFault { FaultCode faultCode(); /** - * The custom fault code, to be used if {@link #faultCode()} is set to {@link FaultCode#CUSTOM}. + * The custom fault code, to be used if {@link #faultCode()} is set to + * {@link FaultCode#CUSTOM}. *

- * The format used is that of {@link QName#toString()}, i.e. "{" + Namespace URI + "}" + local part, where the - * namespace is optional. + * The format used is that of {@link QName#toString()}, i.e. "{" + Namespace URI + "}" + * + local part, where the namespace is optional. *

* Note that custom Fault Codes are only supported on SOAP 1.1. */ String customFaultCode() default ""; - /** The fault string or reason text. By default, it is set to the exception message. */ + /** + * The fault string or reason text. By default, it is set to the exception message. + */ String faultStringOrReason() default ""; /** The fault string locale. By default, it is English. */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapHeader.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapHeader.java index 9f22921d..2d334bfc 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapHeader.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/annotation/SoapHeader.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,9 +33,12 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Documented public @interface SoapHeader { + /** - * The qualified name of the soap header. The format used is that of {@link javax.xml.namespace.QName#toString()}, - * i.e. "{" + Namespace URI + "}" + local part, where the namespace is optional. + * The qualified name of the soap header. The format used is that of + * {@link javax.xml.namespace.QName#toString()}, i.e. "{" + Namespace URI + "}" + + * local part, where the namespace is optional. */ String value(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/AbstractFaultCreatingValidatingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/AbstractFaultCreatingValidatingInterceptor.java index 45bfab2f..758d9ae7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/AbstractFaultCreatingValidatingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/AbstractFaultCreatingValidatingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,6 +21,8 @@ import java.util.Locale; import javax.xml.namespace.QName; import javax.xml.transform.TransformerException; +import org.xml.sax.SAXParseException; + import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.interceptor.AbstractValidatingInterceptor; import org.springframework.ws.soap.SoapBody; @@ -28,12 +30,12 @@ import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapFaultDetail; import org.springframework.ws.soap.SoapFaultDetailElement; import org.springframework.ws.soap.SoapMessage; -import org.xml.sax.SAXParseException; /** - * Subclass of {@code AbstractValidatingInterceptor} that creates a SOAP Fault whenever the request message cannot be - * validated. The contents of the SOAP Fault can be specified by setting the {@code addValidationErrorDetail}, - * {@code faultStringOrReason}, or {@code detailElementName} properties. Further customizing can be accomplished by + * Subclass of {@code AbstractValidatingInterceptor} that creates a SOAP Fault whenever + * the request message cannot be validated. The contents of the SOAP Fault can be + * specified by setting the {@code addValidationErrorDetail}, {@code faultStringOrReason}, + * or {@code detailElementName} properties. Further customizing can be accomplished by * overriding {@code handleRequestValidationErrors}. * * @author Arjen Poutsma @@ -49,7 +51,6 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac /** * Default SOAP Fault Detail name used when a validation errors occur on the request. - * * @see #setDetailElementName(javax.xml.namespace.QName) */ public static final QName DEFAULT_DETAIL_ELEMENT_NAME = new QName("http://springframework.org/spring-ws", @@ -57,7 +58,6 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac /** * Default SOAP Fault string used when a validation errors occur on the request. - * * @see #setFaultStringOrReason(String) */ public static final String DEFAULT_FAULTSTRING_OR_REASON = "Validation error"; @@ -71,10 +71,10 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac private Locale faultStringOrReasonLocale = Locale.ENGLISH; /** - * Returns whether a SOAP Fault detail element should be created when a validation error occurs. This detail element - * will contain the exact validation errors. It is only added when the underlying message is a {@code SoapMessage}. - * Defaults to {@code true}. - * + * Returns whether a SOAP Fault detail element should be created when a validation + * error occurs. This detail element will contain the exact validation errors. It is + * only added when the underlying message is a {@code SoapMessage}. Defaults to + * {@code true}. * @see org.springframework.ws.soap.SoapFault#addFaultDetail() */ public boolean getAddValidationErrorDetail() { @@ -82,55 +82,62 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac } /** - * Indicates whether a SOAP Fault detail element should be created when a validation error occurs. This detail element - * will contain the exact validation errors. It is only added when the underlying message is a {@code SoapMessage}. - * Defaults to {@code true}. - * + * Indicates whether a SOAP Fault detail element should be created when a validation + * error occurs. This detail element will contain the exact validation errors. It is + * only added when the underlying message is a {@code SoapMessage}. Defaults to + * {@code true}. * @see org.springframework.ws.soap.SoapFault#addFaultDetail() */ public void setAddValidationErrorDetail(boolean addValidationErrorDetail) { this.addValidationErrorDetail = addValidationErrorDetail; } - /** Returns the fault detail element name when validation errors occur on the request. */ + /** + * Returns the fault detail element name when validation errors occur on the request. + */ public QName getDetailElementName() { return detailElementName; } /** - * Sets the fault detail element name when validation errors occur on the request. Defaults to - * {@code DEFAULT_DETAIL_ELEMENT_NAME}. - * + * Sets the fault detail element name when validation errors occur on the request. + * Defaults to {@code DEFAULT_DETAIL_ELEMENT_NAME}. * @see #DEFAULT_DETAIL_ELEMENT_NAME */ public void setDetailElementName(QName detailElementName) { this.detailElementName = detailElementName; } - /** Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors occur on the request. */ + /** + * Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors + * occur on the request. + */ public String getFaultStringOrReason() { return faultStringOrReason; } /** - * Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors occur on the request. It is only - * added when the underlying message is a {@code SoapMessage}. Defaults to {@code DEFAULT_FAULTSTRING_OR_REASON}. - * + * Sets the SOAP {@code faultstring} or {@code Reason} used when validation errors + * occur on the request. It is only added when the underlying message is a + * {@code SoapMessage}. Defaults to {@code DEFAULT_FAULTSTRING_OR_REASON}. * @see #DEFAULT_FAULTSTRING_OR_REASON */ public void setFaultStringOrReason(String faultStringOrReason) { this.faultStringOrReason = faultStringOrReason; } - /** Returns the SOAP fault reason locale used when validation errors occur on the request. */ + /** + * Returns the SOAP fault reason locale used when validation errors occur on the + * request. + */ public Locale getFaultStringOrReasonLocale() { return faultStringOrReasonLocale; } /** - * Sets the SOAP fault reason locale used when validation errors occur on the request. It is only added when the - * underlying message is a {@code SoapMessage}. Defaults to English. - * + * Sets the SOAP fault reason locale used when validation errors occur on the request. + * It is only added when the underlying message is a {@code SoapMessage}. Defaults to + * English. * @see java.util.Locale#ENGLISH */ public void setFaultStringOrReasonLocale(Locale faultStringOrReasonLocale) { @@ -138,14 +145,15 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac } /** - * Template method that is called when the request message contains validation errors. This implementation logs all - * errors, returns {@code false}, and creates a {@link SoapBody#addClientOrSenderFault(String,Locale) client or - * sender} {@link SoapFault}, adding a {@link SoapFaultDetail} with all errors if the {@code addValidationErrorDetail} - * property is {@code true}. - * + * Template method that is called when the request message contains validation errors. + * This implementation logs all errors, returns {@code false}, and creates a + * {@link SoapBody#addClientOrSenderFault(String,Locale) client or sender} + * {@link SoapFault}, adding a {@link SoapFaultDetail} with all errors if the + * {@code addValidationErrorDetail} property is {@code true}. * @param messageContext the message context * @param errors the validation errors - * @return {@code true} to continue processing the request, {@code false} (the default) otherwise + * @return {@code true} to continue processing the request, {@code false} (the + * default) otherwise */ @Override protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors) @@ -167,4 +175,5 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac } return false; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/DelegatingSmartSoapEndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/DelegatingSmartSoapEndpointInterceptor.java index abd06d61..fad01b6f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/DelegatingSmartSoapEndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/DelegatingSmartSoapEndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,8 @@ import org.springframework.ws.soap.server.SmartSoapEndpointInterceptor; import org.springframework.ws.soap.server.SoapEndpointInterceptor; /** - * Implementation of the {@link SmartSoapEndpointInterceptor} interface that delegates to a delegate - * {@link SoapEndpointInterceptor}. + * Implementation of the {@link SmartSoapEndpointInterceptor} interface that delegates to + * a delegate {@link SoapEndpointInterceptor}. * * @author Arjen Poutsma * @since 2.0 @@ -33,8 +33,8 @@ public class DelegatingSmartSoapEndpointInterceptor extends DelegatingSmartEndpo implements SmartSoapEndpointInterceptor { /** - * Creates a new instance of the {@code DelegatingSmartSoapEndpointInterceptor} with the given delegate. - * + * Creates a new instance of the {@code DelegatingSmartSoapEndpointInterceptor} with + * the given delegate. * @param delegate the endpoint interceptor to delegate to. */ public DelegatingSmartSoapEndpointInterceptor(EndpointInterceptor delegate) { @@ -46,8 +46,10 @@ public class DelegatingSmartSoapEndpointInterceptor extends DelegatingSmartEndpo EndpointInterceptor delegate = getDelegate(); if (delegate instanceof SoapEndpointInterceptor) { return ((SoapEndpointInterceptor) delegate).understands(header); - } else { + } + else { return false; } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadRootSmartSoapEndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadRootSmartSoapEndpointInterceptor.java index f7b1c27a..b768dd06 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadRootSmartSoapEndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadRootSmartSoapEndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,9 +27,10 @@ import org.springframework.ws.server.endpoint.support.PayloadRootUtils; import org.springframework.xml.transform.TransformerHelper; /** - * Implementation of the {@link org.springframework.ws.soap.server.SmartSoapEndpointInterceptor - * SmartSoapEndpointInterceptor} interface that only intercepts requests that have a specified namespace URI or local - * part (or both) as payload root. + * Implementation of the + * {@link org.springframework.ws.soap.server.SmartSoapEndpointInterceptor + * SmartSoapEndpointInterceptor} interface that only intercepts requests that have a + * specified namespace URI or local part (or both) as payload root. * * @author Arjen Poutsma * @since 2.0 @@ -42,7 +43,8 @@ public class PayloadRootSmartSoapEndpointInterceptor extends DelegatingSmartSoap private final String localPart; - public PayloadRootSmartSoapEndpointInterceptor(EndpointInterceptor delegate, String namespaceUri, String localPart) { + public PayloadRootSmartSoapEndpointInterceptor(EndpointInterceptor delegate, String namespaceUri, + String localPart) { super(delegate); Assert.hasLength(namespaceUri, "namespaceUri can not be empty"); this.namespaceUri = namespaceUri; @@ -62,8 +64,10 @@ public class PayloadRootSmartSoapEndpointInterceptor extends DelegatingSmartSoap } return !StringUtils.hasLength(localPart) || localPart.equals(payloadRootName.getLocalPart()); - } catch (TransformerException e) { + } + catch (TransformerException e) { return false; } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadValidatingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadValidatingInterceptor.java index ffe85cb5..31b3ca9d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadValidatingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadValidatingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,15 +21,17 @@ import javax.xml.transform.Source; import org.springframework.ws.WebServiceMessage; /** - * Interceptor that validates the contents of {@code WebServiceMessage}s using a schema. Allows for both W3C XML and - * RELAX NG schemas. + * Interceptor that validates the contents of {@code WebServiceMessage}s using a schema. + * Allows for both W3C XML and RELAX NG schemas. *

- * When the payload is invalid, this interceptor stops processing of the interceptor chain. Additionally, if the message - * is a SOAP request message, a SOAP Fault is created as reply. Invalid SOAP responses do not result in a fault. + * When the payload is invalid, this interceptor stops processing of the interceptor + * chain. Additionally, if the message is a SOAP request message, a SOAP Fault is created + * as reply. Invalid SOAP responses do not result in a fault. *

- * The schema to validate against is set with the {@code schema} property or {@code schemas} property. By default, only - * the request message is validated, but this behaviour can be changed using the {@code validateRequest} and - * {@code validateResponse} properties. Responses that contains faults are not validated. + * The schema to validate against is set with the {@code schema} property or + * {@code schemas} property. By default, only the request message is validated, but this + * behaviour can be changed using the {@code validateRequest} and {@code validateResponse} + * properties. Responses that contains faults are not validated. * * @author Arjen Poutsma * @see #setSchema(org.springframework.core.io.Resource) @@ -51,4 +53,5 @@ public class PayloadValidatingInterceptor extends AbstractFaultCreatingValidatin protected Source getValidationResponseSource(WebServiceMessage response) { return response.getPayloadSource(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapActionSmartEndpointInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapActionSmartEndpointInterceptor.java index 84cae985..379351fd 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapActionSmartEndpointInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapActionSmartEndpointInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,8 @@ import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.soap.SoapMessage; /** - * Implementation of the {@link org.springframework.ws.server.SmartEndpointInterceptor} interface that only intercepts - * requests that have a specified soap action. + * Implementation of the {@link org.springframework.ws.server.SmartEndpointInterceptor} + * interface that only intercepts requests that have a specified soap action. * * @author Arjen Poutsma * @since 2.0 @@ -48,8 +48,10 @@ public class SoapActionSmartEndpointInterceptor extends DelegatingSmartSoapEndpo soapAction = soapAction.substring(1, soapAction.length() - 1); } return this.soapAction.equals(soapAction); - } else { + } + else { return false; } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapEnvelopeLoggingInterceptor.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapEnvelopeLoggingInterceptor.java index 412b7d78..e0121e08 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapEnvelopeLoggingInterceptor.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapEnvelopeLoggingInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,9 +26,10 @@ import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.server.SoapEndpointInterceptor; /** - * SOAP-specific {@code EndpointInterceptor} that logs the complete request and response envelope of {@code SoapMessage} - * messages. By default, request, response and fault messages are logged, but this behaviour can be changed using the - * {@code logRequest}, {@code logResponse}, {@code logFault} properties. + * SOAP-specific {@code EndpointInterceptor} that logs the complete request and response + * envelope of {@code SoapMessage} messages. By default, request, response and fault + * messages are logged, but this behaviour can be changed using the {@code logRequest}, + * {@code logResponse}, {@code logFault} properties. * * @author Arjen Poutsma * @see #setLogRequest(boolean) @@ -63,8 +64,10 @@ public class SoapEnvelopeLoggingInterceptor extends AbstractLoggingInterceptor i if (message instanceof SoapMessage) { SoapMessage soapMessage = (SoapMessage) message; return soapMessage.getEnvelope().getSource(); - } else { + } + else { return null; } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMapping.java index e9db34e7..a442ffd8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,15 +25,17 @@ import org.springframework.ws.soap.server.SoapEndpointInvocationChain; import org.springframework.ws.soap.server.SoapEndpointMapping; /** - * {@code EndpointMapping} implement that adds SOAP actors or roles to a delegate endpoint. Delegates to another - * {@code EndpointMapping}, set by {@code delegate}, and adds the actors or roles specified by {@code actorsOrRoles}. + * {@code EndpointMapping} implement that adds SOAP actors or roles to a delegate + * endpoint. Delegates to another {@code EndpointMapping}, set by {@code delegate}, and + * adds the actors or roles specified by {@code actorsOrRoles}. *

- * This endpoint mapping makes it possible to set actors/roles on a specific endpoint, without making the all endpoint - * mappings depend on SOAP-specific functionality. For normal use, setting an actor or role on an endpoint is not - * required, the default 'next' role is sufficient. + * This endpoint mapping makes it possible to set actors/roles on a specific endpoint, + * without making the all endpoint mappings depend on SOAP-specific functionality. For + * normal use, setting an actor or role on an endpoint is not required, the default 'next' + * role is sufficient. *

- * It is only in a scenario when a certain endpoint act as a SOAP intermediary for another endpoint, as described in the - * SOAP specificication, this mapping is useful. + * It is only in a scenario when a certain endpoint act as a SOAP intermediary for another + * endpoint, as described in the SOAP specificication, this mapping is useful. * * @author Arjen Poutsma * @see org.springframework.ws.soap.SoapHeader#examineMustUnderstandHeaderElements(String) @@ -71,9 +73,8 @@ public class DelegatingSoapEndpointMapping implements InitializingBean, SoapEndp } /** - * Creates a new {@code SoapEndpointInvocationChain} based on the delegate endpoint, the delegate interceptors, and - * set actors/roles. - * + * Creates a new {@code SoapEndpointInvocationChain} based on the delegate endpoint, + * the delegate interceptors, and set actors/roles. * @see #setActorsOrRoles(String[]) */ @Override @@ -82,7 +83,8 @@ public class DelegatingSoapEndpointMapping implements InitializingBean, SoapEndp if (delegateChain != null) { return new SoapEndpointInvocationChain(delegateChain.getEndpoint(), delegateChain.getInterceptors(), actorsOrRoles, isUltimateReceiver); - } else { + } + else { return null; } } @@ -91,4 +93,5 @@ public class DelegatingSoapEndpointMapping implements InitializingBean, SoapEndp public void afterPropertiesSet() throws Exception { Assert.notNull(delegate, "delegate is required"); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMapping.java index f17e2ea7..3cac0b93 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,8 +34,9 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapAction; import org.springframework.ws.soap.server.endpoint.annotation.SoapActions; /** - * Implementation of the {@link org.springframework.ws.server.EndpointMapping} interface that uses the - * {@link SoapAction} annotation to map methods to the request SOAPAction header. + * Implementation of the {@link org.springframework.ws.server.EndpointMapping} interface + * that uses the {@link SoapAction} annotation to map methods to the request SOAPAction + * header. *

* Endpoints typically have the following form: * @@ -77,9 +78,8 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio } /** - * Creates a new {@code SoapEndpointInvocationChain} based on the given endpoint, and the set interceptors, and - * actors/roles. - * + * Creates a new {@code SoapEndpointInvocationChain} based on the given endpoint, and + * the set interceptors, and actors/roles. * @param endpoint the endpoint * @param interceptors the endpoint interceptors * @return the created invocation chain @@ -87,8 +87,8 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio * @see #setActorsOrRoles(String[]) */ @Override - protected final EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext, Object endpoint, - EndpointInterceptor[] interceptors) { + protected final EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext, + Object endpoint, EndpointInterceptor[] interceptors) { return new SoapEndpointInvocationChain(endpoint, interceptors, actorsOrRoles, isUltimateReceiver); } @@ -100,10 +100,12 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' && soapAction.charAt(soapAction.length() - 1) == '"') { return soapAction.substring(1, soapAction.length() - 1); - } else { + } + else { return soapAction; } - } else { + } + else { return null; } } @@ -123,7 +125,8 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio for (SoapAction soapAction : soapActions.value()) { result.add(soapAction.value()); } - } else { + } + else { SoapAction soapAction = AnnotationUtils.findAnnotation(method, SoapAction.class); if (soapAction != null) { result.add(soapAction.value()); @@ -131,4 +134,5 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio } return result; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMapping.java index 89e53a24..d3cc9e5d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMapping.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,14 +27,15 @@ import org.springframework.ws.soap.server.SoapEndpointInvocationChain; import org.springframework.ws.soap.server.SoapEndpointMapping; /** - * Implementation of the {@code EndpointMapping} interface to map from {@code SOAPAction} headers to endpoint beans. - * Supports both mapping to bean instances and mapping to bean names: the latter is required for prototype handlers. + * Implementation of the {@code EndpointMapping} interface to map from {@code SOAPAction} + * headers to endpoint beans. Supports both mapping to bean instances and mapping to bean + * names: the latter is required for prototype handlers. *

- * The {@code endpointMap} property is suitable for populating the endpoint map with bean references, e.g. via the map - * element in XML bean definitions. + * The {@code endpointMap} property is suitable for populating the endpoint map with bean + * references, e.g. via the map element in XML bean definitions. *

- * Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the - * {@code java.util.Properties} class, like as follows: + * Mappings to bean names can be set via the {@code mappings} property, in a form accepted + * by the {@code java.util.Properties} class, like as follows: * *

  * http://www.springframework.org/spring-ws/samples/airline/BookFlight=bookFlightEndpoint
@@ -43,8 +44,9 @@ import org.springframework.ws.soap.server.SoapEndpointMapping;
  *
  * The syntax is SOAP_ACTION=ENDPOINT_BEAN_NAME.
  * 

- * This endpoint mapping does not read from the request message, and therefore is more suitable for message factories - * which directly read from the transport request (such as the {@link org.springframework.ws.soap.saaj.SaajSoapMessageFactory} with the + * This endpoint mapping does not read from the request message, and therefore is more + * suitable for message factories which directly read from the transport request (such as + * the {@link org.springframework.ws.soap.saaj.SaajSoapMessageFactory} with the * {@code payloadCaching} disabled). * * @author Arjen Poutsma @@ -74,9 +76,8 @@ public class SoapActionEndpointMapping extends AbstractMapBasedEndpointMapping i } /** - * Creates a new {@code SoapEndpointInvocationChain} based on the given endpoint, and the set interceptors, and - * actors/roles. - * + * Creates a new {@code SoapEndpointInvocationChain} based on the given endpoint, and + * the set interceptors, and actors/roles. * @param endpoint the endpoint * @param interceptors the endpoint interceptors * @return the created invocation chain @@ -84,8 +85,8 @@ public class SoapActionEndpointMapping extends AbstractMapBasedEndpointMapping i * @see #setActorsOrRoles(String[]) */ @Override - protected final EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext, Object endpoint, - EndpointInterceptor[] interceptors) { + protected final EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext, + Object endpoint, EndpointInterceptor[] interceptors) { return new SoapEndpointInvocationChain(endpoint, interceptors, actorsOrRoles, isUltimateReceiver); } @@ -97,10 +98,12 @@ public class SoapActionEndpointMapping extends AbstractMapBasedEndpointMapping i if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' && soapAction.charAt(soapAction.length() - 1) == '"') { return soapAction.substring(1, soapAction.length() - 1); - } else { + } + else { return soapAction; } - } else { + } + else { return null; } } @@ -109,4 +112,5 @@ public class SoapActionEndpointMapping extends AbstractMapBasedEndpointMapping i protected boolean validateLookupKey(String key) { return StringUtils.hasLength(key); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Body.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Body.java index 4c2be7d6..8e87014a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Body.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Body.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,8 @@ import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapFaultException; /** - * Subinterface of {@code SoapBody} that exposes SOAP 1.1 functionality. Necessary because SOAP 1.1 differs from SOAP - * 1.2 with respect to SOAP Faults. + * Subinterface of {@code SoapBody} that exposes SOAP 1.1 functionality. Necessary because + * SOAP 1.1 differs from SOAP 1.2 with respect to SOAP Faults. * * @author Arjen Poutsma * @see Soap11Fault @@ -34,9 +34,8 @@ import org.springframework.ws.soap.SoapFaultException; public interface Soap11Body extends SoapBody { /** - * Adds a SOAP 1.1 Fault to the body with a localized message. Adding a fault removes the - * current content of the body. - * + * Adds a SOAP 1.1 Fault to the body with a localized message. + * Adding a fault removes the current content of the body. * @param faultCode the fully qualified fault faultCode * @param faultString the faultString * @param faultStringLocale the faultString locale. May be {@code null} @@ -59,4 +58,5 @@ public interface Soap11Body extends SoapBody { @Override Soap11Fault addVersionMismatchFault(String faultStringOrReason, Locale locale) throws SoapFaultException; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Fault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Fault.java index a522ad18..abdeefff 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Fault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Fault.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,8 @@ import java.util.Locale; import org.springframework.ws.soap.SoapFault; /** - * Subinterface of {@code SoapFault} that exposes SOAP 1.1 functionality. Necessary because SOAP 1.1 differs from SOAP - * 1.2 with respect to SOAP Faults. + * Subinterface of {@code SoapFault} that exposes SOAP 1.1 functionality. Necessary + * because SOAP 1.1 differs from SOAP 1.2 with respect to SOAP Faults. * * @author Arjen Poutsma * @since 1.0.0 diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Header.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Header.java index f490e458..f52ec146 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Header.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap11/Soap11Header.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,9 +31,9 @@ import org.springframework.ws.soap.SoapHeaderException; public interface Soap11Header extends SoapHeader { /** - * Returns an {@code Iterator} over all the {@link SoapHeaderElement header elements} that should be processed for the - * given actors. Headers target to the "next" actor or role will always be included. - * + * Returns an {@code Iterator} over all the {@link SoapHeaderElement header elements} + * that should be processed for the given actors. Headers target to the "next" actor + * or role will always be included. * @param actors an array of actors to search for * @return an iterator over all the header elements that contain the specified actors * @throws SoapHeaderException if the headers cannot be returned diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Body.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Body.java index 45e9f62c..098a5d13 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Body.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Body.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,8 @@ import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapFaultException; /** - * Subinterface of {@code SoapBody} that exposes SOAP 1.2 functionality. Necessary because SOAP 1.1 differs from SOAP - * 1.2 with respect to SOAP Faults. + * Subinterface of {@code SoapBody} that exposes SOAP 1.2 functionality. Necessary because + * SOAP 1.1 differs from SOAP 1.2 with respect to SOAP Faults. * * @author Arjen Poutsma * @since 1.0.0 @@ -36,7 +36,6 @@ public interface Soap12Body extends SoapBody { * Adds a {@code DataEncodingUnknown} fault to the body. *

* Adding a fault removes the current content of the body. - * * @param subcodes the optional fully qualified fault subcodes * @param reason the fault reason * @param locale the language of the fault reason diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Fault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Fault.java index 14f4c2c5..528530f6 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Fault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Fault.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,8 @@ import javax.xml.namespace.QName; import org.springframework.ws.soap.SoapFault; /** - * Subinterface of {@code SoapFault} that exposes SOAP 1.2 functionality. Necessary because SOAP 1.1 differs from SOAP - * 1.2 with respect to SOAP Faults. + * Subinterface of {@code SoapFault} that exposes SOAP 1.2 functionality. Necessary + * because SOAP 1.1 differs from SOAP 1.2 with respect to SOAP Faults. * * @author Arjen Poutsma * @since 1.0.0 @@ -33,15 +33,14 @@ import org.springframework.ws.soap.SoapFault; public interface Soap12Fault extends SoapFault { /** - * Returns an iteration over the fault subcodes. The subcodes are returned in order: from top to bottom. - * + * Returns an iteration over the fault subcodes. The subcodes are returned in order: + * from top to bottom. * @return an Iterator that contains {@code QNames} representing the fault subcodes */ Iterator getFaultSubcodes(); /** * Adds a fault subcode this fault. - * * @param subcode the qualified name of the subcode */ void addFaultSubcode(QName subcode); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Header.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Header.java index 4725342b..77b6920a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Header.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/soap12/Soap12Header.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,27 +34,26 @@ public interface Soap12Header extends SoapHeader { /** * Adds a new NotUnderstood {@code SoapHeaderElement} this header. - * * @param headerName the qualified name of the header that was not understood * @return the created {@code SoapHeaderElement} - * @throws org.springframework.ws.soap.SoapHeaderException if the header cannot be created + * @throws org.springframework.ws.soap.SoapHeaderException if the header cannot be + * created */ SoapHeaderElement addNotUnderstoodHeaderElement(QName headerName); /** * Adds a new Upgrade {@code SoapHeaderElement} this header. - * * @param supportedSoapUris an array of the URIs of SOAP versions supported * @return the created {@code SoapHeaderElement} - * @throws org.springframework.ws.soap.SoapHeaderException if the header cannot be created + * @throws org.springframework.ws.soap.SoapHeaderException if the header cannot be + * created */ SoapHeaderElement addUpgradeHeaderElement(java.lang.String[] supportedSoapUris); /** - * Returns an {@code Iterator} over all the {@link SoapHeaderElement header elements} that should be processed for the - * given roles. Headers target to the "next" role will always be included, and those targeted to "none" will never be - * included. - * + * Returns an {@code Iterator} over all the {@link SoapHeaderElement header elements} + * that should be processed for the given roles. Headers target to the "next" role + * will always be included, and those targeted to "none" will never be included. * @param roles an array of roles to search for * @param isUltimateReceiver whether to search for headers for the ultimate receiver * @return an iterator over all the header elements that contain the specified roles diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java index 189055c4..15228da7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,7 +34,8 @@ public abstract class SoapUtils { private static final Pattern ACTION_PATTERN = Pattern.compile("action\\s*=\\s*([^;]+)"); - private SoapUtils() {} + private SoapUtils() { + } /** Escapes the given SOAP action to be surrounded by quotes. */ public static String escapeAction(String soapAction) { @@ -53,7 +54,6 @@ public abstract class SoapUtils { /** * Returns the value of the action parameter in the given SOAP 1.2 content type. - * * @param contentType the SOAP 1.2 content type * @return the action */ @@ -69,8 +69,8 @@ public abstract class SoapUtils { } /** - * Replaces or adds the value of the action parameter in the given SOAP 1.2 content type. - * + * Replaces or adds the value of the action parameter in the given SOAP 1.2 content + * type. * @param contentType the SOAP 1.2 content type * @param action the action * @return the new content type @@ -86,11 +86,14 @@ public abstract class SoapUtils { matcher.appendReplacement(builder, "action=" + action); matcher.appendTail(builder); return builder.toString(); - } else { + } + else { return contentType + "; action=" + action; } - } else { + } + else { return contentType; } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/stream/StreamingPayload.java b/spring-ws-core/src/main/java/org/springframework/ws/stream/StreamingPayload.java index 3fee6037..70a7139e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/stream/StreamingPayload.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/stream/StreamingPayload.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,7 +21,8 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; /** - * Defines the contract for payloads that can be written directly to a {@link XMLStreamWriter}. + * Defines the contract for payloads that can be written directly to a + * {@link XMLStreamWriter}. * * @author Arjen Poutsma * @see StreamingWebServiceMessage @@ -30,16 +31,15 @@ import javax.xml.stream.XMLStreamWriter; public interface StreamingPayload { /** - * Returns the qualified name of the payload. Only the namespace URI and local part of the returned qualified name are - * significant; they must match the name of the root element produced by {@link #writeTo(XMLStreamWriter)}. - * + * Returns the qualified name of the payload. Only the namespace URI and local part of + * the returned qualified name are significant; they must match the name of the root + * element produced by {@link #writeTo(XMLStreamWriter)}. * @return the qualified name */ QName getName(); /** * Writes this payload to the given {@link XMLStreamWriter}. - * * @param streamWriter the stream writer to write to * @throws XMLStreamException in case of errors */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/stream/StreamingWebServiceMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/stream/StreamingWebServiceMessage.java index e9d73090..548eb5d5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/stream/StreamingWebServiceMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/stream/StreamingWebServiceMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,7 +29,6 @@ public interface StreamingWebServiceMessage extends WebServiceMessage { /** * Sets the streaming payload for this message. - * * @param payload the streaming payload */ void setStreamingPayload(StreamingPayload payload); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/support/DefaultStrategiesHelper.java b/spring-ws-core/src/main/java/org/springframework/ws/support/DefaultStrategiesHelper.java index 31a039c4..e7d0981e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/support/DefaultStrategiesHelper.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/support/DefaultStrategiesHelper.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,14 @@ package org.springframework.ws.support; -import jakarta.servlet.ServletContext; - import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Properties; +import jakarta.servlet.ServletContext; + import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; @@ -49,8 +49,9 @@ import org.springframework.web.context.ServletContextAware; import org.springframework.web.context.WebApplicationContext; /** - * Helper class for for loading default implementations of an interface. Encapsulates a properties object, which - * contains strategy interface names as keys, and comma-separated class names as values. + * Helper class for for loading default implementations of an interface. Encapsulates a + * properties object, which contains strategy interface names as keys, and comma-separated + * class names as values. *

* Simulates the {@link BeanFactory normal lifecycle} for beans, by calling * {@link BeanFactoryAware#setBeanFactory(BeanFactory)}, @@ -64,34 +65,42 @@ public class DefaultStrategiesHelper { /** Keys are strategy interface names, values are implementation class names. */ private Properties defaultStrategies; - /** Initializes a new instance of the {@code DefaultStrategiesHelper} based on the given set of properties. */ + /** + * Initializes a new instance of the {@code DefaultStrategiesHelper} based on the + * given set of properties. + */ public DefaultStrategiesHelper(Properties defaultStrategies) { Assert.notNull(defaultStrategies, "defaultStrategies must not be null"); this.defaultStrategies = defaultStrategies; } - /** Initializes a new instance of the {@code DefaultStrategiesHelper} based on the given resource. */ + /** + * Initializes a new instance of the {@code DefaultStrategiesHelper} based on the + * given resource. + */ public DefaultStrategiesHelper(Resource resource) throws IllegalStateException { try { defaultStrategies = PropertiesLoaderUtils.loadProperties(resource); - } catch (IOException ex) { + } + catch (IOException ex) { throw new IllegalStateException("Could not load '" + resource + "': " + ex.getMessage()); } } /** - * Initializes a new instance of the {@code DefaultStrategiesHelper} based on the given type. + * Initializes a new instance of the {@code DefaultStrategiesHelper} based on the + * given type. *

- * This constructor will attempt to load a 'typeName'.properties file in the same package as the given type. + * This constructor will attempt to load a 'typeName'.properties file in the same + * package as the given type. */ public DefaultStrategiesHelper(Class type) { this(new ClassPathResource(ClassUtils.getShortName(type) + ".properties", type)); } /** - * Create a list of strategy objects for the given strategy interface. Strategies are retrieved from the - * {@code Properties} object given at construction-time. - * + * Create a list of strategy objects for the given strategy interface. Strategies are + * retrieved from the {@code Properties} object given at construction-time. * @param strategyInterface the strategy interface * @return a list of corresponding strategy objects * @throws BeansException if initialization failed @@ -101,12 +110,13 @@ public class DefaultStrategiesHelper { } /** - * Create a list of strategy objects for the given strategy interface. Strategies are retrieved from the - * {@code Properties} object given at construction-time. It instantiates the strategy objects and satisfies - * {@code ApplicationContextAware} with the supplied context if necessary. - * + * Create a list of strategy objects for the given strategy interface. Strategies are + * retrieved from the {@code Properties} object given at construction-time. It + * instantiates the strategy objects and satisfies {@code ApplicationContextAware} + * with the supplied context if necessary. * @param strategyInterface the strategy interface - * @param applicationContext used to satisfy strategies that are application context aware, may be {@code null} + * @param applicationContext used to satisfy strategies that are application context + * aware, may be {@code null} * @return a list of corresponding strategy objects * @throws BeansException if initialization failed */ @@ -120,7 +130,7 @@ public class DefaultStrategiesHelper { return Collections.emptyList(); } String[] classNames = StringUtils.commaDelimitedListToStringArray(value); - List result = new ArrayList<>(classNames.length); + List result = new ArrayList<>(classNames.length); ClassLoader classLoader = null; if (applicationContext != null) { classLoader = applicationContext.getClassLoader(); @@ -137,8 +147,10 @@ public class DefaultStrategiesHelper { } result.sort(new OrderComparator()); return result; - } catch (ClassNotFoundException ex) { - throw new BeanInitializationException("Could not find default strategy class for interface [" + key + "]", ex); + } + catch (ClassNotFoundException ex) { + throw new BeanInitializationException("Could not find default strategy class for interface [" + key + "]", + ex); } } @@ -178,7 +190,8 @@ public class DefaultStrategiesHelper { InitializingBean initializingBean = (InitializingBean) strategy; try { initializingBean.afterPropertiesSet(); - } catch (Throwable ex) { + } + catch (Throwable ex) { throw new BeanCreationException("Invocation of init method failed", ex); } } @@ -187,7 +200,6 @@ public class DefaultStrategiesHelper { /** * Return the default strategy object for the given strategy interface. - * * @param strategyInterface the strategy interface * @return the corresponding strategy object * @throws BeansException if initialization failed @@ -200,10 +212,11 @@ public class DefaultStrategiesHelper { /** * Return the default strategy object for the given strategy interface. *

- * Delegates to {@link #getDefaultStrategies(Class,ApplicationContext)}, expecting a single object in the list. - * + * Delegates to {@link #getDefaultStrategies(Class,ApplicationContext)}, expecting a + * single object in the list. * @param strategyInterface the strategy interface - * @param applicationContext used to satisfy strategies that are application context aware, may be {@code null} + * @param applicationContext used to satisfy strategies that are application context + * aware, may be {@code null} * @return the corresponding strategy object * @throws BeansException if initialization failed */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/support/MarshallingUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/support/MarshallingUtils.java index 01d486a1..0d79def6 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/support/MarshallingUtils.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/support/MarshallingUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.support; -import jakarta.activation.DataHandler; - import java.io.IOException; import javax.xml.transform.Source; +import jakarta.activation.DataHandler; + import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.mime.MimeContainer; @@ -39,14 +39,16 @@ import org.springframework.ws.mime.MimeMessage; */ public abstract class MarshallingUtils { - private MarshallingUtils() {} + private MarshallingUtils() { + } /** - * Unmarshals the payload of the given message using the provided {@link Unmarshaller}. + * Unmarshals the payload of the given message using the provided + * {@link Unmarshaller}. *

- * If the request message has no payload (i.e. {@link WebServiceMessage#getPayloadSource()} returns {@code null}), - * this method will return {@code null}. - * + * If the request message has no payload (i.e. + * {@link WebServiceMessage#getPayloadSource()} returns {@code null}), this method + * will return {@code null}. * @param unmarshaller the unmarshaller * @param message the message of which the payload is to be unmarshalled * @return the unmarshalled object @@ -56,18 +58,20 @@ public abstract class MarshallingUtils { Source payload = message.getPayloadSource(); if (payload == null) { return null; - } else if (unmarshaller instanceof MimeUnmarshaller && message instanceof MimeMessage) { + } + else if (unmarshaller instanceof MimeUnmarshaller && message instanceof MimeMessage) { MimeUnmarshaller mimeUnmarshaller = (MimeUnmarshaller) unmarshaller; MimeMessageContainer container = new MimeMessageContainer((MimeMessage) message); return mimeUnmarshaller.unmarshal(payload, container); - } else { + } + else { return unmarshaller.unmarshal(payload); } } /** - * Marshals the given object to the payload of the given message using the provided {@link Marshaller}. - * + * Marshals the given object to the payload of the given message using the provided + * {@link Marshaller}. * @param marshaller the marshaller * @param graph the root of the object graph to marshal * @param message the message of which the payload is to be unmarshalled @@ -78,7 +82,8 @@ public abstract class MarshallingUtils { MimeMarshaller mimeMarshaller = (MimeMarshaller) marshaller; MimeMessageContainer container = new MimeMessageContainer((MimeMessage) message); mimeMarshaller.marshal(graph, message.getPayloadResult(), container); - } else { + } + else { marshaller.marshal(graph, message.getPayloadResult()); } } @@ -111,6 +116,7 @@ public abstract class MarshallingUtils { Attachment attachment = mimeMessage.getAttachment(contentId); return attachment != null ? attachment.getDataHandler() : null; } + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/support/WebUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/support/WebUtils.java index 2b27b567..055e0452 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/support/WebUtils.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/support/WebUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,9 @@ package org.springframework.ws.support; /** - * Miscellaneous utilities for web applications. Used by various framework classes. NOTE: These are the parts of - * org.springframework.web.util.WebUtils deprecated in Spring Framework 5. + * Miscellaneous utilities for web applications. Used by various framework classes. NOTE: + * These are the parts of org.springframework.web.util.WebUtils deprecated in Spring + * Framework 5. * * @author Greg Turnquist * @author Rod Johnson @@ -28,9 +29,8 @@ package org.springframework.ws.support; public abstract class WebUtils { /** - * Extract the URL filename from the given request URL path. Correctly resolves nested paths such as - * "/products/view.html" as well. - * + * Extract the URL filename from the given request URL path. Correctly resolves nested + * paths such as "/products/view.html" as well. * @param urlPath the request URL path (e.g. "/index.html") * @return the extracted URI filename (e.g. "index") */ @@ -44,9 +44,9 @@ public abstract class WebUtils { } /** - * Extract the full URL filename (including file extension) from the given request URL path. Correctly resolve nested - * paths such as "/products/view.html" and remove any path and or query parameters. - * + * Extract the full URL filename (including file extension) from the given request URL + * path. Correctly resolve nested paths such as "/products/view.html" and remove any + * path and or query parameters. * @param urlPath the request URL path (e.g. "/products/index.html") * @return the extracted URI filename (e.g. "index.html") */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java index f5cf04cd..07da5bf5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,7 +22,8 @@ import java.io.OutputStream; import java.util.Iterator; /** - * Abstract base class for {@link WebServiceConnection} implementations used for receiving requests. + * Abstract base class for {@link WebServiceConnection} implementations used for receiving + * requests. * * @author Arjen Poutsma * @author Greg Turnquist @@ -53,11 +54,11 @@ public abstract class AbstractReceiverConnection extends AbstractWebServiceConne /** * Template method invoked from {@link #close()}. Default implementation is empty. - * * @throws IOException if an I/O error occurs when closing this connection */ @Override - protected void onClose() throws IOException {} + protected void onClose() throws IOException { + } /** Returns the input stream to read the response from. */ protected abstract InputStream getRequestInputStream() throws IOException; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java index aee201b1..aadd217e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,7 +22,8 @@ import java.io.OutputStream; import java.util.Iterator; /** - * Abstract base class for {@link WebServiceConnection} implementations used for sending requests. + * Abstract base class for {@link WebServiceConnection} implementations used for sending + * requests. * * @author Arjen Poutsma * @author Greg Turnquist @@ -50,18 +51,19 @@ public abstract class AbstractSenderConnection extends AbstractWebServiceConnect responseInputStream = new ResponseTransportInputStream(); } return responseInputStream; - } else { + } + else { return null; } } /** * Template method invoked from {@link #close()}. Default implementation is empty. - * * @throws IOException if an I/O error occurs when closing this connection */ @Override - protected void onClose() throws IOException {} + protected void onClose() throws IOException { + } /** Indicates whether this connection has a response. */ protected abstract boolean hasResponse() throws IOException; @@ -84,6 +86,7 @@ public abstract class AbstractSenderConnection extends AbstractWebServiceConnect protected OutputStream createOutputStream() throws IOException { return getRequestOutputStream(); } + } /** Implementation of {@link TransportInputStream} for client-side HTTP. */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractWebServiceConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractWebServiceConnection.java index f05dfbb6..1bdfedd8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractWebServiceConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/AbstractWebServiceConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -49,34 +49,34 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti } /** - * Called before the given message has been written to the {@code TransportOutputStream}. Called from - * {@link #send(WebServiceMessage)}. + * Called before the given message has been written to the + * {@code TransportOutputStream}. Called from {@link #send(WebServiceMessage)}. *

* Default implementation does nothing. - * * @param message the message * @throws IOException when an I/O exception occurs */ - protected void onSendBeforeWrite(WebServiceMessage message) throws IOException {} + protected void onSendBeforeWrite(WebServiceMessage message) throws IOException { + } /** - * Returns a {@code TransportOutputStream} for the given message. Called from {@link #send(WebServiceMessage)}. - * + * Returns a {@code TransportOutputStream} for the given message. Called from + * {@link #send(WebServiceMessage)}. * @return the output stream * @throws IOException when an I/O exception occurs */ protected abstract TransportOutputStream createTransportOutputStream() throws IOException; /** - * Called after the given message has been written to the {@code TransportOutputStream}. Called from - * {@link #send(WebServiceMessage)}. + * Called after the given message has been written to the + * {@code TransportOutputStream}. Called from {@link #send(WebServiceMessage)}. *

* Default implementation does nothing. - * * @param message the message * @throws IOException when an I/O exception occurs */ - protected void onSendAfterWrite(WebServiceMessage message) throws IOException {} + protected void onSendAfterWrite(WebServiceMessage message) throws IOException { + } @Override public final WebServiceMessage receive(WebServiceMessageFactory messageFactory) throws IOException { @@ -92,33 +92,33 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti } /** - * Called before a message has been read from the {@code TransportInputStream}. Called from - * {@link #receive(WebServiceMessageFactory)}. + * Called before a message has been read from the {@code TransportInputStream}. Called + * from {@link #receive(WebServiceMessageFactory)}. *

* Default implementation does nothing. - * * @throws IOException when an I/O exception occurs */ - protected void onReceiveBeforeRead() throws IOException {} + protected void onReceiveBeforeRead() throws IOException { + } /** - * Returns a {@code TransportInputStream}. Called from {@link #receive(WebServiceMessageFactory)}. - * + * Returns a {@code TransportInputStream}. Called from + * {@link #receive(WebServiceMessageFactory)}. * @return the input stream, or {@code null} if no response can be read * @throws IOException when an I/O exception occurs */ protected abstract TransportInputStream createTransportInputStream() throws IOException; /** - * Called when the given message has been read from the {@code TransportInputStream}. Called from - * {@link #receive(WebServiceMessageFactory)}. + * Called when the given message has been read from the {@code TransportInputStream}. + * Called from {@link #receive(WebServiceMessageFactory)}. *

* Default implementation does nothing. - * * @param message the message * @throws IOException when an I/O exception occurs */ - protected void onReceiveAfterRead(WebServiceMessage message) throws IOException {} + protected void onReceiveAfterRead(WebServiceMessage message) throws IOException { + } @Override public final void close() throws IOException { @@ -126,14 +126,16 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti if (tis != null) { try { tis.close(); - } catch (IOException ex) { + } + catch (IOException ex) { ioex = ex; } } if (tos != null) { try { tos.close(); - } catch (IOException ex) { + } + catch (IOException ex) { ioex = ex; } } @@ -152,9 +154,9 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti /** * Template method invoked from {@link #close()}. Default implementation is empty. - * * @throws IOException if an I/O error occurs when closing this connection */ - protected void onClose() throws IOException {} + protected void onClose() throws IOException { + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/EndpointAwareWebServiceConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/EndpointAwareWebServiceConnection.java index e22c6176..3d1d24ca 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/EndpointAwareWebServiceConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/EndpointAwareWebServiceConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,9 @@ package org.springframework.ws.transport; import org.springframework.ws.NoEndpointFoundException; /** - * Sub-interface of {@link WebServiceConnection} that is aware of any server-side situations where an endpoint is not - * found. Typically, this results in a special error codes. + * Sub-interface of {@link WebServiceConnection} that is aware of any server-side + * situations where an endpoint is not found. Typically, this results in a special error + * codes. * * @author Arjen Poutsma * @see NoEndpointFoundException diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/FaultAwareWebServiceConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/FaultAwareWebServiceConnection.java index 283915f6..dff387a3 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/FaultAwareWebServiceConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/FaultAwareWebServiceConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,9 +23,10 @@ import javax.xml.namespace.QName; import org.springframework.ws.soap.SoapFault; /** - * Sub-interface of {@link WebServiceConnection} that is aware of any Fault messages received. Fault messages (such as - * {@link SoapFault} SOAP Faults) often require different processing rules. Typically, fault detection is done by - * inspecting connection error codes, etc. + * Sub-interface of {@link WebServiceConnection} that is aware of any Fault messages + * received. Fault messages (such as {@link SoapFault} SOAP Faults) often require + * different processing rules. Typically, fault detection is done by inspecting connection + * error codes, etc. * * @author Arjen Poutsma * @since 1.0.0 @@ -36,7 +37,6 @@ public interface FaultAwareWebServiceConnection extends WebServiceConnection { * Indicates whether this connection received a fault. *

* Typically implemented by looking at an HTTP status code. - * * @return {@code true} if this connection received a fault; {@code false} otherwise. * @throws IOException in case of I/O errors */ @@ -46,7 +46,6 @@ public interface FaultAwareWebServiceConnection extends WebServiceConnection { * Sets whether this connection will send a fault. *

* Typically implemented by setting an HTTP status code. - * * @param fault {@code true} if this will send a fault; {@code false} otherwise. * @throws IOException in case of I/O errors * @deprecated In favor of {@link #setFaultCode(QName)} @@ -58,9 +57,10 @@ public interface FaultAwareWebServiceConnection extends WebServiceConnection { * Sets a specific fault code. *

* Typically implemented by setting an HTTP status code. - * - * @param faultCode the fault code to be set on the connection, or {@code null} for no fault. + * @param faultCode the fault code to be set on the connection, or {@code null} for no + * fault. * @throws IOException in case of I/O errors */ void setFaultCode(QName faultCode) throws IOException; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/HeadersAwareReceiverWebServiceConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/HeadersAwareReceiverWebServiceConnection.java index bc7ecb3f..5294071b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/HeadersAwareReceiverWebServiceConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/HeadersAwareReceiverWebServiceConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,7 +19,8 @@ import java.io.IOException; import java.util.Iterator; /** - * Interface to define access to header information for certain {@link WebServiceConnection} implementations. + * Interface to define access to header information for certain + * {@link WebServiceConnection} implementations. * * @author Greg Turnquist * @since 2.3 @@ -27,21 +28,20 @@ import java.util.Iterator; public interface HeadersAwareReceiverWebServiceConnection { /** - * Returns an iteration over all the header names this request contains. Returns an empty {@code Iterator} if there - * are no headers. + * Returns an iteration over all the header names this request contains. Returns an + * empty {@code Iterator} if there are no headers. */ Iterator getRequestHeaderNames() throws IOException; /** - * Returns an iteration over all the string values of the specified header. Returns an empty {@code Iterator} if there - * are no headers of the specified name. + * Returns an iteration over all the string values of the specified header. Returns an + * empty {@code Iterator} if there are no headers of the specified name. */ Iterator getRequestHeaders(String name) throws IOException; /** - * Adds a response header with the given name and value. This method can be called multiple times, to allow for - * headers with multiple values. - * + * Adds a response header with the given name and value. This method can be called + * multiple times, to allow for headers with multiple values. * @param name the name of the header * @param value the value of the header */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/HeadersAwareSenderWebServiceConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/HeadersAwareSenderWebServiceConnection.java index 954dceb3..e088fbd1 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/HeadersAwareSenderWebServiceConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/HeadersAwareSenderWebServiceConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,21 +25,20 @@ import java.util.Iterator; public interface HeadersAwareSenderWebServiceConnection { /** - * Returns an iteration over all the header names this request contains. Returns an empty {@code Iterator} if there - * are no headers. + * Returns an iteration over all the header names this request contains. Returns an + * empty {@code Iterator} if there are no headers. */ Iterator getResponseHeaderNames() throws IOException; /** - * Returns an iteration over all the string values of the specified header. Returns an empty {@code Iterator} if there - * are no headers of the specified name. + * Returns an iteration over all the string values of the specified header. Returns an + * empty {@code Iterator} if there are no headers of the specified name. */ Iterator getResponseHeaders(String name) throws IOException; /** - * Adds a request header with the given name and value. This method can be called multiple times, to allow for headers - * with multiple values. - * + * Adds a request header with the given name and value. This method can be called + * multiple times, to allow for headers with multiple values. * @param name the name of the header * @param value the value of the header */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportConstants.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportConstants.java index 538f950e..122106c4 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportConstants.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportConstants.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -50,4 +50,5 @@ public interface TransportConstants { /** The empty SOAP action value. */ String EMPTY_SOAP_ACTION = "\"\""; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportInputStream.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportInputStream.java index f311b469..6153675c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportInputStream.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportInputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,9 @@ import java.util.Iterator; import org.springframework.util.Assert; /** - * A {@code TransportInputStream} is an input stream with MIME input headers. It is used to construct - * {@link org.springframework.ws.WebServiceMessage WebServiceMessages} from a transport. + * A {@code TransportInputStream} is an input stream with MIME input headers. It is used + * to construct {@link org.springframework.ws.WebServiceMessage WebServiceMessages} from a + * transport. * * @author Arjen Poutsma * @see #getHeaderNames() @@ -35,7 +36,8 @@ public abstract class TransportInputStream extends InputStream { private InputStream inputStream; - protected TransportInputStream() {} + protected TransportInputStream() { + } private InputStream getInputStream() throws IOException { if (inputStream == null) { @@ -61,7 +63,8 @@ public abstract class TransportInputStream extends InputStream { public synchronized void mark(int readlimit) { try { getInputStream().mark(readlimit); - } catch (IOException e) { + } + catch (IOException e) { // ignored } } @@ -70,7 +73,8 @@ public abstract class TransportInputStream extends InputStream { public boolean markSupported() { try { return getInputStream().markSupported(); - } catch (IOException e) { + } + catch (IOException e) { return false; } } @@ -104,14 +108,15 @@ public abstract class TransportInputStream extends InputStream { protected abstract InputStream createInputStream() throws IOException; /** - * Returns an iteration over all the header names this stream contains. Returns an empty {@code Iterator} if there are - * no headers. + * Returns an iteration over all the header names this stream contains. Returns an + * empty {@code Iterator} if there are no headers. */ public abstract Iterator getHeaderNames() throws IOException; /** - * Returns an iteration over all the string values of the specified header. Returns an empty {@code Iterator} if there - * are no headers of the specified name. + * Returns an iteration over all the string values of the specified header. Returns an + * empty {@code Iterator} if there are no headers of the specified name. */ public abstract Iterator getHeaders(String name) throws IOException; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportOutputStream.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportOutputStream.java index 1bb975d1..e930a05c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportOutputStream.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/TransportOutputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,8 +22,9 @@ import java.io.OutputStream; import org.springframework.util.Assert; /** - * A {@code TransportOutputStream} is an output stream with MIME input headers. It is used to write - * {@link org.springframework.ws.WebServiceMessage WebServiceMessages} to a transport. + * A {@code TransportOutputStream} is an output stream with MIME input headers. It is used + * to write {@link org.springframework.ws.WebServiceMessage WebServiceMessages} to a + * transport. * * @author Arjen Poutsma * @see #addHeader(String,String) @@ -33,7 +34,8 @@ public abstract class TransportOutputStream extends OutputStream { private OutputStream outputStream; - protected TransportOutputStream() {} + protected TransportOutputStream() { + } private OutputStream getOutputStream() throws IOException { if (outputStream == null) { @@ -73,9 +75,8 @@ public abstract class TransportOutputStream extends OutputStream { } /** - * Adds a header with the given name and value. This method can be called multiple times, to allow for headers with - * multiple values. - * + * Adds a header with the given name and value. This method can be called multiple + * times, to allow for headers with multiple values. * @param name the name of the header * @param value the value of the header */ @@ -83,4 +84,5 @@ public abstract class TransportOutputStream extends OutputStream { /** Returns the output stream to write to. */ protected abstract OutputStream createOutputStream() throws IOException; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceConnection.java index 6f6629e5..fcf6f85a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,8 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; /** - * Represents a point-to-point connection that a client can use for sending {@link WebServiceMessage} objects directly - * to a remote party. + * Represents a point-to-point connection that a client can use for sending + * {@link WebServiceMessage} objects directly to a remote party. *

* A {@code WebServiceConnection} can be obtained using a {@link WebServiceMessageSender}. * @@ -37,16 +37,14 @@ public interface WebServiceConnection extends AutoCloseable { /** * Sends the given message using this connection. - * * @param message the message to be sent * @throws IOException in case of I/O errors */ void send(WebServiceMessage message) throws IOException; /** - * Receives a message using the given {@link WebServiceMessageFactory}. This method blocks until it receives, or - * returns {@code null} when no message is received. - * + * Receives a message using the given {@link WebServiceMessageFactory}. This method + * blocks until it receives, or returns {@code null} when no message is received. * @param messageFactory the message factory used for reading messages * @return the read message, or {@code null} if no message received * @throws IOException in case of I/O errors @@ -57,17 +55,16 @@ public interface WebServiceConnection extends AutoCloseable { URI getUri() throws URISyntaxException; /** - * Indicates whether this connection has an error. Typically, error detection is done by inspecting connection error - * codes, etc. - * + * Indicates whether this connection has an error. Typically, error detection is done + * by inspecting connection error codes, etc. * @return {@code true} if this connection has an error; {@code false} otherwise. */ boolean hasError() throws IOException; /** * Returns the error message. - * - * @return the connection error message, if any; returns {@code null} when no error is present + * @return the connection error message, if any; returns {@code null} when no error is + * present * @see #hasError() */ String getErrorMessage() throws IOException; @@ -75,8 +72,8 @@ public interface WebServiceConnection extends AutoCloseable { /** * Closes this connection. *

- * Once a connection has been closed, it is not available for further use. A new connection needs to be created. - * + * Once a connection has been closed, it is not available for further use. A new + * connection needs to be created. * @throws IOException if an I/O error occurs when closing this connection */ void close() throws IOException; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceMessageReceiver.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceMessageReceiver.java index d0f7e420..7d83481e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceMessageReceiver.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceMessageReceiver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,8 @@ package org.springframework.ws.transport; import org.springframework.ws.context.MessageContext; /** - * Defines the methods for classes capable of receiving {@link org.springframework.ws.WebServiceMessage} instances - * coming in on a transport. + * Defines the methods for classes capable of receiving + * {@link org.springframework.ws.WebServiceMessage} instances coming in on a transport. * * @author Arjen Poutsma * @since 1.0.0 @@ -28,8 +28,8 @@ import org.springframework.ws.context.MessageContext; public interface WebServiceMessageReceiver { /** - * Receives the given message context. The given message context can be used to create a response. - * + * Receives the given message context. The given message context can be used to create + * a response. * @param messageContext the message context to be received */ void receive(MessageContext messageContext) throws Exception; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceMessageSender.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceMessageSender.java index e11bf323..5a306a99 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceMessageSender.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/WebServiceMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,10 +22,11 @@ import java.net.URI; import org.springframework.ws.WebServiceMessage; /** - * Defines the methods for classes capable of sending and receiving {@link WebServiceMessage} instances across a - * transport. + * Defines the methods for classes capable of sending and receiving + * {@link WebServiceMessage} instances across a transport. *

- * The {@code WebServiceMessageSender} is basically a factory for {@link WebServiceConnection} objects. + * The {@code WebServiceMessageSender} is basically a factory for + * {@link WebServiceConnection} objects. * * @author Arjen Poutsma * @see WebServiceConnection @@ -35,7 +36,6 @@ public interface WebServiceMessageSender { /** * Create a new {@link WebServiceConnection} to the specified URI. - * * @param uri the URI to open a connection to * @return the new connection * @throws IOException in case of I/O errors @@ -44,9 +44,9 @@ public interface WebServiceMessageSender { /** * Does this {@link WebServiceMessageSender} support the supplied URI? - * * @param uri the URI to be checked - * @return {@code true} if this {@code WebServiceMessageSender} supports the supplied URI + * @return {@code true} if this {@code WebServiceMessageSender} supports the supplied + * URI */ boolean supports(URI uri); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/context/DefaultTransportContext.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/context/DefaultTransportContext.java index 739541e5..085e4705 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/context/DefaultTransportContext.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/context/DefaultTransportContext.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,7 +29,9 @@ public class DefaultTransportContext implements TransportContext { private final WebServiceConnection connection; - /** Creates a new {@code DefaultTransportContext} that exposes the given connection. */ + /** + * Creates a new {@code DefaultTransportContext} that exposes the given connection. + */ public DefaultTransportContext(WebServiceConnection connection) { Assert.notNull(connection, "'connection' must not be null"); this.connection = connection; @@ -43,4 +45,5 @@ public class DefaultTransportContext implements TransportContext { public String toString() { return connection.toString(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContext.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContext.java index 2f62990f..02ffc75c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContext.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContext.java @@ -1,11 +1,29 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.transport.context; import org.springframework.ws.transport.WebServiceConnection; /** - * Strategy interface for determining the current {@link org.springframework.ws.transport.WebServiceConnection}. + * Strategy interface for determining the current + * {@link org.springframework.ws.transport.WebServiceConnection}. *

- * An instance of this class can be associated with a thread via the {@link TransportContextHolder} class. + * An instance of this class can be associated with a thread via the + * {@link TransportContextHolder} class. * * @author Arjen Poutsma * @since 1.0.0 @@ -14,4 +32,5 @@ public interface TransportContext { /** Returns the current {@code WebServiceConnection}. */ WebServiceConnection getConnection(); + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContextHolder.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContextHolder.java index 6c75d5cd..ca5f3d16 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContextHolder.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContextHolder.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -17,8 +17,9 @@ package org.springframework.ws.transport.context; /** - * Simple holder class that associates a {@code TransportContext} instance with the current thread. The - * {@code TransportContext} will be inherited by any child threads spawned by the current thread. + * Simple holder class that associates a {@code TransportContext} instance with the + * current thread. The {@code TransportContext} will be inherited by any child threads + * spawned by the current thread. * * @author Arjen Poutsma * @see TransportContext @@ -30,8 +31,8 @@ public abstract class TransportContextHolder { /** * Associate the given {@code TransportContext} with the current thread. - * - * @param transportContext the current transport context, or {@code null} to reset the thread-bound context + * @param transportContext the current transport context, or {@code null} to reset the + * thread-bound context */ public static void setTransportContext(TransportContext transportContext) { transportContextHolder.set(transportContext); @@ -39,7 +40,6 @@ public abstract class TransportContextHolder { /** * Return the {@code TransportContext} associated with the current thread, if any. - * * @return the current transport context, or {@code null} if none */ public static TransportContext getTransportContext() { @@ -51,5 +51,7 @@ public abstract class TransportContextHolder { public String toString() { return "Transport State"; } + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpSenderConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpSenderConnection.java index 8c48812e..6fa386cc 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpSenderConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpSenderConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,7 +30,8 @@ import org.springframework.ws.transport.FaultAwareWebServiceConnection; import org.springframework.ws.transport.WebServiceConnection; /** - * Abstract base class for {@link WebServiceConnection} implementations that send request over HTTP. + * Abstract base class for {@link WebServiceConnection} implementations that send request + * over HTTP. * * @author Arjen Poutsma * @author Andreas Veithen @@ -45,7 +46,8 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect private Boolean hasResponse; /** - * The raw response input stream to use instead of calling {@link #getRawResponseInputStream()}. + * The raw response input stream to use instead of calling + * {@link #getRawResponseInputStream()}. */ private PushbackInputStream rawResponseInputStream; @@ -86,11 +88,13 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect int b = rawResponseInputStream.read(); if (b == -1) { hasResponse = Boolean.FALSE; - } else { + } + else { hasResponse = Boolean.TRUE; rawResponseInputStream.unread(b); } - } else { + } + else { hasResponse = contentLength > 0; } return hasResponse; @@ -134,7 +138,8 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect @Override public final boolean hasFault() throws IOException { // SOAP 1.1 specifies a 500 status code for faults - // SOAP 1.2 specifies a 400 status code for sender faults, and 500 for all other faults + // SOAP 1.2 specifies a 400 status code for sender faults, and 500 for all other + // faults switch (getResponseCode()) { case HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR: return isSoap11Response() || isSoap12Response(); @@ -167,8 +172,11 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect @Override @Deprecated - public final void setFault(boolean fault) {} + public final void setFault(boolean fault) { + } @Override - public final void setFaultCode(QName faultCode) throws IOException {} + public final void setFaultCode(QName faultCode) throws IOException { + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpWebServiceMessageSender.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpWebServiceMessageSender.java index a4c3aa57..1e6ff18d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpWebServiceMessageSender.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpWebServiceMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,11 +20,13 @@ import java.net.URI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.ws.transport.WebServiceMessageSender; /** - * Abstract base class for {@link org.springframework.ws.transport.WebServiceMessageSender} implementations that use - * HTTP. + * Abstract base class for + * {@link org.springframework.ws.transport.WebServiceMessageSender} implementations that + * use HTTP. * * @author Arjen Poutsma * @since 1.0.0 @@ -39,19 +41,19 @@ public abstract class AbstractHttpWebServiceMessageSender implements WebServiceM private boolean acceptGzipEncoding = true; /** - * Return whether to accept GZIP encoding, that is, whether to send the HTTP {@code Accept-Encoding} header with - * {@code gzip} as value. + * Return whether to accept GZIP encoding, that is, whether to send the HTTP + * {@code Accept-Encoding} header with {@code gzip} as value. */ public boolean isAcceptGzipEncoding() { return acceptGzipEncoding; } /** - * Set whether to accept GZIP encoding, that is, whether to send the HTTP {@code Accept-Encoding} header with - * {@code gzip} as value. + * Set whether to accept GZIP encoding, that is, whether to send the HTTP + * {@code Accept-Encoding} header with {@code gzip} as value. *

- * Default is {@code true}. Turn this flag off if you do not want GZIP response compression even if enabled on the - * HTTP server. + * Default is {@code true}. Turn this flag off if you do not want GZIP response + * compression even if enabled on the HTTP server. */ public void setAcceptGzipEncoding(boolean acceptGzipEncoding) { this.acceptGzipEncoding = acceptGzipEncoding; @@ -62,4 +64,5 @@ public abstract class AbstractHttpWebServiceMessageSender implements WebServiceM return uri.getScheme().equals(HttpTransportConstants.HTTP_URI_SCHEME) || uri.getScheme().equals(HttpTransportConstants.HTTPS_URI_SCHEME); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/ClientHttpRequestConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/ClientHttpRequestConnection.java index d96f2d0c..ab240afe 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/ClientHttpRequestConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/ClientHttpRequestConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,8 +32,8 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.WebServiceConnection; /** - * Implementation of the {@link WebServiceConnection} interface that is based on the Spring 3 {@link ClientHttpRequest} - * and {@link ClientHttpResponse}. + * Implementation of the {@link WebServiceConnection} interface that is based on the + * Spring 3 {@link ClientHttpRequest} and {@link ClientHttpResponse}. * * @author Krzysztof Trojan * @author Arjen Poutsma diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/ClientHttpRequestMessageSender.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/ClientHttpRequestMessageSender.java index 2c53799f..a73a5099 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/ClientHttpRequestMessageSender.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/ClientHttpRequestMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,7 +27,8 @@ import org.springframework.util.Assert; import org.springframework.ws.transport.WebServiceConnection; /** - * {@code WebServiceMessageSender} implementation based on the {@link ClientHttpRequestFactory} introduced in Spring 3. + * {@code WebServiceMessageSender} implementation based on the + * {@link ClientHttpRequestFactory} introduced in Spring 3. * * @author Krzysztof Trojan * @author Arjen Poutsma @@ -58,9 +59,10 @@ public class ClientHttpRequestMessageSender extends AbstractHttpWebServiceMessag public WebServiceConnection createConnection(URI uri) throws IOException { ClientHttpRequest request = requestFactory.createRequest(uri, HttpMethod.POST); if (isAcceptGzipEncoding()) { - request.getHeaders().add(HttpTransportConstants.HEADER_ACCEPT_ENCODING, - HttpTransportConstants.CONTENT_ENCODING_GZIP); + request.getHeaders() + .add(HttpTransportConstants.HEADER_ACCEPT_ENCODING, HttpTransportConstants.CONTENT_ENCODING_GZIP); } return new ClientHttpRequestConnection(request); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java index 6ace8061..5786a931 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,13 +31,14 @@ import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; import org.apache.commons.httpclient.URIException; import org.apache.commons.httpclient.methods.ByteArrayRequestEntity; import org.apache.commons.httpclient.methods.PostMethod; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.WebServiceConnection; /** - * Implementation of {@link WebServiceConnection} that is based on Jakarta Commons HttpClient. Exposes a - * {@link PostMethod}. + * Implementation of {@link WebServiceConnection} that is based on Jakarta Commons + * HttpClient. Exposes a {@link PostMethod}. * * @author Arjen Poutsma * @author Greg Turnquist @@ -82,7 +83,8 @@ public class CommonsHttpConnection extends AbstractHttpSenderConnection { public URI getUri() throws URISyntaxException { try { return new URI(postMethod.getURI().toString()); - } catch (URIException ex) { + } + catch (URIException ex) { throw new URISyntaxException("", ex.getMessage()); } } @@ -112,14 +114,17 @@ public class CommonsHttpConnection extends AbstractHttpSenderConnection { requestBuffer = null; try { httpClient.executeMethod(postMethod); - } catch (IllegalStateException ex) { + } + catch (IllegalStateException ex) { if ("Connection factory has been shutdown.".equals(ex.getMessage())) { - // The application context has been closed, resulting in a connection factory shutdown and an ISE. + // The application context has been closed, resulting in a connection + // factory shutdown and an ISE. // Let's create a new connection factory for this connection only. connectionManager = new MultiThreadedHttpConnectionManager(); httpClient.setHttpConnectionManager(connectionManager); httpClient.executeMethod(postMethod); - } else { + } + else { throw ex; } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/CommonsHttpMessageSender.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/CommonsHttpMessageSender.java index f2850601..0e5d0b8a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/CommonsHttpMessageSender.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/CommonsHttpMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,6 +32,7 @@ import org.apache.commons.httpclient.URIException; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthScope; import org.apache.commons.httpclient.methods.PostMethod; + import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; @@ -39,11 +40,12 @@ import org.springframework.ws.transport.WebServiceConnection; /** * {@code WebServiceMessageSender} implementation that uses - * Jakarta Commons HttpClient to execute POST requests. + * Jakarta Commons HttpClient + * to execute POST requests. *

- * Allows to use a preconfigured HttpClient instance, potentially with authentication, HTTP connection pooling, etc. - * Authentication can also be set by injecting a {@link Credentials} instance (such as the - * {@link UsernamePasswordCredentials}). + * Allows to use a preconfigured HttpClient instance, potentially with authentication, + * HTTP connection pooling, etc. Authentication can also be set by injecting a + * {@link Credentials} instance (such as the {@link UsernamePasswordCredentials}). * * @author Arjen Poutsma * @see HttpUrlConnectionMessageSender @@ -67,8 +69,8 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende private AuthScope authScope; /** - * Create a new instance of the {@code CommonsHttpMessageSender} with a default {@link HttpClient} that uses a default - * {@link MultiThreadedHttpConnectionManager}. + * Create a new instance of the {@code CommonsHttpMessageSender} with a default + * {@link HttpClient} that uses a default {@link MultiThreadedHttpConnectionManager}. */ public CommonsHttpMessageSender() { httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); @@ -77,8 +79,8 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende } /** - * Create a new instance of the {@code CommonsHttpMessageSender} with the given {@link HttpClient} instance. - * + * Create a new instance of the {@code CommonsHttpMessageSender} with the given + * {@link HttpClient} instance. * @param httpClient the HttpClient instance to use for this sender */ public CommonsHttpMessageSender(HttpClient httpClient) { @@ -103,7 +105,6 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende /** * Sets the credentials to be used. If not set, no authentication is done. - * * @see UsernamePasswordCredentials * @see NTCredentials */ @@ -112,8 +113,8 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende } /** - * Sets the timeout until a connection is etablished. A value of 0 means never timeout. - * + * Sets the timeout until a connection is etablished. A value of 0 means + * never timeout. * @param timeout the timeout value in milliseconds * @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setConnectionTimeout(int) */ @@ -125,8 +126,8 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende } /** - * Set the socket read timeout for the underlying HttpClient. A value of 0 means never timeout. - * + * Set the socket read timeout for the underlying HttpClient. A value of 0 means + * never timeout. * @param timeout the timeout value in milliseconds * @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setSoTimeout(int) */ @@ -139,7 +140,6 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende /** * Sets the maximum number of connections allowed for the underlying HttpClient. - * * @param maxTotalConnections the maximum number of connections allowed * @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setMaxTotalConnections(int) */ @@ -151,8 +151,9 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende } /** - * Sets the maximum number of connections per host for the underlying HttpClient. The maximum number of connections - * per host can be set in a form accepted by the {@code java.util.Properties} class, like as follows: + * Sets the maximum number of connections per host for the underlying HttpClient. The + * maximum number of connections per host can be set in a form accepted by the + * {@code java.util.Properties} class, like as follows: * *

 	 * https://www.example.com=1
@@ -161,35 +162,41 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende
 	 * *=5
 	 * 
* - * The host can be specified as hostname, or as URI (with scheme and port). The special host name {@code *} can be - * used to specify {@link org.apache.commons.httpclient.HostConfiguration#ANY_HOST_CONFIGURATION}. - * - * @param maxConnectionsPerHost a properties object specifying the maximum number of connection + * The host can be specified as hostname, or as URI (with scheme and port). The + * special host name {@code *} can be used to specify + * {@link org.apache.commons.httpclient.HostConfiguration#ANY_HOST_CONFIGURATION}. + * @param maxConnectionsPerHost a properties object specifying the maximum number of + * connection * @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setMaxConnectionsPerHost(org.apache.commons.httpclient.HostConfiguration, - * int) + * int) */ public void setMaxConnectionsPerHost(Map maxConnectionsPerHost) throws URIException { for (String host : maxConnectionsPerHost.keySet()) { HostConfiguration hostConfiguration = new HostConfiguration(); if ("*".equals(host)) { hostConfiguration = HostConfiguration.ANY_HOST_CONFIGURATION; - } else if (host.startsWith("http://")) { + } + else if (host.startsWith("http://")) { HttpURL httpURL = new HttpURL(host); hostConfiguration.setHost(httpURL); - } else if (host.startsWith("https://")) { + } + else if (host.startsWith("https://")) { HttpsURL httpsURL = new HttpsURL(host); hostConfiguration.setHost(httpsURL); - } else { + } + else { hostConfiguration.setHost(host); } int maxHostConnections = Integer.parseInt(maxConnectionsPerHost.get(host)); - getHttpClient().getHttpConnectionManager().getParams().setMaxConnectionsPerHost(hostConfiguration, - maxHostConnections); + getHttpClient().getHttpConnectionManager() + .getParams() + .setMaxConnectionsPerHost(hostConfiguration, maxHostConnections); } } /** - * Returns the authentication scope to be used. Only used when the {@code credentials} property has been set. + * Returns the authentication scope to be used. Only used when the {@code credentials} + * property has been set. *

* By default, the {@link AuthScope#ANY} is returned. */ @@ -198,10 +205,10 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende } /** - * Sets the authentication scope to be used. Only used when the {@code credentials} property has been set. + * Sets the authentication scope to be used. Only used when the {@code credentials} + * property has been set. *

* By default, the {@link AuthScope#ANY} is used. - * * @see #setCredentials(Credentials) */ public void setAuthScope(AuthScope authScope) { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5ClientFactory.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5ClientFactory.java index 7d23dc1d..3c790c7b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5ClientFactory.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5ClientFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2023 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,11 +32,13 @@ import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.util.Timeout; + import org.springframework.beans.factory.FactoryBean; import org.springframework.ws.client.support.interceptor.ClientInterceptor; /** - * {@link FactoryBean} to set up a {@link CloseableHttpClient} using HttpComponents HttpClient 5. + * {@link FactoryBean} to set up a {@link CloseableHttpClient} using HttpComponents + * HttpClient 5. * * @see http://hc.apache.org/httpcomponents-client * @author Lars Uffmann @@ -47,10 +49,9 @@ public class HttpComponents5ClientFactory implements FactoryBean - * NOTE: {@code ANY} was removed from {@link AuthScope} in HttpComponents 5.0. This value object will easy - * migration from HttpComponents 4. Consider using a {@link ClientInterceptor} to implement http client agnostic - * preemptive basic auth. - * + * NOTE: {@code ANY} was removed from {@link AuthScope} in HttpComponents 5.0. + * This value object will easy migration from HttpComponents 4. Consider using a + * {@link ClientInterceptor} to implement http client agnostic preemptive basic auth. * @see AuthScope#AuthScope(String, String, int, String, String) */ public static final AuthScope ANY = new AuthScope(null, null, -1, null, null); @@ -79,7 +80,6 @@ public class HttpComponents5ClientFactory implements FactoryBean * By default, {@link #ANY} is used. - * * @see #setCredentials(Credentials) */ public void setAuthScope(AuthScope authScope) { @@ -99,8 +99,8 @@ public class HttpComponents5ClientFactory implements FactoryBeannever timeout. - * + * Sets the timeout until a connection is established. A value of 0 means + * never timeout. * @param timeout the timeout value */ public void setConnectionTimeout(Duration timeout) { @@ -113,8 +113,8 @@ public class HttpComponents5ClientFactory implements FactoryBeannever timeout. - * + * Set the socket read timeout for the underlying HttpClient. A value of 0 means + * never timeout. * @param timeout the timeout value */ public void setReadTimeout(Duration timeout) { @@ -128,7 +128,6 @@ public class HttpComponents5ClientFactory implements FactoryBean * https://www.example.com=1 @@ -152,8 +152,8 @@ public class HttpComponents5ClientFactory implements FactoryBean *

* The host can be specified as a URI (with scheme and port). - * - * @param maxConnectionsPerHost a properties object specifying the maximum number of connection + * @param maxConnectionsPerHost a properties object specifying the maximum number of + * connection * @see PoolingHttpClientConnectionManager... */ public void setMaxConnectionsPerHost(Map maxConnectionsPerHost) { @@ -170,7 +170,8 @@ public class HttpComponents5ClientFactory implements FactoryBean getResponseHeaderNames() throws IOException { return Arrays.stream(httpResponse.getHeaders()) // - .map(NameValuePair::getName) // - .iterator(); + .map(NameValuePair::getName) // + .iterator(); } @Override public Iterator getResponseHeaders(String name) throws IOException { return Arrays.stream(httpResponse.getHeaders(name)) // - .map(NameValuePair::getValue) // - .iterator(); + .map(NameValuePair::getValue) // + .iterator(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5MessageSender.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5MessageSender.java index d0b96838..8c748174 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5MessageSender.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5MessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2023 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -41,11 +41,13 @@ import org.springframework.util.Assert; import org.springframework.ws.transport.WebServiceConnection; /** - * {@code WebServiceMessageSender} implementation that uses Apache - * HttpClient to execute POST requests. + * {@code WebServiceMessageSender} implementation that uses + * Apache HttpClient to execute + * POST requests. *

- * Allows to use a pre-configured HttpClient instance, potentially with authentication, HTTP connection pooling, etc. - * Authentication can also be set by injecting a {@link Credentials} instance (such as the + * Allows to use a pre-configured HttpClient instance, potentially with authentication, + * HTTP connection pooling, etc. Authentication can also be set by injecting a + * {@link Credentials} instance (such as the * {@link org.apache.hc.client5.http.auth.UsernamePasswordCredentials}). * * @author Alan Stewart @@ -66,8 +68,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS private HttpComponents5ClientFactory clientFactory; /** - * Create a new instance of the {@code HttpClientMessageSender} with a default {@link HttpClient} that uses a default - * {@link PoolingHttpClientConnectionManager}. + * Create a new instance of the {@code HttpClientMessageSender} with a default + * {@link HttpClient} that uses a default {@link PoolingHttpClientConnectionManager}. */ public HttpComponents5MessageSender() { @@ -77,12 +79,13 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS } /** - * Create a new instance of the {@link HttpComponents5MessageSender} with the given {@link HttpClient} instance. + * Create a new instance of the {@link HttpComponents5MessageSender} with the given + * {@link HttpClient} instance. *

- * This constructor does not change the given {@code HttpClient} in any way. As such, it does not set timeouts, nor - * does it {@linkplain HttpClientBuilder#addRequestInterceptorFirst(HttpRequestInterceptor) add} the - * {@link RemoveSoapHeadersInterceptor}. - * + * This constructor does not change the given {@code HttpClient} in any way. As such, + * it does not set timeouts, nor does it + * {@linkplain HttpClientBuilder#addRequestInterceptorFirst(HttpRequestInterceptor) + * add} the {@link RemoveSoapHeadersInterceptor}. * @param httpClient the HttpClient instance to use for this sender */ public HttpComponents5MessageSender(HttpClient httpClient) { @@ -91,8 +94,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS this.httpClient = httpClient; } - /** - * @see HttpComponents5ClientFactory#setAuthScope(AuthScope) + /* + * * @see HttpComponents5ClientFactory#setAuthScope(AuthScope) */ public void setAuthScope(AuthScope authScope) { @@ -103,8 +106,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS this.clientFactory.setAuthScope(authScope); } - /** - * @see HttpComponents5ClientFactory#setCredentials(Credentials) + /* + * * @see HttpComponents5ClientFactory#setCredentials(Credentials) */ public void setCredentials(Credentials credentials) { @@ -129,8 +132,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS this.httpClient = httpClient; } - /** - * @see HttpComponents5ClientFactory#setConnectionTimeout(Duration) + /* + * * @see HttpComponents5ClientFactory#setConnectionTimeout(Duration) */ public void setConnectionTimeout(Duration timeout) { @@ -141,8 +144,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS this.clientFactory.setConnectionTimeout(timeout); } - /** - * @see HttpComponents5ClientFactory#setReadTimeout(Duration) + /* + * * @see HttpComponents5ClientFactory#setReadTimeout(Duration) */ public void setReadTimeout(Duration timeout) { @@ -153,8 +156,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS this.clientFactory.setReadTimeout(timeout); } - /** - * @see HttpComponents5ClientFactory#setMaxTotalConnections(int) + /* + * * @see HttpComponents5ClientFactory#setMaxTotalConnections(int) */ public void setMaxTotalConnections(int maxTotalConnections) { @@ -165,8 +168,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS this.clientFactory.setMaxTotalConnections(maxTotalConnections); } - /** - * @see HttpComponents5ClientFactory#setMaxConnectionsPerHost(Map) + /* + * * @see HttpComponents5ClientFactory#setMaxConnectionsPerHost(Map) */ public void setMaxConnectionsPerHost(Map maxConnectionsPerHost) { @@ -191,7 +194,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS HttpPost httpPost = new HttpPost(uri); if (isAcceptGzipEncoding()) { - httpPost.addHeader(HttpTransportConstants.HEADER_ACCEPT_ENCODING, HttpTransportConstants.CONTENT_ENCODING_GZIP); + httpPost.addHeader(HttpTransportConstants.HEADER_ACCEPT_ENCODING, + HttpTransportConstants.CONTENT_ENCODING_GZIP); } HttpContext httpContext = createContext(uri); @@ -200,9 +204,8 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS } /** - * Template method that allows for creation of an {@link HttpContext} for the given uri. Default implementation returns - * {@code null}. - * + * Template method that allows for creation of an {@link HttpContext} for the given + * uri. Default implementation returns {@code null}. * @param uri the URI to create the context for * @return the context, or {@code null} */ @@ -213,15 +216,16 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS @Override public void destroy() throws Exception { - if (getHttpClient()instanceof CloseableHttpClient client) { + if (getHttpClient() instanceof CloseableHttpClient client) { client.close(); } } /** - * HttpClient {@link HttpRequestInterceptor} implementation that removes {@code Content-Length} and - * {@code Transfer-Encoding} headers from the request. Necessary, because some SAAJ and other SOAP implementations set - * these headers themselves, and HttpClient throws an exception if they have been set. + * HttpClient {@link HttpRequestInterceptor} implementation that removes + * {@code Content-Length} and {@code Transfer-Encoding} headers from the request. + * Necessary, because some SAAJ and other SOAP implementations set these headers + * themselves, and HttpClient throws an exception if they have been set. */ public static class RemoveSoapHeadersInterceptor implements HttpRequestInterceptor { @@ -237,5 +241,7 @@ public class HttpComponents5MessageSender extends AbstractHttpWebServiceMessageS request.removeHeaders(HttpHeaders.CONTENT_LENGTH); } } + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponentsConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponentsConnection.java index 23b37431..b4bc3493 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponentsConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponentsConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,13 +33,14 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.protocol.HttpContext; import org.apache.http.util.EntityUtils; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.WebServiceConnection; /** - * Implementation of {@link WebServiceConnection} that is based on Apache HttpClient. Exposes a {@link HttpPost} and - * {@link HttpResponse}. + * Implementation of {@link WebServiceConnection} that is based on Apache HttpClient. + * Exposes a {@link HttpPost} and {@link HttpResponse}. * * @author Alan Stewart * @author Barry Pitman @@ -83,16 +84,16 @@ public class HttpComponentsConnection extends AbstractHttpSenderConnection { } /* - * URI - */ + * URI + */ @Override public URI getUri() throws URISyntaxException { return new URI(httpPost.getURI().toString()); } /* - * Sending request - */ + * Sending request + */ @Override protected void onSendBeforeWrite(WebServiceMessage message) throws IOException { @@ -115,7 +116,8 @@ public class HttpComponentsConnection extends AbstractHttpSenderConnection { requestBuffer = null; if (httpContext != null) { httpResponse = httpClient.execute(httpPost, httpContext); - } else { + } + else { httpResponse = httpClient.execute(httpPost); } } @@ -171,4 +173,5 @@ public class HttpComponentsConnection extends AbstractHttpSenderConnection { } return Arrays.asList(values).iterator(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponentsMessageSender.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponentsMessageSender.java index 5ebdd815..d0b22fab 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponentsMessageSender.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponentsMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,18 +34,20 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; + import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.ws.transport.WebServiceConnection; /** - * {@code WebServiceMessageSender} implementation that uses Apache - * HttpClient to execute POST requests. + * {@code WebServiceMessageSender} implementation that uses + * Apache HttpClient to execute + * POST requests. *

- * Allows to use a pre-configured HttpClient instance, potentially with authentication, HTTP connection pooling, etc. - * Authentication can also be set by injecting a {@link Credentials} instance (such as the - * {@link UsernamePasswordCredentials}). + * Allows to use a pre-configured HttpClient instance, potentially with authentication, + * HTTP connection pooling, etc. Authentication can also be set by injecting a + * {@link Credentials} instance (such as the {@link UsernamePasswordCredentials}). * * @author Alan Stewart * @author Barry Pitman @@ -69,7 +71,8 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe private AuthScope authScope = AuthScope.ANY; /** - * Create a new instance of the {@code HttpClientMessageSender} with a default {@link HttpClient} that uses a default + * Create a new instance of the {@code HttpClientMessageSender} with a default + * {@link HttpClient} that uses a default * {@link org.apache.http.impl.conn.PoolingClientConnectionManager}. */ public HttpComponentsMessageSender() { @@ -83,13 +86,13 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } /** - * Create a new instance of the {@code HttpClientMessageSender} with the given {@link HttpClient} instance. + * Create a new instance of the {@code HttpClientMessageSender} with the given + * {@link HttpClient} instance. *

- * This constructor does not change the given {@code HttpClient} in any way. As such, it does not set timeouts, nor - * does it + * This constructor does not change the given {@code HttpClient} in any way. As such, + * it does not set timeouts, nor does it * {@linkplain org.apache.http.impl.client.DefaultHttpClient#addRequestInterceptor(org.apache.http.HttpRequestInterceptor) * add} the {@link RemoveSoapHeadersInterceptor}. - * * @param httpClient the HttpClient instance to use for this sender */ public HttpComponentsMessageSender(HttpClient httpClient) { @@ -99,7 +102,6 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe /** * Sets the credentials to be used. If not set, no authentication is done. - * * @see UsernamePasswordCredentials * @see org.apache.http.auth.NTCredentials */ @@ -122,10 +124,11 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } /** - * Sets the timeout until a connection is established. A value of 0 means never timeout. - * + * Sets the timeout until a connection is established. A value of 0 means + * never timeout. * @param timeout the timeout value in milliseconds - * @see org.apache.http.params.HttpConnectionParams#setConnectionTimeout(org.apache.http.params.HttpParams, int) + * @see org.apache.http.params.HttpConnectionParams#setConnectionTimeout(org.apache.http.params.HttpParams, + * int) */ public void setConnectionTimeout(int timeout) { if (timeout < 0) { @@ -135,10 +138,11 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } /** - * Set the socket read timeout for the underlying HttpClient. A value of 0 means never timeout. - * + * Set the socket read timeout for the underlying HttpClient. A value of 0 means + * never timeout. * @param timeout the timeout value in milliseconds - * @see org.apache.http.params.HttpConnectionParams#setSoTimeout(org.apache.http.params.HttpParams, int) + * @see org.apache.http.params.HttpConnectionParams#setSoTimeout(org.apache.http.params.HttpParams, + * int) */ public void setReadTimeout(int timeout) { if (timeout < 0) { @@ -149,7 +153,6 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe /** * Sets the maximum number of connections allowed for the underlying HttpClient. - * * @param maxTotalConnections the maximum number of connections allowed * @see org.apache.http.impl.conn.PoolingClientConnectionManager#setMaxTotal(int) */ @@ -167,8 +170,9 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } /** - * Sets the maximum number of connections per host for the underlying HttpClient. The maximum number of connections - * per host can be set in a form accepted by the {@code java.util.Properties} class, like as follows: + * Sets the maximum number of connections per host for the underlying HttpClient. The + * maximum number of connections per host can be set in a form accepted by the + * {@code java.util.Properties} class, like as follows: * *

 	 * https://www.example.com=1
@@ -177,9 +181,10 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe
 	 * 
*

* The host can be specified as a URI (with scheme and port). - * - * @param maxConnectionsPerHost a properties object specifying the maximum number of connection - * @see org.apache.http.impl.conn.PoolingClientConnectionManager#setMaxPerRoute(HttpRoute, int) + * @param maxConnectionsPerHost a properties object specifying the maximum number of + * connection + * @see org.apache.http.impl.conn.PoolingClientConnectionManager#setMaxPerRoute(HttpRoute, + * int) */ public void setMaxConnectionsPerHost(Map maxConnectionsPerHost) throws URISyntaxException { org.apache.http.conn.ClientConnectionManager connectionManager = getHttpClient().getConnectionManager(); @@ -197,7 +202,8 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe if (uri.getScheme().equals("https")) { route = new HttpRoute(host, null, true); - } else { + } + else { route = new HttpRoute(host); } @@ -208,10 +214,10 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } /** - * Sets the authentication scope to be used. Only used when the {@code credentials} property has been set. + * Sets the authentication scope to be used. Only used when the {@code credentials} + * property has been set. *

* By default, the {@link AuthScope#ANY} is used. - * * @see #setCredentials(Credentials) */ public void setAuthScope(AuthScope authScope) { @@ -222,7 +228,7 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe public void afterPropertiesSet() throws Exception { if (credentials != null && getHttpClient() instanceof org.apache.http.impl.client.DefaultHttpClient) { ((org.apache.http.impl.client.DefaultHttpClient) getHttpClient()).getCredentialsProvider() - .setCredentials(authScope, credentials); + .setCredentials(authScope, credentials); } } @@ -230,16 +236,16 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe public WebServiceConnection createConnection(URI uri) throws IOException { HttpPost httpPost = new HttpPost(uri); if (isAcceptGzipEncoding()) { - httpPost.addHeader(HttpTransportConstants.HEADER_ACCEPT_ENCODING, HttpTransportConstants.CONTENT_ENCODING_GZIP); + httpPost.addHeader(HttpTransportConstants.HEADER_ACCEPT_ENCODING, + HttpTransportConstants.CONTENT_ENCODING_GZIP); } HttpContext httpContext = createContext(uri); return new HttpComponentsConnection(getHttpClient(), httpPost, httpContext); } /** - * Template method that allows for creation of a {@link HttpContext} for the given uri. Default implementation returns - * {@code null}. - * + * Template method that allows for creation of a {@link HttpContext} for the given + * uri. Default implementation returns {@code null}. * @param uri the URI to create the context for * @return the context, or {@code null} */ @@ -253,9 +259,10 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } /** - * HttpClient {@link org.apache.http.HttpRequestInterceptor} implementation that removes {@code Content-Length} and - * {@code Transfer-Encoding} headers from the request. Necessary, because some SAAJ and other SOAP implementations set - * these headers themselves, and HttpClient throws an exception if they have been set. + * HttpClient {@link org.apache.http.HttpRequestInterceptor} implementation that + * removes {@code Content-Length} and {@code Transfer-Encoding} headers from the + * request. Necessary, because some SAAJ and other SOAP implementations set these + * headers themselves, and HttpClient throws an exception if they have been set. */ public static class RemoveSoapHeadersInterceptor implements HttpRequestInterceptor { @@ -270,5 +277,7 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } } } + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java index cbe8e4eb..4ba20486 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,6 @@ package org.springframework.ws.transport.http; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.xml.soap.SOAPConstants; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -29,6 +25,10 @@ import java.util.Iterator; import javax.xml.namespace.QName; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.xml.soap.SOAPConstants; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.AbstractReceiverConnection; import org.springframework.ws.transport.EndpointAwareWebServiceConnection; @@ -53,7 +53,8 @@ public class HttpServletConnection extends AbstractReceiverConnection private boolean statusCodeSet = false; /** - * Constructs a new servlet connection with the given {@code HttpServletRequest} and {@code HttpServletResponse}. + * Constructs a new servlet connection with the given {@code HttpServletRequest} and + * {@code HttpServletResponse}. */ protected HttpServletConnection(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { this.httpServletRequest = httpServletRequest; @@ -97,13 +98,13 @@ public class HttpServletConnection extends AbstractReceiverConnection @Override public URI getUri() throws URISyntaxException { return new URI(httpServletRequest.getScheme(), null, httpServletRequest.getServerName(), - httpServletRequest.getServerPort(), httpServletRequest.getRequestURI(), httpServletRequest.getQueryString(), - null); + httpServletRequest.getServerPort(), httpServletRequest.getRequestURI(), + httpServletRequest.getQueryString(), null); } /* - * Receiving request - */ + * Receiving request + */ @Override public Iterator getRequestHeaderNames() throws IOException { @@ -121,8 +122,8 @@ public class HttpServletConnection extends AbstractReceiverConnection } /* - * Sending response - */ + * Sending response + */ @Override public void addResponseHeader(String name, String value) throws IOException { @@ -160,7 +161,8 @@ public class HttpServletConnection extends AbstractReceiverConnection public void setFault(boolean fault) throws IOException { if (fault) { getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR); - } else { + } + else { getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_OK); } statusCodeSet = true; @@ -171,12 +173,15 @@ public class HttpServletConnection extends AbstractReceiverConnection if (faultCode != null) { if (SOAPConstants.SOAP_SENDER_FAULT.equals(faultCode)) { getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_BAD_REQUEST); - } else { + } + else { getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR); } - } else { + } + else { getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_OK); } statusCodeSet = true; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpTransportConstants.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpTransportConstants.java index c18b88c8..2676c92f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpTransportConstants.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpTransportConstants.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -67,4 +67,5 @@ public interface HttpTransportConstants extends TransportConstants { /** The "POST" HTTP method */ String METHOD_POST = "POST"; + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java index 47971491..3cda6571 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,7 +36,8 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.WebServiceConnection; /** - * Implementation of the {@link WebServiceConnection} interface that uses a {@link HttpURLConnection}. + * Implementation of the {@link WebServiceConnection} interface that uses a + * {@link HttpURLConnection}. * * @author Arjen Poutsma * @author Greg Turnquist @@ -48,8 +49,8 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection { private final HttpURLConnection connection; /** - * Creates a new instance of the {@code HttpUrlConnection} with the given {@code HttpURLConnection}. - * + * Creates a new instance of the {@code HttpUrlConnection} with the given + * {@code HttpURLConnection}. * @param connection the {@code HttpURLConnection} */ protected HttpUrlConnection(HttpURLConnection connection) { @@ -133,7 +134,8 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection { if (headerValues == null) { return Collections.emptyIterator(); - } else { + } + else { return headerValues.iterator(); } } @@ -152,8 +154,10 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection { protected InputStream getRawResponseInputStream() throws IOException { if (connection.getResponseCode() / 100 != 2) { return connection.getErrorStream(); - } else { + } + else { return connection.getInputStream(); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSender.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSender.java index ca4fa7d5..00e14bab 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSender.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,11 +26,12 @@ import java.time.Duration; import org.springframework.ws.transport.WebServiceConnection; /** - * {@code WebServiceMessageSender} implementation that uses standard J2SE facilities to execute POST requests, without - * support for HTTP authentication or advanced configuration options. + * {@code WebServiceMessageSender} implementation that uses standard J2SE facilities to + * execute POST requests, without support for HTTP authentication or advanced + * configuration options. *

- * Consider {@link HttpComponentsMessageSender} for more sophisticated needs: this class is rather limited in its - * capabilities. + * Consider {@link HttpComponentsMessageSender} for more sophisticated needs: this class + * is rather limited in its capabilities. * * @author Arjen Poutsma * @author Kazuki Shimizu @@ -40,11 +41,11 @@ import org.springframework.ws.transport.WebServiceConnection; public class HttpUrlConnectionMessageSender extends AbstractHttpWebServiceMessageSender { private Duration connectionTimeout = Duration.ofSeconds(60); + private Duration readTimeout = Duration.ofSeconds(60); /** * Sets the timeout until a connection is established. - * * @param connectTimeout the timeout value * @see URLConnection#setConnectTimeout(int) * @since 3.0.1 @@ -55,7 +56,6 @@ public class HttpUrlConnectionMessageSender extends AbstractHttpWebServiceMessag /** * Set the socket read timeout. - * * @param readTimeout the timeout value * @see URLConnection#setReadTimeout(int) * @since 3.0.1 @@ -70,7 +70,8 @@ public class HttpUrlConnectionMessageSender extends AbstractHttpWebServiceMessag URLConnection connection = url.openConnection(); if (!(connection instanceof HttpURLConnection)) { throw new HttpTransportException("URI [" + uri + "] is not an HTTP URL"); - } else { + } + else { HttpURLConnection httpURLConnection = (HttpURLConnection) connection; prepareConnection(httpURLConnection); return new HttpUrlConnection(httpURLConnection); @@ -80,10 +81,9 @@ public class HttpUrlConnectionMessageSender extends AbstractHttpWebServiceMessag /** * Template method for preparing the given {@link java.net.HttpURLConnection}. *

- * The default implementation prepares the connection for input and output, sets the HTTP method to POST, disables - * caching, and sets the {@code Accept-Encoding} header to gzip, if {@linkplain #setAcceptGzipEncoding(boolean) - * applicable}. - * + * The default implementation prepares the connection for input and output, sets the + * HTTP method to POST, disables caching, and sets the {@code Accept-Encoding} header + * to gzip, if {@linkplain #setAcceptGzipEncoding(boolean) applicable}. * @param connection the connection to prepare * @throws IOException in case of I/O errors */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/JdkHttpClientConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/JdkHttpClientConnection.java index d1574e06..d1290a8f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/JdkHttpClientConnection.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/JdkHttpClientConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2023-2023 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,13 +34,15 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.http.HttpStatus; import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.WebServiceConnection; /** - * Implementation of the {@link WebServiceConnection} interface that uses Java's built-in {@link HttpClient}. + * Implementation of the {@link WebServiceConnection} interface that uses Java's built-in + * {@link HttpClient}. * * @author Marten Deinum * @see java.net.http.HttpClient @@ -129,8 +131,8 @@ public class JdkHttpClientConnection extends AbstractHttpSenderConnection { if (response != null) { return response.headers() // - .firstValueAsLong(HttpTransportConstants.HEADER_CONTENT_LENGTH) // - .orElse(-1); + .firstValueAsLong(HttpTransportConstants.HEADER_CONTENT_LENGTH) // + .orElse(-1); } return 0; @@ -155,7 +157,8 @@ public class JdkHttpClientConnection extends AbstractHttpSenderConnection { try { response = httpClient.send(request, BodyHandlers.ofInputStream()); - } catch (InterruptedException ex) { + } + catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new IllegalStateException(ex); } @@ -168,4 +171,5 @@ public class JdkHttpClientConnection extends AbstractHttpSenderConnection { response.body().close(); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/JdkHttpClientMessageSender.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/JdkHttpClientMessageSender.java index 8b2575d5..7bc6aeb8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/JdkHttpClientMessageSender.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/JdkHttpClientMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2023-2023 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,11 +27,11 @@ import org.springframework.util.Assert; import org.springframework.ws.transport.WebServiceConnection; /** - * {@code WebServiceMessageSender} implementation that uses the standard Java {@code HttpClient} facilities to execute - * POST requests. + * {@code WebServiceMessageSender} implementation that uses the standard Java + * {@code HttpClient} facilities to execute POST requests. *

- * Can be used with a simple default configured {@code HttpClient} or can be constructed with a pre-configured - * {@code HttpClient}. + * Can be used with a simple default configured {@code HttpClient} or can be constructed + * with a pre-configured {@code HttpClient}. * * @author Marten Deinum * @see java.net.http.HttpClient @@ -49,7 +49,8 @@ public class JdkHttpClientMessageSender extends AbstractHttpWebServiceMessageSen private Duration requestTimeout = DEFAULT_REQUEST_TIMEOUT; - public JdkHttpClientMessageSender() {} + public JdkHttpClientMessageSender() { + } public JdkHttpClientMessageSender(HttpClient httpClient) { @@ -89,4 +90,5 @@ public class JdkHttpClientMessageSender extends AbstractHttpWebServiceMessageSen httpClient = HttpClient.newBuilder().connectTimeout(connectionTimeout).build(); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/LastModifiedHelper.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/LastModifiedHelper.java index 97c2bc0f..7ae287b3 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/LastModifiedHelper.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/LastModifiedHelper.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,9 +23,10 @@ import java.net.URISyntaxException; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; +import org.w3c.dom.Document; + import org.springframework.util.StringUtils; import org.springframework.xml.transform.TraxUtils; -import org.w3c.dom.Document; /** * Utility class that determines the last modified date of a given {@link Source}. @@ -35,11 +36,11 @@ import org.w3c.dom.Document; */ class LastModifiedHelper { - private LastModifiedHelper() {} + private LastModifiedHelper() { + } /** * Returns the last modified date of the given {@link Source}. - * * @param source the source * @return the last modified date, as a long */ @@ -47,7 +48,8 @@ class LastModifiedHelper { if (source instanceof DOMSource) { Document document = TraxUtils.getDocument((DOMSource) source); return document != null ? getLastModified(document.getDocumentURI()) : -1; - } else { + } + else { return getLastModified(source.getSystemId()); } } @@ -62,7 +64,8 @@ class LastModifiedHelper { return documentFile.lastModified(); } } - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { // ignore } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/LocationTransformerObjectSupport.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/LocationTransformerObjectSupport.java index 4d8fc8f6..3a0860a4 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/LocationTransformerObjectSupport.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/LocationTransformerObjectSupport.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,23 +16,23 @@ package org.springframework.ws.transport.http; -import jakarta.servlet.http.HttpServletRequest; - import java.util.List; +import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; -import org.springframework.xml.transform.TransformerObjectSupport; -import org.springframework.xml.xpath.XPathExpression; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Node; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; +import org.springframework.xml.transform.TransformerObjectSupport; +import org.springframework.xml.xpath.XPathExpression; + /** - * Abstract base class for {@link WsdlDefinitionHandlerAdapter} and {@link XsdSchemaHandlerAdapter} that transforms XSD - * and WSDL location attributes. + * Abstract base class for {@link WsdlDefinitionHandlerAdapter} and + * {@link XsdSchemaHandlerAdapter} that transforms XSD and WSDL location attributes. * * @author Arjen Poutsma * @since 2.1.2 @@ -43,8 +43,8 @@ public abstract class LocationTransformerObjectSupport extends TransformerObject private final Log logger = LogFactory.getLog(getClass()); /** - * Transforms the locations of the given definition document using the given XPath expression. - * + * Transforms the locations of the given definition document using the given XPath + * expression. * @param xPathExpression the XPath expression * @param definitionDocument the definition document * @param request the request, used to determine the location to transform to @@ -71,18 +71,20 @@ public abstract class LocationTransformerObjectSupport extends TransformerObject } /** - * Transform the given location string to reflect the given request. If the given location is a full url, the scheme, - * server name, and port are changed. If it is a relative url, the scheme, server name, and port are prepended. Can be - * overridden in subclasses to change this behavior. + * Transform the given location string to reflect the given request. If the given + * location is a full url, the scheme, server name, and port are changed. If it is a + * relative url, the scheme, server name, and port are prepended. Can be overridden in + * subclasses to change this behavior. *

* For instance, if the location attribute defined in the WSDL is - * {@code http://localhost:8080/context/services/myService}, and the request URI for the WSDL is - * {@code http://example.com:80/context/myService.wsdl}, the location will be changed to - * {@code http://example.com:80/context/services/myService}. + * {@code http://localhost:8080/context/services/myService}, and the request URI for + * the WSDL is {@code http://example.com:80/context/myService.wsdl}, the location will + * be changed to {@code http://example.com:80/context/services/myService}. *

- * If the location attribute defined in the WSDL is {@code /services/myService}, and the request URI for the WSDL is - * {@code http://example.com:8080/context/myService.wsdl}, the location will be changed to - * {@code http://example.com:8080/context/services/myService}. + * If the location attribute defined in the WSDL is {@code /services/myService}, and + * the request URI for the WSDL is + * {@code http://example.com:8080/context/myService.wsdl}, the location will be + * changed to {@code http://example.com:8080/context/services/myService}. *

* This method is only called when the {@code transformLocations} property is true. */ @@ -94,19 +96,21 @@ public abstract class LocationTransformerObjectSupport extends TransformerObject String scheme = StringUtils.hasText(xForwardedProto) ? xForwardedProto : request.getScheme(); String serverName = StringUtils.hasText(xForwardedHost) ? xForwardedHost : request.getServerName(); - int serverPort = StringUtils.hasText(xForwardedPort) ? Integer.parseInt(xForwardedPort) : request.getServerPort(); + int serverPort = StringUtils.hasText(xForwardedPort) ? Integer.parseInt(xForwardedPort) + : request.getServerPort(); StringBuilder url = new StringBuilder(scheme); url.append("://").append(serverName); boolean serverHasColonAfterAt = serverName.indexOf("@") < serverName.indexOf(":"); - if(!serverHasColonAfterAt) { + if (!serverHasColonAfterAt) { url.append(':').append(serverPort); } if (location.startsWith("/")) { // a relative path, prepend the context path url.append(request.getContextPath()).append(location); return url.toString(); - } else { + } + else { int idx = location.indexOf("://"); if (idx != -1) { // a full url @@ -121,4 +125,5 @@ public abstract class LocationTransformerObjectSupport extends TransformerObject // unknown location, return the original return location; } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java index 41c46297..2607ffcd 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -43,18 +43,22 @@ import org.springframework.xml.xsd.XsdSchema; /** * Servlet for simplified dispatching of Web service messages. *

- * This servlet is a convenient alternative to the standard Spring-MVC {@link DispatcherServlet} with separate - * {@link WebServiceMessageReceiverHandlerAdapter}, {@link MessageDispatcher}, and {@link WsdlDefinitionHandlerAdapter} - * instances. + * This servlet is a convenient alternative to the standard Spring-MVC + * {@link DispatcherServlet} with separate + * {@link WebServiceMessageReceiverHandlerAdapter}, {@link MessageDispatcher}, and + * {@link WsdlDefinitionHandlerAdapter} instances. *

- * This servlet automatically detects {@link EndpointAdapter EndpointAdapters}, {@link EndpointMapping - * EndpointMappings}, and {@link EndpointExceptionResolver EndpointExceptionResolvers} by type. + * This servlet automatically detects {@link EndpointAdapter EndpointAdapters}, + * {@link EndpointMapping EndpointMappings}, and {@link EndpointExceptionResolver + * EndpointExceptionResolvers} by type. *

- * This servlet also automatically detects any {@link WsdlDefinition} defined in its application context. This WSDL is - * exposed under the bean name: for example, a {@code WsdlDefinition} bean named '{@code echo}' will be exposed as - * {@code echo.wsdl} in this servlet's context: {@code http://localhost:8080/spring-ws/echo.wsdl}. When the - * {@code transformWsdlLocations} init-param is set to {@code true} in this servlet's configuration in {@code web.xml}, - * all {@code location} attributes in the WSDL definitions will reflect the URL of the incoming request. + * This servlet also automatically detects any {@link WsdlDefinition} defined in its + * application context. This WSDL is exposed under the bean name: for example, a + * {@code WsdlDefinition} bean named '{@code echo}' will be exposed as {@code echo.wsdl} + * in this servlet's context: {@code http://localhost:8080/spring-ws/echo.wsdl}. When the + * {@code transformWsdlLocations} init-param is set to {@code true} in this servlet's + * configuration in {@code web.xml}, all {@code location} attributes in the WSDL + * definitions will reflect the URL of the incoming request. * * @author Arjen Poutsma * @see org.springframework.web.servlet.DispatcherServlet @@ -65,22 +69,34 @@ import org.springframework.xml.xsd.XsdSchema; @SuppressWarnings("serial") public class MessageDispatcherServlet extends FrameworkServlet { - /** Well-known name for the {@link WebServiceMessageFactory} bean in the bean factory for this namespace. */ + /** + * Well-known name for the {@link WebServiceMessageFactory} bean in the bean factory + * for this namespace. + */ public static final String DEFAULT_MESSAGE_FACTORY_BEAN_NAME = "messageFactory"; - /** Well-known name for the {@link WebServiceMessageReceiver} object in the bean factory for this namespace. */ + /** + * Well-known name for the {@link WebServiceMessageReceiver} object in the bean + * factory for this namespace. + */ public static final String DEFAULT_MESSAGE_RECEIVER_BEAN_NAME = "messageReceiver"; /** - * Well-known name for the {@link WebServiceMessageReceiverHandlerAdapter} object in the bean factory for this - * namespace. + * Well-known name for the {@link WebServiceMessageReceiverHandlerAdapter} object in + * the bean factory for this namespace. */ public static final String DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME = "messageReceiverHandlerAdapter"; - /** Well-known name for the {@link WsdlDefinitionHandlerAdapter} object in the bean factory for this namespace. */ + /** + * Well-known name for the {@link WsdlDefinitionHandlerAdapter} object in the bean + * factory for this namespace. + */ public static final String DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME = "wsdlDefinitionHandlerAdapter"; - /** Well-known name for the {@link XsdSchemaHandlerAdapter} object in the bean factory for this namespace. */ + /** + * Well-known name for the {@link XsdSchemaHandlerAdapter} object in the bean factory + * for this namespace. + */ public static final String DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME = "xsdSchemaHandlerAdapter"; /** Suffix of a WSDL request uri. */ @@ -130,11 +146,13 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * Constructor to support programmatic configuration of the Servlet with the specified web application context. This - * constructor is useful in Servlet 3.0+ environments where instance-based registration of servlets is possible - * through the {@code ServletContext#addServlet} API. + * Constructor to support programmatic configuration of the Servlet with the specified + * web application context. This constructor is useful in Servlet 3.0+ environments + * where instance-based registration of servlets is possible through the + * {@code ServletContext#addServlet} API. *

- * Using this constructor indicates that the following properties / init-params will be ignored: + * Using this constructor indicates that the following properties / init-params will + * be ignored: *

    *
  • {@link #setContextClass(Class)} / 'contextClass'
  • *
  • {@link #setContextConfigLocation(String)} / 'contextConfigLocation'
  • @@ -143,27 +161,31 @@ public class MessageDispatcherServlet extends FrameworkServlet { *
*

* The given web application context may or may not yet be - * {@linkplain org.springframework.web.context.ConfigurableWebApplicationContext#refresh() refreshed}. If it has - * not already been refreshed (the recommended approach), then the following will occur: + * {@linkplain org.springframework.web.context.ConfigurableWebApplicationContext#refresh() + * refreshed}. If it has not already been refreshed (the recommended + * approach), then the following will occur: *

    *
  • If the given context does not already have a - * {@linkplain org.springframework.web.context.ConfigurableWebApplicationContext#setParent parent}, the root - * application context will be set as the parent.
  • + * {@linkplain org.springframework.web.context.ConfigurableWebApplicationContext#setParent + * parent}, the root application context will be set as the parent. *
  • If the given context has not already been assigned an - * {@linkplain org.springframework.web.context.ConfigurableWebApplicationContext#setId id}, one will be assigned to - * it
  • - *
  • {@code ServletContext} and {@code ServletConfig} objects will be delegated to the application context
  • + * {@linkplain org.springframework.web.context.ConfigurableWebApplicationContext#setId + * id}, one will be assigned to it + *
  • {@code ServletContext} and {@code ServletConfig} objects will be delegated to + * the application context
  • *
  • {@link #postProcessWebApplicationContext} will be called
  • - *
  • Any {@code ApplicationContextInitializer}s specified through the "contextInitializerClasses" init-param or - * through the {@link #setContextInitializers} property will be applied.
  • - *
  • {@link org.springframework.web.context.ConfigurableWebApplicationContext#refresh refresh()} will be called if - * the context implements {@link org.springframework.web.context.ConfigurableWebApplicationContext}
  • + *
  • Any {@code ApplicationContextInitializer}s specified through the + * "contextInitializerClasses" init-param or through the + * {@link #setContextInitializers} property will be applied.
  • + *
  • {@link org.springframework.web.context.ConfigurableWebApplicationContext#refresh + * refresh()} will be called if the context implements + * {@link org.springframework.web.context.ConfigurableWebApplicationContext}
  • *
- * If the context has already been refreshed, none of the above will occur, under the assumption that the user has - * performed these actions (or not) per their specific needs. + * If the context has already been refreshed, none of the above will occur, under the + * assumption that the user has performed these actions (or not) per their specific + * needs. *

* See {@link org.springframework.web.WebApplicationInitializer} for usage examples. - * * @param webApplicationContext the context to use * @see FrameworkServlet#FrameworkServlet(WebApplicationContext) * @see org.springframework.web.WebApplicationInitializer @@ -202,44 +224,48 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * Indicates whether relative address locations in the WSDL are to be transformed using the request URI of the - * incoming {@link HttpServletRequest}. + * Indicates whether relative address locations in the WSDL are to be transformed + * using the request URI of the incoming {@link HttpServletRequest}. */ public boolean isTransformWsdlLocations() { return transformWsdlLocations; } /** - * Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming - * {@link HttpServletRequest}. Defaults to {@code false}. + * Sets whether relative address locations in the WSDL are to be transformed using the + * request URI of the incoming {@link HttpServletRequest}. Defaults to {@code false}. */ public void setTransformWsdlLocations(boolean transformWsdlLocations) { this.transformWsdlLocations = transformWsdlLocations; } /** - * Indicates whether relative address locations in the XSD are to be transformed using the request URI of the incoming - * {@link HttpServletRequest}. + * Indicates whether relative address locations in the XSD are to be transformed using + * the request URI of the incoming {@link HttpServletRequest}. */ public boolean isTransformSchemaLocations() { return transformSchemaLocations; } /** - * Sets whether relative address locations in the XSD are to be transformed using the request URI of the incoming - * {@link HttpServletRequest}. Defaults to {@code false}. + * Sets whether relative address locations in the XSD are to be transformed using the + * request URI of the incoming {@link HttpServletRequest}. Defaults to {@code false}. */ public void setTransformSchemaLocations(boolean transformSchemaLocations) { this.transformSchemaLocations = transformSchemaLocations; } - /** Returns the bean name used to lookup a {@link WebServiceMessageReceiverHandlerAdapter}. */ + /** + * Returns the bean name used to lookup a + * {@link WebServiceMessageReceiverHandlerAdapter}. + */ public String getMessageReceiverHandlerAdapterBeanName() { return messageReceiverHandlerAdapterBeanName; } /** - * Sets the bean name used to lookup a {@link WebServiceMessageReceiverHandlerAdapter}. Defaults to + * Sets the bean name used to lookup a + * {@link WebServiceMessageReceiverHandlerAdapter}. Defaults to * {@link #DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME}. */ public void setMessageReceiverHandlerAdapterBeanName(String messageReceiverHandlerAdapterBeanName) { @@ -252,8 +278,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * Sets the bean name used to lookup a {@link WsdlDefinitionHandlerAdapter}. Defaults to - * {@link #DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME}. + * Sets the bean name used to lookup a {@link WsdlDefinitionHandlerAdapter}. Defaults + * to {@link #DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME}. */ public void setWsdlDefinitionHandlerAdapterBeanName(String wsdlDefinitionHandlerAdapterBeanName) { this.wsdlDefinitionHandlerAdapterBeanName = wsdlDefinitionHandlerAdapterBeanName; @@ -272,7 +298,7 @@ public class MessageDispatcherServlet extends FrameworkServlet { this.xsdSchemaHandlerAdapterBeanName = xsdSchemaHandlerAdapterBeanName; } - @Override + @Override protected void doService(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { WsdlDefinition definition = getWsdlDefinition(httpServletRequest); @@ -315,11 +341,12 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * Determines the {@link WsdlDefinition} for a given request, or {@code null} if none is found. + * Determines the {@link WsdlDefinition} for a given request, or {@code null} if none + * is found. *

- * Default implementation checks whether the request method is {@code GET}, whether the request uri ends with - * {@code ".wsdl"}, and if there is a {@code WsdlDefinition} with the same name as the filename in the request uri. - * + * Default implementation checks whether the request method is {@code GET}, whether + * the request uri ends with {@code ".wsdl"}, and if there is a {@code WsdlDefinition} + * with the same name as the filename in the request uri. * @param request the {@code HttpServletRequest} * @return a definition, or {@code null} */ @@ -328,17 +355,19 @@ public class MessageDispatcherServlet extends FrameworkServlet { && request.getRequestURI().endsWith(WSDL_SUFFIX_NAME)) { String fileName = WebUtils.extractFilenameFromUrlPath(request.getRequestURI()); return wsdlDefinitions.get(fileName); - } else { + } + else { return null; } } /** - * Determines the {@link XsdSchema} for a given request, or {@code null} if none is found. + * Determines the {@link XsdSchema} for a given request, or {@code null} if none is + * found. *

- * Default implementation checks whether the request method is {@code GET}, whether the request uri ends with - * {@code ".xsd"}, and if there is a {@code XsdSchema} with the same name as the filename in the request uri. - * + * Default implementation checks whether the request method is {@code GET}, whether + * the request uri ends with {@code ".xsd"}, and if there is a {@code XsdSchema} with + * the same name as the filename in the request uri. * @param request the {@code HttpServletRequest} * @return a schema, or {@code null} */ @@ -347,7 +376,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { && request.getRequestURI().endsWith(XSD_SUFFIX_NAME)) { String fileName = WebUtils.extractFilenameFromUrlPath(request.getRequestURI()); return xsdSchemas.get(fileName); - } else { + } + else { return null; } } @@ -371,12 +401,14 @@ public class MessageDispatcherServlet extends FrameworkServlet { try { messageReceiverHandlerAdapter = context.getBean(getMessageReceiverHandlerAdapterBeanName(), WebServiceMessageReceiverHandlerAdapter.class); - } catch (NoSuchBeanDefinitionException ignored) { + } + catch (NoSuchBeanDefinitionException ignored) { messageReceiverHandlerAdapter = new WebServiceMessageReceiverHandlerAdapter(); } initWebServiceMessageFactory(context); messageReceiverHandlerAdapter.afterPropertiesSet(); - } catch (Exception ex) { + } + catch (Exception ex) { throw new BeanInitializationException("Could not initialize WebServiceMessageReceiverHandlerAdapter", ex); } } @@ -385,7 +417,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { WebServiceMessageFactory messageFactory; try { messageFactory = context.getBean(getMessageFactoryBeanName(), WebServiceMessageFactory.class); - } catch (NoSuchBeanDefinitionException ignored) { + } + catch (NoSuchBeanDefinitionException ignored) { messageFactory = defaultStrategiesHelper.getDefaultStrategy(WebServiceMessageFactory.class, context); if (logger.isDebugEnabled()) { logger.debug("No WebServiceMessageFactory found in servlet '" + getServletName() + "': using default"); @@ -400,13 +433,15 @@ public class MessageDispatcherServlet extends FrameworkServlet { wsdlDefinitionHandlerAdapter = context.getBean(getWsdlDefinitionHandlerAdapterBeanName(), WsdlDefinitionHandlerAdapter.class); - } catch (NoSuchBeanDefinitionException ignored) { + } + catch (NoSuchBeanDefinitionException ignored) { wsdlDefinitionHandlerAdapter = new WsdlDefinitionHandlerAdapter(); } wsdlDefinitionHandlerAdapter.setTransformLocations(isTransformWsdlLocations()); wsdlDefinitionHandlerAdapter.setTransformSchemaLocations(isTransformSchemaLocations()); wsdlDefinitionHandlerAdapter.afterPropertiesSet(); - } catch (Exception ex) { + } + catch (Exception ex) { throw new BeanInitializationException("Could not initialize WsdlDefinitionHandlerAdapter", ex); } } @@ -414,14 +449,17 @@ public class MessageDispatcherServlet extends FrameworkServlet { private void initXsdSchemaHandlerAdapter(ApplicationContext context) { try { try { - xsdSchemaHandlerAdapter = context.getBean(getXsdSchemaHandlerAdapterBeanName(), XsdSchemaHandlerAdapter.class); + xsdSchemaHandlerAdapter = context.getBean(getXsdSchemaHandlerAdapterBeanName(), + XsdSchemaHandlerAdapter.class); - } catch (NoSuchBeanDefinitionException ignored) { + } + catch (NoSuchBeanDefinitionException ignored) { xsdSchemaHandlerAdapter = new XsdSchemaHandlerAdapter(); } xsdSchemaHandlerAdapter.setTransformSchemaLocations(isTransformSchemaLocations()); xsdSchemaHandlerAdapter.afterPropertiesSet(); - } catch (Exception ex) { + } + catch (Exception ex) { throw new BeanInitializationException("Could not initialize XsdSchemaHandlerAdapter", ex); } } @@ -429,7 +467,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { private void initMessageReceiver(ApplicationContext context) { try { messageReceiver = context.getBean(getMessageReceiverBeanName(), WebServiceMessageReceiver.class); - } catch (NoSuchBeanDefinitionException ex) { + } + catch (NoSuchBeanDefinitionException ex) { messageReceiver = defaultStrategiesHelper.getDefaultStrategy(WebServiceMessageReceiver.class, context); if (messageReceiver instanceof BeanNameAware) { ((BeanNameAware) messageReceiver).setBeanName(getServletName()); @@ -461,4 +500,5 @@ public class MessageDispatcherServlet extends FrameworkServlet { } } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapter.java index 259c48fb..10c8bfd2 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,12 +29,14 @@ import org.springframework.ws.transport.support.WebServiceMessageReceiverObjectS /** * Adapter to use the {@link WebServiceMessageReceiver} interface with the generic * {@link org.springframework.web.servlet.DispatcherServlet}. Requires a - * {@link org.springframework.ws.WebServiceMessageFactory} which is used to convert the incoming - * {@code HttpServletRequest} into a {@code WebServiceMessage}, and passes that context to the mapped - * {@code WebServiceMessageReceiver}. If a response is created, that is sent via the {@code HttpServletResponse}. + * {@link org.springframework.ws.WebServiceMessageFactory} which is used to convert the + * incoming {@code HttpServletRequest} into a {@code WebServiceMessage}, and passes that + * context to the mapped {@code WebServiceMessageReceiver}. If a response is created, that + * is sent via the {@code HttpServletResponse}. *

- * Note that the {@code MessageDispatcher} implements the {@code WebServiceMessageReceiver} interface, enabling this - * adapter to function as a gateway to further message handling logic. + * Note that the {@code MessageDispatcher} implements the + * {@code WebServiceMessageReceiver} interface, enabling this adapter to function as a + * gateway to further message handling logic. * * @author Arjen Poutsma * @see #setMessageFactory(org.springframework.ws.WebServiceMessageFactory) @@ -58,10 +60,12 @@ public class WebServiceMessageReceiverHandlerAdapter extends WebServiceMessageRe WebServiceConnection connection = new HttpServletConnection(httpServletRequest, httpServletResponse); try { handleConnection(connection, (WebServiceMessageReceiver) handler); - } catch (InvalidXmlException ex) { + } + catch (InvalidXmlException ex) { handleInvalidXmlException(httpServletRequest, httpServletResponse, handler, ex); } - } else { + } + else { handleNonPostMethod(httpServletRequest, httpServletResponse, handler); } return null; @@ -73,11 +77,11 @@ public class WebServiceMessageReceiverHandlerAdapter extends WebServiceMessageRe } /** - * Template method that is invoked when the request method is not {@code POST}. Called from - * {@link #handle(HttpServletRequest, HttpServletResponse, Object)}. + * Template method that is invoked when the request method is not {@code POST}. Called + * from {@link #handle(HttpServletRequest, HttpServletResponse, Object)}. *

- * Default implementation set the response status to 405: Method Not Allowed. Can be overridden in subclasses. - * + * Default implementation set the response status to 405: Method Not Allowed. Can be + * overridden in subclasses. * @param httpServletRequest current HTTP request * @param httpServletResponse current HTTP response * @param handler current handler @@ -88,11 +92,12 @@ public class WebServiceMessageReceiverHandlerAdapter extends WebServiceMessageRe } /** - * Template method that is invoked when parsing the request results in a {@link InvalidXmlException}. Called from + * Template method that is invoked when parsing the request results in a + * {@link InvalidXmlException}. Called from * {@link #handle(HttpServletRequest, HttpServletResponse, Object)}. *

- * Default implementation set the response status to 400: Bad Request. Can be overridden in subclasses. - * + * Default implementation set the response status to 400: Bad Request. Can be + * overridden in subclasses. * @param httpServletRequest current HTTP request * @param httpServletResponse current HTTP response * @param handler current handler diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapter.java index 7acd4f0c..1faad98b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.transport.http; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - import java.util.HashMap; import java.util.Map; @@ -28,38 +25,44 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.w3c.dom.Document; + import org.springframework.beans.factory.InitializingBean; import org.springframework.web.servlet.HandlerAdapter; import org.springframework.web.servlet.ModelAndView; import org.springframework.ws.wsdl.WsdlDefinition; import org.springframework.xml.xpath.XPathExpression; import org.springframework.xml.xpath.XPathExpressionFactory; -import org.w3c.dom.Document; /** - * Adapter to use the {@code WsdlDefinition} interface with the generic {@code DispatcherServlet}. + * Adapter to use the {@code WsdlDefinition} interface with the generic + * {@code DispatcherServlet}. *

- * Reads the source from the mapped {@code WsdlDefinition} implementation, and writes that as the result to the - * {@code HttpServletResponse}. + * Reads the source from the mapped {@code WsdlDefinition} implementation, and writes that + * as the result to the {@code HttpServletResponse}. *

- * If the property {@code transformLocations} is set to {@code true}, this adapter will change {@code location} - * attributes in the WSDL definition to reflect the URL of the incoming request. If the location field in the original - * WSDL is an absolute path, the scheme, hostname, and port will be changed. If the location is a relative path, the - * scheme, hostname, port, and context path will be prepended. This behavior can be customized by overriding the - * {@code transformLocation()} method. + * If the property {@code transformLocations} is set to {@code true}, this adapter will + * change {@code location} attributes in the WSDL definition to reflect the URL of the + * incoming request. If the location field in the original WSDL is an absolute path, the + * scheme, hostname, and port will be changed. If the location is a relative path, the + * scheme, hostname, port, and context path will be prepended. This behavior can be + * customized by overriding the {@code transformLocation()} method. *

* For instance, if the location attribute defined in the WSDL is - * {@code http://localhost:8080/context/services/myService}, and the request URI for the WSDL is - * {@code http://example.com/context/myService.wsdl}, the location will be changed to - * {@code http://example.com/context/services/myService}. + * {@code http://localhost:8080/context/services/myService}, and the request URI for the + * WSDL is {@code http://example.com/context/myService.wsdl}, the location will be changed + * to {@code http://example.com/context/services/myService}. *

- * If the location attribute defined in the WSDL is {@code /services/myService}, and the request URI for the WSDL is - * {@code http://example.com:8080/context/myService.wsdl}, the location will be changed to - * {@code http://example.com:8080/context/services/myService}. + * If the location attribute defined in the WSDL is {@code /services/myService}, and the + * request URI for the WSDL is {@code http://example.com:8080/context/myService.wsdl}, the + * location will be changed to {@code http://example.com:8080/context/services/myService}. *

- * When {@code transformLocations} is enabled, all {@code location} attributes found in the WSDL definition are changed - * by default. This behavior can be customized by changing the {@code locationExpression} property, which is an XPath - * expression that matches the attributes to change. + * When {@code transformLocations} is enabled, all {@code location} attributes found in + * the WSDL definition are changed by default. This behavior can be customized by changing + * the {@code locationExpression} property, which is an XPath expression that matches the + * attributes to change. * * @author Arjen Poutsma * @see WsdlDefinition @@ -71,10 +74,16 @@ import org.w3c.dom.Document; public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSupport implements HandlerAdapter, InitializingBean { - /** Default XPath expression used for extracting all {@code location} attributes from the WSDL definition. */ + /** + * Default XPath expression used for extracting all {@code location} attributes from + * the WSDL definition. + */ public static final String DEFAULT_LOCATION_EXPRESSION = "//@location"; - /** Default XPath expression used for extracting all {@code schemaLocation} attributes from the WSDL definition. */ + /** + * Default XPath expression used for extracting all {@code schemaLocation} attributes + * from the WSDL definition. + */ public static final String DEFAULT_SCHEMA_LOCATION_EXPRESSION = "//@schemaLocation"; private static final String CONTENT_TYPE = "text/xml"; @@ -94,7 +103,8 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo private boolean transformSchemaLocations = false; /** - * Sets the XPath expression used for extracting the {@code location} attributes from the WSDL 1.1 definition. + * Sets the XPath expression used for extracting the {@code location} attributes from + * the WSDL 1.1 definition. *

* Defaults to {@code DEFAULT_LOCATION_EXPRESSION}. */ @@ -103,7 +113,8 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo } /** - * Sets the XPath expression used for extracting the {@code schemaLocation} attributes from the WSDL 1.1 definition. + * Sets the XPath expression used for extracting the {@code schemaLocation} attributes + * from the WSDL 1.1 definition. *

* Defaults to {@code DEFAULT_SCHEMA_LOCATION_EXPRESSION}. */ @@ -112,16 +123,17 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo } /** - * Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming - * {@code HttpServletRequest}. Defaults to {@code false}. + * Sets whether relative address locations in the WSDL are to be transformed using the + * request URI of the incoming {@code HttpServletRequest}. Defaults to {@code false}. */ public void setTransformLocations(boolean transformLocations) { this.transformLocations = transformLocations; } /** - * Sets whether relative address schema locations in the WSDL are to be transformed using the request URI of the - * incoming {@code HttpServletRequest}. Defaults to {@code false}. + * Sets whether relative address schema locations in the WSDL are to be transformed + * using the request URI of the incoming {@code HttpServletRequest}. Defaults to + * {@code false}. */ public void setTransformSchemaLocations(boolean transformSchemaLocations) { this.transformSchemaLocations = transformSchemaLocations; @@ -158,7 +170,8 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo response.setContentType(CONTENT_TYPE); StreamResult responseResult = new StreamResult(response.getOutputStream()); transformer.transform(definitionSource, responseResult); - } else { + } + else { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } return null; @@ -171,18 +184,19 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo @Override public void afterPropertiesSet() throws Exception { - locationXPathExpression = XPathExpressionFactory.createXPathExpression(locationExpression, expressionNamespaces); + locationXPathExpression = XPathExpressionFactory.createXPathExpression(locationExpression, + expressionNamespaces); schemaLocationXPathExpression = XPathExpressionFactory.createXPathExpression(schemaLocationExpression, expressionNamespaces); } /** - * Transforms all {@code location} attributes to reflect the server name given {@code HttpServletRequest}. Determines - * the suitable attributes by evaluating the defined XPath expression, and delegates to {@code transformLocation} to - * do the transformation for all attributes that match. + * Transforms all {@code location} attributes to reflect the server name given + * {@code HttpServletRequest}. Determines the suitable attributes by evaluating the + * defined XPath expression, and delegates to {@code transformLocation} to do the + * transformation for all attributes that match. *

* This method is only called when the {@code transformLocations} property is true. - * * @see #setLocationExpression(String) * @see #setTransformLocations(boolean) * @see #transformLocation(String,jakarta.servlet.http.HttpServletRequest) @@ -192,12 +206,13 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo } /** - * Transforms all {@code schemaLocation} attributes to reflect the server name given {@code HttpServletRequest}. - * Determines the suitable attributes by evaluating the defined XPath expression, and delegates to - * {@code transformLocation} to do the transformation for all attributes that match. + * Transforms all {@code schemaLocation} attributes to reflect the server name given + * {@code HttpServletRequest}. Determines the suitable attributes by evaluating the + * defined XPath expression, and delegates to {@code transformLocation} to do the + * transformation for all attributes that match. *

- * This method is only called when the {@code transformSchemaLocations} property is true. - * + * This method is only called when the {@code transformSchemaLocations} property is + * true. * @see #setSchemaLocationExpression(String) * @see #setTransformSchemaLocations(boolean) * @see #transformLocation(String,jakarta.servlet.http.HttpServletRequest) diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapter.java index 07473afa..df1abd95 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.transport.http; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - import java.util.HashMap; import java.util.Map; @@ -28,19 +25,24 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.w3c.dom.Document; + import org.springframework.beans.factory.InitializingBean; import org.springframework.web.servlet.HandlerAdapter; import org.springframework.web.servlet.ModelAndView; import org.springframework.xml.xpath.XPathExpression; import org.springframework.xml.xpath.XPathExpressionFactory; import org.springframework.xml.xsd.XsdSchema; -import org.w3c.dom.Document; /** - * Adapter to use the {@link XsdSchema} interface with the generic {@code DispatcherServlet}. + * Adapter to use the {@link XsdSchema} interface with the generic + * {@code DispatcherServlet}. *

- * Reads the source from the mapped {@link XsdSchema} implementation, and writes that as the result to the - * {@code HttpServletResponse}. Allows for post-processing the schema in subclasses. + * Reads the source from the mapped {@link XsdSchema} implementation, and writes that as + * the result to the {@code HttpServletResponse}. Allows for post-processing the schema in + * subclasses. * * @author Arjen Poutsma * @see XsdSchema @@ -51,7 +53,8 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport implements HandlerAdapter, InitializingBean { /** - * Default XPath expression used for extracting all {@code schemaLocation} attributes from the WSDL definition. + * Default XPath expression used for extracting all {@code schemaLocation} attributes + * from the WSDL definition. */ public static final String DEFAULT_SCHEMA_LOCATION_EXPRESSION = "//@schemaLocation"; @@ -66,7 +69,8 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport private boolean transformSchemaLocations = false; /** - * Sets the XPath expression used for extracting the {@code schemaLocation} attributes from the WSDL 1.1 definition. + * Sets the XPath expression used for extracting the {@code schemaLocation} attributes + * from the WSDL 1.1 definition. *

* Defaults to {@code DEFAULT_SCHEMA_LOCATION_EXPRESSION}. */ @@ -75,8 +79,9 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport } /** - * Sets whether relative address schema locations in the WSDL are to be transformed using the request URI of the - * incoming {@code HttpServletRequest}. Defaults to {@code false}. + * Sets whether relative address schema locations in the WSDL are to be transformed + * using the request URI of the incoming {@code HttpServletRequest}. Defaults to + * {@code false}. */ public void setTransformSchemaLocations(boolean transformSchemaLocations) { this.transformSchemaLocations = transformSchemaLocations; @@ -106,7 +111,8 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport response.setContentType(CONTENT_TYPE); StreamResult responseResult = new StreamResult(response.getOutputStream()); transformer.transform(schemaSource, responseResult); - } else { + } + else { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } return null; @@ -124,11 +130,10 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport } /** - * Returns the {@link Source} of the given schema. Allows for post-processing and transformation of the schema in - * sub-classes. + * Returns the {@link Source} of the given schema. Allows for post-processing and + * transformation of the schema in sub-classes. *

* Default implementation simply returns {@link XsdSchema#getSource()}. - * * @param schema the schema * @return the source of the given schema * @throws Exception in case of errors @@ -138,12 +143,13 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport } /** - * Transforms all {@code schemaLocation} attributes to reflect the server name given {@code HttpServletRequest}. - * Determines the suitable attributes by evaluating the defined XPath expression, and delegates to {@code + * Transforms all {@code schemaLocation} attributes to reflect the server name given + * {@code HttpServletRequest}. Determines the suitable attributes by evaluating the + * defined XPath expression, and delegates to {@code * transformLocation} to do the transformation for all attributes that match. *

- * This method is only called when the {@code transformSchemaLocations} property is true. - * + * This method is only called when the {@code transformSchemaLocations} property is + * true. * @see #setSchemaLocationExpression(String) * @see #transformLocation(String, jakarta.servlet.http.HttpServletRequest) */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/support/AbstractAnnotationConfigMessageDispatcherServletInitializer.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/support/AbstractAnnotationConfigMessageDispatcherServletInitializer.java index 86fccb8d..d457a6e5 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/support/AbstractAnnotationConfigMessageDispatcherServletInitializer.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/support/AbstractAnnotationConfigMessageDispatcherServletInitializer.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,12 +25,14 @@ import org.springframework.web.servlet.support.AbstractDispatcherServletInitiali import org.springframework.ws.transport.http.MessageDispatcherServlet; /** - * Base class for {@link WebApplicationInitializer} implementations that register a {@link MessageDispatcherServlet} - * configured with annotated classes, e.g. Spring's {@link Configuration @Configuration} classes. + * Base class for {@link WebApplicationInitializer} implementations that register a + * {@link MessageDispatcherServlet} configured with annotated classes, e.g. Spring's + * {@link Configuration @Configuration} classes. *

* Concrete implementations are required to implement {@link #getRootConfigClasses()} and - * {@link #getServletConfigClasses()} as well as {@link #getServletMappings()}. Further template and customization - * methods are provided by {@link AbstractDispatcherServletInitializer}. + * {@link #getServletConfigClasses()} as well as {@link #getServletMappings()}. Further + * template and customization methods are provided by + * {@link AbstractDispatcherServletInitializer}. * * @author Arjen Poutsma * @since 2.2 @@ -41,9 +43,9 @@ public abstract class AbstractAnnotationConfigMessageDispatcherServletInitialize /** * {@inheritDoc} *

- * This implementation creates an {@link AnnotationConfigWebApplicationContext}, providing it the annotated classes - * returned by {@link #getRootConfigClasses()}. Returns {@code null} if {@link #getRootConfigClasses()} returns - * {@code null}. + * This implementation creates an {@link AnnotationConfigWebApplicationContext}, + * providing it the annotated classes returned by {@link #getRootConfigClasses()}. + * Returns {@code null} if {@link #getRootConfigClasses()} returns {@code null}. */ @Override protected WebApplicationContext createRootApplicationContext() { @@ -52,7 +54,8 @@ public abstract class AbstractAnnotationConfigMessageDispatcherServletInitialize AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext(); rootAppContext.register(configClasses); return rootAppContext; - } else { + } + else { return null; } } @@ -60,8 +63,8 @@ public abstract class AbstractAnnotationConfigMessageDispatcherServletInitialize /** * {@inheritDoc} *

- * This implementation creates an {@link AnnotationConfigWebApplicationContext}, providing it the annotated classes - * returned by {@link #getServletConfigClasses()}. + * This implementation creates an {@link AnnotationConfigWebApplicationContext}, + * providing it the annotated classes returned by {@link #getServletConfigClasses()}. */ @Override protected WebApplicationContext createServletApplicationContext() { @@ -74,21 +77,22 @@ public abstract class AbstractAnnotationConfigMessageDispatcherServletInitialize } /** - * Specify {@link org.springframework.context.annotation.Configuration @Configuration} and/or - * {@link org.springframework.stereotype.Component @Component} classes to be provided to the - * {@linkplain #createRootApplicationContext() root application context}. - * - * @return the configuration classes for the root application context, or {@code null} if creation and registration of - * a root context is not desired + * Specify {@link org.springframework.context.annotation.Configuration @Configuration} + * and/or {@link org.springframework.stereotype.Component @Component} classes to be + * provided to the {@linkplain #createRootApplicationContext() root application + * context}. + * @return the configuration classes for the root application context, or {@code null} + * if creation and registration of a root context is not desired */ protected abstract Class[] getRootConfigClasses(); /** - * Specify {@link org.springframework.context.annotation.Configuration @Configuration} and/or - * {@link org.springframework.stereotype.Component @Component} classes to be provided to the - * {@linkplain #createServletApplicationContext() dispatcher servlet application context}. - * - * @return the configuration classes for the dispatcher servlet application context (may not be empty or {@code null}) + * Specify {@link org.springframework.context.annotation.Configuration @Configuration} + * and/or {@link org.springframework.stereotype.Component @Component} classes to be + * provided to the {@linkplain #createServletApplicationContext() dispatcher servlet + * application context}. + * @return the configuration classes for the dispatcher servlet application context + * (may not be empty or {@code null}) */ protected abstract Class[] getServletConfigClasses(); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/support/AbstractMessageDispatcherServletInitializer.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/support/AbstractMessageDispatcherServletInitializer.java index 6786198d..3f61273c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/http/support/AbstractMessageDispatcherServletInitializer.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/support/AbstractMessageDispatcherServletInitializer.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,16 +26,19 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.ws.transport.http.MessageDispatcherServlet; /** - * Base class for {@link org.springframework.web.WebApplicationInitializer WebApplicationInitializer} implementations - * that register a {@link MessageDispatcherServlet} in the servlet context. + * Base class for {@link org.springframework.web.WebApplicationInitializer + * WebApplicationInitializer} implementations that register a + * {@link MessageDispatcherServlet} in the servlet context. *

- * Concrete implementations are required to implement {@link #createServletApplicationContext()}, which gets invoked - * from {@link #registerMessageDispatcherServlet(ServletContext)}. Further customization can be achieved by overriding - * {@link #customizeRegistration(ServletRegistration.Dynamic)}. + * Concrete implementations are required to implement + * {@link #createServletApplicationContext()}, which gets invoked from + * {@link #registerMessageDispatcherServlet(ServletContext)}. Further customization can be + * achieved by overriding {@link #customizeRegistration(ServletRegistration.Dynamic)}. *

- * Because this class extends from {@link AbstractContextLoaderInitializer}, concrete implementations are also required - * to implement {@link #createRootApplicationContext()} to set up a parent "root" application context. - * If a root context is not desired, implementations can simply return {@code null} in the + * Because this class extends from {@link AbstractContextLoaderInitializer}, concrete + * implementations are also required to implement {@link #createRootApplicationContext()} + * to set up a parent "root" application context. If a root context is + * not desired, implementations can simply return {@code null} in the * {@code createRootApplicationContext()} implementation. * * @author Arjen Poutsma @@ -49,7 +52,8 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra public static final String DEFAULT_SERVLET_NAME = "messageDispatcher"; /** - * The default servlet mappings. Can be customized by overriding {@link #getServletMappings()}. + * The default servlet mappings. Can be customized by overriding + * {@link #getServletMappings()}. */ public static final String[] DEFAULT_SERVLET_MAPPINGS = new String[] { "/services", "*.wsdl" }; @@ -63,12 +67,13 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra /** * Register a {@link MessageDispatcherServlet} against the given servlet context. *

- * This method will create a {@code MessageDispatcherServlet} with the name returned by {@link #getServletName()}, - * initializing it with the application context returned from {@link #createServletApplicationContext()}, and mapping - * it to the patterns returned from {@link #getServletMappings()}. + * This method will create a {@code MessageDispatcherServlet} with the name returned + * by {@link #getServletName()}, initializing it with the application context returned + * from {@link #createServletApplicationContext()}, and mapping it to the patterns + * returned from {@link #getServletMappings()}. *

- * Further customization can be achieved by overriding {@link #customizeRegistration(ServletRegistration.Dynamic)}. - * + * Further customization can be achieved by overriding + * {@link #customizeRegistration(ServletRegistration.Dynamic)}. * @param servletContext the context to register the servlet against */ protected void registerMessageDispatcherServlet(ServletContext servletContext) { @@ -95,9 +100,8 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra } /** - * Return the name under which the {@link MessageDispatcherServlet} will be registered. Defaults to - * {@link #DEFAULT_SERVLET_NAME}. - * + * Return the name under which the {@link MessageDispatcherServlet} will be + * registered. Defaults to {@link #DEFAULT_SERVLET_NAME}. * @see #registerMessageDispatcherServlet(ServletContext) */ protected String getServletName() { @@ -105,20 +109,20 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra } /** - * Create a servlet application context to be provided to the {@code MessageDispatcherServlet}. + * Create a servlet application context to be provided to the + * {@code MessageDispatcherServlet}. *

* The returned context is delegated to Spring's - * {@link MessageDispatcherServlet#MessageDispatcherServlet(WebApplicationContext)}. As such, it typically contains - * endpoints, interceptors and other web service-related beans. - * + * {@link MessageDispatcherServlet#MessageDispatcherServlet(WebApplicationContext)}. + * As such, it typically contains endpoints, interceptors and other web + * service-related beans. * @see #registerMessageDispatcherServlet(ServletContext) */ protected abstract WebApplicationContext createServletApplicationContext(); /** - * Specify the servlet mapping(s) for the {@code MessageDispatcherServlet}. Defaults to - * {@link #DEFAULT_SERVLET_MAPPINGS}. - * + * Specify the servlet mapping(s) for the {@code MessageDispatcherServlet}. Defaults + * to {@link #DEFAULT_SERVLET_MAPPINGS}. * @see #registerMessageDispatcherServlet(ServletContext) */ protected String[] getServletMappings() { @@ -126,16 +130,16 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra } /** - * Indicates whether relative address locations in the WSDL are to be transformed using the request URI of the - * incoming HTTP request. Defaults to {@code false}. + * Indicates whether relative address locations in the WSDL are to be transformed + * using the request URI of the incoming HTTP request. Defaults to {@code false}. */ public boolean isTransformWsdlLocations() { return false; } /** - * Indicates whether relative address locations in the XSD are to be transformed using the request URI of the incoming - * HTTP request. Defaults to {@code false}. + * Indicates whether relative address locations in the XSD are to be transformed using + * the request URI of the incoming HTTP request. Defaults to {@code false}. */ protected boolean isTransformSchemaLocations() { return false; @@ -144,10 +148,11 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra /** * Optionally perform further registration customization once * {@link #registerMessageDispatcherServlet(ServletContext)} has completed. - * - * @param registration the {@code MessageDispatcherServlet} registration to be customized + * @param registration the {@code MessageDispatcherServlet} registration to be + * customized * @see #registerMessageDispatcherServlet(ServletContext) */ - protected void customizeRegistration(ServletRegistration.Dynamic registration) {} + protected void customizeRegistration(ServletRegistration.Dynamic registration) { + } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/support/EnumerationIterator.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/support/EnumerationIterator.java index de6847df..6bbe4b5c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/support/EnumerationIterator.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/support/EnumerationIterator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -47,4 +47,5 @@ public class EnumerationIterator implements Iterator { public void remove() { throw new UnsupportedOperationException(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/support/TransportUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/support/TransportUtils.java index b6d43f7e..cf7a6c62 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/support/TransportUtils.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/support/TransportUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,10 +20,12 @@ import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.ws.transport.WebServiceConnection; /** - * Generic utility methods for working with Web service transports. Mainly for internal use within the framework. + * Generic utility methods for working with Web service transports. Mainly for internal + * use within the framework. * * @author Arjen Poutsma * @since 1.5.0 @@ -33,18 +35,19 @@ public abstract class TransportUtils { private static final Log logger = LogFactory.getLog(TransportUtils.class); /** - * Close the given {@link WebServiceConnection} and ignore any thrown exception. This is useful for typical - * {@code finally} blocks. - * + * Close the given {@link WebServiceConnection} and ignore any thrown exception. This + * is useful for typical {@code finally} blocks. * @param connection the web service connection to close (may be {@code null}) */ public static void closeConnection(WebServiceConnection connection) { if (connection != null) { try { connection.close(); - } catch (IOException ex) { + } + catch (IOException ex) { logger.debug("Could not close WebServiceConnection", ex); - } catch (Throwable ex) { + } + catch (Throwable ex) { logger.debug("Unexpected exception on closing WebServiceConnection", ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupport.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupport.java index e8f83804..5b3ae71b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupport.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupport.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,6 +20,7 @@ import java.net.URISyntaxException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.ws.FaultAwareWebServiceMessage; @@ -37,8 +38,9 @@ import org.springframework.ws.transport.context.TransportContext; import org.springframework.ws.transport.context.TransportContextHolder; /** - * Convenience base class for server-side transport objects. Contains a {@link WebServiceMessageFactory}, and has - * methods for handling incoming {@link WebServiceConnection}s. + * Convenience base class for server-side transport objects. Contains a + * {@link WebServiceMessageFactory}, and has methods for handling incoming + * {@link WebServiceConnection}s. * * @author Arjen Poutsma * @see #handleConnection @@ -67,14 +69,16 @@ public abstract class WebServiceMessageReceiverObjectSupport implements Initiali } /** - * Handles an incoming connection by {@link WebServiceConnection#receive(WebServiceMessageFactory) receving} a message - * from it, passing it to the {@link WebServiceMessageReceiver#receive(MessageContext) receiver}, and - * {@link WebServiceConnection#send(WebServiceMessage) sending} the response (if any). + * Handles an incoming connection by + * {@link WebServiceConnection#receive(WebServiceMessageFactory) receving} a message + * from it, passing it to the {@link WebServiceMessageReceiver#receive(MessageContext) + * receiver}, and {@link WebServiceConnection#send(WebServiceMessage) sending} the + * response (if any). *

* Stores the given connection in the {@link TransportContext}. - * * @param connection the incoming connection - * @param receiver the handler of the message, typically a {@link org.springframework.ws.server.MessageDispatcher} + * @param receiver the handler of the message, typically a + * {@link org.springframework.ws.server.MessageDispatcher} */ protected final void handleConnection(WebServiceConnection connection, WebServiceMessageReceiver receiver) throws Exception { @@ -88,16 +92,19 @@ public abstract class WebServiceMessageReceiverObjectSupport implements Initiali receiver.receive(messageContext); if (messageContext.hasResponse()) { WebServiceMessage response = messageContext.getResponse(); - if (response instanceof FaultAwareWebServiceMessage && connection instanceof FaultAwareWebServiceConnection) { + if (response instanceof FaultAwareWebServiceMessage + && connection instanceof FaultAwareWebServiceConnection) { FaultAwareWebServiceMessage faultResponse = (FaultAwareWebServiceMessage) response; FaultAwareWebServiceConnection faultConnection = (FaultAwareWebServiceConnection) connection; faultConnection.setFaultCode(faultResponse.getFaultCode()); } connection.send(messageContext.getResponse()); } - } catch (NoEndpointFoundException ex) { + } + catch (NoEndpointFoundException ex) { handleNoEndpointFoundException(ex, connection, receiver); - } finally { + } + finally { TransportUtils.closeConnection(connection); TransportContextHolder.setTransportContext(previousTransportContext); } @@ -106,9 +113,9 @@ public abstract class WebServiceMessageReceiverObjectSupport implements Initiali /** * Template method for handling {@code NoEndpointFoundException}s. *

- * Default implementation calls {@link EndpointAwareWebServiceConnection#endpointNotFound()} on the given connection, - * if possible. - * + * Default implementation calls + * {@link EndpointAwareWebServiceConnection#endpointNotFound()} on the given + * connection, if possible. * @param ex the {@code NoEndpointFoundException} * @param connection the current {@code WebServiceConnection} * @param receiver the {@code WebServiceMessageReceiver} @@ -125,7 +132,8 @@ public abstract class WebServiceMessageReceiverObjectSupport implements Initiali if (logger.isDebugEnabled()) { try { logger.debug("Accepting incoming [" + connection + "] at [" + connection.getUri() + "]"); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { // ignore } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/WsdlDefinition.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/WsdlDefinition.java index aee08576..101b9d75 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/WsdlDefinition.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/WsdlDefinition.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -28,7 +28,6 @@ public interface WsdlDefinition { /** * Returns the {@code Source} of the definition. - * * @return the {@code Source} of this WSDL definition */ Source getSource(); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/WsdlDefinitionException.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/WsdlDefinitionException.java index f6026d12..b08b3937 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/WsdlDefinitionException.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/WsdlDefinitionException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public class WsdlDefinitionException extends WebServiceException { public WsdlDefinitionException(String reason, Throwable throwable) { super(reason, throwable); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java index 80f36205..ec46690c 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,9 +31,10 @@ import org.springframework.xml.xsd.XsdSchema; import org.springframework.xml.xsd.XsdSchemaCollection; /** - * Convenient implementation of {@link Wsdl11Definition} that creates a SOAP 1.1 or 1.2 binding based on naming - * conventions in one or more inlined XSD schemas. Delegates to {@link InliningXsdSchemaTypesProvider}, - * {@link DefaultMessagesProvider}, {@link SuffixBasedPortTypesProvider}, {@link SoapProvider} underneath; effectively + * Convenient implementation of {@link Wsdl11Definition} that creates a SOAP 1.1 or 1.2 + * binding based on naming conventions in one or more inlined XSD schemas. Delegates to + * {@link InliningXsdSchemaTypesProvider}, {@link DefaultMessagesProvider}, + * {@link SuffixBasedPortTypesProvider}, {@link SoapProvider} underneath; effectively * equivalent to using a {@link ProviderBasedWsdl4jDefinition} with all these providers. *

* Example configuration: @@ -86,16 +87,16 @@ public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBe } /** - * Sets the single XSD schema to inline. Either this property, or {@link #setSchemaCollection(XsdSchemaCollection) - * schemaCollection} must be set. + * Sets the single XSD schema to inline. Either this property, or + * {@link #setSchemaCollection(XsdSchemaCollection) schemaCollection} must be set. */ public void setSchema(XsdSchema schema) { typesProvider.setSchema(schema); } /** - * Sets the XSD schema collection to inline. Either this property, or {@link #setSchema(XsdSchema) schema} must be - * set. + * Sets the XSD schema collection to inline. Either this property, or + * {@link #setSchema(XsdSchema) schema} must be set. */ public void setSchemaCollection(XsdSchemaCollection schemaCollection) { typesProvider.setSchemaCollection(schemaCollection); @@ -143,16 +144,19 @@ public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBe } /** - * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation - * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. - * + * Sets the SOAP Actions for this binding. Keys are + * {@link javax.wsdl.BindingOperation#getName() binding operation names}; values are + * {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action + * URIs}. * @param soapActions the soap */ public void setSoapActions(Properties soapActions) { soapProvider.setSoapActions(soapActions); } - /** Sets the value used for the binding transport attribute value. Defaults to HTTP. */ + /** + * Sets the value used for the binding transport attribute value. Defaults to HTTP. + */ public void setTransportUri(String transportUri) { soapProvider.setTransportUri(transportUri); } @@ -189,4 +193,5 @@ public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBe public Source getSource() { return delegate.getSource(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/ProviderBasedWsdl4jDefinition.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/ProviderBasedWsdl4jDefinition.java index 28294e09..9c79d21f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/ProviderBasedWsdl4jDefinition.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/ProviderBasedWsdl4jDefinition.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,11 +30,12 @@ import org.springframework.ws.wsdl.wsdl11.provider.ServicesProvider; import org.springframework.ws.wsdl.wsdl11.provider.TypesProvider; /** - * Implementation of the {@link Wsdl11Definition} that uses a provider-based mechanism to populate a WSDL4J - * {@link Definition}. + * Implementation of the {@link Wsdl11Definition} that uses a provider-based mechanism to + * populate a WSDL4J {@link Definition}. *

- * All providers are optional, indicating that a particular part of the WSDL will not be created. Providers can be set - * via various properties. The providers are {@link #afterPropertiesSet() invoked} in the following order: + * All providers are optional, indicating that a particular part of the WSDL will not be + * created. Providers can be set via various properties. The providers are + * {@link #afterPropertiesSet() invoked} in the following order: *

    *
  1. {@link ImportsProvider}
  2. *
  3. {@link TypesProvider}
  4. @@ -44,7 +45,8 @@ import org.springframework.ws.wsdl.wsdl11.provider.TypesProvider; *
  5. {@link ServicesProvider}
  6. *
*

- * This definition requires the target namespace to be set via {@link #setTargetNamespace(String)} + * This definition requires the target namespace to be set via + * {@link #setTargetNamespace(String)} * * @author Arjen Poutsma * @see #setImportsProvider(ImportsProvider) @@ -78,7 +80,6 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I * Returns the {@link ImportsProvider} for this definition. *

* Default is {@code null}, indicating that no {@code <import>} will be created - * * @return the import provider; or {@code null} */ public ImportsProvider getImportsProvider() { @@ -89,7 +90,6 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I * Sets the {@link ImportsProvider} for this definition. *

* Default is {@code null}, indicating that no {@code <import>} will be created - * * @param importsProvider the import provider */ public void setImportsProvider(ImportsProvider importsProvider) { @@ -100,7 +100,6 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I * Returns the {@link TypesProvider} for this definition. *

* Defaults to {@code null}, indicating that no {@code <types>} will be created - * * @return the types provider; or {@code null} */ public TypesProvider getTypesProvider() { @@ -111,7 +110,6 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I * Sets the {@link TypesProvider} for this definition. *

* Defaults to {@code null}, indicating that no {@code <types>} will be created - * * @param typesProvider the types provider; or {@code null} */ public void setTypesProvider(TypesProvider typesProvider) { @@ -121,8 +119,8 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Returns the {@link MessagesProvider} for this definition. *

- * Defaults to {@code null}, indicating that no {@code <message>} will be created - * + * Defaults to {@code null}, indicating that no {@code <message>} will be + * created * @return the messages provider; or {@code null} */ public MessagesProvider getMessagesProvider() { @@ -132,8 +130,8 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Sets the {@link MessagesProvider} for this definition. *

- * Defaults to {@code null}, indicating that no {@code <message>} will be created - * + * Defaults to {@code null}, indicating that no {@code <message>} will be + * created * @param messagesProvider the messages provider; or {@code null} */ public void setMessagesProvider(MessagesProvider messagesProvider) { @@ -143,8 +141,8 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Returns the {@link PortTypesProvider} for this definition. *

- * Defaults to {@code null}, indicating that no {@code <portType>} will be created - * + * Defaults to {@code null}, indicating that no {@code <portType>} will be + * created * @return the port types provider; or {@code null} */ public PortTypesProvider getPortTypesProvider() { @@ -154,8 +152,8 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Sets the {@link PortTypesProvider} for this definition. *

- * Defaults to {@code null}, indicating that no {@code <portType>} will be created - * + * Defaults to {@code null}, indicating that no {@code <portType>} will be + * created * @param portTypesProvider the port types provider; or {@code null} */ public void setPortTypesProvider(PortTypesProvider portTypesProvider) { @@ -165,8 +163,8 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Returns the {@link BindingsProvider} for this definition. *

- * Defaults to {@code null}, indicating that no {@code <binding>} will be created - * + * Defaults to {@code null}, indicating that no {@code <binding>} will be + * created * @return the binding provider; or {@code null} */ public BindingsProvider getBindingsProvider() { @@ -176,8 +174,8 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Sets the {@link BindingsProvider} for this definition. *

- * Defaults to {@code null}, indicating that no {@code <binding>} will be created - * + * Defaults to {@code null}, indicating that no {@code <binding>} will be + * created * @param bindingsProvider the bindings provider; or {@code null} */ public void setBindingsProvider(BindingsProvider bindingsProvider) { @@ -187,8 +185,8 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Returns the {@link ServicesProvider} for this definition. *

- * Defaults to {@code null}, indicating that no {@code <service>} will be created - * + * Defaults to {@code null}, indicating that no {@code <service>} will be + * created * @return the services provider; or {@code null} */ public ServicesProvider getServicesProvider() { @@ -198,8 +196,8 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Sets the {@link ServicesProvider} for this definition. *

- * Defaults to {@code null}, indicating that no {@code <service>} will be created - * + * Defaults to {@code null}, indicating that no {@code <service>} will be + * created * @param servicesProvider the services provider; or {@code null} */ public void setServicesProvider(ServicesProvider servicesProvider) { @@ -208,7 +206,6 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Returns the target namespace for the WSDL definition. - * * @return the target namespace * @see javax.wsdl.Definition#getTargetNamespace() */ @@ -218,7 +215,6 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I /** * Sets the target namespace used for this definition. Required. - * * @param targetNamespace the target namespace * @see javax.wsdl.Definition#setTargetNamespace(String) */ @@ -253,4 +249,5 @@ public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements I } setDefinition(definition); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/SimpleWsdl11Definition.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/SimpleWsdl11Definition.java index 3f4ea159..4a8bfccb 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/SimpleWsdl11Definition.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/SimpleWsdl11Definition.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,14 +20,15 @@ import java.io.IOException; import javax.xml.transform.Source; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; import org.springframework.util.Assert; import org.springframework.ws.wsdl.WsdlDefinitionException; import org.springframework.xml.transform.ResourceSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; /** * The default {@link Wsdl11Definition} implementation. @@ -47,13 +48,15 @@ public class SimpleWsdl11Definition implements Wsdl11Definition, InitializingBea *

* A subsequent call to the {@link #setWsdl(Resource)} method is required. */ - public SimpleWsdl11Definition() {} + public SimpleWsdl11Definition() { + } /** - * Create a new instance of the {@link SimpleWsdl11Definition} class with the specified resource. - * + * Create a new instance of the {@link SimpleWsdl11Definition} class with the + * specified resource. * @param wsdlResource the WSDL resource; must not be {@code null} - * @throws IllegalArgumentException if the supplied {@code wsdlResource} is {@code null} + * @throws IllegalArgumentException if the supplied {@code wsdlResource} is + * {@code null} */ public SimpleWsdl11Definition(Resource wsdlResource) { Assert.notNull(wsdlResource, "wsdlResource must not be null"); @@ -72,16 +75,18 @@ public class SimpleWsdl11Definition implements Wsdl11Definition, InitializingBea XMLReader xmlReader = XMLReaderFactory.createXMLReader(); xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); return new ResourceSource(xmlReader, wsdlResource); - } catch (SAXException ex) { + } + catch (SAXException ex) { throw new WsdlDefinitionException("Could not create XMLReader", ex); - } catch (IOException ex) { + } + catch (IOException ex) { throw new WsdlDefinitionException("Could not create source from " + this.wsdlResource, ex); } } /** - * Set the WSDL resource to be exposed by calls to this instances' {@link #getSource()} method. - * + * Set the WSDL resource to be exposed by calls to this instances' + * {@link #getSource()} method. * @param wsdlResource the WSDL resource */ public void setWsdl(Resource wsdlResource) { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/Wsdl4jDefinition.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/Wsdl4jDefinition.java index b4bfb486..453df942 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/Wsdl4jDefinition.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/Wsdl4jDefinition.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,14 +23,16 @@ import javax.wsdl.xml.WSDLWriter; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; +import org.w3c.dom.Document; + import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.ws.wsdl.WsdlDefinitionException; -import org.w3c.dom.Document; /** - * Implementation of the {@code Wsdl11Definition} based on WSDL4J. A {@link javax.wsdl.Definition} can be given as as - * constructor argument, or set using a property. + * Implementation of the {@code Wsdl11Definition} based on WSDL4J. A + * {@link javax.wsdl.Definition} can be given as as constructor argument, or set using a + * property. * * @author Arjen Poutsma * @author Greg Turnquist @@ -47,14 +49,13 @@ public class Wsdl4jDefinition implements Wsdl11Definition { /** * Constructs a new, empty {@code Wsdl4jDefinition}. - * * @see #setDefinition(javax.wsdl.Definition) */ - public Wsdl4jDefinition() {} + public Wsdl4jDefinition() { + } /** * Constructs a new {@code Wsdl4jDefinition} based on the given {@code Definition}. - * * @param definition the WSDL4J definition */ public Wsdl4jDefinition(Definition definition) { @@ -84,7 +85,8 @@ public class Wsdl4jDefinition implements Wsdl11Definition { WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter(); Document document = wsdlWriter.getDocument(definition); return new DOMSource(document); - } catch (WSDLException ex) { + } + catch (WSDLException ex) { throw new WsdlDefinitionException(ex.getMessage(), ex); } } @@ -99,4 +101,5 @@ public class Wsdl4jDefinition implements Wsdl11Definition { } return builder.toString(); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java index edf10c26..39e4ecf4 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,6 +31,7 @@ import javax.xml.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.util.Assert; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; @@ -60,8 +61,8 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { } /** - * Creates a single {@link PortType}, and calls {@link #populatePortType(Definition, PortType)} with it. - * + * Creates a single {@link PortType}, and calls + * {@link #populatePortType(Definition, PortType)} with it. * @param definition the WSDL4J {@code Definition} * @throws WSDLException in case of errors */ @@ -81,7 +82,6 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { * Called after the {@link PortType} has been created. *

* Default implementation sets the name of the port type to the defined value. - * * @param portType the WSDL4J {@code PortType} * @throws WSDLException in case of errors * @see #setPortTypeName(String) @@ -122,12 +122,14 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { input.setMessage(message); populateInput(definition, input); operation.setInput(input); - } else if (isOutputMessage(message)) { + } + else if (isOutputMessage(message)) { Output output = definition.createOutput(); output.setMessage(message); populateOutput(definition, output); operation.setOutput(output); - } else if (isFaultMessage(message)) { + } + else if (isFaultMessage(message)) { Fault fault = definition.createFault(); fault.setMessage(message); populateFault(definition, fault); @@ -137,35 +139,35 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { operation.setStyle(getOperationType(operation)); operation.setUndefined(false); if (logger.isDebugEnabled()) { - logger.debug("Adding operation [" + operation.getName() + "] to port type [" + portType.getQName() + "]"); + logger + .debug("Adding operation [" + operation.getName() + "] to port type [" + portType.getQName() + "]"); } portType.addOperation(operation); } } /** - * Template method that returns the name of the operation coupled to the given {@link Message}. Subclasses can return - * {@code null} to indicate that a message should not be coupled to an operation. - * + * Template method that returns the name of the operation coupled to the given + * {@link Message}. Subclasses can return {@code null} to indicate that a message + * should not be coupled to an operation. * @param message the WSDL4J {@code Message} * @return the operation name; or {@code null} */ protected abstract String getOperationName(Message message); /** - * Indicates whether the given name name should be included as {@link Input} message in the definition. - * + * Indicates whether the given name name should be included as {@link Input} message + * in the definition. * @param message the message * @return {@code true} if to be included as input; {@code false} otherwise */ protected abstract boolean isInputMessage(Message message); /** - * Called after the {@link javax.wsdl.Input} has been created, but it's added to the operation. Subclasses can - * override this method to define the input name. + * Called after the {@link javax.wsdl.Input} has been created, but it's added to the + * operation. Subclasses can override this method to define the input name. *

* Default implementation sets the input name to the message name. - * * @param definition the WSDL4J {@code Definition} * @param input the WSDL4J {@code Input} */ @@ -174,19 +176,18 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { } /** - * Indicates whether the given name name should be included as {@link Output} message in the definition. - * + * Indicates whether the given name name should be included as {@link Output} message + * in the definition. * @param message the message * @return {@code true} if to be included as output; {@code false} otherwise */ protected abstract boolean isOutputMessage(Message message); /** - * Called after the {@link javax.wsdl.Output} has been created, but it's added to the operation. Subclasses can - * override this method to define the output name. + * Called after the {@link javax.wsdl.Output} has been created, but it's added to the + * operation. Subclasses can override this method to define the output name. *

* Default implementation sets the output name to the message name. - * * @param definition the WSDL4J {@code Definition} * @param output the WSDL4J {@code Output} */ @@ -195,19 +196,18 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { } /** - * Indicates whether the given name name should be included as {@link Fault} message in the definition. - * + * Indicates whether the given name name should be included as {@link Fault} message + * in the definition. * @param message the message * @return {@code true} if to be included as fault; {@code false} otherwise */ protected abstract boolean isFaultMessage(Message message); /** - * Called after the {@link javax.wsdl.Fault} has been created, but it's added to the operation. Subclasses can - * override this method to define the fault name. + * Called after the {@link javax.wsdl.Fault} has been created, but it's added to the + * operation. Subclasses can override this method to define the fault name. *

* Default implementation sets the fault name to the message name. - * * @param definition the WSDL4J {@code Definition} * @param fault the WSDL4J {@code Fault} */ @@ -218,9 +218,9 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { /** * Returns the {@link OperationType} for the given operation. *

- * Default implementation returns {@link OperationType#REQUEST_RESPONSE} if both input and output are set; - * {@link OperationType#ONE_WAY} if only input is set, or {@link OperationType#NOTIFICATION} if only output is set. - * + * Default implementation returns {@link OperationType#REQUEST_RESPONSE} if both input + * and output are set; {@link OperationType#ONE_WAY} if only input is set, or + * {@link OperationType#NOTIFICATION} if only output is set. * @param operation the WSDL4J {@code Operation} * @return the operation type for the operation */ @@ -228,11 +228,14 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { if (operation.getInput() != null && operation.getOutput() != null) { return OperationType.REQUEST_RESPONSE; - } else if (operation.getInput() != null && operation.getOutput() == null) { + } + else if (operation.getInput() != null && operation.getOutput() == null) { return OperationType.ONE_WAY; - } else if (operation.getInput() == null && operation.getOutput() != null) { + } + else if (operation.getInput() == null && operation.getOutput() != null) { return OperationType.NOTIFICATION; - } else { + } + else { return null; } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultConcretePartProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultConcretePartProvider.java index 7cc3a207..08a14ea4 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultConcretePartProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultConcretePartProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,36 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import javax.wsdl.*; +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Operation; +import javax.wsdl.OperationType; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.wsdl.WSDLException; import javax.xml.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.util.Assert; import org.springframework.util.StringUtils; /** - * Default implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces. + * Default implementation of the {@link BindingsProvider} and {@link ServicesProvider} + * interfaces. *

- * Creates a {@code binding} that matches any present {@code portType}, and a service containing {@code port}s that - * match the {@code binding}s. Lets subclasses populate these through template methods. * + * Creates a {@code binding} that matches any present {@code portType}, and a service + * containing {@code port}s that match the {@code binding}s. Lets subclasses populate + * these through template methods. * * * @author Arjen Poutsma * @since 1.5.0 @@ -68,11 +85,11 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr /** * Creates a {@link Binding} for each {@link PortType} in the definition, and calls - * {@link #populateBinding(Definition,javax.wsdl.Binding)} with it. Creates a {@link BindingOperation} for each - * {@link Operation} in the port type, a {@link BindingInput} for each {@link Input} in the operation, etc. + * {@link #populateBinding(Definition,javax.wsdl.Binding)} with it. Creates a + * {@link BindingOperation} for each {@link Operation} in the port type, a + * {@link BindingInput} for each {@link Input} in the operation, etc. *

* Calls the various {@code populate} methods with the created WSDL4J objects. - * * @param definition the WSDL4J {@code Definition} * @throws WSDLException in case of errors * @see #populateBinding(Definition,javax.wsdl.Binding) @@ -104,12 +121,12 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr } /** - * Called after the {@link Binding} has been created, but before any sub-elements are added. Subclasses can override - * this method to define the binding name, or add extensions to it. + * Called after the {@link Binding} has been created, but before any sub-elements are + * added. Subclasses can override this method to define the binding name, or add + * extensions to it. *

- * Default implementation sets the binding name to the port type name with the {@link #getBindingSuffix() suffix} - * appended to it. - * + * Default implementation sets the binding name to the port type name with the + * {@link #getBindingSuffix() suffix} appended to it. * @param definition the WSDL4J {@code Definition} * @param binding the WSDL4J {@code Binding} */ @@ -119,7 +136,8 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr if (portTypeName != null) { - QName bindingName = new QName(portTypeName.getNamespaceURI(), portTypeName.getLocalPart() + getBindingSuffix()); + QName bindingName = new QName(portTypeName.getNamespaceURI(), + portTypeName.getLocalPart() + getBindingSuffix()); if (logger.isDebugEnabled()) { logger.debug("Creating binding [" + bindingName + "]"); } @@ -141,11 +159,14 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr if (OperationType.REQUEST_RESPONSE.equals(operation.getStyle())) { createBindingInput(definition, operation, bindingOperation); createBindingOutput(definition, operation, bindingOperation); - } else if (OperationType.ONE_WAY.equals(operation.getStyle())) { + } + else if (OperationType.ONE_WAY.equals(operation.getStyle())) { createBindingInput(definition, operation, bindingOperation); - } else if (OperationType.NOTIFICATION.equals(operation.getStyle())) { + } + else if (OperationType.NOTIFICATION.equals(operation.getStyle())) { createBindingOutput(definition, operation, bindingOperation); - } else if (OperationType.SOLICIT_RESPONSE.equals(operation.getStyle())) { + } + else if (OperationType.SOLICIT_RESPONSE.equals(operation.getStyle())) { createBindingOutput(definition, operation, bindingOperation); createBindingInput(definition, operation, bindingOperation); } @@ -164,11 +185,12 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr } /** - * Called after the {@link BindingOperation} has been created, but before any sub-elements are added. Subclasses can - * override this method to define the binding name, or add extensions to it. + * Called after the {@link BindingOperation} has been created, but before any + * sub-elements are added. Subclasses can override this method to define the binding + * name, or add extensions to it. *

- * Default implementation sets the name of the binding operation to the name of the operation. - * + * Default implementation sets the name of the binding operation to the name of the + * operation. * @param definition the WSDL4J {@code Definition} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws WSDLException in case of errors @@ -195,14 +217,14 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr } /** - * Called after the {@link BindingInput} has been created. Subclasses can override this method to define the name, or - * add extensions to it. + * Called after the {@link BindingInput} has been created. Subclasses can override + * this method to define the name, or add extensions to it. *

* Default implementation set the name of the binding input to the name of the input. - * * @param definition the WSDL4J {@code Definition} * @param bindingInput the WSDL4J {@code BindingInput} - * @param input the corresponding WSDL4J {@code Input} @throws WSDLException in case of errors + * @param input the corresponding WSDL4J {@code Input} @throws WSDLException in case + * of errors */ protected void populateBindingInput(Definition definition, BindingInput bindingInput, Input input) throws WSDLException { @@ -210,14 +232,15 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr } /** - * Called after the {@link BindingOutput} has been created. Subclasses can override this method to define the name, or - * add extensions to it. + * Called after the {@link BindingOutput} has been created. Subclasses can override + * this method to define the name, or add extensions to it. *

- * Default implementation sets the name of the binding output to the name of the output. - * + * Default implementation sets the name of the binding output to the name of the + * output. * @param definition the WSDL4J {@code Definition} * @param bindingOutput the WSDL4J {@code BindingOutput} - * @param output the corresponding WSDL4J {@code Output} @throws WSDLException in case of errors + * @param output the corresponding WSDL4J {@code Output} @throws WSDLException in case + * of errors */ protected void populateBindingOutput(Definition definition, BindingOutput bindingOutput, Output output) throws WSDLException { @@ -225,13 +248,13 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr } /** - * Called after the {@link BindingFault} has been created. Subclasses can implement this method to define the name, or - * add extensions to it. + * Called after the {@link BindingFault} has been created. Subclasses can implement + * this method to define the name, or add extensions to it. *

* Default implementation set the name of the binding fault to the name of the fault. - * * @param bindingFault the WSDL4J {@code BindingFault} - * @param fault the corresponding WSDL4J {@code Fault} @throws WSDLException in case of errors + * @param fault the corresponding WSDL4J {@code Fault} @throws WSDLException in case + * of errors */ protected void populateBindingFault(Definition definition, BindingFault bindingFault, Fault fault) throws WSDLException { @@ -239,10 +262,10 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr } /** - * Creates a single {@link Service} if not present, and calls {@link #populateService(Definition, Service)} with it. - * Creates a corresponding {@link Port} for each {@link Binding}, which is passed to + * Creates a single {@link Service} if not present, and calls + * {@link #populateService(Definition, Service)} with it. Creates a corresponding + * {@link Port} for each {@link Binding}, which is passed to * {@link #populatePort(javax.wsdl.Definition,javax.wsdl.Port)}. - * * @param definition the WSDL4J {@code Definition} * @throws WSDLException in case of errors */ @@ -254,7 +277,8 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr Service service; if (definition.getServices().isEmpty()) { service = definition.createService(); - } else { + } + else { service = (Service) definition.getServices().values().iterator().next(); } @@ -267,11 +291,12 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr } /** - * Called after the {@link Service} has been created, but before any sub-elements are added. Subclasses can implement - * this method to define the service name, or add extensions to it. + * Called after the {@link Service} has been created, but before any sub-elements are + * added. Subclasses can implement this method to define the service name, or add + * extensions to it. *

- * Default implementation sets the name to the {@link #setServiceName(String) serviceName} property. - * + * Default implementation sets the name to the {@link #setServiceName(String) + * serviceName} property. * @param service the WSDL4J {@code Service} * @throws WSDLException in case of errors */ @@ -316,11 +341,11 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr } /** - * Called after the {@link Port} has been created, but before any sub-elements are added. Subclasses can implement - * this method to define the port name, or add extensions to it. + * Called after the {@link Port} has been created, but before any sub-elements are + * added. Subclasses can implement this method to define the port name, or add + * extensions to it. *

* Default implementation sets the port name to the binding name. - * * @param definition the WSDL4J {@code Definition} * @param port the WSDL4J {@code Port} * @throws WSDLException in case of errors @@ -330,4 +355,5 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr String portName = port.getBinding().getQName().getLocalPart(); port.setName(portName); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProvider.java index 3dc7b6f4..c3c7ba0a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,11 +27,12 @@ import javax.xml.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.util.Assert; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.springframework.util.Assert; + /** * Default implementation of the {@link MessagesProvider}. *

@@ -97,7 +98,6 @@ public class DefaultMessagesProvider implements MessagesProvider { /** * Returns the name attribute of the given element. - * * @param element the element whose name to return * @return the name of the element */ @@ -106,11 +106,11 @@ public class DefaultMessagesProvider implements MessagesProvider { } /** - * Indicates whether the given element should be includes as {@link Message} in the definition. + * Indicates whether the given element should be includes as {@link Message} in the + * definition. *

- * Default implementation checks whether the element has the XML Schema namespace, and if it has the local name - * "element". - * + * Default implementation checks whether the element has the XML Schema namespace, and + * if it has the local name "element". * @param element the element elligable for being a message * @return {@code true} if to be included as message; {@code false} otherwise */ @@ -124,7 +124,6 @@ public class DefaultMessagesProvider implements MessagesProvider { * Called after the {@link Message} has been created. *

* Default implementation sets the name of the message to the element name. - * * @param definition the WSDL4J {@code Definition} * @param message the WSDL4J {@code Message} * @param elementName the element name @@ -143,7 +142,6 @@ public class DefaultMessagesProvider implements MessagesProvider { * Called after the {@link Part} has been created. *

* Default implementation sets the element name of the part. - * * @param definition the WSDL4J {@code Definition} * @param part the WSDL4J {@code Part} * @param elementName the elementName @throws WSDLException in case of errors @@ -154,4 +152,5 @@ public class DefaultMessagesProvider implements MessagesProvider { part.setElementName(elementName); part.setName(elementName.getLocalPart()); } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProvider.java index f4cca7c7..1115d777 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,18 +26,19 @@ import javax.xml.transform.dom.DOMResult; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + import org.springframework.util.Assert; import org.springframework.ws.wsdl.WsdlDefinitionException; import org.springframework.xml.transform.TransformerObjectSupport; import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.xsd.XsdSchema; import org.springframework.xml.xsd.XsdSchemaCollection; -import org.w3c.dom.Document; -import org.w3c.dom.Element; /** - * Implementation of {@link TypesProvider} that inlines a {@link XsdSchema} or {@link XsdSchemaCollection} into the - * WSDL. + * Implementation of {@link TypesProvider} that inlines a {@link XsdSchema} or + * {@link XsdSchemaCollection} into the WSDL. * * @author Arjen Poutsma * @since 1.5.0 @@ -52,8 +53,8 @@ public class InliningXsdSchemaTypesProvider extends TransformerObjectSupport imp private XsdSchemaCollection schemaCollection; /** - * Sets the single XSD schema to inline. Either this property, or {@link #setSchemaCollection(XsdSchemaCollection) - * schemaCollection} must be set. + * Sets the single XSD schema to inline. Either this property, or + * {@link #setSchemaCollection(XsdSchemaCollection) schemaCollection} must be set. */ public void setSchema(final XsdSchema schema) { this.schemaCollection = new XsdSchemaCollection() { @@ -74,8 +75,8 @@ public class InliningXsdSchemaTypesProvider extends TransformerObjectSupport imp } /** - * Sets the XSD schema collection to inline. Either this property, or {@link #setSchema(XsdSchema) schema} must be - * set. + * Sets the XSD schema collection to inline. Either this property, or + * {@link #setSchema(XsdSchema) schema} must be set. */ public void setSchemaCollection(XsdSchemaCollection schemaCollection) { this.schemaCollection = schemaCollection; @@ -92,13 +93,14 @@ public class InliningXsdSchemaTypesProvider extends TransformerObjectSupport imp } if (schemas.length == 1) { definition.addNamespace(SCHEMA_PREFIX, schemas[i].getTargetNamespace()); - } else { + } + else { String prefix = SCHEMA_PREFIX + i; definition.addNamespace(prefix, schemas[i].getTargetNamespace()); } Element schemaElement = getSchemaElement(schemas[i]); - Schema schema = (Schema) definition.getExtensionRegistry().createExtension(Types.class, - new QName("http://www.w3.org/2001/XMLSchema", "schema")); + Schema schema = (Schema) definition.getExtensionRegistry() + .createExtension(Types.class, new QName("http://www.w3.org/2001/XMLSchema", "schema")); types.addExtensibilityElement(schema); schema.setElement(schemaElement); } @@ -111,7 +113,8 @@ public class InliningXsdSchemaTypesProvider extends TransformerObjectSupport imp transform(schema.getSource(), result); Document schemaDocument = (Document) result.getNode(); return schemaDocument.getDocumentElement(); - } catch (TransformerException e) { + } + catch (TransformerException e) { throw new WsdlDefinitionException("Could not transform schema source to Document"); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11Provider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11Provider.java index c615fdb1..d18b586b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11Provider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11Provider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,7 +18,17 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Properties; -import javax.wsdl.*; +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.WSDLException; import javax.wsdl.extensions.ExtensibilityElement; import javax.wsdl.extensions.ExtensionRegistry; import javax.wsdl.extensions.soap.SOAPAddress; @@ -31,10 +41,12 @@ import javax.xml.namespace.QName; import org.springframework.util.Assert; /** - * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces that are SOAP 1.1 specific. + * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces + * that are SOAP 1.1 specific. *

- * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the SOAP Actions defined in the - * resulting WSDL can be set. Additionaly, the transport uri can be changed from the default HTTP transport by using the + * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the + * SOAP Actions defined in the resulting WSDL can be set. Additionaly, the transport uri + * can be changed from the default HTTP transport by using the * {@link #setTransportUri(String) transportUri} property. * * @author Arjen Poutsma @@ -67,9 +79,10 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Returns the SOAP Actions for this binding. Keys are {@link BindingOperation#getName() binding operation names}; - * values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. - * + * Returns the SOAP Actions for this binding. Keys are + * {@link BindingOperation#getName() binding operation names}; values are + * {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action + * URIs}. * @return the soap actions */ public Properties getSoapActions() { @@ -77,9 +90,10 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Sets the SOAP Actions for this binding. Keys are {@link BindingOperation#getName() binding operation names}; values - * are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. - * + * Sets the SOAP Actions for this binding. Keys are {@link BindingOperation#getName() + * binding operation names}; values are + * {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action + * URIs}. * @param soapActions the soap */ public void setSoapActions(Properties soapActions) { @@ -89,8 +103,8 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Returns the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. - * + * Returns the value used for the binding transport attribute value. Defaults to + * {@link #DEFAULT_TRANSPORT_URI}. * @return the binding transport value */ public String getTransportUri() { @@ -98,8 +112,8 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Sets the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. - * + * Sets the value used for the binding transport attribute value. Defaults to + * {@link #DEFAULT_TRANSPORT_URI}. * @param transportUri the binding transport value */ public void setTransportUri(String transportUri) { @@ -119,13 +133,15 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link Binding} has been created, but before any sub-elements are added. Subclasses can override - * this method to define the binding name, or add extensions to it. + * Called after the {@link Binding} has been created, but before any sub-elements are + * added. Subclasses can override this method to define the binding name, or add + * extensions to it. *

- * Default implementation calls {@link DefaultConcretePartProvider#populateBinding(Definition, Binding)}, adds the - * SOAP 1.1 namespace, creates a {@link SOAPBinding}, and calls {@link #populateSoapBinding(SOAPBinding, Binding)} - * sets the binding name to the port type name with the {@link #getBindingSuffix() suffix} appended to it. - * + * Default implementation calls + * {@link DefaultConcretePartProvider#populateBinding(Definition, Binding)}, adds the + * SOAP 1.1 namespace, creates a {@link SOAPBinding}, and calls + * {@link #populateSoapBinding(SOAPBinding, Binding)} sets the binding name to the + * port type name with the {@link #getBindingSuffix() suffix} appended to it. * @param definition the WSDL4J {@code Definition} * @param binding the WSDL4J {@code Binding} */ @@ -142,9 +158,9 @@ public class Soap11Provider extends DefaultConcretePartProvider { /** * Called after the {@link SOAPBinding} has been created. *

- * Default implementation sets the binding style to {@code "document"}, and set the transport URI to the - * {@link #setTransportUri(String) transportUri} property value. Subclasses can override this behavior. - * + * Default implementation sets the binding style to {@code "document"}, and set the + * transport URI to the {@link #setTransportUri(String) transportUri} property value. + * Subclasses can override this behavior. * @param soapBinding the WSDL4J {@code SOAPBinding} * @throws WSDLException in case of errors * @see SOAPBinding#setStyle(String) @@ -159,16 +175,17 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link BindingFault} has been created. Subclasses can override this method to define the name, or - * add extensions to it. + * Called after the {@link BindingFault} has been created. Subclasses can override + * this method to define the name, or add extensions to it. *

* Default implementation calls - * {@link DefaultConcretePartProvider#populateBindingFault(Definition, BindingFault, Fault)}, creates a - * {@link SOAPFault}, and calls {@link #populateSoapFault(BindingFault, SOAPFault)}. - * + * {@link DefaultConcretePartProvider#populateBindingFault(Definition, BindingFault, Fault)}, + * creates a {@link SOAPFault}, and calls + * {@link #populateSoapFault(BindingFault, SOAPFault)}. * @param definition the WSDL4J {@code Definition} * @param bindingFault the WSDL4J {@code BindingFault} - * @param fault the corresponding WSDL4J {@code Fault} @throws WSDLException in case of errors + * @param fault the corresponding WSDL4J {@code Fault} @throws WSDLException in case + * of errors */ @Override protected void populateBindingFault(Definition definition, BindingFault bindingFault, Fault fault) @@ -183,9 +200,8 @@ public class Soap11Provider extends DefaultConcretePartProvider { /** * Called after the {@link SOAPFault} has been created. *

- * Default implementation sets the use style to {@code "literal"}, and sets the name equal to the binding fault. - * Subclasses can override this behavior. - * + * Default implementation sets the use style to {@code "literal"}, and sets the name + * equal to the binding fault. Subclasses can override this behavior. * @param bindingFault the WSDL4J {@code BindingFault} * @param soapFault the WSDL4J {@code SOAPFault} * @throws WSDLException in case of errors @@ -198,16 +214,16 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link BindingInput} has been created. Subclasses can implement this method to define the name, or - * add extensions to it. + * Called after the {@link BindingInput} has been created. Subclasses can implement + * this method to define the name, or add extensions to it. *

* Default implementation calls * {@link DefaultConcretePartProvider#populateBindingInput(Definition, javax.wsdl.BindingInput, javax.wsdl.Input)}, * creates a {@link SOAPBody}, and calls {@link #populateSoapBody(SOAPBody)}. - * * @param definition the WSDL4J {@code Definition} * @param bindingInput the WSDL4J {@code BindingInput} - * @param input the corresponding WSDL4J {@code Input} @throws WSDLException in case of errors + * @param input the corresponding WSDL4J {@code Input} @throws WSDLException in case + * of errors */ @Override protected void populateBindingInput(Definition definition, BindingInput bindingInput, Input input) @@ -222,8 +238,8 @@ public class Soap11Provider extends DefaultConcretePartProvider { /** * Called after the {@link SOAPBody} has been created. *

- * Default implementation sets the use style to {@code "literal"}. Subclasses can override this behavior. - * + * Default implementation sets the use style to {@code "literal"}. Subclasses can + * override this behavior. * @param soapBody the WSDL4J {@code SOAPBody} * @throws WSDLException in case of errors * @see SOAPBody#setUse(String) @@ -233,14 +249,14 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link BindingOperation} has been created, but before any sub-elements are added. Subclasses can - * implement this method to define the binding name, or add extensions to it. + * Called after the {@link BindingOperation} has been created, but before any + * sub-elements are added. Subclasses can implement this method to define the binding + * name, or add extensions to it. *

* Default implementation calls - * {@link DefaultConcretePartProvider#populateBindingOperation(Definition, BindingOperation)}, creates a - * {@link SOAPOperation}, and calls {@link #populateSoapOperation} sets the name of the binding operation to the name - * of the operation. - * + * {@link DefaultConcretePartProvider#populateBindingOperation(Definition, BindingOperation)}, + * creates a {@link SOAPOperation}, and calls {@link #populateSoapOperation} sets the + * name of the binding operation to the name of the operation. * @param definition the WSDL4J {@code Definition} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws WSDLException in case of errors @@ -250,7 +266,8 @@ public class Soap11Provider extends DefaultConcretePartProvider { throws WSDLException { super.populateBindingOperation(definition, bindingOperation); - SOAPOperation soapOperation = (SOAPOperation) createSoapExtension(definition, BindingOperation.class, "operation"); + SOAPOperation soapOperation = (SOAPOperation) createSoapExtension(definition, BindingOperation.class, + "operation"); populateSoapOperation(soapOperation, bindingOperation); bindingOperation.addExtensibilityElement(soapOperation); } @@ -258,9 +275,9 @@ public class Soap11Provider extends DefaultConcretePartProvider { /** * Called after the {@link SOAPOperation} has been created. *

- * Default implementation sets {@code SOAPAction} to the corresponding {@link #setSoapActions(java.util.Properties) - * soapActions} property, and defaults to "". - * + * Default implementation sets {@code SOAPAction} to the corresponding + * {@link #setSoapActions(java.util.Properties) soapActions} property, and defaults to + * "". * @param soapOperation the WSDL4J {@code SOAPOperation} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws WSDLException in case of errors @@ -276,16 +293,16 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link BindingInput} has been created. Subclasses can implement this method to define the name, or - * add extensions to it. + * Called after the {@link BindingInput} has been created. Subclasses can implement + * this method to define the name, or add extensions to it. *

* Default implementation calls - * {@link DefaultConcretePartProvider#populateBindingOutput(Definition, BindingOutput, Output)}, creates a - * {@link SOAPBody}, and calls {@link #populateSoapBody(SOAPBody)}. - * + * {@link DefaultConcretePartProvider#populateBindingOutput(Definition, BindingOutput, Output)}, + * creates a {@link SOAPBody}, and calls {@link #populateSoapBody(SOAPBody)}. * @param definition the WSDL4J {@code Definition} * @param bindingOutput the WSDL4J {@code BindingOutput} - * @param output the corresponding WSDL4J {@code Output} @throws WSDLException in case of errors + * @param output the corresponding WSDL4J {@code Output} @throws WSDLException in case + * of errors */ @Override protected void populateBindingOutput(Definition definition, BindingOutput bindingOutput, Output output) @@ -298,13 +315,13 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link Port} has been created, but before any sub-elements are added. Subclasses can implement - * this method to define the port name, or add extensions to it. + * Called after the {@link Port} has been created, but before any sub-elements are + * added. Subclasses can implement this method to define the port name, or add + * extensions to it. *

* Default implementation calls - * {@link DefaultConcretePartProvider#populatePort(javax.wsdl.Definition,javax.wsdl.Port)}, creates a - * {@link SOAPAddress}, and calls {@link #populateSoapAddress(SOAPAddress)}. - * + * {@link DefaultConcretePartProvider#populatePort(javax.wsdl.Definition,javax.wsdl.Port)}, + * creates a {@link SOAPAddress}, and calls {@link #populateSoapAddress(SOAPAddress)}. * @param port the WSDL4J {@code Port} * @throws WSDLException in case of errors */ @@ -325,9 +342,9 @@ public class Soap11Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link SOAPAddress} has been created. Default implementation sets the location URI to the value - * set on this builder. Subclasses can override this behavior. - * + * Called after the {@link SOAPAddress} has been created. Default implementation sets + * the location URI to the value set on this builder. Subclasses can override this + * behavior. * @param soapAddress the WSDL4J {@code SOAPAddress} * @throws WSDLException in case of errors * @see SOAPAddress#setLocationURI(String) @@ -339,9 +356,9 @@ public class Soap11Provider extends DefaultConcretePartProvider { /** * Creates a SOAP extensibility element. - * * @param definition the WSDL4J {@code Definition} - * @param parentType a class object indicating where in the WSDL definition this extension will exist + * @param parentType a class object indicating where in the WSDL definition this + * extension will exist * @param localName the local name of the extensibility element * @return the extensibility element * @throws WSDLException in case of errors @@ -349,7 +366,8 @@ public class Soap11Provider extends DefaultConcretePartProvider { */ private ExtensibilityElement createSoapExtension(Definition definition, Class parentType, String localName) throws WSDLException { - return definition.getExtensionRegistry().createExtension(parentType, new QName(SOAP_11_NAMESPACE_URI, localName)); + return definition.getExtensionRegistry() + .createExtension(parentType, new QName(SOAP_11_NAMESPACE_URI, localName)); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12Provider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12Provider.java index 0614e63f..9b57ed5a 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12Provider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12Provider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,7 +18,17 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Properties; -import javax.wsdl.*; +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.WSDLException; import javax.wsdl.extensions.ExtensibilityElement; import javax.wsdl.extensions.soap12.SOAP12Address; import javax.wsdl.extensions.soap12.SOAP12Binding; @@ -30,10 +40,12 @@ import javax.xml.namespace.QName; import org.springframework.util.Assert; /** - * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces that are SOAP 1.2 specific. + * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces + * that are SOAP 1.2 specific. *

- * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the SOAP Actions defined in the - * resulting WSDL can be set. Additionaly, the transport uri can be changed from the default HTTP transport by using the + * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the + * SOAP Actions defined in the resulting WSDL can be set. Additionaly, the transport uri + * can be changed from the default HTTP transport by using the * {@link #setTransportUri(String) transportUri} property. * * @author Arjen Poutsma @@ -66,9 +78,10 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Returns the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation - * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. - * + * Returns the SOAP Actions for this binding. Keys are + * {@link javax.wsdl.BindingOperation#getName() binding operation names}; values are + * {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action + * URIs}. * @return the soap actions */ public Properties getSoapActions() { @@ -76,9 +89,10 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation - * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. - * + * Sets the SOAP Actions for this binding. Keys are + * {@link javax.wsdl.BindingOperation#getName() binding operation names}; values are + * {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action + * URIs}. * @param soapActions the soap */ public void setSoapActions(Properties soapActions) { @@ -88,8 +102,8 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Returns the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. - * + * Returns the value used for the binding transport attribute value. Defaults to + * {@link #DEFAULT_TRANSPORT_URI}. * @return the binding transport value */ public String getTransportUri() { @@ -97,8 +111,8 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Sets the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. - * + * Sets the value used for the binding transport attribute value. Defaults to + * {@link #DEFAULT_TRANSPORT_URI}. * @param transportUri the binding transport value */ public void setTransportUri(String transportUri) { @@ -118,15 +132,17 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link javax.wsdl.Binding} has been created, but before any sub-elements are added. Subclasses can - * override this method to define the binding name, or add extensions to it. + * Called after the {@link javax.wsdl.Binding} has been created, but before any + * sub-elements are added. Subclasses can override this method to define the binding + * name, or add extensions to it. *

* Default implementation calls - * {@link DefaultConcretePartProvider#populateBinding(javax.wsdl.Definition, javax.wsdl.Binding)}, adds the SOAP 1.1 - * namespace, creates a {@link javax.wsdl.extensions.soap.SOAPBinding}, and calls - * {@link #populateSoapBinding(javax.wsdl.extensions.soap12.SOAP12Binding, javax.wsdl.Binding)} sets the binding name - * to the port type name with the {@link #getBindingSuffix() suffix} appended to it. - * + * {@link DefaultConcretePartProvider#populateBinding(javax.wsdl.Definition, javax.wsdl.Binding)}, + * adds the SOAP 1.1 namespace, creates a + * {@link javax.wsdl.extensions.soap.SOAPBinding}, and calls + * {@link #populateSoapBinding(javax.wsdl.extensions.soap12.SOAP12Binding, javax.wsdl.Binding)} + * sets the binding name to the port type name with the {@link #getBindingSuffix() + * suffix} appended to it. * @param definition the WSDL4J {@code Definition} * @param binding the WSDL4J {@code Binding} */ @@ -143,9 +159,9 @@ public class Soap12Provider extends DefaultConcretePartProvider { /** * Called after the {@link javax.wsdl.extensions.soap.SOAPBinding} has been created. *

- * Default implementation sets the binding style to {@code "document"}, and set the transport URI to the - * {@link #setTransportUri(String) transportUri} property value. Subclasses can override this behavior. - * + * Default implementation sets the binding style to {@code "document"}, and set the + * transport URI to the {@link #setTransportUri(String) transportUri} property value. + * Subclasses can override this behavior. * @param soapBinding the WSDL4J {@code SOAPBinding} * @throws javax.wsdl.WSDLException in case of errors * @see javax.wsdl.extensions.soap.SOAPBinding#setStyle(String) @@ -160,17 +176,17 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link javax.wsdl.BindingFault} has been created. Subclasses can override this method to define - * the name, or add extensions to it. + * Called after the {@link javax.wsdl.BindingFault} has been created. Subclasses can + * override this method to define the name, or add extensions to it. *

* Default implementation calls * {@link DefaultConcretePartProvider#populateBindingFault(javax.wsdl.Definition, javax.wsdl.BindingFault, javax.wsdl.Fault)}, * creates a {@link javax.wsdl.extensions.soap.SOAPFault}, and calls * {@link #populateSoapFault(javax.wsdl.BindingFault, javax.wsdl.extensions.soap12.SOAP12Fault)}. - * * @param definition the WSDL4J {@code Definition} * @param bindingFault the WSDL4J {@code BindingFault} - * @param fault the corresponding WSDL4J {@code Fault} @throws WSDLException in case of errors + * @param fault the corresponding WSDL4J {@code Fault} @throws WSDLException in case + * of errors */ @Override protected void populateBindingFault(Definition definition, BindingFault bindingFault, Fault fault) @@ -185,9 +201,8 @@ public class Soap12Provider extends DefaultConcretePartProvider { /** * Called after the {@link javax.wsdl.extensions.soap.SOAPFault} has been created. *

- * Default implementation sets the use style to {@code "literal"}, and sets the name equal to the binding fault. - * Subclasses can override this behavior. - * + * Default implementation sets the use style to {@code "literal"}, and sets the name + * equal to the binding fault. Subclasses can override this behavior. * @param bindingFault the WSDL4J {@code BindingFault} * @param soapFault the WSDL4J {@code SOAPFault} * @throws javax.wsdl.WSDLException in case of errors @@ -200,17 +215,17 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link javax.wsdl.BindingInput} has been created. Subclasses can implement this method to define - * the name, or add extensions to it. + * Called after the {@link javax.wsdl.BindingInput} has been created. Subclasses can + * implement this method to define the name, or add extensions to it. *

* Default implementation calls * {@link DefaultConcretePartProvider#populateBindingInput(javax.wsdl.Definition, javax.wsdl.BindingInput, javax.wsdl.Input)}, * creates a {@link javax.wsdl.extensions.soap.SOAPBody}, and calls * {@link #populateSoapBody(javax.wsdl.extensions.soap12.SOAP12Body)}. 2 - * * @param definition the WSDL4J {@code Definition} * @param bindingInput the WSDL4J {@code BindingInput} - * @param input the corresponding WSDL4J {@code Input} @throws WSDLException in case of errors + * @param input the corresponding WSDL4J {@code Input} @throws WSDLException in case + * of errors */ @Override protected void populateBindingInput(Definition definition, BindingInput bindingInput, Input input) @@ -225,8 +240,8 @@ public class Soap12Provider extends DefaultConcretePartProvider { /** * Called after the {@link javax.wsdl.extensions.soap.SOAPBody} has been created. *

- * Default implementation sets the use style to {@code "literal"}. Subclasses can override this behavior. - * + * Default implementation sets the use style to {@code "literal"}. Subclasses can + * override this behavior. * @param soapBody the WSDL4J {@code SOAPBody} * @throws javax.wsdl.WSDLException in case of errors * @see javax.wsdl.extensions.soap.SOAPBody#setUse(String) @@ -236,14 +251,15 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link javax.wsdl.BindingOperation} has been created, but before any sub-elements are added. - * Subclasses can implement this method to define the binding name, or add extensions to it. + * Called after the {@link javax.wsdl.BindingOperation} has been created, but before + * any sub-elements are added. Subclasses can implement this method to define the + * binding name, or add extensions to it. *

* Default implementation calls * {@link DefaultConcretePartProvider#populateBindingOperation(javax.wsdl.Definition, javax.wsdl.BindingOperation)}, - * creates a {@link javax.wsdl.extensions.soap.SOAPOperation}, and calls {@link #populateSoapOperation} sets the name - * of the binding operation to the name of the operation. - * + * creates a {@link javax.wsdl.extensions.soap.SOAPOperation}, and calls + * {@link #populateSoapOperation} sets the name of the binding operation to the name + * of the operation. * @param definition the WSDL4J {@code Definition} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws javax.wsdl.WSDLException in case of errors @@ -262,9 +278,9 @@ public class Soap12Provider extends DefaultConcretePartProvider { /** * Called after the {@link javax.wsdl.extensions.soap.SOAPOperation} has been created. *

- * Default implementation sets {@code SOAPAction} to the corresponding {@link #setSoapActions(java.util.Properties) - * soapActions} property, and defaults to "". - * + * Default implementation sets {@code SOAPAction} to the corresponding + * {@link #setSoapActions(java.util.Properties) soapActions} property, and defaults to + * "". * @param soapOperation the WSDL4J {@code SOAPOperation} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws javax.wsdl.WSDLException in case of errors @@ -280,17 +296,17 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link javax.wsdl.BindingInput} has been created. Subclasses can implement this method to define - * the name, or add extensions to it. + * Called after the {@link javax.wsdl.BindingInput} has been created. Subclasses can + * implement this method to define the name, or add extensions to it. *

* Default implementation calls * {@link DefaultConcretePartProvider#populateBindingOutput(javax.wsdl.Definition, javax.wsdl.BindingOutput, javax.wsdl.Output)}, * creates a {@link javax.wsdl.extensions.soap.SOAPBody}, and calls * {@link #populateSoapBody(javax.wsdl.extensions.soap12.SOAP12Body)}. - * * @param definition the WSDL4J {@code Definition} * @param bindingOutput the WSDL4J {@code BindingOutput} - * @param output the corresponding WSDL4J {@code Output} @throws WSDLException in case of errors + * @param output the corresponding WSDL4J {@code Output} @throws WSDLException in case + * of errors */ @Override protected void populateBindingOutput(Definition definition, BindingOutput bindingOutput, Output output) @@ -303,13 +319,14 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link javax.wsdl.Port} has been created, but before any sub-elements are added. Subclasses can - * implement this method to define the port name, or add extensions to it. + * Called after the {@link javax.wsdl.Port} has been created, but before any + * sub-elements are added. Subclasses can implement this method to define the port + * name, or add extensions to it. *

* Default implementation calls - * {@link DefaultConcretePartProvider#populatePort(javax.wsdl.Definition,javax.wsdl.Port)}, creates a - * {@link javax.wsdl.extensions.soap.SOAPAddress}, and calls {@link #populateSoapAddress(SOAP12Address)}. - * + * {@link DefaultConcretePartProvider#populatePort(javax.wsdl.Definition,javax.wsdl.Port)}, + * creates a {@link javax.wsdl.extensions.soap.SOAPAddress}, and calls + * {@link #populateSoapAddress(SOAP12Address)}. * @param port the WSDL4J {@code Port} * @throws WSDLException in case of errors */ @@ -330,9 +347,9 @@ public class Soap12Provider extends DefaultConcretePartProvider { } /** - * Called after the {@link SOAP12Address} has been created. Default implementation sets the location URI to the value - * set on this builder. Subclasses can override this behavior. - * + * Called after the {@link SOAP12Address} has been created. Default implementation + * sets the location URI to the value set on this builder. Subclasses can override + * this behavior. * @param soapAddress the WSDL4J {@code SOAPAddress} * @throws WSDLException in case of errors * @see SOAP12Address#setLocationURI(String) @@ -344,9 +361,9 @@ public class Soap12Provider extends DefaultConcretePartProvider { /** * Creates a SOAP extensibility element. - * * @param definition the WSDL4J {@code Definition} - * @param parentType a class object indicating where in the WSDL definition this extension will exist + * @param parentType a class object indicating where in the WSDL definition this + * extension will exist * @param localName the local name of the extensibility element * @return the extensibility element * @throws WSDLException in case of errors @@ -354,7 +371,8 @@ public class Soap12Provider extends DefaultConcretePartProvider { */ private ExtensibilityElement createSoapExtension(Definition definition, Class parentType, String localName) throws WSDLException { - return definition.getExtensionRegistry().createExtension(parentType, new QName(SOAP_12_NAMESPACE_URI, localName)); + return definition.getExtensionRegistry() + .createExtension(parentType, new QName(SOAP_12_NAMESPACE_URI, localName)); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProvider.java index 5ca20bad..c8c81d96 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,15 +22,18 @@ import javax.wsdl.Definition; import javax.wsdl.WSDLException; /** - * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces that supports SOAP 1.1 and - * SOAP 1.2. Delegates to {@link Soap11Provider} and {@link Soap12Provider}. + * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces + * that supports SOAP 1.1 and SOAP 1.2. Delegates to {@link Soap11Provider} and + * {@link Soap12Provider}. *

- * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the SOAP Actions defined in the - * resulting WSDL can be set. Additionally, the transport uri can be changed from the default HTTP transport by using - * the {@link #setTransportUri(String) transportUri} property. + * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the + * SOAP Actions defined in the resulting WSDL can be set. Additionally, the transport uri + * can be changed from the default HTTP transport by using the + * {@link #setTransportUri(String) transportUri} property. *

- * The {@link #setCreateSoap11Binding(boolean) createSoap11} and {@link #setCreateSoap12Binding(boolean) createSoap12} - * properties indicate whether a SOAP 1.1 or SOAP 1.2 binding should be created. These properties default to + * The {@link #setCreateSoap11Binding(boolean) createSoap11} and + * {@link #setCreateSoap12Binding(boolean) createSoap12} properties indicate whether a + * SOAP 1.1 or SOAP 1.2 binding should be created. These properties default to * {@code true} and {@code false} respectively. * * @author Arjen Poutsma @@ -65,9 +68,10 @@ public class SoapProvider implements BindingsProvider, ServicesProvider { } /** - * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation - * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. - * + * Sets the SOAP Actions for this binding. Keys are + * {@link javax.wsdl.BindingOperation#getName() binding operation names}; values are + * {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action + * URIs}. * @param soapActions the soap */ public void setSoapActions(Properties soapActions) { @@ -75,7 +79,9 @@ public class SoapProvider implements BindingsProvider, ServicesProvider { soap12BindingProvider.setSoapActions(soapActions); } - /** Sets the value used for the binding transport attribute value. Defaults to HTTP. */ + /** + * Sets the value used for the binding transport attribute value. Defaults to HTTP. + */ public void setTransportUri(String transportUri) { soap11BindingProvider.setTransportUri(transportUri); soap12BindingProvider.setTransportUri(transportUri); @@ -112,4 +118,5 @@ public class SoapProvider implements BindingsProvider, ServicesProvider { soap12BindingProvider.addServices(definition); } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedMessagesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedMessagesProvider.java index 810f5b73..151c540f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedMessagesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedMessagesProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,10 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import org.springframework.util.Assert; import org.w3c.dom.Element; +import org.springframework.util.Assert; + /** * Implementation of the {@link MessagesProvider} interface that is based on suffixes. * @@ -44,7 +45,6 @@ public class SuffixBasedMessagesProvider extends DefaultMessagesProvider { /** * Returns the suffix used to detect request elements in the schema. - * * @see #DEFAULT_REQUEST_SUFFIX */ public String getRequestSuffix() { @@ -53,7 +53,6 @@ public class SuffixBasedMessagesProvider extends DefaultMessagesProvider { /** * Sets the suffix used to detect request elements in the schema. - * * @see #DEFAULT_REQUEST_SUFFIX */ public void setRequestSuffix(String requestSuffix) { @@ -63,7 +62,6 @@ public class SuffixBasedMessagesProvider extends DefaultMessagesProvider { /** * Returns the suffix used to detect response elements in the schema. - * * @see #DEFAULT_RESPONSE_SUFFIX */ public String getResponseSuffix() { @@ -72,7 +70,6 @@ public class SuffixBasedMessagesProvider extends DefaultMessagesProvider { /** * Sets the suffix used to detect response elements in the schema. - * * @see #DEFAULT_RESPONSE_SUFFIX */ public void setResponseSuffix(String responseSuffix) { @@ -82,7 +79,6 @@ public class SuffixBasedMessagesProvider extends DefaultMessagesProvider { /** * Returns the suffix used to detect fault elements in the schema. - * * @see #DEFAULT_FAULT_SUFFIX */ public String getFaultSuffix() { @@ -91,7 +87,6 @@ public class SuffixBasedMessagesProvider extends DefaultMessagesProvider { /** * Sets the suffix used to detect fault elements in the schema. - * * @see #DEFAULT_FAULT_SUFFIX */ public void setFaultSuffix(String faultSuffix) { @@ -106,8 +101,10 @@ public class SuffixBasedMessagesProvider extends DefaultMessagesProvider { Assert.hasText(elementName, "Element has no name"); return elementName.endsWith(getRequestSuffix()) || elementName.endsWith(getResponseSuffix()) || elementName.endsWith(getFaultSuffix()); - } else { + } + else { return false; } } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProvider.java index 7a834f56..bdff0c25 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -45,7 +45,6 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * Returns the suffix used to detect request elements in the schema. - * * @see #DEFAULT_REQUEST_SUFFIX */ public String getRequestSuffix() { @@ -54,7 +53,6 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * Sets the suffix used to detect request elements in the schema. - * * @see #DEFAULT_REQUEST_SUFFIX */ public void setRequestSuffix(String requestSuffix) { @@ -64,7 +62,6 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * Returns the suffix used to detect response elements in the schema. - * * @see #DEFAULT_RESPONSE_SUFFIX */ public String getResponseSuffix() { @@ -73,7 +70,6 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * Sets the suffix used to detect response elements in the schema. - * * @see #DEFAULT_RESPONSE_SUFFIX */ public void setResponseSuffix(String responseSuffix) { @@ -83,7 +79,6 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * Returns the suffix used to detect fault elements in the schema. - * * @see #DEFAULT_FAULT_SUFFIX */ public String getFaultSuffix() { @@ -92,7 +87,6 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * Sets the suffix used to detect fault elements in the schema. - * * @see #DEFAULT_FAULT_SUFFIX */ public void setFaultSuffix(String faultSuffix) { @@ -106,9 +100,11 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { if (messageName != null) { if (messageName.endsWith(getRequestSuffix())) { return messageName.substring(0, messageName.length() - getRequestSuffix().length()); - } else if (messageName.endsWith(getResponseSuffix())) { + } + else if (messageName.endsWith(getResponseSuffix())) { return messageName.substring(0, messageName.length() - getResponseSuffix().length()); - } else if (messageName.endsWith(getFaultSuffix())) { + } + else if (messageName.endsWith(getFaultSuffix())) { return messageName.substring(0, messageName.length() - getFaultSuffix().length()); } } @@ -116,10 +112,11 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { } /** - * Indicates whether the given name name should be included as {@link javax.wsdl.Input} message in the definition. + * Indicates whether the given name name should be included as + * {@link javax.wsdl.Input} message in the definition. *

- * This implementation checks whether the message name ends with the {@link #setRequestSuffix(String) requestSuffix}. - * + * This implementation checks whether the message name ends with the + * {@link #setRequestSuffix(String) requestSuffix}. * @param message the message * @return {@code true} if to be included as input; {@code false} otherwise */ @@ -130,11 +127,11 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { } /** - * Indicates whether the given name name should be included as {@link javax.wsdl.Output} message in the definition. + * Indicates whether the given name name should be included as + * {@link javax.wsdl.Output} message in the definition. *

- * This implementation checks whether the message name ends with the {@link #setResponseSuffix(String) - * responseSuffix}. - * + * This implementation checks whether the message name ends with the + * {@link #setResponseSuffix(String) responseSuffix}. * @param message the message * @return {@code true} if to be included as output; {@code false} otherwise */ @@ -145,10 +142,11 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { } /** - * Indicates whether the given name name should be included as {@link javax.wsdl.Fault} message in the definition. + * Indicates whether the given name name should be included as + * {@link javax.wsdl.Fault} message in the definition. *

- * This implementation checks whether the message name ends with the {@link #setFaultSuffix(String) faultSuffix}. - * + * This implementation checks whether the message name ends with the + * {@link #setFaultSuffix(String) faultSuffix}. * @param message the message * @return {@code true} if to be included as fault; {@code false} otherwise */ @@ -161,4 +159,5 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { private String getMessageName(Message message) { return message.getQName().getLocalPart(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/AbstractWebServiceMessageFactoryTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/AbstractWebServiceMessageFactoryTestCase.java index 6ba4ecf2..b9e7a2f9 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/AbstractWebServiceMessageFactoryTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/AbstractWebServiceMessageFactoryTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,11 +16,11 @@ package org.springframework.ws; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public abstract class AbstractWebServiceMessageFactoryTestCase { protected WebServiceMessageFactory messageFactory; @@ -39,4 +39,5 @@ public abstract class AbstractWebServiceMessageFactoryTestCase { } protected abstract WebServiceMessageFactory createMessageFactory() throws Exception; + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/AbstractWebServiceMessageTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/AbstractWebServiceMessageTestCase.java index e9b016f1..d83ee053 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/AbstractWebServiceMessageTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/AbstractWebServiceMessageTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws; -import static org.xmlunit.assertj.XmlAssert.*; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -46,6 +44,12 @@ import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; +import org.xml.sax.helpers.XMLReaderFactory; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.util.FileCopyUtils; @@ -55,11 +59,8 @@ import org.springframework.xml.XMLInputFactoryUtils; import org.springframework.xml.sax.SaxUtils; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; + +import static org.xmlunit.assertj.XmlAssert.assertThat; public abstract class AbstractWebServiceMessageTestCase { @@ -159,7 +160,9 @@ public abstract class AbstractWebServiceMessageTestCase { ByteArrayOutputStream expectedStream = new ByteArrayOutputStream(); FileCopyUtils.copy(payload.getInputStream(), expectedStream); - assertThat(resultStream.toString(StandardCharsets.UTF_8)).and(expectedStream.toString(StandardCharsets.UTF_8)).ignoreWhitespace().areIdentical(); + assertThat(resultStream.toString(StandardCharsets.UTF_8)).and(expectedStream.toString(StandardCharsets.UTF_8)) + .ignoreWhitespace() + .areIdentical(); validateMessage(); } @@ -194,4 +197,5 @@ public abstract class AbstractWebServiceMessageTestCase { } protected abstract WebServiceMessage createWebServiceMessage() throws Exception; + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/MockWebServiceMessage.java b/spring-ws-core/src/test/java/org/springframework/ws/MockWebServiceMessage.java index a811d812..1a299059 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/MockWebServiceMessage.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/MockWebServiceMessage.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -57,7 +57,8 @@ public class MockWebServiceMessage implements FaultAwareWebServiceMessage { private String faultReason; - public MockWebServiceMessage() {} + public MockWebServiceMessage() { + } public MockWebServiceMessage(Source source) throws TransformerException { @@ -192,21 +193,26 @@ public class MockWebServiceMessage implements FaultAwareWebServiceMessage { } @Override - public void close() {} + public void close() { + } @Override - public void flush() {} + public void flush() { + } @Override public void write(char cbuf[], int off, int len) { if (off < 0 || off > cbuf.length || len < 0 || off + len > cbuf.length || off + len < 0) { throw new IndexOutOfBoundsException(); - } else if (len == 0) { + } + else if (len == 0) { return; } content.append(cbuf, off, len); } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/MockWebServiceMessageFactory.java b/spring-ws-core/src/test/java/org/springframework/ws/MockWebServiceMessageFactory.java index 9b579f36..9ea07b83 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/MockWebServiceMessageFactory.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/MockWebServiceMessageFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,8 +34,10 @@ public class MockWebServiceMessageFactory implements WebServiceMessageFactory { try { return new MockWebServiceMessage(new StreamSource(inputStream)); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new IOException(ex.getMessage()); } } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/core/AbstractSoap11WebServiceTemplateIntegrationTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/client/core/AbstractSoap11WebServiceTemplateIntegrationTestCase.java index 0b576e63..fc87e94c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/core/AbstractSoap11WebServiceTemplateIntegrationTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/core/AbstractSoap11WebServiceTemplateIntegrationTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,7 +16,17 @@ package org.springframework.ws.client.core; -import static org.assertj.core.api.Assertions.*; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.StringTokenizer; + +import javax.xml.namespace.QName; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; import jakarta.activation.DataHandler; import jakarta.mail.util.ByteArrayDataSource; @@ -31,19 +41,6 @@ import jakarta.xml.soap.MimeHeaders; import jakarta.xml.soap.SOAPBody; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPMessage; - -import java.io.IOException; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.StringTokenizer; - -import javax.xml.namespace.QName; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.eclipse.jetty.server.Connector; @@ -55,6 +52,8 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.XmlMappingException; @@ -68,7 +67,9 @@ import org.springframework.ws.transport.support.FreePortScanner; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { @@ -137,7 +138,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { logger.info(">>> Test case"); StringResult result = new StringResult(); - boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/echo", new StringSource(messagePayload), result); + boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/echo", new StringSource(messagePayload), + result); assertThat(b).isTrue(); XmlAssert.assertThat(result.toString()).and(messagePayload).ignoreWhitespace().areIdentical(); @@ -146,8 +148,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { @Test public void sendSourceAndReceiveToResultNoResponse() { - boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/noResponse", new StringSource(messagePayload), - new StringResult()); + boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/noResponse", + new StringSource(messagePayload), new StringResult()); assertThat(b).isFalse(); } @@ -166,7 +168,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { assertThat(requestObject).isEqualTo(graph); try { transformer.transform(new StringSource(messagePayload), result); - } catch (TransformerException e) { + } + catch (TransformerException e) { throw new RuntimeException(e); } } @@ -217,7 +220,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { assertThat(requestObject).isEqualTo(graph); try { transformer.transform(new StringSource(messagePayload), result); - } catch (TransformerException e) { + } + catch (TransformerException e) { throw new RuntimeException(e); } } @@ -240,8 +244,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { public void notFound() { assertThatExceptionOfType(WebServiceTransportException.class) - .isThrownBy(() -> template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", - new StringSource(messagePayload), new StringResult())); + .isThrownBy(() -> template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", + new StringSource(messagePayload), new StringResult())); } @Test @@ -249,8 +253,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { Result result = new StringResult(); - assertThatExceptionOfType(SoapFaultClientException.class).isThrownBy( - () -> template.sendSourceAndReceiveToResult(baseUrl + "/soap/fault", new StringSource(messagePayload), result)); + assertThatExceptionOfType(SoapFaultClientException.class).isThrownBy(() -> template + .sendSourceAndReceiveToResult(baseUrl + "/soap/fault", new StringSource(messagePayload), result)); } @Test @@ -261,19 +265,20 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { template.setCheckConnectionForError(false); assertThatExceptionOfType(SoapFaultClientException.class).isThrownBy(() -> template - .sendSourceAndReceiveToResult(baseUrl + "/soap/badRequestFault", new StringSource(messagePayload), result)); + .sendSourceAndReceiveToResult(baseUrl + "/soap/badRequestFault", new StringSource(messagePayload), result)); } @Test public void attachment() { - template.sendSourceAndReceiveToResult(baseUrl + "/soap/attachment", new StringSource(messagePayload), message -> { + template.sendSourceAndReceiveToResult(baseUrl + "/soap/attachment", new StringSource(messagePayload), + message -> { - SoapMessage soapMessage = (SoapMessage) message; - final String attachmentContent = "content"; - soapMessage.addAttachment("attachment-1", - new DataHandler(new ByteArrayDataSource(attachmentContent, "text/plain"))); - }, new StringResult()); + SoapMessage soapMessage = (SoapMessage) message; + final String attachmentContent = "content"; + soapMessage.addAttachment("attachment-1", + new DataHandler(new ByteArrayDataSource(attachmentContent, "text/plain"))); + }, new StringResult()); } /** Servlet that returns and error message for a given status code. */ @@ -290,6 +295,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.sendError(sc); } + } /** Abstract SOAP Servlet */ @@ -311,7 +317,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { try { messageFactory = MessageFactory.newInstance(); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new ServletException("Unable to create message factory" + ex.getMessage()); } } @@ -339,10 +346,12 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { putHeaders(reply.getMimeHeaders(), resp); reply.writeTo(resp.getOutputStream()); - } else if (sc == -1) { + } + else if (sc == -1) { resp.setStatus(HttpServletResponse.SC_ACCEPTED); } - } catch (Exception ex) { + } + catch (Exception ex) { throw new ServletException("SAAJ POST failed " + ex.getMessage(), ex); } } @@ -378,6 +387,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { } protected abstract SOAPMessage onMessage(SOAPMessage message) throws SOAPException; + } @SuppressWarnings("serial") @@ -387,6 +397,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { protected SOAPMessage onMessage(SOAPMessage message) { return message; } + } @SuppressWarnings("serial") @@ -396,6 +407,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { protected SOAPMessage onMessage(SOAPMessage message) { return null; } + } @SuppressWarnings("serial") @@ -409,6 +421,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { body.addFault(new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"), "Server fault"); return response; } + } @SuppressWarnings("serial") @@ -420,6 +433,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { assertThat(message.countAttachments()).isEqualTo(1); return null; } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/core/AbstractSoap12WebServiceTemplateIntegrationTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/client/core/AbstractSoap12WebServiceTemplateIntegrationTestCase.java index e5d3c006..94391b67 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/core/AbstractSoap12WebServiceTemplateIntegrationTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/core/AbstractSoap12WebServiceTemplateIntegrationTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,7 +16,16 @@ package org.springframework.ws.client.core; -import static org.assertj.core.api.Assertions.*; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.StringTokenizer; + +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; import jakarta.activation.CommandMap; import jakarta.activation.DataHandler; @@ -34,18 +43,6 @@ import jakarta.xml.soap.SOAPBody; import jakarta.xml.soap.SOAPConstants; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPMessage; - -import java.io.IOException; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.StringTokenizer; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; - import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -55,6 +52,8 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.XmlMappingException; @@ -67,7 +66,9 @@ import org.springframework.ws.transport.support.FreePortScanner; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { @@ -117,8 +118,9 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { } /** - * A workaround for the faulty XmlDataContentHandler in the SAAJ RI, which cannot handle mime types such as "text/xml; - * charset=UTF-8", causing issues with Axiom. We basically reset the command map + * A workaround for the faulty XmlDataContentHandler in the SAAJ RI, which cannot + * handle mime types such as "text/xml; charset=UTF-8", causing issues with Axiom. We + * basically reset the command map */ @BeforeEach public void removeXmlDataContentHandler() throws SOAPException { @@ -142,7 +144,8 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { public void sendSourceAndReceiveToResult() { StringResult result = new StringResult(); - boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/echo", new StringSource(messagePayload), result); + boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/echo", new StringSource(messagePayload), + result); assertThat(b).isTrue(); XmlAssert.assertThat(result.toString()).and(messagePayload).ignoreWhitespace().areIdentical(); @@ -151,8 +154,8 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { @Test public void sendSourceAndReceiveToResultNoResponse() { - boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/noResponse", new StringSource(messagePayload), - new StringResult()); + boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/noResponse", + new StringSource(messagePayload), new StringResult()); assertThat(b).isFalse(); } @@ -170,7 +173,8 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { assertThat(requestObject).isEqualTo(graph); try { transformer.transform(new StringSource(messagePayload), result); - } catch (TransformerException e) { + } + catch (TransformerException e) { throw new RuntimeException(e); } } @@ -221,7 +225,8 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { try { transformer.transform(new StringSource(messagePayload), result); - } catch (TransformerException e) { + } + catch (TransformerException e) { throw new RuntimeException(e); } } @@ -244,8 +249,8 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { public void notFound() { assertThatExceptionOfType(WebServiceTransportException.class) - .isThrownBy(() -> template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", - new StringSource(messagePayload), new StringResult())); + .isThrownBy(() -> template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", + new StringSource(messagePayload), new StringResult())); } @Test @@ -254,7 +259,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { Result result = new StringResult(); assertThatExceptionOfType(SoapFaultClientException.class).isThrownBy(() -> template - .sendSourceAndReceiveToResult(baseUrl + "/soap/receiverFault", new StringSource(messagePayload), result)); + .sendSourceAndReceiveToResult(baseUrl + "/soap/receiverFault", new StringSource(messagePayload), result)); } @Test @@ -263,19 +268,20 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { Result result = new StringResult(); assertThatExceptionOfType(SoapFaultClientException.class).isThrownBy(() -> template - .sendSourceAndReceiveToResult(baseUrl + "/soap/senderFault", new StringSource(messagePayload), result)); + .sendSourceAndReceiveToResult(baseUrl + "/soap/senderFault", new StringSource(messagePayload), result)); } @Test public void attachment() { - template.sendSourceAndReceiveToResult(baseUrl + "/soap/attachment", new StringSource(messagePayload), message -> { + template.sendSourceAndReceiveToResult(baseUrl + "/soap/attachment", new StringSource(messagePayload), + message -> { - SoapMessage soapMessage = (SoapMessage) message; - final String attachmentContent = "content"; - soapMessage.addAttachment("attachment-1", - new DataHandler(new ByteArrayDataSource(attachmentContent, "text/plain"))); - }, new StringResult()); + SoapMessage soapMessage = (SoapMessage) message; + final String attachmentContent = "content"; + soapMessage.addAttachment("attachment-1", + new DataHandler(new ByteArrayDataSource(attachmentContent, "text/plain"))); + }, new StringResult()); } /** Servlet that returns and error message for a given status code. */ @@ -292,6 +298,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.sendError(sc); } + } /** Abstract SOAP Servlet */ @@ -307,7 +314,8 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { try { messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new ServletException("Unable to create message factory" + ex.getMessage()); } } @@ -325,20 +333,24 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { SOAPBody replyBody = reply.getSOAPBody(); if (!replyBody.hasFault()) { resp.setStatus(HttpServletResponse.SC_OK); - } else { + } + else { if (replyBody.getFault().getFaultCodeAsQName().equals(SOAPConstants.SOAP_SENDER_FAULT)) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); - } else { + } + else { resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } putHeaders(reply.getMimeHeaders(), resp); reply.writeTo(resp.getOutputStream()); - } else { + } + else { resp.setStatus(HttpServletResponse.SC_ACCEPTED); } - } catch (Exception ex) { + } + catch (Exception ex) { throw new ServletException("SAAJ POST failed " + ex.getMessage(), ex); } } @@ -374,6 +386,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { } protected abstract SOAPMessage onMessage(SOAPMessage message) throws SOAPException; + } @SuppressWarnings("serial") @@ -383,6 +396,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { protected SOAPMessage onMessage(SOAPMessage message) { return message; } + } @SuppressWarnings("serial") @@ -392,6 +406,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { protected SOAPMessage onMessage(SOAPMessage message) { return null; } + } @SuppressWarnings("serial") @@ -405,6 +420,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { body.addFault(SOAPConstants.SOAP_RECEIVER_FAULT, "Receiver Fault"); return response; } + } @SuppressWarnings("serial") @@ -418,6 +434,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { body.addFault(SOAPConstants.SOAP_SENDER_FAULT, "Sender Fault"); return response; } + } @SuppressWarnings("serial") @@ -429,5 +446,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { assertThat(message.countAttachments()).isEqualTo(1); return null; } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/core/DomPoxWebServiceTemplateIntegrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/client/core/DomPoxWebServiceTemplateIntegrationTest.java index 3e394640..b8193bec 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/core/DomPoxWebServiceTemplateIntegrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/core/DomPoxWebServiceTemplateIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,6 @@ package org.springframework.ws.client.core; -import static org.assertj.core.api.Assertions.*; - -import jakarta.servlet.ServletConfig; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServlet; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - import java.io.IOException; import javax.xml.parsers.DocumentBuilder; @@ -33,6 +25,11 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -41,6 +38,9 @@ import org.eclipse.jetty.servlet.ServletHolder; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.ws.client.WebServiceTransportException; import org.springframework.ws.pox.dom.DomPoxMessageFactory; import org.springframework.ws.transport.http.HttpComponentsMessageSender; @@ -49,8 +49,8 @@ import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.w3c.dom.Document; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; public class DomPoxWebServiceTemplateIntegrationTest { @@ -102,9 +102,9 @@ public class DomPoxWebServiceTemplateIntegrationTest { XmlAssert.assertThat(result.toString()).and(content).ignoreWhitespace().areIdentical(); assertThatExceptionOfType(WebServiceTransportException.class).isThrownBy(() -> template - .sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", new StringSource(content), new StringResult())); - assertThatExceptionOfType(WebServiceTransportException.class).isThrownBy( - () -> template.sendSourceAndReceiveToResult(baseUrl + "/errors/server", new StringSource(content), result)); + .sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", new StringSource(content), new StringResult())); + assertThatExceptionOfType(WebServiceTransportException.class).isThrownBy(() -> template + .sendSourceAndReceiveToResult(baseUrl + "/errors/server", new StringSource(content), result)); } /** Servlet that returns and error message for a given status code. */ @@ -121,6 +121,7 @@ public class DomPoxWebServiceTemplateIntegrationTest { protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.sendError(sc); } + } /** Simple POX Servlet. */ @@ -148,10 +149,12 @@ public class DomPoxWebServiceTemplateIntegrationTest { Document message = documentBuilder.parse(req.getInputStream()); Transformer transformer = transformerFactory.newTransformer(); transformer.transform(new DOMSource(message), new StreamResult(resp.getOutputStream())); - } catch (Exception ex) { + } + catch (Exception ex) { throw new ServletException("POX POST failed" + ex.getMessage()); } } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/core/SaajSoap11WebServiceTemplateIntegrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/client/core/SaajSoap11WebServiceTemplateIntegrationTest.java index 70c1d77e..d4b5b4ee 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/core/SaajSoap11WebServiceTemplateIntegrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/core/SaajSoap11WebServiceTemplateIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,4 +33,5 @@ public class SaajSoap11WebServiceTemplateIntegrationTest extends AbstractSoap11W MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); return new SaajSoapMessageFactory(messageFactory); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/core/SaajSoap12WebServiceTemplateIntegrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/client/core/SaajSoap12WebServiceTemplateIntegrationTest.java index e42ca14c..4df53833 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/core/SaajSoap12WebServiceTemplateIntegrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/core/SaajSoap12WebServiceTemplateIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,4 +33,5 @@ public class SaajSoap12WebServiceTemplateIntegrationTest extends AbstractSoap12W MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); return new SaajSoapMessageFactory(messageFactory); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/core/SimpleFaultMessageResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/client/core/SimpleFaultMessageResolverTest.java index d549d948..5e7d1f35 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/core/SimpleFaultMessageResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/core/SimpleFaultMessageResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,18 @@ package org.springframework.ws.client.core; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.FaultAwareWebServiceMessage; import org.springframework.ws.client.WebServiceFaultException; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class SimpleFaultMessageResolverTest { private SimpleFaultMessageResolver resolver; @@ -43,8 +47,9 @@ public class SimpleFaultMessageResolverTest { replay(messageMock); assertThatExceptionOfType(WebServiceFaultException.class).isThrownBy(() -> resolver.resolveFault(messageMock)) - .withMessage(message); + .withMessage(message); verify(messageMock); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/core/SimpleSaajServlet.java b/spring-ws-core/src/test/java/org/springframework/ws/client/core/SimpleSaajServlet.java index 6d5790a8..dbf68f0b 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/core/SimpleSaajServlet.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/core/SimpleSaajServlet.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,6 +16,10 @@ package org.springframework.ws.client.core; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.StringTokenizer; + import jakarta.servlet.ServletConfig; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; @@ -27,10 +31,6 @@ import jakarta.xml.soap.MimeHeaders; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPMessage; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.StringTokenizer; - import org.springframework.util.StringUtils; /** @@ -51,7 +51,8 @@ public class SimpleSaajServlet extends HttpServlet { try { msgFactory = MessageFactory.newInstance(); - } catch (SOAPException ex) { + } + catch (SOAPException ex) { throw new ServletException("Unable to create message factory" + ex.getMessage()); } } @@ -97,14 +98,16 @@ public class SimpleSaajServlet extends HttpServlet { if (reply.saveRequired()) { reply.saveChanges(); } - resp.setStatus( - !reply.getSOAPBody().hasFault() ? HttpServletResponse.SC_OK : HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + resp.setStatus(!reply.getSOAPBody().hasFault() ? HttpServletResponse.SC_OK + : HttpServletResponse.SC_INTERNAL_SERVER_ERROR); putHeaders(reply.getMimeHeaders(), resp); reply.writeTo(resp.getOutputStream()); - } else { + } + else { resp.setStatus(HttpServletResponse.SC_ACCEPTED); } - } catch (Exception ex) { + } + catch (Exception ex) { throw new ServletException("SAAJ POST failed " + ex.getMessage()); } } @@ -112,4 +115,5 @@ public class SimpleSaajServlet extends HttpServlet { protected SOAPMessage onMessage(SOAPMessage message) { return message; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/core/WebServiceTemplateTest.java b/spring-ws-core/src/test/java/org/springframework/ws/client/core/WebServiceTemplateTest.java index 4649cf07..d022508f 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/core/WebServiceTemplateTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/core/WebServiceTemplateTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.client.core; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; - import java.io.IOException; import java.net.URI; @@ -27,6 +24,7 @@ import javax.xml.transform.Source; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.ws.MockWebServiceMessage; @@ -43,6 +41,15 @@ import org.springframework.ws.transport.WebServiceMessageSender; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.mockito.Mockito.isA; +import static org.mockito.Mockito.isNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.when; + @SuppressWarnings("unchecked") public class WebServiceTemplateTest { @@ -171,7 +178,8 @@ public class WebServiceTemplateTest { connectionMock.close(); assertThatExceptionOfType(WebServiceTransportException.class) - .isThrownBy(() -> template.sendAndReceive(null, extractorMock)).withMessage(errorMessage); + .isThrownBy(() -> template.sendAndReceive(null, extractorMock)) + .withMessage(errorMessage); } @Test @@ -446,4 +454,5 @@ public class WebServiceTemplateTest { assertThat(result).isNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/support/destination/Wsdl11DestinationProviderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/client/support/destination/Wsdl11DestinationProviderTest.java index a31ba0eb..c4ba8f35 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/support/destination/Wsdl11DestinationProviderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/support/destination/Wsdl11DestinationProviderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,17 @@ package org.springframework.ws.client.support.destination; -import static org.assertj.core.api.Assertions.*; - import java.net.URI; import java.net.URISyntaxException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import static org.assertj.core.api.Assertions.assertThat; + public class Wsdl11DestinationProviderTest { private Wsdl11DestinationProvider provider; @@ -66,4 +67,5 @@ public class Wsdl11DestinationProviderTest { assertThat(result).isEqualTo(new URI("http://example.com/soap12")); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/support/interceptor/ClientInterceptorAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/client/support/interceptor/ClientInterceptorAdapterTest.java index bf7d709d..955ab117 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/support/interceptor/ClientInterceptorAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/support/interceptor/ClientInterceptorAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -15,15 +15,16 @@ */ package org.springframework.ws.client.support.interceptor; -import static org.assertj.core.api.Assertions.*; - import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; + import org.springframework.ws.client.WebServiceClientException; import org.springframework.ws.context.MessageContext; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Greg Turnquist */ @@ -32,7 +33,8 @@ public class ClientInterceptorAdapterTest { @Test public void handleEmptyInterceptor() { - ClientInterceptor interceptor = new ClientInterceptorAdapter() {}; + ClientInterceptor interceptor = new ClientInterceptorAdapter() { + }; assertThat(interceptor.handleRequest(null)).isTrue(); assertThat(interceptor.handleResponse(null)).isTrue(); @@ -53,7 +55,8 @@ public class ClientInterceptorAdapterTest { List bits = interceptor.getBits(); - assertThat(bits).containsExactly("handled request", "handled response", "handled fault", "handled afterCompletion"); + assertThat(bits).containsExactly("handled request", "handled response", "handled fault", + "handled afterCompletion"); } static class TestClientInterceptorAdapter extends ClientInterceptorAdapter { @@ -93,5 +96,7 @@ public class ClientInterceptorAdapterTest { public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException { bits.add("handled afterCompletion"); } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/client/support/interceptor/PayloadValidatingInterceptorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/client/support/interceptor/PayloadValidatingInterceptorTest.java index 620d9c09..366c8657 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/client/support/interceptor/PayloadValidatingInterceptorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/client/support/interceptor/PayloadValidatingInterceptorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,20 +16,18 @@ package org.springframework.ws.client.support.interceptor; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPMessage; - import java.io.InputStream; import javax.xml.XMLConstants; import javax.xml.transform.Transformer; import javax.xml.transform.stream.StreamSource; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.io.ClassPathResource; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -43,6 +41,10 @@ import org.springframework.ws.soap.saaj.support.SaajUtils; import org.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.xsd.SimpleXsdSchema; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class PayloadValidatingInterceptorTest { private PayloadValidatingInterceptor interceptor; @@ -90,7 +92,7 @@ public class PayloadValidatingInterceptorTest { context = new DefaultMessageContext(invalidMessage, soap11Factory); assertThatExceptionOfType(WebServiceClientException.class).isThrownBy(() -> interceptor.handleRequest(context)) - .withMessageContaining("XML validation error on response"); + .withMessageContaining("XML validation error on response"); } @Test @@ -101,7 +103,7 @@ public class PayloadValidatingInterceptorTest { context = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); assertThatExceptionOfType(WebServiceClientException.class).isThrownBy(() -> interceptor.handleRequest(context)) - .withMessageContaining("XML validation error on response"); + .withMessageContaining("XML validation error on response"); } @Test @@ -144,10 +146,11 @@ public class PayloadValidatingInterceptorTest { @Test public void testNamespacesInType() throws Exception { - // Make sure we use Xerces for this testcase: the JAXP implementation used internally by JDK 1.5 has a bug + // Make sure we use Xerces for this testcase: the JAXP implementation used + // internally by JDK 1.5 has a bug // See http://opensource.atlassian.com/projects/spring/browse/SWS-35 String previousSchemaFactory = System - .getProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, ""); + .getProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, ""); System.setProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, "org.apache.xerces.jaxp.validation.XMLSchemaFactory"); @@ -158,13 +161,15 @@ public class PayloadValidatingInterceptorTest { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage saajMessage = SaajUtils.loadMessage(new ClassPathResource(VALID_SOAP_MESSAGE, getClass()), messageFactory); - context = new DefaultMessageContext(new SaajSoapMessage(saajMessage), new SaajSoapMessageFactory(messageFactory)); + context = new DefaultMessageContext(new SaajSoapMessage(saajMessage), + new SaajSoapMessageFactory(messageFactory)); boolean result = interceptor.handleRequest(context); assertThat(result).isTrue(); assertThat(context.hasResponse()).isFalse(); - } finally { + } + finally { // Reset the property System.setProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, previousSchemaFactory); @@ -191,7 +196,7 @@ public class PayloadValidatingInterceptorTest { context = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); assertThatExceptionOfType(WebServiceClientException.class).isThrownBy(() -> interceptor.handleRequest(context)) - .withMessageContaining("XML validation error on response"); + .withMessageContaining("XML validation error on response"); } @Test @@ -257,4 +262,5 @@ public class PayloadValidatingInterceptorTest { assertThat(result).isTrue(); assertThat(context.hasResponse()).isFalse(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParserTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParserTest.java index 92fcd8e8..e3d4b795 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParserTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParserTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,12 @@ package org.springframework.ws.config; -import static org.assertj.core.api.Assertions.*; - import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.ws.server.EndpointAdapter; @@ -49,6 +48,8 @@ import org.springframework.ws.soap.server.endpoint.adapter.method.SoapHeaderElem import org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver; import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Arjen Poutsma */ @@ -58,7 +59,8 @@ public class AnnotationDrivenBeanDefinitionParserTest { @BeforeEach public void setUp() throws Exception { - applicationContext = new ClassPathXmlApplicationContext("annotationDrivenBeanDefinitionParserTest.xml", getClass()); + applicationContext = new ClassPathXmlApplicationContext("annotationDrivenBeanDefinitionParserTest.xml", + getClass()); } @Test @@ -89,7 +91,8 @@ public class AnnotationDrivenBeanDefinitionParserTest { SoapHeaderElementMethodArgumentResolver.class, DomPayloadMethodProcessor.class, SourcePayloadMethodProcessor.class, Dom4jPayloadMethodProcessor.class, XmlRootElementPayloadMethodProcessor.class, JaxbElementPayloadMethodProcessor.class, - JDomPayloadMethodProcessor.class, StaxPayloadMethodArgumentResolver.class, XomPayloadMethodProcessor.class); + JDomPayloadMethodProcessor.class, StaxPayloadMethodArgumentResolver.class, + XomPayloadMethodProcessor.class); List returnValueHandlers = endpointAdapter.getMethodReturnValueHandlers(); @@ -103,10 +106,12 @@ public class AnnotationDrivenBeanDefinitionParserTest { @Test public void endpointExceptionResolver() { - Map result = applicationContext.getBeansOfType(EndpointExceptionResolver.class); + Map result = applicationContext + .getBeansOfType(EndpointExceptionResolver.class); assertThat(result).hasSize(2); assertThat(result.values()).hasAtLeastOneElementOfType(SoapFaultAnnotationExceptionResolver.class); assertThat(result.values()).hasAtLeastOneElementOfType(SimpleSoapExceptionResolver.class); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/DummyInterceptor.java b/spring-ws-core/src/test/java/org/springframework/ws/config/DummyInterceptor.java index c0bab74d..e8ce7ae5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/DummyInterceptor.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/DummyInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,7 +22,8 @@ import org.springframework.ws.server.EndpointInterceptor; public class DummyInterceptor implements EndpointInterceptor { - @Autowired private DummyInterceptorDependency autowiredDependency; + @Autowired + private DummyInterceptorDependency autowiredDependency; private DummyInterceptorDependency propertyDependency; @@ -54,5 +55,7 @@ public class DummyInterceptor implements EndpointInterceptor { } @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception {} + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception { + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/DummyMarshaller.java b/spring-ws-core/src/test/java/org/springframework/ws/config/DummyMarshaller.java index a6e0bda0..12c7b665 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/DummyMarshaller.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/DummyMarshaller.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -41,4 +41,5 @@ public class DummyMarshaller implements Marshaller, Unmarshaller { public Object unmarshal(Source source) throws XmlMappingException, IOException { throw new UnsupportedOperationException(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/MyInterceptor.java b/spring-ws-core/src/test/java/org/springframework/ws/config/MyInterceptor.java index 148afd89..32dce4ff 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/MyInterceptor.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/MyInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -50,5 +50,7 @@ public class MyInterceptor implements EndpointInterceptor { } @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {} + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) { + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/WebServiceNamespaceHandlerTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/WebServiceNamespaceHandlerTest.java index 6edca6dc..1cd0a8f0 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/WebServiceNamespaceHandlerTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/WebServiceNamespaceHandlerTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,17 @@ package org.springframework.ws.config; -import static org.assertj.core.api.Assertions.*; - import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter; +import static org.assertj.core.api.Assertions.assertThat; + public class WebServiceNamespaceHandlerTest { private ApplicationContext applicationContext; @@ -39,8 +40,9 @@ public class WebServiceNamespaceHandlerTest { public void testMarshallingMethods() throws Exception { Map result = applicationContext - .getBeansOfType(MarshallingMethodEndpointAdapter.class); + .getBeansOfType(MarshallingMethodEndpointAdapter.class); assertThat(result).isNotEmpty(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/WebServicesNamespaceHandlerTigerTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/WebServicesNamespaceHandlerTigerTest.java index 5d21ac00..8c98c6c5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/WebServicesNamespaceHandlerTigerTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/WebServicesNamespaceHandlerTigerTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,31 +16,33 @@ package org.springframework.ws.config; -import static org.assertj.core.api.Assertions.*; - import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter; import org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter; +import static org.assertj.core.api.Assertions.assertThat; + public class WebServicesNamespaceHandlerTigerTest { private ApplicationContext applicationContext; @BeforeEach public void setUp() throws Exception { - applicationContext = new ClassPathXmlApplicationContext("webServicesNamespaceHandlerTest-tiger.xml", getClass()); + applicationContext = new ClassPathXmlApplicationContext("webServicesNamespaceHandlerTest-tiger.xml", + getClass()); } @Test public void testMarshallingEndpoints() { Map result = applicationContext - .getBeansOfType(GenericMarshallingMethodEndpointAdapter.class); + .getBeansOfType(GenericMarshallingMethodEndpointAdapter.class); assertThat(result).isNotEmpty(); } @@ -49,8 +51,9 @@ public class WebServicesNamespaceHandlerTigerTest { public void testXpathEndpoints() { Map result = applicationContext - .getBeansOfType(XPathParamAnnotationMethodEndpointAdapter.class); + .getBeansOfType(XPathParamAnnotationMethodEndpointAdapter.class); assertThat(result).isNotEmpty(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/WsdlBeanDefinitionParserTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/WsdlBeanDefinitionParserTest.java index 355ca0a9..12b2f5cd 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/WsdlBeanDefinitionParserTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/WsdlBeanDefinitionParserTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,19 @@ package org.springframework.ws.config; -import static org.assertj.core.api.Assertions.*; - import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition; import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Arjen Poutsma */ @@ -63,4 +64,5 @@ public class WsdlBeanDefinitionParserTest { assertThat(result).isNotEmpty(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/DefaultWsConfigurationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/DefaultWsConfigurationTest.java index 0fe5d086..30d4d276 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/DefaultWsConfigurationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/DefaultWsConfigurationTest.java @@ -1,9 +1,24 @@ -package org.springframework.ws.config.annotation; +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ -import static org.assertj.core.api.Assertions.*; +package org.springframework.ws.config.annotation; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -15,6 +30,8 @@ import org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMap import org.springframework.ws.soap.server.endpoint.annotation.SoapAction; import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Arjen Poutsma */ @@ -36,7 +53,7 @@ public class DefaultWsConfigurationTest { public void payloadRootAnnotationMethodEndpointMapping() { PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext - .getBean(PayloadRootAnnotationMethodEndpointMapping.class); + .getBean(PayloadRootAnnotationMethodEndpointMapping.class); assertThat(endpointMapping.getOrder()).isEqualTo(0); } @@ -45,7 +62,7 @@ public class DefaultWsConfigurationTest { public void soapActionAnnotationMethodEndpointMapping() { SoapActionAnnotationMethodEndpointMapping endpointMapping = this.applicationContext - .getBean(SoapActionAnnotationMethodEndpointMapping.class); + .getBean(SoapActionAnnotationMethodEndpointMapping.class); assertThat(endpointMapping.getOrder()).isEqualTo(1); } @@ -54,7 +71,7 @@ public class DefaultWsConfigurationTest { public void annotationActionEndpointMapping() { AnnotationActionEndpointMapping endpointMapping = this.applicationContext - .getBean(AnnotationActionEndpointMapping.class); + .getBean(AnnotationActionEndpointMapping.class); assertThat(endpointMapping.getOrder()).isEqualTo(2); } @@ -76,13 +93,15 @@ public class DefaultWsConfigurationTest { public TestEndpoint testEndpoint() { return new TestEndpoint(); } + } @Endpoint private static class TestEndpoint { @SoapAction("handle") - public void handle() {} + public void handle() { + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/WsConfigurationSupportTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/WsConfigurationSupportTest.java index 79558b6c..22734395 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/WsConfigurationSupportTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/WsConfigurationSupportTest.java @@ -1,11 +1,26 @@ -package org.springframework.ws.config.annotation; +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ -import static org.assertj.core.api.Assertions.*; +package org.springframework.ws.config.annotation; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -15,6 +30,8 @@ import org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapt import org.springframework.ws.server.endpoint.interceptor.EndpointInterceptorAdapter; import org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Arjen Poutsma */ @@ -36,7 +53,7 @@ public class WsConfigurationSupportTest { public void interceptors() { PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext - .getBean(PayloadRootAnnotationMethodEndpointMapping.class); + .getBean(PayloadRootAnnotationMethodEndpointMapping.class); assertThat(endpointMapping.getOrder()).isEqualTo(0); @@ -49,7 +66,8 @@ public class WsConfigurationSupportTest { @Test public void defaultMethodEndpointAdapter() { - DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); + DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext + .getBean(DefaultMethodEndpointAdapter.class); assertThat(endpointAdapter).isNotNull(); assertThat(endpointAdapter).isInstanceOf(MyDefaultMethodEndpointAdapter.class); @@ -68,6 +86,7 @@ public class WsConfigurationSupportTest { public DefaultMethodEndpointAdapter defaultMethodEndpointAdapter() { return new MyDefaultMethodEndpointAdapter(); } + } public static class MyInterceptor extends EndpointInterceptorAdapter { diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/WsConfigurerAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/WsConfigurerAdapterTest.java index a47ba18d..20f4dee0 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/WsConfigurerAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/annotation/WsConfigurerAdapterTest.java @@ -1,11 +1,26 @@ -package org.springframework.ws.config.annotation; +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ -import static org.assertj.core.api.Assertions.*; +package org.springframework.ws.config.annotation; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; @@ -18,6 +33,8 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHa import org.springframework.ws.server.endpoint.interceptor.EndpointInterceptorAdapter; import org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Arjen Poutsma */ @@ -39,7 +56,7 @@ public class WsConfigurerAdapterTest { public void interceptors() { PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext - .getBean(PayloadRootAnnotationMethodEndpointMapping.class); + .getBean(PayloadRootAnnotationMethodEndpointMapping.class); assertThat(endpointMapping.getOrder()).isEqualTo(0); @@ -52,7 +69,8 @@ public class WsConfigurerAdapterTest { @Test public void argumentResolvers() { - DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); + DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext + .getBean(DefaultMethodEndpointAdapter.class); List argumentResolvers = endpointAdapter.getCustomMethodArgumentResolvers(); @@ -67,7 +85,8 @@ public class WsConfigurerAdapterTest { @Test public void returnValueHandlers() { - DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); + DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext + .getBean(DefaultMethodEndpointAdapter.class); List returnValueHandlers = endpointAdapter.getCustomMethodReturnValueHandlers(); @@ -97,9 +116,12 @@ public class WsConfigurerAdapterTest { public void addReturnValueHandlers(List returnValueHandlers) { returnValueHandlers.add(new MyReturnValueHandler()); } + } - public static class MyInterceptor extends EndpointInterceptorAdapter {} + public static class MyInterceptor extends EndpointInterceptorAdapter { + + } public static class MyMethodArgumentResolver implements MethodArgumentResolver { @@ -112,6 +134,7 @@ public class WsConfigurerAdapterTest { public Object resolveArgument(MessageContext messageContext, MethodParameter parameter) throws Exception { return null; } + } public static class MyReturnValueHandler implements MethodReturnValueHandler { @@ -123,6 +146,9 @@ public class WsConfigurerAdapterTest { @Override public void handleReturnValue(MessageContext messageContext, MethodParameter returnType, Object returnValue) - throws Exception {} + throws Exception { + } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/context/DefaultMessageContextTest.java b/spring-ws-core/src/test/java/org/springframework/ws/context/DefaultMessageContextTest.java index 7e14c126..8502c79d 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/context/DefaultMessageContextTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/context/DefaultMessageContextTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,19 @@ package org.springframework.ws.context; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class DefaultMessageContextTest { private DefaultMessageContext context; @@ -81,4 +85,5 @@ public class DefaultMessageContextTest { assertThat(context.containsProperty(name)).isFalse(); assertThat(context.getPropertyNames()).isEmpty(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/pox/dom/DomPoxMessageFactoryTest.java b/spring-ws-core/src/test/java/org/springframework/ws/pox/dom/DomPoxMessageFactoryTest.java index d1c18f84..24bd645b 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/pox/dom/DomPoxMessageFactoryTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/pox/dom/DomPoxMessageFactoryTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,4 +25,5 @@ public class DomPoxMessageFactoryTest extends AbstractWebServiceMessageFactoryTe protected WebServiceMessageFactory createMessageFactory() throws Exception { return new DomPoxMessageFactory(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/pox/dom/DomPoxMessageTest.java b/spring-ws-core/src/test/java/org/springframework/ws/pox/dom/DomPoxMessageTest.java index 6fa382ce..2ef85263 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/pox/dom/DomPoxMessageTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/pox/dom/DomPoxMessageTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.pox.dom; -import static org.xmlunit.assertj.XmlAssert.*; - import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; @@ -28,11 +26,14 @@ import javax.xml.transform.TransformerFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.w3c.dom.Document; + +import static org.xmlunit.assertj.XmlAssert.assertThat; public class DomPoxMessageTest { @@ -86,4 +87,5 @@ public class DomPoxMessageTest { assertThat(os.toString(StandardCharsets.UTF_8)).and(content).ignoreWhitespace().areIdentical(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/MessageDispatcherTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/MessageDispatcherTest.java index ebe187b1..9b2a8056 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/MessageDispatcherTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/MessageDispatcherTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,11 @@ package org.springframework.ws.server; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.util.Collections; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.NoEndpointFoundException; @@ -33,6 +31,16 @@ import org.springframework.ws.server.endpoint.adapter.PayloadEndpointAdapter; import org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping; import org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.createStrictMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.expectLastCall; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class MessageDispatcherTest { private MessageDispatcher dispatcher; @@ -150,7 +158,8 @@ public class MessageDispatcherTest { try { dispatcher.processEndpointException(messageContext, endpoint, ex); - } catch (Exception result) { + } + catch (Exception result) { assertThat(result).isEqualTo(ex); } @@ -341,7 +350,8 @@ public class MessageDispatcherTest { messageContext.getResponse(); try { dispatcher.dispatch(messageContext); - } catch (RuntimeException ex) { + } + catch (RuntimeException ex) { } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractEndpointTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractEndpointTestCase.java index a489cc78..9aad3758 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractEndpointTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractEndpointTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,14 +33,15 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.Test; -import org.springframework.util.xml.StaxUtils; -import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.springframework.xml.XMLInputFactoryUtils; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; +import org.springframework.util.xml.StaxUtils; +import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.XMLInputFactoryUtils; + @SuppressWarnings("Since15") public abstract class AbstractEndpointTestCase { @@ -103,4 +104,5 @@ public abstract class AbstractEndpointTestCase { } protected abstract void testSource(Source requestSource) throws Exception; + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractMessageEndpointTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractMessageEndpointTestCase.java index 6d08d86c..628fdd51 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractMessageEndpointTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractMessageEndpointTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,19 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import javax.xml.transform.Source; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.xml.transform.StringSource; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractMessageEndpointTestCase extends AbstractEndpointTestCase { @@ -71,8 +72,10 @@ public abstract class AbstractMessageEndpointTestCase extends AbstractEndpointTe endpoint.invoke(context); assertThat(context.hasResponse()).isTrue(); - XmlAssert.assertThat(((MockWebServiceMessage) context.getResponse()).getPayloadAsString()).and(RESPONSE) - .ignoreWhitespace().areSimilar(); + XmlAssert.assertThat(((MockWebServiceMessage) context.getResponse()).getPayloadAsString()) + .and(RESPONSE) + .ignoreWhitespace() + .areSimilar(); } protected abstract MessageEndpoint createNoResponseEndpoint(); diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractPayloadEndpointTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractPayloadEndpointTestCase.java index a23c2764..c3cac787 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractPayloadEndpointTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/AbstractPayloadEndpointTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,18 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import javax.xml.transform.Source; import javax.xml.transform.Transformer; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractPayloadEndpointTestCase extends AbstractEndpointTestCase { @@ -78,4 +79,5 @@ public abstract class AbstractPayloadEndpointTestCase extends AbstractEndpointTe protected abstract PayloadEndpoint createResponseEndpoint() throws Exception; protected abstract PayloadEndpoint createNoRequestEndpoint() throws Exception; + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/DomPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/DomPayloadEndpointTest.java index ee40d079..a8c1661a 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/DomPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/DomPayloadEndpointTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,11 +16,11 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import org.w3c.dom.Document; import org.w3c.dom.Element; +import static org.assertj.core.api.Assertions.assertThat; + public class DomPayloadEndpointTest extends AbstractPayloadEndpointTestCase { @Override @@ -65,4 +65,5 @@ public class DomPayloadEndpointTest extends AbstractPayloadEndpointTestCase { } }; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/EndpointExceptionResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/EndpointExceptionResolverTest.java index 3836f0d3..5d8947a6 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/EndpointExceptionResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/EndpointExceptionResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,15 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import java.util.Collections; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.context.MessageContext; +import static org.assertj.core.api.Assertions.assertThat; + /** * Test for AbstractEndpointExceptionResolver * @@ -59,5 +60,7 @@ public class EndpointExceptionResolverTest { assertThat(matched).isTrue(); } - public void emptyMethod() {} + public void emptyMethod() { + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/JDomPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/JDomPayloadEndpointTest.java index e801ccb4..a07a9f0a 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/JDomPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/JDomPayloadEndpointTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,11 +16,11 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import org.jdom2.Element; import org.jdom2.Namespace; +import static org.assertj.core.api.Assertions.assertThat; + public class JDomPayloadEndpointTest extends AbstractPayloadEndpointTestCase { @Override @@ -64,4 +64,5 @@ public class JDomPayloadEndpointTest extends AbstractPayloadEndpointTestCase { } }; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/MarshallingPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/MarshallingPayloadEndpointTest.java index 7e6fbd15..ae462528 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/MarshallingPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/MarshallingPayloadEndpointTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; @@ -32,6 +29,8 @@ import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.XmlMappingException; @@ -46,7 +45,15 @@ import org.springframework.ws.mime.MimeMessage; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.eq; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; public class MarshallingPayloadEndpointTest { @@ -80,7 +87,8 @@ public class MarshallingPayloadEndpointTest { XmlAssert.assertThat(writer.toString()).and("").ignoreWhitespace().areIdentical(); return 42L; - } catch (Exception e) { + } + catch (Exception e) { fail(e.getMessage()); return null; @@ -97,7 +105,8 @@ public class MarshallingPayloadEndpointTest { try { transformer.transform(new StreamSource(new StringReader("")), result); - } catch (TransformerException e) { + } + catch (TransformerException e) { fail(e.getMessage()); } } @@ -145,7 +154,8 @@ public class MarshallingPayloadEndpointTest { XmlAssert.assertThat(writer.toString()).and("").ignoreWhitespace().areIdentical(); return (long) 42; - } catch (Exception e) { + } + catch (Exception e) { fail(e.getMessage()); return null; } @@ -264,6 +274,7 @@ public class MarshallingPayloadEndpointTest { public boolean supports(Class clazz) { return false; } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java index ac7e45c4..dd2f0019 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,13 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import java.lang.reflect.Method; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class MethodEndpointTest { private MethodEndpoint endpoint; @@ -88,4 +88,5 @@ public class MethodEndpointTest { myMethodInvoked = true; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/SaxPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/SaxPayloadEndpointTest.java index 33011b48..886e6192 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/SaxPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/SaxPayloadEndpointTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,17 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import javax.xml.transform.Source; -import org.springframework.xml.transform.StringSource; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.helpers.DefaultHandler; +import org.springframework.xml.transform.StringSource; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; + public class SaxPayloadEndpointTest extends AbstractPayloadEndpointTestCase { @Override @@ -97,5 +99,7 @@ public class SaxPayloadEndpointTest extends AbstractPayloadEndpointTestCase { assertThat(qName).isEqualTo(localName); assertThat(uri).isEqualTo(NAMESPACE_URI); } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/StaxEventPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/StaxEventPayloadEndpointTest.java index 6a5af73a..0a4ee164 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/StaxEventPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/StaxEventPayloadEndpointTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import java.util.Collections; import javax.xml.namespace.QName; @@ -28,6 +26,8 @@ import javax.xml.stream.events.Namespace; import javax.xml.stream.events.XMLEvent; import javax.xml.stream.util.XMLEventConsumer; +import static org.assertj.core.api.Assertions.assertThat; + /** * Test case for AbstractStaxEventPayloadEndpoint. * @@ -95,7 +95,8 @@ public class StaxEventPayloadEndpointTest extends AbstractMessageEndpointTestCas Namespace namespace = eventFactory.createNamespace(NAMESPACE_URI); QName name = new QName(NAMESPACE_URI, RESPONSE_ELEMENT); - eventWriter.add(eventFactory.createStartElement(name, null, Collections.singleton(namespace).iterator())); + eventWriter + .add(eventFactory.createStartElement(name, null, Collections.singleton(namespace).iterator())); eventWriter.add(eventFactory.createEndElement(name, Collections.singleton(namespace).iterator())); eventWriter.add(eventFactory.createEndDocument()); } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/DefaultMethodEndpointAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/DefaultMethodEndpointAdapterTest.java index 3aef155c..4af56c87 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/DefaultMethodEndpointAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/DefaultMethodEndpointAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,13 @@ package org.springframework.ws.server.endpoint.adapter; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.io.IOException; import java.util.Arrays; import java.util.Collections; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -34,7 +32,19 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver; import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler; -/** @author Arjen Poutsma */ +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.eq; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.isNull; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + +/** + * @author Arjen Poutsma + */ public class DefaultMethodEndpointAdapterTest { private DefaultMethodEndpointAdapter adapter; @@ -141,8 +151,7 @@ public class DefaultMethodEndpointAdapterTest { // arg 1 expect(argumentResolver1.supportsParameter(isA(MethodParameter.class))).andReturn(false); expect(argumentResolver2.supportsParameter(isA(MethodParameter.class))).andReturn(true); - expect(argumentResolver2.resolveArgument(eq(messageContext), isA(MethodParameter.class))) - .andReturn(42); + expect(argumentResolver2.resolveArgument(eq(messageContext), isA(MethodParameter.class))).andReturn(42); expect(returnValueHandler.supportsReturnType(isA(MethodParameter.class))).andReturn(true); returnValueHandler.handleReturnValue(eq(messageContext), isA(MethodParameter.class), eq(value)); @@ -195,7 +204,8 @@ public class DefaultMethodEndpointAdapterTest { try { adapter.invoke(messageContext, exceptionEndpoint); fail("IOException expected"); - } catch (IOException expected) { + } + catch (IOException expected) { // expected } @@ -226,4 +236,5 @@ public class DefaultMethodEndpointAdapterTest { supportedArgument = s; throw new IOException(s); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapterTest.java index 381ca809..efb7cca3 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/GenericMarshallingMethodEndpointAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.server.endpoint.adapter; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.lang.reflect.Method; import javax.xml.transform.Result; @@ -26,6 +23,7 @@ import javax.xml.transform.Source; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.oxm.GenericMarshaller; import org.springframework.oxm.GenericUnmarshaller; import org.springframework.ws.WebServiceMessage; @@ -36,6 +34,13 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class GenericMarshallingMethodEndpointAdapterTest { private GenericMarshallingMethodEndpointAdapter adapter; @@ -211,7 +216,8 @@ public class GenericMarshallingMethodEndpointAdapterTest { return type; } - public void unsupportedMultipleParams(String s1, String s2) {} + public void unsupportedMultipleParams(String s1, String s2) { + } public String unsupportedWrongParam(String s) { return s; diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapterTest.java index 3860b711..7129d35e 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.server.endpoint.adapter; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.lang.reflect.Method; import javax.xml.transform.Result; @@ -26,6 +23,7 @@ import javax.xml.transform.Source; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.ws.MockWebServiceMessage; @@ -34,6 +32,13 @@ import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MethodEndpoint; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class MarshallingMethodEndpointAdapterTest { private MarshallingMethodEndpointAdapter adapter; @@ -148,7 +153,8 @@ public class MarshallingMethodEndpointAdapterTest { @Test public void testUnsupportedMethodMultipleParams() throws NoSuchMethodException { - Method unsupported = getClass().getMethod("unsupportedMultipleParams", new Class[] { String.class, String.class }); + Method unsupported = getClass().getMethod("unsupportedMultipleParams", + new Class[] { String.class, String.class }); replay(marshallerMock, unmarshallerMock); @@ -195,7 +201,8 @@ public class MarshallingMethodEndpointAdapterTest { return new MyType(); } - public void unsupportedMultipleParams(String s1, String s2) {} + public void unsupportedMultipleParams(String s1, String s2) { + } public String unsupportedWrongParam(String s) { return s; diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapterTest.java index 3c608e0b..4b230e98 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MessageMethodEndpointAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,16 @@ package org.springframework.ws.server.endpoint.adapter; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MethodEndpoint; +import static org.assertj.core.api.Assertions.assertThat; + public class MessageMethodEndpointAdapterTest { private MessageMethodEndpointAdapter adapter; @@ -50,15 +51,16 @@ public class MessageMethodEndpointAdapterTest { public void testUnsupportedMethodMultipleParams() throws NoSuchMethodException { assertThat(adapter.supportsInternal(new MethodEndpoint(this, "unsupportedMultipleParams", - new Class[] { MessageContext.class, MessageContext.class }))).isFalse(); + new Class[] { MessageContext.class, MessageContext.class }))) + .isFalse(); } @Test public void testUnsupportedMethodWrongParam() throws NoSuchMethodException { - assertThat( - adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[] { String.class }))) - .isFalse(); + assertThat(adapter + .supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[] { String.class }))) + .isFalse(); } @Test @@ -77,7 +79,10 @@ public class MessageMethodEndpointAdapterTest { supportedInvoked = true; } - public void unsupportedMultipleParams(MessageContext s1, MessageContext s2) {} + public void unsupportedMultipleParams(MessageContext s1, MessageContext s2) { + } + + public void unsupportedWrongParam(String request) { + } - public void unsupportedWrongParam(String request) {} } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapterTest.java index 47df19bb..c494e770 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/PayloadMethodEndpointAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,13 @@ package org.springframework.ws.server.endpoint.adapter; -import static org.assertj.core.api.Assertions.*; - import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.WebServiceMessage; @@ -31,6 +30,8 @@ import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MethodEndpoint; +import static org.assertj.core.api.Assertions.assertThat; + public class PayloadMethodEndpointAdapterTest { private PayloadMethodEndpointAdapter adapter; @@ -66,23 +67,24 @@ public class PayloadMethodEndpointAdapterTest { public void testUnsupportedMethodMultipleParams() throws NoSuchMethodException { assertThat(adapter.supportsInternal( - new MethodEndpoint(this, "unsupportedMultipleParams", new Class[] { Source.class, Source.class }))).isFalse(); + new MethodEndpoint(this, "unsupportedMultipleParams", new Class[] { Source.class, Source.class }))) + .isFalse(); } @Test public void testUnsupportedMethodWrongReturnType() throws NoSuchMethodException { - assertThat( - adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongReturnType", new Class[] { Source.class }))) - .isFalse(); + assertThat(adapter + .supportsInternal(new MethodEndpoint(this, "unsupportedWrongReturnType", new Class[] { Source.class }))) + .isFalse(); } @Test public void testUnsupportedMethodWrongParam() throws NoSuchMethodException { - assertThat( - adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[] { String.class }))) - .isFalse(); + assertThat(adapter + .supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[] { String.class }))) + .isFalse(); } @Test @@ -121,7 +123,8 @@ public class PayloadMethodEndpointAdapterTest { return request; } - public void unsupportedMultipleParams(Source s1, Source s2) {} + public void unsupportedMultipleParams(Source s1, Source s2) { + } public Source unsupportedWrongParam(String request) { return null; diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapterTest.java index 8ee8bc6f..e9b02573 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.server.endpoint.adapter; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.util.HashMap; import java.util.Map; @@ -29,6 +26,12 @@ import javax.xml.transform.dom.DOMSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -38,11 +41,12 @@ import org.springframework.ws.server.endpoint.annotation.XPathParam; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; public class XPathParamAnnotationMethodEndpointAdapterTest { @@ -74,7 +78,8 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { @Test public void testUnsupportedInvalidReturnType() throws NoSuchMethodException { - MethodEndpoint endpoint = new MethodEndpoint(this, "unsupportedInvalidReturnType", new Class[] { String.class }); + MethodEndpoint endpoint = new MethodEndpoint(this, "unsupportedInvalidReturnType", + new Class[] { String.class }); assertThat(adapter.supports(endpoint)).isFalse(); } @@ -191,7 +196,8 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { assertThat(namespacesInvoked).isTrue(); } - public void supportedVoid(@XPathParam("/") String param1) {} + public void supportedVoid(@XPathParam("/") String param1) { + } public Source supportedSource(@XPathParam("/") String param1) { @@ -203,9 +209,9 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { return null; } - public void supportedTypes(@XPathParam("/root/child") boolean param1, @XPathParam("/root/child/number") double param2, - @XPathParam("/root/child") Node param3, @XPathParam("/root/*") NodeList param4, - @XPathParam("/root/child/text") String param5) { + public void supportedTypes(@XPathParam("/root/child") boolean param1, + @XPathParam("/root/child/number") double param2, @XPathParam("/root/child") Node param3, + @XPathParam("/root/*") NodeList param4, @XPathParam("/root/child/text") String param5) { supportedTypesInvoked = true; @@ -225,11 +231,13 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { return null; } - public void unsupportedInvalidParamType(@XPathParam("/") int param1) {} + public void unsupportedInvalidParamType(@XPathParam("/") int param1) { + } public void namespaces(@XPathParam(".") Node param) { namespacesInvoked = true; assertThat(param.getLocalName()).isEqualTo("child"); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/AbstractMethodArgumentResolverTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/AbstractMethodArgumentResolverTestCase.java index b8fb7f09..1f6f8288 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/AbstractMethodArgumentResolverTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/AbstractMethodArgumentResolverTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.server.endpoint.adapter.method; +import javax.xml.transform.TransformerException; + import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPMessage; -import javax.xml.transform.TransformerException; - import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -75,4 +75,5 @@ public class AbstractMethodArgumentResolverTestCase extends TransformerObjectSup return new DefaultMessageContext(request, soapMessageFactory); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadMethodProcessorTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadMethodProcessorTestCase.java index 83c687df..ff3192f6 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadMethodProcessorTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/AbstractPayloadMethodProcessorTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,17 @@ package org.springframework.ws.server.endpoint.adapter.method; -import static org.assertj.core.api.Assertions.*; - import javax.xml.transform.Source; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; import org.springframework.xml.transform.StringResult; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMethodArgumentResolverTestCase { @@ -56,7 +57,8 @@ public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMet assertThat(processor.supportsParameter(supportedParameter)).isTrue(); } - MethodParameter unsupportedParameter = new MethodParameter(getClass().getMethod("unsupported", String.class), 0); + MethodParameter unsupportedParameter = new MethodParameter(getClass().getMethod("unsupported", String.class), + 0); assertThat(processor.supportsParameter(unsupportedParameter)).isFalse(); } @@ -68,7 +70,8 @@ public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMet assertThat(processor.supportsReturnType(supportedReturnType)).isTrue(); } - MethodParameter unsupportedReturnType = new MethodParameter(getClass().getMethod("unsupported", String.class), -1); + MethodParameter unsupportedReturnType = new MethodParameter(getClass().getMethod("unsupported", String.class), + -1); assertThat(processor.supportsReturnType(unsupportedReturnType)).isFalse(); } @@ -104,7 +107,8 @@ public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMet } } - protected void testArgument(Object argument, MethodParameter parameter) {} + protected void testArgument(Object argument, MethodParameter parameter) { + } @Test public void saajReturnValue() throws Exception { diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/MarshallingPayloadMethodProcessorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/MarshallingPayloadMethodProcessorTest.java index 0b66b76c..730c9b0a 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/MarshallingPayloadMethodProcessorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/MarshallingPayloadMethodProcessorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.server.endpoint.adapter.method; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.lang.reflect.Type; import javax.xml.transform.Result; @@ -26,6 +23,7 @@ import javax.xml.transform.Source; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.MethodParameter; import org.springframework.oxm.GenericMarshaller; import org.springframework.oxm.GenericUnmarshaller; @@ -33,6 +31,15 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.RequestPayload; import org.springframework.ws.server.endpoint.annotation.ResponsePayload; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.eq; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class MarshallingPayloadMethodProcessorTest extends AbstractMethodArgumentResolverTestCase { private MarshallingPayloadMethodProcessor processor; @@ -203,4 +210,5 @@ public class MarshallingPayloadMethodProcessorTest extends AbstractMethodArgumen public static class MyObject { } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/MessageContextMethodArgumentResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/MessageContextMethodArgumentResolverTest.java index c595086d..d794cbe9 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/MessageContextMethodArgumentResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/MessageContextMethodArgumentResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,16 @@ package org.springframework.ws.server.endpoint.adapter.method; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; +import static org.assertj.core.api.Assertions.assertThat; + public class MessageContextMethodArgumentResolverTest { private MessageContextMethodArgumentResolver resolver; @@ -53,6 +54,7 @@ public class MessageContextMethodArgumentResolverTest { assertThat(result).isSameAs(messageContext); } - public void supported(MessageContext messageContext) {} + public void supported(MessageContext messageContext) { + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/SourcePayloadMethodProcessorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/SourcePayloadMethodProcessorTest.java index e2d6f4b8..5f9336e0 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/SourcePayloadMethodProcessorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/SourcePayloadMethodProcessorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,7 +27,9 @@ import org.springframework.ws.server.endpoint.annotation.RequestPayload; import org.springframework.ws.server.endpoint.annotation.ResponsePayload; import org.springframework.xml.transform.StringSource; -/** @author Arjen Poutsma */ +/** + * @author Arjen Poutsma + */ public class SourcePayloadMethodProcessorTest extends AbstractPayloadMethodProcessorTestCase { @Override @@ -86,4 +88,5 @@ public class SourcePayloadMethodProcessorTest extends AbstractPayloadMethodProce public StAXSource stax(@RequestPayload StAXSource source) { return source; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/StaxPayloadMethodArgumentResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/StaxPayloadMethodArgumentResolverTest.java index 729dbe0f..5950f7f4 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/StaxPayloadMethodArgumentResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/StaxPayloadMethodArgumentResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.server.endpoint.adapter.method; -import static org.assertj.core.api.Assertions.*; - import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; @@ -27,11 +25,16 @@ import javax.xml.stream.events.XMLEvent; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.RequestPayload; -/** @author Arjen Poutsma */ +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Arjen Poutsma + */ @SuppressWarnings("Since15") public class StaxPayloadMethodArgumentResolverTest extends AbstractMethodArgumentResolverTestCase { @@ -170,9 +173,13 @@ public class StaxPayloadMethodArgumentResolverTest extends AbstractMethodArgumen assertThat(startElement.getName().getLocalPart()).isEqualTo(LOCAL_NAME); } - public void invalid(XMLStreamReader streamReader) {} + public void invalid(XMLStreamReader streamReader) { + } - public void streamReader(@RequestPayload XMLStreamReader streamReader) {} + public void streamReader(@RequestPayload XMLStreamReader streamReader) { + } + + public void eventReader(@RequestPayload XMLEventReader streamReader) { + } - public void eventReader(@RequestPayload XMLEventReader streamReader) {} } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolverTest.java index f29f1fd0..9a2c715c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/XPathParamMethodArgumentResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,13 @@ package org.springframework.ws.server.endpoint.adapter.method; -import static org.assertj.core.api.Assertions.*; - import java.lang.reflect.Method; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -30,8 +31,8 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.Namespace; import org.springframework.ws.server.endpoint.annotation.Namespaces; import org.springframework.ws.server.endpoint.annotation.XPathParam; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; + +import static org.assertj.core.api.Assertions.assertThat; @Namespaces(@Namespace(prefix = "tns", uri = "http://springframework.org/spring-ws")) public class XPathParamMethodArgumentResolverTest { @@ -201,20 +202,25 @@ public class XPathParamMethodArgumentResolverTest { assertThat(result).isEqualTo("text"); } - public void unsupported(String s) {} + public void unsupported(String s) { + } public void supportedTypes( // @XPathParam("/root/child") boolean param1, // @XPathParam("/root/child/number") double param2, // @XPathParam("/root/child") Node param3, // @XPathParam("/root/*") NodeList param4, // - @XPathParam("/root/child/text") String param5) {} + @XPathParam("/root/child/text") String param5) { + } - public void convertedType(@XPathParam("/root/child/number") int param) {} + public void convertedType(@XPathParam("/root/child/number") int param) { + } @Namespaces(@Namespace(prefix = "tns", uri = "http://springframework.org/spring-ws")) - public void namespacesMethod(@XPathParam("/tns:root") String s) {} + public void namespacesMethod(@XPathParam("/tns:root") String s) { + } - public void namespacesClass(@XPathParam("/tns:root") String s) {} + public void namespacesClass(@XPathParam("/tns:root") String s) { + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/JDomPayloadMethodProcessorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/JDomPayloadMethodProcessorTest.java index 0474501c..6b53ca76 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/JDomPayloadMethodProcessorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/JDomPayloadMethodProcessorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,16 @@ package org.springframework.ws.server.endpoint.adapter.method.dom; -import static org.assertj.core.api.Assertions.*; - import org.jdom2.Element; + import org.springframework.core.MethodParameter; import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadMethodProcessorTestCase; import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; import org.springframework.ws.server.endpoint.annotation.RequestPayload; import org.springframework.ws.server.endpoint.annotation.ResponsePayload; +import static org.assertj.core.api.Assertions.assertThat; + public class JDomPayloadMethodProcessorTest extends AbstractPayloadMethodProcessorTestCase { @Override @@ -62,4 +63,5 @@ public class JDomPayloadMethodProcessorTest extends AbstractPayloadMethodProcess public Element element(@RequestPayload Element element) { return element; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/XomPayloadMethodProcessorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/XomPayloadMethodProcessorTest.java index 573ca819..86b8042e 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/XomPayloadMethodProcessorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/XomPayloadMethodProcessorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.server.endpoint.adapter.method.dom; -import static org.assertj.core.api.Assertions.*; - import nu.xom.Element; import org.springframework.core.MethodParameter; @@ -26,6 +24,8 @@ import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSour import org.springframework.ws.server.endpoint.annotation.RequestPayload; import org.springframework.ws.server.endpoint.annotation.ResponsePayload; +import static org.assertj.core.api.Assertions.assertThat; + public class XomPayloadMethodProcessorTest extends AbstractPayloadMethodProcessorTestCase { @Override @@ -63,4 +63,5 @@ public class XomPayloadMethodProcessorTest extends AbstractPayloadMethodProcesso public Element element(@RequestPayload Element element) { return element; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/JaxbElementPayloadMethodProcessorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/JaxbElementPayloadMethodProcessorTest.java index 75d866ba..8499fbd8 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/JaxbElementPayloadMethodProcessorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/JaxbElementPayloadMethodProcessorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,16 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb; -import static org.assertj.core.api.Assertions.*; +import javax.xml.namespace.QName; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlType; - -import javax.xml.namespace.QName; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -35,7 +34,8 @@ import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.RequestPayload; import org.springframework.ws.server.endpoint.annotation.ResponsePayload; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public class JaxbElementPayloadMethodProcessorTest { @@ -98,7 +98,9 @@ public class JaxbElementPayloadMethodProcessorTest { MockWebServiceMessage response = (MockWebServiceMessage) messageContext.getResponse(); XmlAssert.assertThat(response.getPayloadAsString()) - .and("Foo").ignoreWhitespace().areIdentical(); + .and("Foo") + .ignoreWhitespace() + .areIdentical(); } @Test @@ -107,15 +109,18 @@ public class JaxbElementPayloadMethodProcessorTest { MessageContext messageContext = new DefaultMessageContext(new MockWebServiceMessageFactory()); String s = "Foo"; - JAXBElement element = new JAXBElement<>(new QName("http://springframework.org", "string"), String.class, s); + JAXBElement element = new JAXBElement<>(new QName("http://springframework.org", "string"), String.class, + s); processor.handleReturnValue(messageContext, stringReturnType, element); assertThat(messageContext.hasResponse()).isTrue(); MockWebServiceMessage response = (MockWebServiceMessage) messageContext.getResponse(); - XmlAssert.assertThat(response.getPayloadAsString()).and("Foo") - .ignoreWhitespace().areIdentical(); + XmlAssert.assertThat(response.getPayloadAsString()) + .and("Foo") + .ignoreWhitespace() + .areIdentical(); } @Test @@ -151,6 +156,7 @@ public class JaxbElementPayloadMethodProcessorTest { public void setString(String string) { this.string = string; } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/XmlRootElementPayloadMethodProcessorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/XmlRootElementPayloadMethodProcessorTest.java index cc037c5a..1bd4e582 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/XmlRootElementPayloadMethodProcessorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/XmlRootElementPayloadMethodProcessorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,25 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.bind.JAXBException; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - import java.io.OutputStream; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.sax.SAXSource; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.AttributesImpl; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -40,12 +44,8 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.RequestPayload; import org.springframework.ws.server.endpoint.annotation.ResponsePayload; import org.springframework.xml.sax.AbstractXmlReader; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.AttributesImpl; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public class XmlRootElementPayloadMethodProcessorTest { @@ -164,7 +164,8 @@ public class XmlRootElementPayloadMethodProcessorTest { } }; - // Create a message context with that request. Note that the message factory doesn't matter here: + // Create a message context with that request. Note that the message factory + // doesn't matter here: // it is required but not used. MessageContext messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); @@ -191,7 +192,9 @@ public class XmlRootElementPayloadMethodProcessorTest { MockWebServiceMessage response = (MockWebServiceMessage) messageContext.getResponse(); XmlAssert.assertThat(response.getPayloadAsString()) - .and("Foo").ignoreWhitespace().areIdentical(); + .and("Foo") + .ignoreWhitespace() + .areIdentical(); } @Test @@ -210,7 +213,8 @@ public class XmlRootElementPayloadMethodProcessorTest { return rootElement; } - public void type(@RequestPayload MyType type) {} + public void type(@RequestPayload MyType type) { + } @XmlRootElement(name = "root", namespace = "http://springframework.org") public static class MyRootElement { @@ -225,6 +229,7 @@ public class XmlRootElementPayloadMethodProcessorTest { public void setString(String string) { this.string = string; } + } @XmlType(name = "root", namespace = "http://springframework.org") @@ -240,6 +245,7 @@ public class XmlRootElementPayloadMethodProcessorTest { public void setString(String string) { this.string = string; } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptorTest.java index 645f500c..bd34659c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,16 @@ package org.springframework.ws.server.endpoint.interceptor; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPMessage; - import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXSource; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.ws.MockWebServiceMessage; @@ -41,7 +40,9 @@ import org.springframework.xml.sax.SaxUtils; import org.springframework.xml.transform.ResourceSource; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; public class PayloadTransformingInterceptorTest { @@ -187,4 +188,5 @@ public class PayloadTransformingInterceptorTest { public void testNoStylesheetsSet() { assertThatIllegalArgumentException().isThrownBy(() -> interceptor.afterPropertiesSet()); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/BridgedMethodRegistrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/BridgedMethodRegistrationTest.java index f5c04816..e8dd994d 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/BridgedMethodRegistrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/BridgedMethodRegistrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,13 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import java.lang.reflect.Method; import javax.xml.namespace.QName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -32,18 +31,23 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.ws.server.endpoint.annotation.Endpoint; import org.springframework.ws.server.endpoint.annotation.PayloadRoot; +import static org.assertj.core.api.Assertions.assertThat; + @ExtendWith(SpringExtension.class) @ContextConfiguration("bridged-method-registration.xml") public class BridgedMethodRegistrationTest { - @Autowired private PayloadRootAnnotationMethodEndpointMapping mapping; + @Autowired + private PayloadRootAnnotationMethodEndpointMapping mapping; - @Autowired private ApplicationContext applicationContext; + @Autowired + private ApplicationContext applicationContext; @Test public void registration() throws NoSuchMethodException { - MethodEndpoint bridgedMethod = mapping.lookupEndpoint(new QName("http://springframework.org/spring-ws", "Request")); + MethodEndpoint bridgedMethod = mapping + .lookupEndpoint(new QName("http://springframework.org/spring-ws", "Request")); assertThat(bridgedMethod).isNotNull(); @@ -60,6 +64,7 @@ public class BridgedMethodRegistrationTest { public A doIt() { return this; } + } public static class B extends A { @@ -68,6 +73,7 @@ public class BridgedMethodRegistrationTest { public B doIt() { return this; } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/CgLibProxyRegistrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/CgLibProxyRegistrationTest.java index 38b48155..8c4dc59e 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/CgLibProxyRegistrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/CgLibProxyRegistrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import java.lang.reflect.Method; import javax.xml.namespace.QName; @@ -25,6 +23,7 @@ import javax.xml.transform.Source; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -34,18 +33,23 @@ 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 static org.assertj.core.api.Assertions.assertThat; + @ExtendWith(SpringExtension.class) @ContextConfiguration("cglib-proxy-registration.xml") public class CgLibProxyRegistrationTest { - @Autowired private PayloadRootAnnotationMethodEndpointMapping mapping; + @Autowired + private PayloadRootAnnotationMethodEndpointMapping mapping; - @Autowired private ApplicationContext applicationContext; + @Autowired + private ApplicationContext applicationContext; @Test public void registration() throws NoSuchMethodException { - MethodEndpoint cglibProxy = mapping.lookupEndpoint(new QName("http://springframework.org/spring-ws", "Request")); + MethodEndpoint cglibProxy = mapping + .lookupEndpoint(new QName("http://springframework.org/spring-ws", "Request")); assertThat(cglibProxy).isNotNull(); @@ -60,7 +64,8 @@ public class CgLibProxyRegistrationTest { @PayloadRoot(localPart = "Request", namespace = "http://springframework.org/spring-ws") @Log - public void doIt(@RequestPayload Source payload) {} + public void doIt(@RequestPayload Source payload) { + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/EndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/EndpointMappingTest.java index d8a58673..d2901941 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/EndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/EndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,9 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -29,6 +28,8 @@ import org.springframework.ws.server.EndpointInvocationChain; import org.springframework.ws.server.endpoint.interceptor.DelegatingSmartEndpointInterceptor; import org.springframework.ws.server.endpoint.interceptor.EndpointInterceptorAdapter; +import static org.assertj.core.api.Assertions.assertThat; + /** * Test case for {@link AbstractEndpointMapping}. */ @@ -198,6 +199,7 @@ public class EndpointMappingTest { private MyEndpoint() { constructorCount++; } + } private static class MySmartEndpointInterceptor extends DelegatingSmartEndpointInterceptor { @@ -205,6 +207,7 @@ public class EndpointMappingTest { private MySmartEndpointInterceptor() { super(new EndpointInterceptorAdapter()); } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/JdkProxyRegistrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/JdkProxyRegistrationTest.java index d739e420..fca9360f 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/JdkProxyRegistrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/JdkProxyRegistrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import java.lang.reflect.Method; import javax.xml.namespace.QName; @@ -25,6 +23,7 @@ import javax.xml.transform.Source; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -34,13 +33,17 @@ 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 static org.assertj.core.api.Assertions.assertThat; + @ExtendWith(SpringExtension.class) @ContextConfiguration("jdk-proxy-registration.xml") public class JdkProxyRegistrationTest { - @Autowired private PayloadRootAnnotationMethodEndpointMapping mapping; + @Autowired + private PayloadRootAnnotationMethodEndpointMapping mapping; - @Autowired private ApplicationContext applicationContext; + @Autowired + private ApplicationContext applicationContext; @Test public void registration() throws NoSuchMethodException { @@ -61,12 +64,14 @@ public class JdkProxyRegistrationTest { @PayloadRoot(localPart = "Request", namespace = "http://springframework.org/spring-ws") @Log void doIt(Source payload); + } public static class MyEndpointImpl implements MyEndpoint { @Override - public void doIt(@RequestPayload Source payload) {} + public void doIt(@RequestPayload Source payload) { + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/LogAspect.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/LogAspect.java index 04d22a73..fecd32a2 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/LogAspect.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/LogAspect.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -47,7 +47,8 @@ public class LogAspect { try { return joinPoint.proceed(); - } finally { + } + finally { logger.info("After: " + joinPoint.getSignature()); } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/MapBasedSoapEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/MapBasedSoapEndpointMappingTest.java index f65b5508..e615f4b7 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/MapBasedSoapEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/MapBasedSoapEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,17 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import java.util.Arrays; import java.util.Map; import java.util.TreeMap; import org.junit.jupiter.api.Test; + import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.context.MessageContext; +import static org.assertj.core.api.Assertions.assertThat; + /** * Test case for AbstractMapBasedEndpointMapping. */ @@ -126,6 +127,7 @@ public class MapBasedSoapEndpointMappingTest { protected String getLookupKeyForMessage(MessageContext messageContext) throws Exception { return key; } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMappingTest.java index 8a9e8277..720d53df 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,20 +16,18 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPMessage; - import java.lang.reflect.Method; import java.util.Collections; import javax.xml.namespace.QName; import javax.xml.transform.Source; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPMessage; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -49,13 +47,17 @@ import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.server.SoapMessageDispatcher; +import static org.assertj.core.api.Assertions.assertThat; + @ExtendWith(SpringExtension.class) @ContextConfiguration("payloadRootAnnotationMethodEndpointMapping.xml") public class PayloadRootAnnotationMethodEndpointMappingTest { - @Autowired private PayloadRootAnnotationMethodEndpointMapping mapping; + @Autowired + private PayloadRootAnnotationMethodEndpointMapping mapping; - @Autowired private ApplicationContext applicationContext; + @Autowired + private ApplicationContext applicationContext; @Test public void registrationSingle() throws NoSuchMethodException { @@ -122,8 +124,8 @@ public class PayloadRootAnnotationMethodEndpointMappingTest { MessageDispatcher messageDispatcher = new SoapMessageDispatcher(); messageDispatcher.setApplicationContext(applicationContext); - messageDispatcher.setEndpointMappings(Collections. singletonList(mapping)); - messageDispatcher.setEndpointAdapters(Collections. singletonList(adapter)); + messageDispatcher.setEndpointMappings(Collections.singletonList(mapping)); + messageDispatcher.setEndpointAdapters(Collections.singletonList(adapter)); messageDispatcher.receive(messageContext); @@ -156,7 +158,8 @@ public class PayloadRootAnnotationMethodEndpointMappingTest { @PayloadRoots({ // @PayloadRoot(localPart = "Request1", namespace = "http://springframework.org/spring-ws"), @PayloadRoot(localPart = "Request2", namespace = "http://springframework.org/spring-ws") }) - public void doItMultiple() {} + public void doItMultiple() { + } @PayloadRoot(localPart = "Request3", namespace = "http://springframework.org/spring-ws") @PayloadRoot(localPart = "Request4", namespace = "http://springframework.org/spring-ws") @@ -174,4 +177,5 @@ public class PayloadRootAnnotationMethodEndpointMappingTest { } } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootQNameEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootQNameEndpointMappingTest.java index c0992274..6ed6cd7d 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootQNameEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootQNameEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,18 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; +import static org.assertj.core.api.Assertions.assertThat; + public class PayloadRootQNameEndpointMappingTest { private PayloadRootQNameEndpointMapping mapping; @@ -59,4 +60,5 @@ public class PayloadRootQNameEndpointMappingTest { assertThat(qName).isNotNull(); assertThat(qName).isEqualTo(new QName("namespace", "localname", "prefix")); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMappingTest.java index f49ea413..22475ae9 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,16 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; +import static org.assertj.core.api.Assertions.assertThat; + public class SimpleMethodEndpointMappingTest { private SimpleMethodEndpointMapping mapping; @@ -77,5 +78,7 @@ public class SimpleMethodEndpointMappingTest { public void request() { } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/UriEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/UriEndpointMappingTest.java index bbde46ad..46bd1465 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/UriEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/UriEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,12 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.net.URI; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; @@ -31,6 +29,12 @@ import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.context.DefaultTransportContext; import org.springframework.ws.transport.context.TransportContextHolder; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class UriEndpointMappingTest { private UriEndpointMapping mapping; @@ -89,4 +93,5 @@ public class UriEndpointMappingTest { assertThat(mapping.validateLookupKey("http://example.com/services")).isTrue(); assertThat(mapping.validateLookupKey("some string")).isFalse(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMappingTest.java index 98f46b0d..9a036393 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,16 @@ package org.springframework.ws.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; +import static org.assertj.core.api.Assertions.assertThat; + public class XPathPayloadEndpointMappingTest { private XPathPayloadEndpointMapping mapping; @@ -48,4 +49,5 @@ public class XPathPayloadEndpointMappingTest { assertThat(result).isNotNull(); assertThat(result).isEqualTo("value"); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/jaxb/XmlRootElementEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/jaxb/XmlRootElementEndpointMappingTest.java index 6b7a126f..76d61f0b 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/jaxb/XmlRootElementEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/mapping/jaxb/XmlRootElementEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,16 @@ package org.springframework.ws.server.endpoint.mapping.jaxb; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.bind.annotation.XmlRootElement; - import java.lang.reflect.Method; import javax.xml.namespace.QName; +import jakarta.xml.bind.annotation.XmlRootElement; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class XmlRootElementEndpointMappingTest { private XmlRootElementEndpointMapping mapping; @@ -45,7 +44,8 @@ public class XmlRootElementEndpointMappingTest { assertThat(name).isEqualTo(new QName("myNamespace", "myRoot")); } - public void rootElement(MyRootElement rootElement) {} + public void rootElement(MyRootElement rootElement) { + } @XmlRootElement(name = "myRoot", namespace = "myNamespace") public static class MyRootElement { diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/support/PayloadRootUtilsTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/support/PayloadRootUtilsTest.java index d743bb1f..a324a10e 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/support/PayloadRootUtilsTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/support/PayloadRootUtilsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.server.endpoint.support; -import static org.assertj.core.api.Assertions.*; - import java.io.StringReader; import javax.xml.namespace.QName; @@ -32,13 +30,16 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.InputSource; + import org.springframework.util.xml.StaxUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.XMLInputFactoryUtils; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.InputSource; + +import static org.assertj.core.api.Assertions.assertThat; public class PayloadRootUtilsTest { @@ -120,4 +121,5 @@ public class PayloadRootUtilsTest { assertThat(qName).isNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapElementTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapElementTestCase.java index 5f4800cc..4f12d17e 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapElementTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapElementTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap; -import static org.assertj.core.api.Assertions.*; - import java.util.Iterator; import javax.xml.namespace.QName; @@ -26,8 +24,11 @@ import javax.xml.transform.TransformerFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.xml.transform.TransformerFactoryUtils; +import static org.assertj.core.api.Assertions.assertThat; + public abstract class AbstractSoapElementTestCase { private SoapElement soapElement; @@ -73,4 +74,5 @@ public abstract class AbstractSoapElementTestCase { String namespace = "http://springframework.org/spring-ws"; soapElement.addNamespaceDeclaration(prefix, namespace); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapEnvelopeTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapEnvelopeTestCase.java index 351f0e34..f9586965 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapEnvelopeTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapEnvelopeTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,10 @@ package org.springframework.ws.soap; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public abstract class AbstractSoapEnvelopeTestCase extends AbstractSoapElementTestCase { protected SoapEnvelope soapEnvelope; @@ -48,4 +48,5 @@ public abstract class AbstractSoapEnvelopeTestCase extends AbstractSoapElementTe assertThat(body).isNotNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java index be6331f3..eb6dec14 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,17 @@ package org.springframework.ws.soap; -import static org.assertj.core.api.Assertions.*; - import java.util.Iterator; import javax.xml.namespace.QName; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTestCase { @@ -100,8 +101,9 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest transformer.transform(headerElement.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("") - .ignoreWhitespace().areSimilar(); + .and("") + .ignoreWhitespace() + .areSimilar(); assertThat(iterator.hasNext()).isFalse(); } @@ -169,4 +171,5 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest XmlAssert.assertThat(result.toString()).and(expected).ignoreWhitespace().areSimilar(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageFactoryTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageFactoryTestCase.java index 878b8895..bce5ff1c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageFactoryTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageFactoryTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,15 @@ package org.springframework.ws.soap; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.Test; + import org.springframework.ws.AbstractWebServiceMessageFactoryTestCase; import org.springframework.ws.InvalidXmlException; import org.springframework.ws.WebServiceMessage; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public abstract class AbstractSoapMessageFactoryTestCase extends AbstractWebServiceMessageFactoryTestCase { @Test @@ -51,4 +53,5 @@ public abstract class AbstractSoapMessageFactoryTestCase extends AbstractWebServ @Test public abstract void testCreateSoapMessageMissingContentType() throws Exception; + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageTestCase.java index f072276a..7594923a 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap; -import static org.assertj.core.api.Assertions.*; - import java.io.ByteArrayOutputStream; import java.util.Map; import java.util.regex.Matcher; @@ -28,6 +26,9 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import org.junit.jupiter.api.Test; +import org.xml.sax.SAXParseException; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.io.Resource; import org.springframework.util.StringUtils; import org.springframework.ws.mime.AbstractMimeMessageTestCase; @@ -39,8 +40,9 @@ import org.springframework.ws.transport.TransportConstants; import org.springframework.xml.transform.StringResult; import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.validation.XmlValidatorFactory; -import org.xml.sax.SAXParseException; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; public abstract class AbstractSoapMessageTestCase extends AbstractMimeMessageTestCase { @@ -64,7 +66,8 @@ public abstract class AbstractSoapMessageTestCase extends AbstractMimeMessageTes @Test public void testValidate() throws Exception { - XmlValidator validator = XmlValidatorFactory.createValidator(getSoapSchemas(), XmlValidatorFactory.SCHEMA_W3C_XML); + XmlValidator validator = XmlValidatorFactory.createValidator(getSoapSchemas(), + XmlValidatorFactory.SCHEMA_W3C_XML); SAXParseException[] errors = validator.validate(soapMessage.getEnvelope().getSource()); if (errors.length > 0) { diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/AbstractWsAddressingTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/AbstractWsAddressingTestCase.java index 7387f28b..34e5b938 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/AbstractWsAddressingTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/AbstractWsAddressingTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,21 @@ package org.springframework.ws.soap.addressing; -import static org.assertj.core.api.Assertions.*; +import java.io.IOException; +import java.io.InputStream; import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.MimeHeaders; import jakarta.xml.soap.SOAPConstants; import jakarta.xml.soap.SOAPException; - -import java.io.IOException; -import java.io.InputStream; - import org.junit.jupiter.api.BeforeEach; -import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.w3c.dom.Document; import org.xmlunit.assertj.XmlAssert; +import org.springframework.ws.soap.saaj.SaajSoapMessage; + +import static org.assertj.core.api.Assertions.assertThat; + public abstract class AbstractWsAddressingTestCase { protected MessageFactory messageFactory; @@ -50,7 +50,8 @@ public abstract class AbstractWsAddressingTestCase { try { return new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, is)); - } finally { + } + finally { is.close(); } } @@ -60,10 +61,11 @@ public abstract class AbstractWsAddressingTestCase { Document expectedDocument = expected.getSaajMessage().getSOAPPart(); Document resultDocument = result.getSaajMessage().getSOAPPart(); - XmlAssert.assertThat(resultDocument).and(expectedDocument) // - .ignoreWhitespace() // - .ignoreChildNodesOrder() // - .areSimilar(); + XmlAssert.assertThat(resultDocument) + .and(expectedDocument) // + .ignoreWhitespace() // + .ignoreChildNodesOrder() // + .areSimilar(); } protected void assertXMLNotSimilar(SaajSoapMessage expected, SaajSoapMessage result) { @@ -71,8 +73,10 @@ public abstract class AbstractWsAddressingTestCase { Document expectedDocument = expected.getSaajMessage().getSOAPPart(); Document resultDocument = result.getSaajMessage().getSOAPPart(); - XmlAssert.assertThat(resultDocument).and(expectedDocument) // - .ignoreWhitespace() // - .areNotSimilar(); + XmlAssert.assertThat(resultDocument) + .and(expectedDocument) // + .ignoreWhitespace() // + .areNotSimilar(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/ActionCallback10Test.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/ActionCallback10Test.java index df9cb1b8..6d4e826e 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/ActionCallback10Test.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/ActionCallback10Test.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,4 +30,5 @@ public class ActionCallback10Test extends AbstractActionCallbackTestCase { protected String getTestPath() { return "10"; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/ActionCallback200408Test.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/ActionCallback200408Test.java index d6c90a54..480a6881 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/ActionCallback200408Test.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/ActionCallback200408Test.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,4 +30,5 @@ public class ActionCallback200408Test extends AbstractActionCallbackTestCase { protected String getTestPath() { return "200408"; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategyTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategyTest.java index f24c5893..23d6b6d7 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategyTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategyTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,13 @@ package org.springframework.ws.soap.addressing.messageid; -import static org.assertj.core.api.Assertions.*; - import java.net.URI; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class UuidMessageIdStrategyTest { private MessageIdStrategy strategy; @@ -44,4 +44,5 @@ public class UuidMessageIdStrategyTest { assertThat(messageId2).isNotNull(); assertThat(messageId2).isNotEqualTo(messageId1); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AddressingInterceptor10Test.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AddressingInterceptor10Test.java index 5943c075..f3a4fccc 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AddressingInterceptor10Test.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AddressingInterceptor10Test.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.soap.addressing.server; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.net.URI; import org.springframework.ws.context.DefaultMessageContext; @@ -29,6 +26,11 @@ import org.springframework.ws.soap.addressing.version.AddressingVersion; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class AddressingInterceptor10Test extends AbstractAddressingInterceptorTestCase { @Override @@ -55,8 +57,7 @@ public class AddressingInterceptor10Test extends AbstractAddressingInterceptorTe SaajSoapMessage expectedResponse = loadSaajMessage(getTestPath() + "/response-anonymous.xml"); - assertXMLSimilar(expectedResponse, - (SaajSoapMessage) context.getResponse()); + assertXMLSimilar(expectedResponse, (SaajSoapMessage) context.getResponse()); verify(strategyMock); } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AddressingInterceptor200408Test.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AddressingInterceptor200408Test.java index d9df59f4..7c3b7a3c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AddressingInterceptor200408Test.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AddressingInterceptor200408Test.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -35,4 +35,5 @@ public class AddressingInterceptor200408Test extends AbstractAddressingIntercept public void testNoneReplyTo() throws Exception { // This version of the spec does not have none addresses } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AnnotationActionMethodEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AnnotationActionMethodEndpointMappingTest.java index 8a98fb64..cc532eff 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AnnotationActionMethodEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AnnotationActionMethodEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,16 @@ package org.springframework.ws.soap.addressing.server; -import static org.assertj.core.api.Assertions.*; +import java.io.IOException; +import java.io.InputStream; import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.MimeHeaders; import jakarta.xml.soap.SOAPConstants; import jakarta.xml.soap.SOAPException; - -import java.io.IOException; -import java.io.InputStream; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; @@ -41,6 +39,8 @@ import org.springframework.ws.soap.addressing.server.annotation.Address; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Arjen Poutsma * @author Nate Stoddard @@ -96,7 +96,8 @@ public class AnnotationActionMethodEndpointMappingTest { try { SaajSoapMessage message = new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, is)); return new DefaultMessageContext(message, new SaajSoapMessageFactory(messageFactory)); - } finally { + } + finally { is.close(); } } @@ -109,6 +110,7 @@ public class AnnotationActionMethodEndpointMappingTest { public void doIt() { } + } private static class MyInterceptor extends DelegatingSmartEndpointInterceptor { @@ -116,6 +118,7 @@ public class AnnotationActionMethodEndpointMappingTest { public MyInterceptor() { super(new PayloadLoggingInterceptor()); } + } private static class MySmartInterceptor extends DelegatingSmartEndpointInterceptor { @@ -127,5 +130,7 @@ public class AnnotationActionMethodEndpointMappingTest { public boolean shouldIntercept(MessageContext messageContext, Object endpoint) { return false; } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/SimpleActionEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/SimpleActionEndpointMappingTest.java index 906541b0..f717df21 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/SimpleActionEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/SimpleActionEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,13 @@ package org.springframework.ws.soap.addressing.server; -import static org.assertj.core.api.Assertions.*; - import java.net.URI; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; @@ -34,6 +33,8 @@ import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor; +import static org.assertj.core.api.Assertions.assertThat; + public class SimpleActionEndpointMappingTest extends AbstractWsAddressingTestCase { private SimpleActionEndpointMapping mapping; @@ -96,4 +97,5 @@ public class SimpleActionEndpointMappingTest extends AbstractWsAddressingTestCas private static class Endpoint2 { } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/client/core/SaajSoapActionCallbackTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/client/core/SaajSoapActionCallbackTest.java index 33eaa7d5..12212b3c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/client/core/SaajSoapActionCallbackTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/client/core/SaajSoapActionCallbackTest.java @@ -1,21 +1,37 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.soap.client.core; -import static org.assertj.core.api.Assertions.*; +import java.io.IOException; import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.SOAPConstants; import jakarta.xml.soap.SOAPException; - -import java.io.IOException; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.support.SoapUtils; import org.springframework.ws.transport.TransportConstants; +import static org.assertj.core.api.Assertions.assertThat; + public class SaajSoapActionCallbackTest { private SaajSoapMessageFactory saaj11Factory = new SaajSoapMessageFactory(); @@ -41,8 +57,9 @@ public class SaajSoapActionCallbackTest { public void noSoapAction11ShouldProduceEmptySoapActionHeader() { SaajSoapMessage message = saaj11Factory.createWebServiceMessage(); - String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders() - .getHeader(TransportConstants.HEADER_SOAP_ACTION); + String[] soapActionHeaders = message.getSaajMessage() + .getMimeHeaders() + .getHeader(TransportConstants.HEADER_SOAP_ACTION); assertThat(soapActionHeaders).containsExactly("\"\""); } @@ -53,8 +70,9 @@ public class SaajSoapActionCallbackTest { SaajSoapMessage message = saaj11Factory.createWebServiceMessage(); SoapActionCallback callback = new SoapActionCallback("testAction"); callback.doWithMessage(message); - String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders() - .getHeader(TransportConstants.HEADER_SOAP_ACTION); + String[] soapActionHeaders = message.getSaajMessage() + .getMimeHeaders() + .getHeader(TransportConstants.HEADER_SOAP_ACTION); assertThat(soapActionHeaders).containsExactly("\"testAction\""); } @@ -65,8 +83,9 @@ public class SaajSoapActionCallbackTest { SaajSoapMessage message = saaj11Factory.createWebServiceMessage(); SoapActionCallback callback = new SoapActionCallback(null); callback.doWithMessage(message); - String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders() - .getHeader(TransportConstants.HEADER_SOAP_ACTION); + String[] soapActionHeaders = message.getSaajMessage() + .getMimeHeaders() + .getHeader(TransportConstants.HEADER_SOAP_ACTION); assertThat(soapActionHeaders).containsExactly("\"\""); } @@ -75,8 +94,9 @@ public class SaajSoapActionCallbackTest { public void noSoapAction12() { SaajSoapMessage message = saaj12Factory.createWebServiceMessage(); - String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders() - .getHeader(TransportConstants.HEADER_SOAP_ACTION); + String[] soapActionHeaders = message.getSaajMessage() + .getMimeHeaders() + .getHeader(TransportConstants.HEADER_SOAP_ACTION); assertThat(soapActionHeaders).isNull(); } @@ -87,9 +107,12 @@ public class SaajSoapActionCallbackTest { SaajSoapMessage message = saaj12Factory.createWebServiceMessage(); SoapActionCallback callback = new SoapActionCallback("testAction"); callback.doWithMessage(message); - String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders() - .getHeader(TransportConstants.HEADER_SOAP_ACTION); - String[] contentTypes = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_CONTENT_TYPE); + String[] soapActionHeaders = message.getSaajMessage() + .getMimeHeaders() + .getHeader(TransportConstants.HEADER_SOAP_ACTION); + String[] contentTypes = message.getSaajMessage() + .getMimeHeaders() + .getHeader(TransportConstants.HEADER_CONTENT_TYPE); assertThat(soapActionHeaders).isNull(); assertThat(SoapUtils.extractActionFromContentType(contentTypes[0])).isEqualTo("\"testAction\""); @@ -101,11 +124,15 @@ public class SaajSoapActionCallbackTest { SaajSoapMessage message = saaj12Factory.createWebServiceMessage(); SoapActionCallback callback = new SoapActionCallback(null); callback.doWithMessage(message); - String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders() - .getHeader(TransportConstants.HEADER_SOAP_ACTION); - String[] contentTypes = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_CONTENT_TYPE); + String[] soapActionHeaders = message.getSaajMessage() + .getMimeHeaders() + .getHeader(TransportConstants.HEADER_SOAP_ACTION); + String[] contentTypes = message.getSaajMessage() + .getMimeHeaders() + .getHeader(TransportConstants.HEADER_CONTENT_TYPE); assertThat(soapActionHeaders).isNull(); assertThat(SoapUtils.extractActionFromContentType(contentTypes[0])).isEqualTo("\"\""); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11BodyTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11BodyTest.java index 26318865..1a080f18 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11BodyTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11BodyTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,19 @@ package org.springframework.ws.soap.saaj; -import static org.assertj.core.api.Assertions.*; +import java.util.Locale; import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.SOAPBody; import jakarta.xml.soap.SOAPConstants; import jakarta.xml.soap.SOAPMessage; - -import java.util.Locale; - import org.junit.jupiter.api.Test; + import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.soap11.AbstractSoap11BodyTestCase; +import static org.assertj.core.api.Assertions.assertThat; + public class SaajSoap11BodyTest extends AbstractSoap11BodyTestCase { @Override @@ -60,4 +60,5 @@ public class SaajSoap11BodyTest extends AbstractSoap11BodyTestCase { assertThat(saajSoapBody.getFault().getFaultStringLocale()).isNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11EnvelopeTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11EnvelopeTest.java index 4e8c0184..b2a08101 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11EnvelopeTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11EnvelopeTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,4 +33,5 @@ public class SaajSoap11EnvelopeTest extends AbstractSoap11EnvelopeTestCase { return new SaajSoapEnvelope(saajMessage.getSOAPPart().getEnvelope(), true); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11HeaderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11HeaderTest.java index ab4062e0..62ee5f06 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11HeaderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11HeaderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,4 +33,5 @@ public class SaajSoap11HeaderTest extends AbstractSoap11HeaderTestCase { return new SaajSoap11Header(saajMessage.getSOAPPart().getEnvelope().getHeader()); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11MessageFactoryTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11MessageFactoryTest.java index 45ae6c3c..3b946057 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11MessageFactoryTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/SaajSoap11MessageFactoryTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,23 +16,23 @@ package org.springframework.ws.soap.saaj; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPMessage; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.Map; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.Test; + import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.soap11.AbstractSoap11MessageFactoryTestCase; +import static org.assertj.core.api.Assertions.assertThat; + public class SaajSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTestCase { @Override @@ -54,4 +54,5 @@ public class SaajSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTe assertThat(result).startsWith(" iterator = responseHeader.examineAllHeaderElements(); @@ -183,7 +188,8 @@ public class SoapMessageDispatcherTest { SoapHeaderElement headerElement = iterator.next(); - assertThat(headerElement.getName()).isEqualTo(new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood")); + assertThat(headerElement.getName()) + .isEqualTo(new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood")); verify(interceptorMock); } @@ -194,7 +200,7 @@ public class SoapMessageDispatcherTest { MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); SOAPMessage request = messageFactory.createMessage(); SOAPHeaderElement header = request.getSOAPHeader() - .addHeaderElement(new QName("http://www.springframework.org", "Header", "spring-ws")); + .addHeaderElement(new QName("http://www.springframework.org", "Header", "spring-ws")); String headerActor = "http://www/springframework.org/role"; header.setActor(headerActor); header.setMustUnderstand(true); @@ -220,7 +226,7 @@ public class SoapMessageDispatcherTest { MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); SOAPMessage request = messageFactory.createMessage(); SOAPHeaderElement header = request.getSOAPHeader() - .addHeaderElement(new QName("http://www.springframework.org", "Header", "spring-ws")); + .addHeaderElement(new QName("http://www.springframework.org", "Header", "spring-ws")); String headerRole = "http://www/springframework.org/role"; header.setRole(headerRole); header.setMustUnderstand(true); @@ -266,7 +272,7 @@ public class SoapMessageDispatcherTest { MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); SOAPMessage request = messageFactory.createMessage(); SOAPHeaderElement header = request.getSOAPHeader() - .addHeaderElement(new QName("http://www.springframework.org", "Header")); + .addHeaderElement(new QName("http://www.springframework.org", "Header")); header.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT); header.setMustUnderstand(true); SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory); diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/FaultCreatingValidatingMarshallingPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/FaultCreatingValidatingMarshallingPayloadEndpointTest.java index 7aca8fd0..c7e51d34 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/FaultCreatingValidatingMarshallingPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/FaultCreatingValidatingMarshallingPayloadEndpointTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,6 @@ package org.springframework.ws.soap.server.endpoint; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.Detail; -import jakarta.xml.soap.DetailEntry; -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPFault; -import jakarta.xml.soap.SOAPMessage; - import java.io.IOException; import java.util.Iterator; @@ -31,8 +23,14 @@ import javax.xml.namespace.QName; import javax.xml.transform.Result; import javax.xml.transform.Source; +import jakarta.xml.soap.Detail; +import jakarta.xml.soap.DetailEntry; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPFault; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; @@ -45,6 +43,9 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; + public class FaultCreatingValidatingMarshallingPayloadEndpointTest { private MessageContext messageContext; @@ -91,7 +92,8 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { SOAPFault fault = response.getSOAPBody().getFault(); - assertThat(fault.getFaultCodeAsQName()).isEqualTo(new QName("http://schemas.xmlsoap.org/soap/envelope/", "Client")); + assertThat(fault.getFaultCodeAsQName()) + .isEqualTo(new QName("http://schemas.xmlsoap.org/soap/envelope/", "Client")); assertThat(fault.getFaultString()).isEqualTo(endpoint.getFaultStringOrReason()); Detail detail = fault.getDetail(); @@ -105,14 +107,14 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { DetailEntry detailEntry = (DetailEntry) iterator.next(); assertThat(detailEntry.getElementQName()) - .isEqualTo(new QName("http://springframework.org/spring-ws", "ValidationError")); + .isEqualTo(new QName("http://springframework.org/spring-ws", "ValidationError")); assertThat(detailEntry.getTextContent()).isEqualTo("Name is required"); assertThat(iterator.hasNext()).isTrue(); detailEntry = (DetailEntry) iterator.next(); assertThat(detailEntry.getElementQName()) - .isEqualTo(new QName("http://springframework.org/spring-ws", "ValidationError")); + .isEqualTo(new QName("http://springframework.org/spring-ws", "ValidationError")); assertThat(detailEntry.getTextContent()).isEqualTo("Age Cannot be negative"); assertThat(iterator.hasNext()).isFalse(); } @@ -156,10 +158,12 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { if (p.getAge() < 0) { e.rejectValue("age", "age.negativevalue"); - } else if (p.getAge() > 110) { + } + else if (p.getAge() > 110) { e.rejectValue("age", "too.darn.old"); } } + } private static class Person { @@ -193,6 +197,7 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { public String toString() { return "Person{" + name + "," + age + "}"; } + } private static class PersonMarshaller implements Unmarshaller, Marshaller { @@ -214,7 +219,9 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { } @Override - public void marshal(Object graph, Result result) throws XmlMappingException, IOException {} + public void marshal(Object graph, Result result) throws XmlMappingException, IOException { + } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolverTest.java index 7cffdc34..af6406eb 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,11 @@ package org.springframework.ws.soap.server.endpoint; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.util.Locale; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -30,6 +28,12 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.soap11.Soap11Body; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class SimpleSoapExceptionResolverTest { private SimpleSoapExceptionResolver exceptionResolver; @@ -68,4 +72,5 @@ public class SimpleSoapExceptionResolverTest { verify(factoryMock, messageMock, bodyMock); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolverTest.java index 3d19cfbe..9323af10 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,16 @@ package org.springframework.ws.soap.server.endpoint; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPMessage; - import java.util.Locale; import javax.xml.namespace.QName; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; @@ -40,6 +38,8 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapFault; import org.springframework.ws.soap.soap11.Soap11Fault; import org.springframework.ws.soap.soap12.Soap12Fault; +import static org.assertj.core.api.Assertions.assertThat; + public class SoapFaultAnnotationExceptionResolverTest { private SoapFaultAnnotationExceptionResolver resolver; @@ -256,6 +256,7 @@ public class SoapFaultAnnotationExceptionResolverTest { public NoStringOrReasonException(String message) { super(message); } + } @SoapFault(faultCode = FaultCode.SENDER, faultStringOrReason = "Sender error") diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditorTest.java index 490c7173..cb258810 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap.server.endpoint; -import static org.assertj.core.api.Assertions.*; - import java.util.Locale; import javax.xml.namespace.QName; @@ -25,6 +23,8 @@ import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class SoapFaultDefinitionEditorTest { private SoapFaultDefinitionEditor editor; @@ -92,4 +92,5 @@ public class SoapFaultDefinitionEditorTest { assertThat(editor.getValue()).isNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultMappingExceptionResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultMappingExceptionResolverTest.java index 7d8d19a8..56a0bcf5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultMappingExceptionResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultMappingExceptionResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,16 @@ package org.springframework.ws.soap.server.endpoint; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPMessage; - import java.io.IOException; import java.util.Locale; import java.util.Properties; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; @@ -39,6 +37,8 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.soap11.Soap11Fault; import org.springframework.ws.soap.soap12.Soap12Fault; +import static org.assertj.core.api.Assertions.assertThat; + public class SoapFaultMappingExceptionResolverTest { private SoapFaultMappingExceptionResolver resolver; @@ -245,4 +245,5 @@ public class SoapFaultMappingExceptionResolverTest { assertThat(fault.getFaultStringOrReason()).isEqualTo("java.io.IOException"); assertThat(fault.getFaultDetail()).isNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapHeaderElementMethodArgumentResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapHeaderElementMethodArgumentResolverTest.java index c2686d84..221d1739 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapHeaderElementMethodArgumentResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapHeaderElementMethodArgumentResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,13 @@ package org.springframework.ws.soap.server.endpoint.adapter.method; -import static org.assertj.core.api.Assertions.*; - import java.util.List; import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.adapter.method.AbstractMethodArgumentResolverTestCase; @@ -31,6 +30,9 @@ import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.server.endpoint.annotation.SoapHeader; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + /** * @author Tareq Abedrabbo */ @@ -66,10 +68,12 @@ public class SoapHeaderElementMethodArgumentResolverTest extends AbstractMethodA } soapHeaderWithEmptyValue = new MethodParameter( getClass().getMethod("soapHeaderWithEmptyValue", SoapHeaderElement.class), 0); - soapHeaderElementParameter = new MethodParameter(getClass().getMethod("soapHeaderElement", SoapHeaderElement.class), + soapHeaderElementParameter = new MethodParameter( + getClass().getMethod("soapHeaderElement", SoapHeaderElement.class), 0); + soapHeaderElementListParameter = new MethodParameter(getClass().getMethod("soapHeaderElementList", List.class), + 0); + soapHeaderMismatch = new MethodParameter(getClass().getMethod("soapHeaderMismatch", SoapHeaderElement.class), 0); - soapHeaderElementListParameter = new MethodParameter(getClass().getMethod("soapHeaderElementList", List.class), 0); - soapHeaderMismatch = new MethodParameter(getClass().getMethod("soapHeaderMismatch", SoapHeaderElement.class), 0); soapHeaderMismatchList = new MethodParameter(getClass().getMethod("soapHeaderMismatchList", List.class), 0); } @@ -84,7 +88,7 @@ public class SoapHeaderElementMethodArgumentResolverTest extends AbstractMethodA public void failOnEmptyValue() { assertThatIllegalArgumentException() - .isThrownBy(() -> resolver.resolveArgument(messageContext, soapHeaderWithEmptyValue)); + .isThrownBy(() -> resolver.resolveArgument(messageContext, soapHeaderWithEmptyValue)); } @Test @@ -138,16 +142,21 @@ public class SoapHeaderElementMethodArgumentResolverTest extends AbstractMethodA assertThat((List) result).isEmpty(); } - public void soapHeaderWithEmptyValue(@SoapHeader("") SoapHeaderElement element) {} + public void soapHeaderWithEmptyValue(@SoapHeader("") SoapHeaderElement element) { + } - public void soapHeaderElement(@SoapHeader("{http://springframework.org/ws}header") SoapHeaderElement element) {} + public void soapHeaderElement(@SoapHeader("{http://springframework.org/ws}header") SoapHeaderElement element) { + } public void soapHeaderElementList( - @SoapHeader("{http://springframework.org/ws}header") List elements) {} + @SoapHeader("{http://springframework.org/ws}header") List elements) { + } - public void soapHeaderMismatch(@SoapHeader("{http://springframework.org/ws}xxx") SoapHeaderElement element) {} + public void soapHeaderMismatch(@SoapHeader("{http://springframework.org/ws}xxx") SoapHeaderElement element) { + } public void soapHeaderMismatchList( - @SoapHeader("{http://springframework.org/ws}xxx") List elements) {} + @SoapHeader("{http://springframework.org/ws}xxx") List elements) { + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapMethodArgumentResolverTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapMethodArgumentResolverTest.java index 604e0e8d..be1d8c64 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapMethodArgumentResolverTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/adapter/method/SoapMethodArgumentResolverTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,9 @@ package org.springframework.ws.soap.server.endpoint.adapter.method; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.adapter.method.AbstractMethodArgumentResolverTestCase; @@ -28,7 +27,11 @@ import org.springframework.ws.soap.SoapEnvelope; import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapMessage; -/** @author Arjen Poutsma */ +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Arjen Poutsma + */ public class SoapMethodArgumentResolverTest extends AbstractMethodArgumentResolverTestCase { private SoapMethodArgumentResolver resolver; @@ -100,9 +103,13 @@ public class SoapMethodArgumentResolverTest extends AbstractMethodArgumentResolv } - public void soapEnvelope(SoapEnvelope soapEnvelope) {} + public void soapEnvelope(SoapEnvelope soapEnvelope) { + } - public void soapBody(SoapBody soapBody) {} + public void soapBody(SoapBody soapBody) { + } + + public void soapHeader(SoapHeader soapHeader) { + } - public void soapHeader(SoapHeader soapHeader) {} } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadRootSmartSoapEndpointInterceptorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadRootSmartSoapEndpointInterceptorTest.java index 72f35604..df633e51 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadRootSmartSoapEndpointInterceptorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadRootSmartSoapEndpointInterceptorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,9 @@ package org.springframework.ws.soap.server.endpoint.interceptor; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -27,6 +26,9 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.server.endpoint.interceptor.EndpointInterceptorAdapter; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class PayloadRootSmartSoapEndpointInterceptorTest { private EndpointInterceptor delegate; @@ -45,7 +47,8 @@ public class PayloadRootSmartSoapEndpointInterceptorTest { namespaceUri = "http://springframework.org/spring-ws"; localPart = "element"; - MockWebServiceMessage request = new MockWebServiceMessage("<" + localPart + " xmlns=\"" + namespaceUri + "\" />"); + MockWebServiceMessage request = new MockWebServiceMessage( + "<" + localPart + " xmlns=\"" + namespaceUri + "\" />"); messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); } @@ -53,7 +56,7 @@ public class PayloadRootSmartSoapEndpointInterceptorTest { public void neitherNamespaceNorLocalPart() { assertThatIllegalArgumentException() - .isThrownBy(() -> new PayloadRootSmartSoapEndpointInterceptor(delegate, null, null)); + .isThrownBy(() -> new PayloadRootSmartSoapEndpointInterceptor(delegate, null, null)); } @Test diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadValidatingInterceptorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadValidatingInterceptorTest.java index 28fe58f6..e4bf27f9 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadValidatingInterceptorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/PayloadValidatingInterceptorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,6 @@ package org.springframework.ws.soap.server.endpoint.interceptor; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPMessage; - import java.io.InputStream; import java.util.Locale; @@ -29,8 +23,14 @@ import javax.xml.XMLConstants; import javax.xml.transform.Transformer; import javax.xml.transform.stream.StreamSource; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + import org.springframework.core.io.ClassPathResource; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -46,8 +46,9 @@ import org.springframework.ws.soap.soap12.Soap12Fault; import org.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.validation.ValidationErrorHandler; import org.springframework.xml.xsd.SimpleXsdSchema; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; public class PayloadValidatingInterceptorTest { @@ -109,7 +110,8 @@ public class PayloadValidatingInterceptorTest { Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault(); assertThat(fault.getFaultCode()).isEqualTo(SoapVersion.SOAP_11.getClientOrSenderFaultName()); - assertThat(fault.getFaultStringOrReason()).isEqualTo(PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON); + assertThat(fault.getFaultStringOrReason()) + .isEqualTo(PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON); assertThat(fault.getFaultDetail()).isNotNull(); } @@ -134,7 +136,7 @@ public class PayloadValidatingInterceptorTest { assertThat(fault.getFaultCode()).isEqualTo(SoapVersion.SOAP_12.getClientOrSenderFaultName()); assertThat(fault.getFaultReasonText(Locale.ENGLISH)) - .isEqualTo(PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON); + .isEqualTo(PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON); assertThat(fault.getFaultDetail()).isNotNull(); } @@ -218,10 +220,11 @@ public class PayloadValidatingInterceptorTest { @Test public void testNamespacesInType() throws Exception { - // Make sure we use Xerces for this testcase: the JAXP implementation used internally by JDK 1.5 has a bug + // Make sure we use Xerces for this testcase: the JAXP implementation used + // internally by JDK 1.5 has a bug // See http://opensource.atlassian.com/projects/spring/browse/SWS-35 String previousSchemaFactory = System - .getProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, ""); + .getProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, ""); System.setProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, "org.apache.xerces.jaxp.validation.XMLSchemaFactory"); try { @@ -231,13 +234,15 @@ public class PayloadValidatingInterceptorTest { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage saajMessage = SaajUtils.loadMessage(new ClassPathResource(VALID_SOAP_MESSAGE, getClass()), messageFactory); - context = new DefaultMessageContext(new SaajSoapMessage(saajMessage), new SaajSoapMessageFactory(messageFactory)); + context = new DefaultMessageContext(new SaajSoapMessage(saajMessage), + new SaajSoapMessageFactory(messageFactory)); boolean result = interceptor.handleRequest(context, null); assertThat(result).isTrue(); assertThat(context.hasResponse()).isFalse(); - } finally { + } + finally { // Reset the property System.setProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, previousSchemaFactory); @@ -339,11 +344,14 @@ public class PayloadValidatingInterceptorTest { return new SAXParseException[0]; } - public void warning(SAXParseException exception) throws SAXException {} + public void warning(SAXParseException exception) throws SAXException { + } - public void error(SAXParseException exception) throws SAXException {} + public void error(SAXParseException exception) throws SAXException { + } - public void fatalError(SAXParseException exception) throws SAXException {} + public void fatalError(SAXParseException exception) throws SAXException { + } }; interceptor.setErrorHandler(errorHandler); @@ -357,4 +365,5 @@ public class PayloadValidatingInterceptorTest { assertThat(result).isTrue(); assertThat(context.hasResponse()).isFalse(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapActionSmartEndpointInterceptorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapActionSmartEndpointInterceptorTest.java index 3304f8a1..0bff675c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapActionSmartEndpointInterceptorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapActionSmartEndpointInterceptorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,9 @@ package org.springframework.ws.soap.server.endpoint.interceptor; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; @@ -27,6 +26,9 @@ import org.springframework.ws.server.endpoint.interceptor.EndpointInterceptorAda import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class SoapActionSmartEndpointInterceptorTest { private EndpointInterceptor delegate; @@ -74,4 +76,5 @@ public class SoapActionSmartEndpointInterceptorTest { assertThat(result).isFalse(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMappingTest.java index 7ca1c01d..922da73d 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,11 +16,9 @@ package org.springframework.ws.soap.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; @@ -28,6 +26,12 @@ import org.springframework.ws.server.EndpointInvocationChain; import org.springframework.ws.server.EndpointMapping; import org.springframework.ws.soap.server.SoapEndpointInvocationChain; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class DelegatingSoapEndpointMappingTest { private DelegatingSoapEndpointMapping endpointMapping; @@ -60,4 +64,5 @@ public class DelegatingSoapEndpointMappingTest { verify(mock); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMappingTest.java index 03cb5f66..2eb09627 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,11 @@ package org.springframework.ws.soap.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.lang.reflect.Method; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -34,6 +32,12 @@ import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.server.endpoint.annotation.SoapAction; import org.springframework.ws.soap.server.endpoint.annotation.SoapActions; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class SoapActionAnnotationMethodEndpointMappingTest { private SoapActionAnnotationMethodEndpointMapping mapping; @@ -133,7 +137,8 @@ public class SoapActionAnnotationMethodEndpointMappingTest { @SoapActions({ @SoapAction("http://springframework.org/spring-ws/SoapAction1"), @SoapAction("http://springframework.org/spring-ws/SoapAction2") }) - public void doItMultiple() {} + public void doItMultiple() { + } @SoapAction("http://springframework.org/spring-ws/SoapAction3") @SoapAction("http://springframework.org/spring-ws/SoapAction4") @@ -142,4 +147,5 @@ public class SoapActionAnnotationMethodEndpointMappingTest { } } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMappingTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMappingTest.java index 4bc3ea8e..7c009067 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMappingTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMappingTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,17 @@ package org.springframework.ws.soap.server.endpoint.mapping; -import static org.assertj.core.api.Assertions.*; - import jakarta.xml.soap.MessageFactory; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; +import static org.assertj.core.api.Assertions.assertThat; + public class SoapActionEndpointMappingTest { private SoapActionEndpointMapping mapping; @@ -62,4 +62,5 @@ public class SoapActionEndpointMappingTest { public void testValidateLookupKey() { assertThat(mapping.validateLookupKey("SoapAction")).isTrue(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11BodyTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11BodyTestCase.java index e1900201..a10f935f 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11BodyTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11BodyTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,13 @@ package org.springframework.ws.soap.soap11; -import static org.assertj.core.api.Assertions.*; - import java.util.Locale; import javax.xml.namespace.QName; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.ws.soap.AbstractSoapBodyTestCase; import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapFaultDetail; @@ -30,7 +30,8 @@ import org.springframework.ws.soap.SoapFaultDetailElement; import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCase { @@ -50,8 +51,10 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas StringResult result = new StringResult(); transformer.transform(soapBody.getSource(), result); - XmlAssert.assertThat(result.toString()).and("") - .ignoreWhitespace().areSimilar(); + XmlAssert.assertThat(result.toString()) + .and("") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -60,7 +63,7 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas SoapFault fault = soapBody.addMustUnderstandFault("SOAP Must Understand Error", null); assertThat(fault.getFaultCode()) - .isEqualTo(new QName("http://schemas.xmlsoap.org/soap/envelope/", "MustUnderstand")); + .isEqualTo(new QName("http://schemas.xmlsoap.org/soap/envelope/", "MustUnderstand")); assertPayloadEqual("" + "" + soapBody.getName().getPrefix() + ":MustUnderstand" + "SOAP Must Understand Error"); @@ -108,8 +111,8 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas assertThat(fault.getFaultActorOrRole()).isEqualTo(actor); assertPayloadEqual("" + "spring:fault" - + "" + faultString + "" + "" + actor + "" - + ""); + + "" + faultString + "" + "" + actor + + "" + ""); } @Test @@ -149,7 +152,8 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas assertPayloadEqual( "" - + "spring:fault" + "" + faultString + "" + "" + + "spring:fault" + "" + faultString + "" + + "" + "" + "" + "" + ""); @@ -159,14 +163,16 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas @Test public void testAddFaultWithDetailResult() throws Exception { - SoapFault fault = ((Soap11Body) soapBody).addFault(new QName("namespace", "localPart", "prefix"), "Fault", null); + SoapFault fault = ((Soap11Body) soapBody).addFault(new QName("namespace", "localPart", "prefix"), "Fault", + null); SoapFaultDetail detail = fault.addFaultDetail(); transformer.transform(new StringSource(""), detail.getResult()); transformer.transform(new StringSource(""), detail.getResult()); assertPayloadEqual("" - + "prefix:localPart" + "Fault" - + "" + "" + "" - + ""); + + "prefix:localPart" + + "Fault" + "" + "" + + "" + ""); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11EnvelopeTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11EnvelopeTestCase.java index df85945a..8ef520d9 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11EnvelopeTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11EnvelopeTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,23 @@ package org.springframework.ws.soap.soap11; -import static org.assertj.core.api.Assertions.*; - import javax.xml.namespace.QName; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.ws.soap.AbstractSoapEnvelopeTestCase; import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoap11EnvelopeTestCase extends AbstractSoapEnvelopeTestCase { @Test public void testGetName() { - assertThat(soapEnvelope.getName()).isEqualTo(new QName(SoapVersion.SOAP_11.getEnvelopeNamespaceUri(), "Envelope")); + assertThat(soapEnvelope.getName()) + .isEqualTo(new QName(SoapVersion.SOAP_11.getEnvelopeNamespaceUri(), "Envelope")); } @Test @@ -40,8 +42,9 @@ public abstract class AbstractSoap11EnvelopeTestCase extends AbstractSoapEnvelop transformer.transform(soapEnvelope.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("

") - .ignoreWhitespace().areSimilar(); + .and("
") + .ignoreWhitespace() + .areSimilar(); } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11HeaderTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11HeaderTestCase.java index 98bcdf83..79c6f799 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11HeaderTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11HeaderTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,20 @@ package org.springframework.ws.soap.soap11; -import static org.assertj.core.api.Assertions.*; - import java.util.Iterator; import javax.xml.namespace.QName; import org.assertj.core.api.Condition; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.ws.soap.AbstractSoapHeaderTestCase; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTestCase { @@ -51,8 +52,9 @@ public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTes transformer.transform(soapHeader.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("").ignoreWhitespace() - .areSimilar(); + .and("") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -68,7 +70,7 @@ public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTes headerElement = soapHeader.addHeaderElement(qName); headerElement.setActorOrRole(SoapVersion.SOAP_11.getNextActorOrRoleUri()); Iterator iterator = ((Soap11Header) soapHeader) - .examineHeaderElementsToProcess(new String[] { "role1" }); + .examineHeaderElementsToProcess(new String[] { "role1" }); assertThat(iterator).isNotNull(); assertThat(iterator.hasNext()).isTrue(); @@ -94,7 +96,8 @@ public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTes qName = new QName(NAMESPACE, "localName3", PREFIX); headerElement = soapHeader.addHeaderElement(qName); headerElement.setActorOrRole(SoapVersion.SOAP_11.getNextActorOrRoleUri()); - Iterator iterator = ((Soap11Header) soapHeader).examineHeaderElementsToProcess(new String[0]); + Iterator iterator = ((Soap11Header) soapHeader) + .examineHeaderElementsToProcess(new String[0]); assertThat(iterator).isNotNull(); assertThat(iterator.hasNext()).isTrue(); diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java index 1ee8aa30..c81b18fd 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap.soap11; -import static org.assertj.core.api.Assertions.*; - import java.io.InputStream; import java.util.Collections; import java.util.HashMap; @@ -25,6 +23,7 @@ import java.util.Iterator; import java.util.Map; import org.junit.jupiter.api.Test; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.mime.Attachment; import org.springframework.ws.soap.AbstractSoapMessageFactoryTestCase; @@ -33,6 +32,8 @@ import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.transport.MockTransportInputStream; import org.springframework.ws.transport.TransportInputStream; +import static org.assertj.core.api.Assertions.assertThat; + public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapMessageFactoryTestCase { @Test @@ -214,4 +215,5 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM assertThat(soapMessage.getVersion()).isEqualTo(SoapVersion.SOAP_11); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageTestCase.java index 00d98105..6fe370e7 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap.soap11; -import static org.assertj.core.api.Assertions.*; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; @@ -27,6 +25,10 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.InputStreamSource; @@ -37,9 +39,8 @@ import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.transport.MockTransportOutputStream; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.StringSource; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageTestCase { @@ -68,10 +69,11 @@ public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageT String result = bos.toString(StandardCharsets.UTF_8); XmlAssert.assertThat(result) - .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" - + getHeader() + "<" + getNS() + ":Body>") - .ignoreWhitespace().areIdentical(); + .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + + getHeader() + "<" + getNS() + ":Body>") + .ignoreWhitespace() + .areIdentical(); String contentType = tos.getHeaders().get("Content-Type"); @@ -144,10 +146,11 @@ public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageT String result = bos.toString(StandardCharsets.UTF_8); XmlAssert.assertThat(result) - .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" - + getHeader() + "<" + getNS() + ":Body>") - .ignoreWhitespace().areIdentical(); + .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + + getHeader() + "<" + getNS() + ":Body>") + .ignoreWhitespace() + .areIdentical(); } @Override @@ -173,10 +176,11 @@ public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageT String result = bos.toString(StandardCharsets.UTF_8); XmlAssert.assertThat(result) - .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" - + getHeader() + "<" + getNS() + ":Body>") - .ignoreWhitespace().areIdentical(); + .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + + getHeader() + "<" + getNS() + ":Body>") + .ignoreWhitespace() + .areIdentical(); } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12BodyTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12BodyTestCase.java index 2c01676d..1f6163fb 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12BodyTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12BodyTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,14 @@ package org.springframework.ws.soap.soap12; -import static org.assertj.core.api.Assertions.*; - import java.util.Iterator; import java.util.Locale; import javax.xml.namespace.QName; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.ws.soap.AbstractSoapBodyTestCase; import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapFaultDetail; @@ -31,7 +31,8 @@ import org.springframework.ws.soap.SoapFaultDetailElement; import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCase { @@ -51,8 +52,10 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas StringResult result = new StringResult(); transformer.transform(soapBody.getSource(), result); - XmlAssert.assertThat(result.toString()).and("") - .ignoreWhitespace().areSimilar(); + XmlAssert.assertThat(result.toString()) + .and("") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -60,17 +63,20 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas SoapFault fault = soapBody.addMustUnderstandFault("SOAP Must Understand Error", Locale.ENGLISH); - assertThat(fault.getFaultCode()).isEqualTo(new QName("http://www.w3.org/2003/05/soap-envelope", "MustUnderstand")); + assertThat(fault.getFaultCode()) + .isEqualTo(new QName("http://www.w3.org/2003/05/soap-envelope", "MustUnderstand")); StringResult result = new StringResult(); transformer.transform(fault.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("" + "" - + soapBody.getName().getPrefix() + ":MustUnderstand" - + "SOAP Must Understand Error" - + "") - .ignoreWhitespace().areSimilar(); + .and("" + + "" + soapBody.getName().getPrefix() + + ":MustUnderstand" + + "SOAP Must Understand Error" + + "") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -84,11 +90,13 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas transformer.transform(fault.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("" + "" - + soapBody.getName().getPrefix() + ":Sender" - + "faultString" - + "") - .ignoreWhitespace().areSimilar(); + .and("" + + "" + soapBody.getName().getPrefix() + + ":Sender" + + "faultString" + + "") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -102,11 +110,13 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas transformer.transform(fault.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("" + "" - + soapBody.getName().getPrefix() + ":Receiver" - + "faultString" - + "") - .ignoreWhitespace().areSimilar(); + .and("" + + "" + soapBody.getName().getPrefix() + + ":Receiver" + + "faultString" + + "") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -114,19 +124,22 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas SoapFault fault = soapBody.addServerOrReceiverFault("faultString", Locale.ENGLISH); SoapFaultDetail detail = fault.addFaultDetail(); - SoapFaultDetailElement detailElement = detail.addFaultDetailElement(new QName("namespace", "localPart", "prefix")); + SoapFaultDetailElement detailElement = detail + .addFaultDetailElement(new QName("namespace", "localPart", "prefix")); StringSource detailContents = new StringSource(""); transformer.transform(detailContents, detailElement.getResult()); StringResult result = new StringResult(); transformer.transform(fault.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("" + "" - + soapBody.getName().getPrefix() + ":Receiver" + "" - + "faultString" - + "" - + "") - .ignoreWhitespace().areSimilar(); + .and("" + + "" + soapBody.getName().getPrefix() + ":Receiver" + + "" + + "faultString" + + "" + + "") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -140,12 +153,14 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas transformer.transform(fault.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("" + "" - + soapBody.getName().getPrefix() + ":Receiver" + "" - + "faultString" - + "" + "" + "" - + "") - .ignoreWhitespace().areSimilar(); + .and("" + + "" + soapBody.getName().getPrefix() + ":Receiver" + + "" + + "faultString" + + "" + "" + "" + + "") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -168,14 +183,15 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas transformer.transform(fault.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("" + "" - + soapBody.getName().getPrefix() + ":Receiver" - + "spring-ws:Subcode1" - + "spring-ws:Subcode2" - + "" - + "faultString" - + "") - .ignoreWhitespace().areSimilar(); + .and("" + + "" + soapBody.getName().getPrefix() + ":Receiver" + + "spring-ws:Subcode1" + + "spring-ws:Subcode2" + + "" + + "faultString" + + "") + .ignoreWhitespace() + .areSimilar(); } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12EnvelopeTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12EnvelopeTestCase.java index 910d03bd..fdb33421 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12EnvelopeTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12EnvelopeTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,23 @@ package org.springframework.ws.soap.soap12; -import static org.assertj.core.api.Assertions.*; - import javax.xml.namespace.QName; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.ws.soap.AbstractSoapEnvelopeTestCase; import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoap12EnvelopeTestCase extends AbstractSoapEnvelopeTestCase { @Test public void testGetName() { - assertThat(soapEnvelope.getName()).isEqualTo(new QName(SoapVersion.SOAP_12.getEnvelopeNamespaceUri(), "Envelope")); + assertThat(soapEnvelope.getName()) + .isEqualTo(new QName(SoapVersion.SOAP_12.getEnvelopeNamespaceUri(), "Envelope")); } @Test @@ -40,8 +42,9 @@ public abstract class AbstractSoap12EnvelopeTestCase extends AbstractSoapEnvelop transformer.transform(soapEnvelope.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("
" + "") - .ignoreWhitespace().areSimilar(); + .and("
" + "") + .ignoreWhitespace() + .areSimilar(); } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12HeaderTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12HeaderTestCase.java index ef614964..980c742a 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12HeaderTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12HeaderTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,20 @@ package org.springframework.ws.soap.soap12; -import static org.assertj.core.api.Assertions.*; - import java.util.Iterator; import javax.xml.namespace.QName; import org.assertj.core.api.Condition; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.ws.soap.AbstractSoapHeaderTestCase; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTestCase { @@ -48,8 +49,10 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes StringResult result = new StringResult(); transformer.transform(soapHeader.getSource(), result); - XmlAssert.assertThat(result.toString()).and("
") - .ignoreWhitespace().areSimilar(); + XmlAssert.assertThat(result.toString()) + .and("
") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -62,10 +65,11 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes transformer.transform(soapHeader.getSource(), result); XmlAssert.assertThat(result.toString()) - .and("
" - + "" - + "
") - .ignoreWhitespace().areSimilar(); + .and("
" + + "" + + "
") + .ignoreWhitespace() + .areSimilar(); } @Test @@ -81,13 +85,13 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes assertThat(header.getName()).isEqualTo(new QName("http://www.w3.org/2003/05/soap-envelope", "Upgrade")); // XMLUnit can't test this: /* - assertXMLEqual("Invalid contents of header", "
" + - "" + - "" + - "" + - "" + - "
", result.toString()); - */ + * assertXMLEqual("Invalid contents of header", + * "
" + "" + + * "" + * + + * "" + * + "" + "
", result.toString()); + */ } @Test @@ -103,7 +107,7 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes headerElement = soapHeader.addHeaderElement(qName); headerElement.setActorOrRole(SoapVersion.SOAP_12.getNextActorOrRoleUri()); Iterator iterator = ((Soap12Header) soapHeader) - .examineHeaderElementsToProcess(new String[] { "role1" }, false); + .examineHeaderElementsToProcess(new String[] { "role1" }, false); assertThat(iterator).isNotNull(); assertThat(iterator.hasNext()).isTrue(); @@ -151,7 +155,7 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName); headerElement.setActorOrRole(SoapVersion.SOAP_12.getUltimateReceiverRoleUri()); Iterator iterator = ((Soap12Header) soapHeader) - .examineHeaderElementsToProcess(new String[] { "role" }, true); + .examineHeaderElementsToProcess(new String[] { "role" }, true); assertThat(iterator).isNotNull(); @@ -168,4 +172,5 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes assertThat(name).is(new Condition<>(value -> new QName(NAMESPACE, "localName1", PREFIX).equals(value) || new QName(NAMESPACE, "localName3", PREFIX).equals(value), "")); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java index 6ad602ca..ef3dbcf5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap.soap12; -import static org.assertj.core.api.Assertions.*; - import java.io.InputStream; import java.util.Collections; import java.util.HashMap; @@ -33,6 +31,8 @@ import org.springframework.ws.transport.MockTransportInputStream; import org.springframework.ws.transport.TransportConstants; import org.springframework.ws.transport.TransportInputStream; +import static org.assertj.core.api.Assertions.assertThat; + public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapMessageFactoryTestCase { @Override @@ -81,8 +81,8 @@ public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapM InputStream is = AbstractSoap12MessageFactoryTestCase.class.getResourceAsStream("soap12-attachment.bin"); Map headers = new HashMap(); - headers.put("Content-Type", - "multipart/related;" + "type=\"application/soap+xml\";" + "boundary=\"----=_Part_0_11416420.1149699787554\""); + headers.put("Content-Type", "multipart/related;" + "type=\"application/soap+xml\";" + + "boundary=\"----=_Part_0_11416420.1149699787554\""); TransportInputStream tis = new MockTransportInputStream(is, headers); WebServiceMessage message = messageFactory.createWebServiceMessage(tis); @@ -138,4 +138,5 @@ public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapM assertThat(soapMessage.getVersion()).isEqualTo(SoapVersion.SOAP_12); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageTestCase.java index 1ea2b5de..8b204d20 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap.soap12; -import static org.assertj.core.api.Assertions.*; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; @@ -27,6 +25,10 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.InputStreamSource; @@ -38,9 +40,8 @@ import org.springframework.ws.transport.MockTransportOutputStream; import org.springframework.ws.transport.TransportConstants; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.StringSource; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageTestCase { @@ -71,10 +72,11 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT String result = bos.toString(StandardCharsets.UTF_8); XmlAssert.assertThat(result) - .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + getHeader() - + "<" + getNS() + ":Body>") - .ignoreWhitespace().areIdentical(); + .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + + getHeader() + "<" + getNS() + ":Body>") + .ignoreWhitespace() + .areIdentical(); String contentType = tos.getHeaders().get(TransportConstants.HEADER_CONTENT_TYPE); @@ -145,10 +147,11 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT String result = bos.toString(StandardCharsets.UTF_8); XmlAssert.assertThat(result) - .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + getHeader() - + "<" + getNS() + ":Body>") - .ignoreWhitespace().areIdentical(); + .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + + getHeader() + "<" + getNS() + ":Body>") + .ignoreWhitespace() + .areIdentical(); } @Override @@ -174,9 +177,11 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT String result = bos.toString(StandardCharsets.UTF_8); XmlAssert.assertThat(result) - .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + getHeader() - + "<" + getNS() + ":Body>") - .ignoreWhitespace().areIdentical(); + .and("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + + getHeader() + "<" + getNS() + ":Body>") + .ignoreWhitespace() + .areIdentical(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java index 2da60152..ae37c479 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,10 @@ package org.springframework.ws.soap.support; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class SoapUtilsTest { @Test @@ -85,4 +85,5 @@ public class SoapUtilsTest { assertThat(SoapUtils.extractActionFromContentType(result)).isEqualTo(anotherSoapAction); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/support/ChangelogCreator.java b/spring-ws-core/src/test/java/org/springframework/ws/support/ChangelogCreator.java index a160bd4f..ce26e237 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/support/ChangelogCreator.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/support/ChangelogCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -15,21 +15,20 @@ */ package org.springframework.ws.support; -import net.minidev.json.JSONArray; - import java.time.Duration; import java.time.LocalDate; import java.util.Iterator; import java.util.List; +import com.jayway.jsonpath.JsonPath; +import net.minidev.json.JSONArray; + import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.Links; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; -import com.jayway.jsonpath.JsonPath; - /** * Little helper to build a changelog from the tickets of a particular milestone. * @@ -39,23 +38,27 @@ import com.jayway.jsonpath.JsonPath; class ChangelogCreator { private static final int MILESTONE_ID = 91; + private static final String URI_TEMPLATE = "https://api.github.com/repos/spring-projects/spring-ws/issues?milestone={id}&state=closed"; public static void main(String... args) { /* - * If you run into github rate limiting issues, you can always use a Github Personal Token by adding - * {@code .header(HttpHeaders.AUTHORIZATION, "token your-github-token")} to the webClient call. + * If you run into github rate limiting issues, you can always use a Github + * Personal Token by adding {@code .header(HttpHeaders.AUTHORIZATION, + * "token your-github-token")} to the webClient call. */ WebClient webClient = WebClient.create(); try { HttpEntity response = webClient // - .get().uri(URI_TEMPLATE, MILESTONE_ID) // - // .header(HttpHeaders.AUTHORIZATION, "token ") // - .exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) // - .block(Duration.ofSeconds(10)); + .get() + .uri(URI_TEMPLATE, MILESTONE_ID) // + // .header(HttpHeaders.AUTHORIZATION, "token ") // + .exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) // + .block(Duration.ofSeconds(10)); boolean keepChecking = true; boolean printHeader = true; @@ -71,15 +74,18 @@ class ChangelogCreator { if (links.getLink(IanaLinkRelations.NEXT).isPresent()) { response = webClient // - .get().uri(links.getRequiredLink(IanaLinkRelations.NEXT).expand().getHref()) // - .exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) // - .block(Duration.ofSeconds(10)); + .get() + .uri(links.getRequiredLink(IanaLinkRelations.NEXT).expand().getHref()) // + .exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) // + .block(Duration.ofSeconds(10)); - } else { + } + else { keepChecking = false; } } - } catch (Exception e) { + } + catch (Exception e) { System.out.println("Couldn't retrieve MILESTONE " + MILESTONE_ID); } } @@ -93,8 +99,8 @@ class ChangelogCreator { Iterator ids = ((JSONArray) idPath.read(content)).iterator(); if (header) { - System.out.println( - "Changes in version " + JsonPath.read(content, "$[0].milestone.title") + " (" + LocalDate.now() + ")"); + System.out.println("Changes in version " + JsonPath.read(content, "$[0].milestone.title") + " (" + + LocalDate.now() + ")"); System.out.println("----------------------------------------"); } @@ -104,4 +110,5 @@ class ChangelogCreator { System.out.println(format.endsWith(".") ? format : format.concat(".")); } } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/support/DefaultStrategiesHelperTest.java b/spring-ws-core/src/test/java/org/springframework/ws/support/DefaultStrategiesHelperTest.java index 36249982..bd6c5eb1 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/support/DefaultStrategiesHelperTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/support/DefaultStrategiesHelperTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,11 @@ package org.springframework.ws.support; -import static org.assertj.core.api.Assertions.*; - import java.util.List; import java.util.Properties; import org.junit.jupiter.api.Test; + import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.context.ApplicationContext; @@ -30,6 +29,9 @@ import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public class DefaultStrategiesHelperTest { @Test @@ -89,7 +91,7 @@ public class DefaultStrategiesHelperTest { applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class); assertThatExceptionOfType(BeanInitializationException.class) - .isThrownBy(() -> helper.getDefaultStrategy(Strategy.class, applicationContext)); + .isThrownBy(() -> helper.getDefaultStrategy(Strategy.class, applicationContext)); } @Test @@ -119,5 +121,7 @@ public class DefaultStrategiesHelperTest { public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/support/MarshallingUtilsTest.java b/spring-ws-core/src/test/java/org/springframework/ws/support/MarshallingUtilsTest.java index 2c263b3c..b930ee87 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/support/MarshallingUtilsTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/support/MarshallingUtilsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,11 @@ package org.springframework.ws.support; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import javax.xml.transform.Result; import javax.xml.transform.Source; import org.junit.jupiter.api.Test; + import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.mime.MimeContainer; @@ -33,6 +31,14 @@ import org.springframework.ws.mime.MimeMessage; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.eq; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class MarshallingUtilsTest { @Test @@ -127,4 +133,5 @@ public class MarshallingUtilsTest { verify(marshallerMock, messageMock); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/MockTransportInputStream.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/MockTransportInputStream.java index cf9c2687..91f79f36 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/MockTransportInputStream.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/MockTransportInputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -62,4 +62,5 @@ public class MockTransportInputStream extends TransportInputStream { String[] values = StringUtils.delimitedListToStringArray(headers.get(name), ", "); return Arrays.asList(values).iterator(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/MockTransportOutputStream.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/MockTransportOutputStream.java index 4b7238ec..7b4a8866 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/MockTransportOutputStream.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/MockTransportOutputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -47,4 +47,5 @@ public class MockTransportOutputStream extends TransportOutputStream { public void addHeader(String name, String value) { headers.put(name, value); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/AbstractHttpSenderConnectionTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/AbstractHttpSenderConnectionTest.java index 56959f0d..7e2ff0ea 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/AbstractHttpSenderConnectionTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/AbstractHttpSenderConnectionTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; - import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Collections; @@ -28,19 +25,25 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.CountingInputStream; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + /** * @author Andreas Veithen */ public class AbstractHttpSenderConnectionTest { /** - * Tests that {@link AbstractHttpSenderConnection} doesn't consume the response stream before passing it to the - * message factory. This is a regression test for SWS-707. - * - * @param chunking Specifies whether the test should simulate a response with chunking enabled. + * Tests that {@link AbstractHttpSenderConnection} doesn't consume the response stream + * before passing it to the message factory. This is a regression test for SWS-707. + * @param chunking Specifies whether the test should simulate a response with chunking + * enabled. * @throws Exception */ private void testSupportsStreaming(boolean chunking) throws Exception { @@ -78,4 +81,5 @@ public class AbstractHttpSenderConnectionTest { public void testSupportsStreamingWithChunkingDisabled() throws Exception { testSupportsStreaming(false); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/AbstractHttpWebServiceMessageSenderIntegrationTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/AbstractHttpWebServiceMessageSenderIntegrationTestCase.java index 61c5abc6..57d51a7d 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/AbstractHttpWebServiceMessageSenderIntegrationTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/AbstractHttpWebServiceMessageSenderIntegrationTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,6 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.assertThat; - -import jakarta.servlet.Servlet; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServlet; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.xml.soap.*; - import java.io.OutputStream; import java.net.URI; import java.nio.charset.StandardCharsets; @@ -35,6 +26,16 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; +import jakarta.servlet.Servlet; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.MimeHeaders; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPMessage; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -43,6 +44,8 @@ import org.eclipse.jetty.servlet.ServletHolder; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.beans.factory.InitializingBean; import org.springframework.util.FileCopyUtils; import org.springframework.ws.WebServiceMessage; @@ -55,7 +58,8 @@ import org.springframework.ws.transport.support.FreePortScanner; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractHttpWebServiceMessageSenderIntegrationTestCase { @@ -191,7 +195,7 @@ public abstract class AbstractHttpWebServiceMessageSenderIntegrationTestCase { @@ -34,10 +34,11 @@ class HttpComponents5ContentTypeIntegrationTest }; HttpClient client = HttpClientBuilder.create() // - .addRequestInterceptorFirst(new HttpComponents5MessageSender.RemoveSoapHeadersInterceptor()) // - .addExecInterceptorFirst("handler with assertion", testHandler) // - .build(); + .addRequestInterceptorFirst(new HttpComponents5MessageSender.RemoveSoapHeadersInterceptor()) // + .addExecInterceptorFirst("handler with assertion", testHandler) // + .build(); return new HttpComponents5MessageSender(client); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponents5MessageSenderIntegrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponents5MessageSenderIntegrationTest.java index e34d3b85..84a96ff4 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponents5MessageSenderIntegrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponents5MessageSenderIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,15 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.AssertionsForClassTypes.*; -import static org.springframework.ws.transport.http.HttpComponents5ClientFactory.*; - -import jakarta.servlet.http.HttpServlet; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.xml.soap.MessageFactory; - import java.io.IOException; import java.net.URI; import java.util.HashMap; import java.util.Map; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.xml.soap.MessageFactory; import org.apache.hc.client5.http.HttpRoute; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; @@ -38,6 +34,7 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.servlet.ServletContextHandler; import org.junit.jupiter.api.Test; + import org.springframework.context.support.StaticApplicationContext; import org.springframework.util.FileCopyUtils; import org.springframework.ws.soap.saaj.SaajSoapMessage; @@ -45,6 +42,9 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.support.FreePortScanner; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.springframework.ws.transport.http.HttpComponents5ClientFactory.getPort; + class HttpComponents5MessageSenderIntegrationTest extends AbstractHttpWebServiceMessageSenderIntegrationTestCase { @@ -138,12 +138,14 @@ class HttpComponents5MessageSenderIntegrationTest connection.receive(new SaajSoapMessageFactory(messageFactory)); appContext.close(); - } finally { + } + finally { if (connection != null) { try { connection.close(); - } catch (IOException ex) { + } + catch (IOException ex) { // ignore } } @@ -164,6 +166,7 @@ class HttpComponents5MessageSenderIntegrationTest FileCopyUtils.copy(request.getInputStream(), response.getOutputStream()); } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponents5MessageSenderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponents5MessageSenderTest.java index 2496ddc1..70a17fc2 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponents5MessageSenderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponents5MessageSenderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,15 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; - import java.time.Duration; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; + class HttpComponents5MessageSenderTest { @Test @@ -51,4 +52,5 @@ class HttpComponents5MessageSenderTest { messageSender.afterPropertiesSet(); assertThat(messageSender.getHttpClient()).isSameAs(httpClient); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponentsMessageSenderIntegrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponentsMessageSenderIntegrationTest.java index 676340eb..9c937da5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponentsMessageSenderIntegrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponentsMessageSenderIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,16 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; - -import jakarta.servlet.http.HttpServlet; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.xml.soap.MessageFactory; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.xml.soap.MessageFactory; import org.apache.http.HttpHost; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.impl.conn.PoolingClientConnectionManager; @@ -38,6 +35,7 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.servlet.ServletContextHandler; import org.junit.jupiter.api.Test; + import org.springframework.context.support.StaticApplicationContext; import org.springframework.util.FileCopyUtils; import org.springframework.ws.soap.saaj.SaajSoapMessage; @@ -45,6 +43,8 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.support.FreePortScanner; +import static org.assertj.core.api.Assertions.assertThat; + public class HttpComponentsMessageSenderIntegrationTest extends AbstractHttpWebServiceMessageSenderIntegrationTestCase { @@ -64,7 +64,7 @@ public class HttpComponentsMessageSenderIntegrationTest assertThat(route1.isSecure()).isTrue(); assertThat(route1.getTargetHost().getHostName()).isEqualTo("www.example.com"); assertThat(route1.getTargetHost().getPort()) - .has(new Condition<>(value -> value == -1 || value == 443, "verify port")); + .has(new Condition<>(value -> value == -1 || value == 443, "verify port")); final String url2 = "http://www.example.com:8080"; URI uri2 = new URI(url2); @@ -83,7 +83,7 @@ public class HttpComponentsMessageSenderIntegrationTest assertThat(route3.isSecure()).isFalse(); assertThat(route3.getTargetHost().getHostName()).isEqualTo("www.springframework.org"); assertThat(route3.getTargetHost().getPort()) - .has(new Condition<>(value -> value == -1 || value == 80, "verify port")); + .has(new Condition<>(value -> value == -1 || value == 80, "verify port")); HttpComponentsMessageSender messageSender = new HttpComponentsMessageSender(); messageSender.setMaxTotalConnections(2); @@ -94,7 +94,8 @@ public class HttpComponentsMessageSenderIntegrationTest messageSender.setMaxConnectionsPerHost(maxConnectionsPerHost); PoolingClientConnectionManager poolingClientConnectionManager = (PoolingClientConnectionManager) messageSender - .getHttpClient().getConnectionManager(); + .getHttpClient() + .getConnectionManager(); assertThat(poolingClientConnectionManager.getMaxPerRoute(route1)).isEqualTo(1); assertThat(poolingClientConnectionManager.getMaxPerRoute(route2)).isEqualTo(7); @@ -135,11 +136,13 @@ public class HttpComponentsMessageSenderIntegrationTest connection.receive(new SaajSoapMessageFactory(messageFactory)); appContext.close(); - } finally { + } + finally { if (connection != null) { try { connection.close(); - } catch (IOException ex) { + } + catch (IOException ex) { // ignore } } @@ -160,6 +163,7 @@ public class HttpComponentsMessageSenderIntegrationTest FileCopyUtils.copy(request.getInputStream(), response.getOutputStream()); } + } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpServletConnectionTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpServletConnectionTest.java index 284a3ec3..85103539 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpServletConnectionTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpServletConnectionTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,20 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.MimeHeaders; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPMessage; - import java.io.IOException; import java.nio.charset.StandardCharsets; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.MimeHeaders; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.ws.soap.SoapVersion; @@ -39,7 +38,8 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public class HttpServletConnectionTest { @@ -112,7 +112,10 @@ public class HttpServletConnectionTest { connection.send(message); assertThat(httpServletResponse.getHeader(HEADER_NAME)).isEqualTo(HEADER_VALUE); - XmlAssert.assertThat(httpServletResponse.getContentAsString()).and(SOAP_CONTENT).ignoreWhitespace().areIdentical(); + XmlAssert.assertThat(httpServletResponse.getContentAsString()) + .and(SOAP_CONTENT) + .ignoreWhitespace() + .areIdentical(); } @Test diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSenderIntegrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSenderIntegrationTest.java index b664cef3..6f3aa4e0 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSenderIntegrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSenderIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; - import java.time.Duration; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class HttpUrlConnectionMessageSenderIntegrationTest extends AbstractHttpWebServiceMessageSenderIntegrationTestCase { @@ -36,10 +36,12 @@ public class HttpUrlConnectionMessageSenderIntegrationTest this.messageSender.setConnectionTimeout(Duration.ofSeconds(3)); this.messageSender.setReadTimeout(Duration.ofSeconds(5)); - try (HttpUrlConnection connection = (HttpUrlConnection) this.messageSender.createConnection(this.connectionUri)) { + try (HttpUrlConnection connection = (HttpUrlConnection) this.messageSender + .createConnection(this.connectionUri)) { assertThat(connection.getConnection().getConnectTimeout()).isEqualTo(3000); assertThat(connection.getConnection().getReadTimeout()).isEqualTo(5000); } } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/JdkHttpClientMessageSenderIntegrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/JdkHttpClientMessageSenderIntegrationTest.java index b8c31f95..7a1df471 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/JdkHttpClientMessageSenderIntegrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/JdkHttpClientMessageSenderIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2023-2023 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,4 +23,5 @@ public class JdkHttpClientMessageSenderIntegrationTest protected JdkHttpClientMessageSender createMessageSender() { return new JdkHttpClientMessageSender(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/LastModifiedHelperTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/LastModifiedHelperTest.java index 5f690770..8bdca5af 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/LastModifiedHelperTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/LastModifiedHelperTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMSource; @@ -25,11 +23,14 @@ import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.ResourceSource; -import org.w3c.dom.Document; + +import static org.assertj.core.api.Assertions.assertThat; public class LastModifiedHelperTest { @@ -71,4 +72,5 @@ public class LastModifiedHelperTest { assertThat(result).isEqualTo(expected); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletIntegrationTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletIntegrationTest.java index 2e6e195f..c13c3b8d 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletIntegrationTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,7 +16,9 @@ package org.springframework.ws.transport.http; -import static org.xmlunit.assertj.XmlAssert.*; +import java.io.File; + +import javax.xml.namespace.QName; import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.SOAPConnection; @@ -24,11 +26,6 @@ import jakarta.xml.soap.SOAPConnectionFactory; import jakarta.xml.soap.SOAPElement; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPMessage; - -import java.io.File; - -import javax.xml.namespace.QName; - import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -37,9 +34,12 @@ import org.eclipse.jetty.servlet.ServletHolder; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.transport.support.EchoPayloadEndpoint; import org.springframework.ws.transport.support.FreePortScanner; +import static org.xmlunit.assertj.XmlAssert.assertThat; + /** * @author Arjen Poutsma */ @@ -67,7 +67,7 @@ public class MessageDispatcherServletIntegrationTest { jettyContext.setContextPath("/"); String resourceBase = new File(MessageDispatcherServletIntegrationTest.class.getResource("WEB-INF").toURI()) - .getParent(); + .getParent(); jettyContext.setResourceBase(resourceBase); @@ -99,7 +99,7 @@ public class MessageDispatcherServletIntegrationTest { SOAPMessage request = messageFactory.createMessage(); SOAPElement element = request.getSOAPBody() - .addChildElement(new QName(EchoPayloadEndpoint.NAMESPACE, EchoPayloadEndpoint.LOCAL_PART)); + .addChildElement(new QName(EchoPayloadEndpoint.NAMESPACE, EchoPayloadEndpoint.LOCAL_PART)); element.setTextContent("Hello World"); SOAPConnection connection = connectionFactory.createConnection(); @@ -108,4 +108,5 @@ public class MessageDispatcherServletIntegrationTest { assertThat(response.getSOAPPart()).and(request.getSOAPPart()).ignoreWhitespace().areIdentical(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletTest.java index eeb82e7f..b2709d7c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,19 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; - -import jakarta.servlet.ServletConfig; -import jakarta.servlet.ServletException; - import java.io.ByteArrayInputStream; import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; import org.springframework.core.io.ClassPathResource; @@ -43,8 +43,8 @@ import org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMa import org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver; import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition; import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.w3c.dom.Document; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public class MessageDispatcherServletTest { @@ -96,7 +96,8 @@ public class MessageDispatcherServletTest { servlet.setContextClass(WsdlDefinitionWebApplicationContext.class); servlet.init(config); - MockHttpServletRequest request = new MockHttpServletRequest(HttpTransportConstants.METHOD_GET, "/definition.wsdl"); + MockHttpServletRequest request = new MockHttpServletRequest(HttpTransportConstants.METHOD_GET, + "/definition.wsdl"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance(); @@ -119,6 +120,7 @@ public class MessageDispatcherServletTest { super.refresh(); } + } private static class WsdlDefinitionWebApplicationContext extends StaticWebApplicationContext { @@ -132,5 +134,7 @@ public class MessageDispatcherServletTest { super.refresh(); } + } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java index 80eb7b99..62e2881e 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,14 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - -import jakarta.servlet.http.HttpServletResponse; - import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.StandardCharsets; +import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.ws.FaultAwareWebServiceMessage; @@ -37,6 +34,13 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.transport.WebServiceMessageReceiver; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class WebServiceMessageReceiverHandlerAdapterTest { private static final String REQUEST = " {}); + adapter.handle(httpRequest, httpResponse, (WebServiceMessageReceiver) messageContext -> { + }); assertThat(httpResponse.getStatus()).isEqualTo(HttpServletResponse.SC_METHOD_NOT_ALLOWED); @@ -93,7 +98,8 @@ public class WebServiceMessageReceiverHandlerAdapterTest { replayMockControls(); - adapter.handle(httpRequest, httpResponse, (WebServiceMessageReceiver) messageContext -> {}); + adapter.handle(httpRequest, httpResponse, (WebServiceMessageReceiver) messageContext -> { + }); assertThat(httpResponse.getStatus()).isEqualTo(HttpServletResponse.SC_ACCEPTED); assertThat(httpResponse.getContentAsString()).hasSize(0); @@ -171,11 +177,13 @@ public class WebServiceMessageReceiverHandlerAdapterTest { httpRequest.setContent(REQUEST.getBytes(StandardCharsets.UTF_8)); httpRequest.setContentType("text/xml; charset=\"utf-8\""); httpRequest.setCharacterEncoding("UTF-8"); - expect(factoryMock.createWebServiceMessage(isA(InputStream.class))).andThrow(new InvalidXmlException(null, null)); + expect(factoryMock.createWebServiceMessage(isA(InputStream.class))) + .andThrow(new InvalidXmlException(null, null)); replayMockControls(); - adapter.handle(httpRequest, httpResponse, (WebServiceMessageReceiver) messageContext -> {}); + adapter.handle(httpRequest, httpResponse, (WebServiceMessageReceiver) messageContext -> { + }); assertThat(httpResponse.getStatus()).isEqualTo(HttpServletResponse.SC_BAD_REQUEST); diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapterTest.java index 7d0b6eeb..a2ed147e 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,18 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; - -import jakarta.servlet.http.HttpServletResponse; - import java.io.ByteArrayInputStream; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.mock.web.MockHttpServletRequest; @@ -35,8 +35,8 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.util.FileCopyUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.xsd.SimpleXsdSchema; -import org.w3c.dom.Document; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public class XsdSchemaHandlerAdapterTest { @@ -119,4 +119,5 @@ public class XsdSchemaHandlerAdapterTest { XmlAssert.assertThat(resultingDocument).and(expectedDocument).ignoreWhitespace().areIdentical(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/support/EchoPayloadEndpoint.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/support/EchoPayloadEndpoint.java index 20a73cbe..5c5dfec9 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/support/EchoPayloadEndpoint.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/support/EchoPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -35,4 +35,5 @@ public class EchoPayloadEndpoint { public Source invoke(@RequestPayload Source request) throws Exception { return request; } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/support/FreePortScanner.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/support/FreePortScanner.java index c3ebdb8b..7c4c640c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/support/FreePortScanner.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/support/FreePortScanner.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -61,7 +61,8 @@ public abstract class FreePortScanner { String.format("There were no ports available in the range %d to %d", minPort, maxPort)); } candidatePort = getRandomPort(minPort, portRange); - } while (!isPortAvailable(candidatePort)); + } + while (!isPortAvailable(candidatePort)); return candidatePort; } @@ -78,12 +79,15 @@ public abstract class FreePortScanner { InetSocketAddress sa = new InetSocketAddress(port); serverSocket.bind(sa); return true; - } catch (IOException e) { + } + catch (IOException e) { return false; } - } catch (IOException ex) { + } + catch (IOException ex) { throw new IllegalStateException("Unable to create ServerSocket.", ex); } } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupportTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupportTest.java index e4ab5e4d..acc29a96 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupportTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupportTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,11 @@ package org.springframework.ws.transport.support; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; - import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.WebServiceMessage; @@ -31,6 +29,12 @@ import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.transport.FaultAwareWebServiceConnection; import org.springframework.ws.transport.WebServiceMessageReceiver; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.isA; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class WebServiceMessageReceiverObjectSupportTest { private WebServiceMessageReceiverObjectSupport receiverSupport; @@ -71,8 +75,8 @@ public class WebServiceMessageReceiverObjectSupportTest { receiverSupport.handleConnection(connectionMock, receiver); - verify(connectionMock).receive(messageFactory); - } + verify(connectionMock).receive(messageFactory); + } @Test public void handleConnectionFaultResponse() throws Exception { @@ -103,7 +107,7 @@ public class WebServiceMessageReceiverObjectSupportTest { @Test public void handleConnectionNoResponse() throws Exception { - when(connectionMock.receive(messageFactory)).thenReturn(request); + when(connectionMock.receive(messageFactory)).thenReturn(request); connectionMock.close(); WebServiceMessageReceiver receiver = new WebServiceMessageReceiver() { @@ -121,4 +125,5 @@ public class WebServiceMessageReceiverObjectSupportTest { private static class MyReceiverSupport extends WebServiceMessageReceiverObjectSupport { } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11DefinitionTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11DefinitionTest.java index 2a67e331..f7f1ba97 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11DefinitionTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11DefinitionTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11; -import static org.xmlunit.assertj.XmlAssert.*; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -26,13 +24,16 @@ import javax.xml.transform.dom.DOMResult; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.xsd.SimpleXsdSchema; import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection; -import org.w3c.dom.Document; + +import static org.xmlunit.assertj.XmlAssert.assertThat; public class DefaultWsdl11DefinitionTest { @@ -146,4 +147,5 @@ public class DefaultWsdl11DefinitionTest { assertThat(result).and(expected).ignoreWhitespace().areIdentical(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/SimpleWsdl11DefinitionTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/SimpleWsdl11DefinitionTest.java index c38563d2..56cc8a38 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/SimpleWsdl11DefinitionTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/SimpleWsdl11DefinitionTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,13 @@ package org.springframework.ws.wsdl.wsdl11; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.io.ClassPathResource; +import static org.assertj.core.api.Assertions.assertThat; + public class SimpleWsdl11DefinitionTest { private SimpleWsdl11Definition definition; @@ -38,4 +39,5 @@ public class SimpleWsdl11DefinitionTest { public void testGetSource() { assertThat(definition.getSource()).isNotNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/Wsdl4jDefinitionTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/Wsdl4jDefinitionTest.java index b93efda7..048c4aec 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/Wsdl4jDefinitionTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/Wsdl4jDefinitionTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11; -import static org.assertj.core.api.Assertions.assertThat; - import java.io.InputStream; import javax.wsdl.Definition; @@ -31,12 +29,15 @@ import javax.xml.transform.dom.DOMResult; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.springframework.xml.transform.TransformerFactoryUtils; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xmlunit.assertj.XmlAssert; +import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.transform.TransformerFactoryUtils; + +import static org.assertj.core.api.Assertions.assertThat; + public class Wsdl4jDefinitionTest { private Wsdl4jDefinition definition; @@ -73,4 +74,5 @@ public class Wsdl4jDefinitionTest { XmlAssert.assertThat(result.getNode()).and(expected).ignoreWhitespace().areIdentical(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProviderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProviderTest.java index 1a325f3e..4e863471 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProviderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProviderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import static org.assertj.core.api.Assertions.*; - import javax.wsdl.Definition; import javax.wsdl.Message; import javax.wsdl.Part; @@ -30,11 +28,14 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.sax.SaxUtils; -import org.w3c.dom.Document; + +import static org.assertj.core.api.Assertions.assertThat; public class DefaultMessagesProviderTest { @@ -68,8 +69,8 @@ public class DefaultMessagesProviderTest { Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(resource)); Types types = definition.createTypes(); definition.setTypes(types); - Schema schema = (Schema) definition.getExtensionRegistry().createExtension(Types.class, - new QName("http://www.w3.org/2001/XMLSchema", "schema")); + Schema schema = (Schema) definition.getExtensionRegistry() + .createExtension(Types.class, new QName("http://www.w3.org/2001/XMLSchema", "schema")); types.addExtensibilityElement(schema); schema.setElement(schemaDocument.getDocumentElement()); @@ -104,4 +105,5 @@ public class DefaultMessagesProviderTest { assertThat(part).isNotNull(); assertThat(part.getElementName()).isEqualTo(new QName(schemaNamespace, "GetOrderFault")); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProviderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProviderTest.java index b765a267..359f3e9c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProviderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProviderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import static org.assertj.core.api.Assertions.*; - import javax.wsdl.Definition; import javax.wsdl.Types; import javax.wsdl.extensions.schema.Schema; @@ -25,11 +23,14 @@ import javax.wsdl.factory.WSDLFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.xml.xsd.SimpleXsdSchema; import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection; +import static org.assertj.core.api.Assertions.assertThat; + public class InliningXsdSchemaTypesProviderTest { private InliningXsdSchemaTypesProvider provider; @@ -102,4 +103,5 @@ public class InliningXsdSchemaTypesProviderTest { assertThat(wsdlSchema.getElement()).isNotNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11ProviderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11ProviderTest.java index 8f9b569b..ffa6af23 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11ProviderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11ProviderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import static org.assertj.core.api.Assertions.*; - import java.util.Properties; import javax.wsdl.Binding; @@ -45,6 +43,8 @@ import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class Soap11ProviderTest { private Soap11Provider provider; @@ -161,4 +161,5 @@ public class Soap11ProviderTest { assertThat(soapAddress.getLocationURI()).isEqualTo(locationUri); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12ProviderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12ProviderTest.java index 1737cea0..687c0d1d 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12ProviderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12ProviderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import static org.assertj.core.api.Assertions.*; - import java.util.Properties; import javax.wsdl.Binding; @@ -45,6 +43,8 @@ import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class Soap12ProviderTest { private Soap12Provider provider; @@ -160,4 +160,5 @@ public class Soap12ProviderTest { assertThat(soapAddress.getLocationURI()).isEqualTo(locationUri); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProviderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProviderTest.java index 994099ae..6e3edde5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProviderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProviderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import static org.assertj.core.api.Assertions.*; - import java.util.Properties; import javax.wsdl.Binding; @@ -36,6 +34,8 @@ import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class SoapProviderTest { private SoapProvider provider; @@ -112,4 +112,5 @@ public class SoapProviderTest { assertThat(port).isNotNull(); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedMessagesProviderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedMessagesProviderTest.java index ae22a390..95be78e5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedMessagesProviderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedMessagesProviderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import static org.assertj.core.api.Assertions.*; - import javax.wsdl.Definition; import javax.wsdl.Message; import javax.wsdl.Part; @@ -30,11 +28,14 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.sax.SaxUtils; -import org.w3c.dom.Document; + +import static org.assertj.core.api.Assertions.assertThat; public class SuffixBasedMessagesProviderTest { @@ -69,8 +70,8 @@ public class SuffixBasedMessagesProviderTest { Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(resource)); Types types = definition.createTypes(); definition.setTypes(types); - Schema schema = (Schema) definition.getExtensionRegistry().createExtension(Types.class, - new QName("http://www.w3.org/2001/XMLSchema", "schema")); + Schema schema = (Schema) definition.getExtensionRegistry() + .createExtension(Types.class, new QName("http://www.w3.org/2001/XMLSchema", "schema")); types.addExtensibilityElement(schema); schema.setElement(schemaDocument.getDocumentElement()); @@ -96,4 +97,5 @@ public class SuffixBasedMessagesProviderTest { assertThat(part).isNotNull(); assertThat(part.getElementName()).isEqualTo(new QName(schemaNamespace, "GetOrderResponse")); } + } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProviderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProviderTest.java index 58ccd66c..40a6e043 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProviderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProviderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import static org.assertj.core.api.Assertions.*; - import javax.wsdl.Definition; import javax.wsdl.Message; import javax.wsdl.Operation; @@ -28,6 +26,8 @@ import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class SuffixBasedPortTypesProviderTest { private SuffixBasedPortTypesProvider provider; @@ -75,4 +75,5 @@ public class SuffixBasedPortTypesProviderTest { assertThat(operation.getOutput()).isNotNull(); assertThat(operation.getFaults()).isNotEmpty(); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.java index 8fd34556..bb6c0bf3 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,6 +23,7 @@ import javax.xml.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.util.Assert; import org.springframework.ws.client.WebServiceClientException; import org.springframework.ws.client.support.interceptor.ClientInterceptor; @@ -37,14 +38,15 @@ import org.springframework.ws.soap.server.SoapEndpointInterceptor; import org.springframework.ws.soap.soap11.Soap11Body; /** - * Interceptor base class for interceptors that handle WS-Security. Can be used on the server side, registered in a + * Interceptor base class for interceptors that handle WS-Security. Can be used on the + * server side, registered in a * {@link org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping#setInterceptors(org.springframework.ws.server.EndpointInterceptor[]) * endpoint mapping}; or on the client side, on the - * {@link org.springframework.ws.client.core.WebServiceTemplate#setInterceptors(ClientInterceptor[]) web service - * template}. + * {@link org.springframework.ws.client.core.WebServiceTemplate#setInterceptors(ClientInterceptor[]) + * web service template}. *

- * Subclasses of this base class can be configured to secure incoming and secure outgoing messages. By default, both are - * on. + * Subclasses of this base class can be configured to secure incoming and secure outgoing + * messages. By default, both are on. * * @author Arjen Poutsma * @since 1.0.0 @@ -69,27 +71,41 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter private EndpointExceptionResolver exceptionResolver; - /** Indicates whether server-side incoming request are to be validated. Defaults to {@code true}. */ + /** + * Indicates whether server-side incoming request are to be validated. Defaults to + * {@code true}. + */ public void setValidateRequest(boolean validateRequest) { this.validateRequest = validateRequest; } - /** Indicates whether server-side outgoing responses are to be secured. Defaults to {@code true}. */ + /** + * Indicates whether server-side outgoing responses are to be secured. Defaults to + * {@code true}. + */ public void setSecureResponse(boolean secureResponse) { this.secureResponse = secureResponse; } - /** Indicates whether client-side outgoing requests are to be secured. Defaults to {@code true}. */ + /** + * Indicates whether client-side outgoing requests are to be secured. Defaults to + * {@code true}. + */ public void setSecureRequest(boolean secureRequest) { this.secureRequest = secureRequest; } - /** Indicates whether client-side incoming responses are to be validated. Defaults to {@code true}. */ + /** + * Indicates whether client-side incoming responses are to be validated. Defaults to + * {@code true}. + */ public void setValidateResponse(boolean validateResponse) { this.validateResponse = validateResponse; } - /** Provide an {@link EndpointExceptionResolver} for resolving validation exceptions. */ + /** + * Provide an {@link EndpointExceptionResolver} for resolving validation exceptions. + */ public void setExceptionResolver(EndpointExceptionResolver exceptionResolver) { this.exceptionResolver = exceptionResolver; } @@ -105,9 +121,9 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter /** * Validates a server-side incoming request. Delegates to - * {@link #validateMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext)} if - * the {@link #setValidateRequest(boolean) validateRequest} property is {@code true}. - * + * {@link #validateMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext)} + * if the {@link #setValidateRequest(boolean) validateRequest} property is + * {@code true}. * @param messageContext the message context, containing the request to be validated * @param endpoint chosen endpoint to invoke * @return {@code true} if the request was valid; {@code false} otherwise. @@ -118,27 +134,30 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter public final boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception { if (validateRequest) { Assert.isInstanceOf(SoapMessage.class, messageContext.getRequest()); - if (skipValidationIfNoHeaderPresent && !isSecurityHeaderPresent((SoapMessage) messageContext.getRequest())) { + if (skipValidationIfNoHeaderPresent + && !isSecurityHeaderPresent((SoapMessage) messageContext.getRequest())) { return true; } try { validateMessage((SoapMessage) messageContext.getRequest(), messageContext); return true; - } catch (WsSecurityValidationException ex) { + } + catch (WsSecurityValidationException ex) { return handleValidationException(ex, messageContext); - } catch (WsSecurityFaultException ex) { + } + catch (WsSecurityFaultException ex) { return handleFaultException(ex, messageContext); } - } else { + } + else { return true; } } /** * Secures a server-side outgoing response. Delegates to - * {@link #secureMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext)} if - * the {@link #setSecureResponse(boolean) secureResponse} property is {@code true}. - * + * {@link #secureMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext)} + * if the {@link #setSecureResponse(boolean) secureResponse} property is {@code true}. * @param messageContext the message context, containing the response to be secured * @param endpoint chosen endpoint to invoke * @return {@code true} if the response was secured; {@code false} otherwise. @@ -154,13 +173,16 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter Assert.isInstanceOf(SoapMessage.class, messageContext.getResponse()); try { secureMessage((SoapMessage) messageContext.getResponse(), messageContext); - } catch (WsSecuritySecurementException ex) { + } + catch (WsSecuritySecurementException ex) { result = handleSecurementException(ex, messageContext); - } catch (WsSecurityFaultException ex) { + } + catch (WsSecurityFaultException ex) { result = handleFaultException(ex, messageContext); } } - } finally { + } + finally { if (!result) { messageContext.clearResponse(); } @@ -190,9 +212,8 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter /** * Secures a client-side outgoing request. Delegates to - * {@link #secureMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext)} if - * the {@link #setSecureRequest(boolean) secureRequest} property is {@code true}. - * + * {@link #secureMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext)} + * if the {@link #setSecureRequest(boolean) secureRequest} property is {@code true}. * @param messageContext the message context, containing the request to be secured * @return {@code true} if the response was secured; {@code false} otherwise. * @throws Exception in case of errors @@ -205,21 +226,24 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter try { secureMessage((SoapMessage) messageContext.getRequest(), messageContext); return true; - } catch (WsSecuritySecurementException ex) { + } + catch (WsSecuritySecurementException ex) { return handleSecurementException(ex, messageContext); - } catch (WsSecurityFaultException ex) { + } + catch (WsSecurityFaultException ex) { return handleFaultException(ex, messageContext); } - } else { + } + else { return true; } } /** * Validates a client-side incoming response. Delegates to - * {@link #validateMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext)} if - * the {@link #setValidateResponse(boolean) validateResponse} property is {@code true}. - * + * {@link #validateMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext)} + * if the {@link #setValidateResponse(boolean) validateResponse} property is + * {@code true}. * @param messageContext the message context, containing the response to be validated * @return {@code true} if the request was valid; {@code false} otherwise. * @throws Exception in case of errors @@ -230,18 +254,22 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter if (validateResponse) { Assert.isTrue(messageContext.hasResponse(), "MessageContext contains no response"); Assert.isInstanceOf(SoapMessage.class, messageContext.getResponse()); - if (skipValidationIfNoHeaderPresent && !isSecurityHeaderPresent((SoapMessage) messageContext.getResponse())) { + if (skipValidationIfNoHeaderPresent + && !isSecurityHeaderPresent((SoapMessage) messageContext.getResponse())) { return true; } try { validateMessage((SoapMessage) messageContext.getResponse(), messageContext); return true; - } catch (WsSecurityValidationException ex) { + } + catch (WsSecurityValidationException ex) { return handleValidationException(ex, messageContext); - } catch (WsSecurityFaultException ex) { + } + catch (WsSecurityFaultException ex) { return handleFaultException(ex, messageContext); } - } else { + } + else { return true; } } @@ -258,11 +286,12 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter } /** - * Handles an securement exception. Default implementation logs the given exception, and returns {@code false}. - * + * Handles an securement exception. Default implementation logs the given exception, + * and returns {@code false}. * @param ex the validation exception * @param messageContext the message context - * @return {@code true} to continue processing the message, {@code false} (the default) otherwise + * @return {@code true} to continue processing the message, {@code false} (the + * default) otherwise */ protected boolean handleSecurementException(WsSecuritySecurementException ex, MessageContext messageContext) { if (logger.isErrorEnabled()) { @@ -272,13 +301,14 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter } /** - * Handles an invalid SOAP message. Default implementation logs the given exception, delegates to the set - * {@link #setExceptionResolver(EndpointExceptionResolver) exceptionResolver} if any, or creates a SOAP 1.1 Client or - * SOAP 1.2 Sender Fault with the exception message as fault string, and returns {@code false}. - * + * Handles an invalid SOAP message. Default implementation logs the given exception, + * delegates to the set {@link #setExceptionResolver(EndpointExceptionResolver) + * exceptionResolver} if any, or creates a SOAP 1.1 Client or SOAP 1.2 Sender Fault + * with the exception message as fault string, and returns {@code false}. * @param ex the validation exception * @param messageContext the message context - * @return {@code true} to continue processing the message, {@code false} (the default) otherwise + * @return {@code true} to continue processing the message, {@code false} (the + * default) otherwise */ protected boolean handleValidationException(WsSecurityValidationException ex, MessageContext messageContext) { if (logger.isWarnEnabled()) { @@ -286,7 +316,8 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter } if (exceptionResolver != null) { exceptionResolver.resolveException(messageContext, null, ex); - } else { + } + else { if (logger.isDebugEnabled()) { logger.debug("No exception resolver present, creating basic soap fault"); } @@ -297,12 +328,13 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter } /** - * Handles a fault exception.Default implementation logs the given exception, and creates a SOAP Fault with the - * properties of the given exception, and returns {@code false}. - * + * Handles a fault exception.Default implementation logs the given exception, and + * creates a SOAP Fault with the properties of the given exception, and returns + * {@code false}. * @param ex the validation exception * @param messageContext the message context - * @return {@code true} to continue processing the message, {@code false} (the default) otherwise + * @return {@code true} to continue processing the message, {@code false} (the + * default) otherwise */ protected boolean handleFaultException(WsSecurityFaultException ex, MessageContext messageContext) { if (logger.isWarnEnabled()) { @@ -312,7 +344,8 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter SoapFault fault; if (response instanceof Soap11Body) { fault = ((Soap11Body) response).addFault(ex.getFaultCode(), ex.getFaultString(), Locale.ENGLISH); - } else { + } + else { fault = response.addClientOrSenderFault(ex.getFaultString(), Locale.ENGLISH); } fault.setFaultActorOrRole(ex.getFaultActor()); @@ -320,9 +353,9 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter } /** - * Abstract template method. Subclasses are required to validate the request contained in the given - * {@link SoapMessage}, and replace the original request with the validated version. - * + * Abstract template method. Subclasses are required to validate the request contained + * in the given {@link SoapMessage}, and replace the original request with the + * validated version. * @param soapMessage the soap message to validate * @throws WsSecurityValidationException in case of validation errors */ @@ -330,9 +363,9 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter throws WsSecurityValidationException; /** - * Abstract template method. Subclasses are required to secure the response contained in the given - * {@link SoapMessage}, and replace the original response with the secured version. - * + * Abstract template method. Subclasses are required to secure the response contained + * in the given {@link SoapMessage}, and replace the original response with the + * secured version. * @param soapMessage the soap message to secure * @throws WsSecuritySecurementException in case of securement errors */ @@ -358,4 +391,5 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter } return false; } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityException.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityException.java index bddcfdcc..891c7d36 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityException.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,8 @@ package org.springframework.ws.soap.security; import org.springframework.ws.WebServiceException; /** - * Exception indicating that something went wrong during WS-Security executions. Has specific subclasses for securement - * and validation. + * Exception indicating that something went wrong during WS-Security executions. Has + * specific subclasses for securement and validation. * * @author Arjen Poutsma * @since 1.0.0 @@ -35,4 +35,5 @@ public abstract class WsSecurityException extends WebServiceException { public WsSecurityException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityFaultException.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityFaultException.java index 924ff135..6a699dfb 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityFaultException.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityFaultException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,7 +33,10 @@ public abstract class WsSecurityFaultException extends WsSecurityException { private String faultActor; - /** Construct a new {@code WsSecurityFaultException} with the given fault code, string, and actor. */ + /** + * Construct a new {@code WsSecurityFaultException} with the given fault code, string, + * and actor. + */ public WsSecurityFaultException(QName faultCode, String faultString, String faultActor) { super(faultString); this.faultCode = faultCode; @@ -55,4 +58,5 @@ public abstract class WsSecurityFaultException extends WsSecurityException { public String getFaultActor() { return faultActor; } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecuritySecurementException.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecuritySecurementException.java index 8e9c008b..c799f953 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecuritySecurementException.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecuritySecurementException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,9 @@ package org.springframework.ws.soap.security; /** * Exception indicating that something went wrong during the securement of a message. *

- * This is a checked exception since we want it to be caught, logged and handled rather than cause the application to - * fail. Failure to secure a message is usually not a fatal problem. + * This is a checked exception since we want it to be caught, logged and handled rather + * than cause the application to fail. Failure to secure a message is usually not a fatal + * problem. * * @author Arjen Poutsma * @since 1.0.0 @@ -35,4 +36,5 @@ public abstract class WsSecuritySecurementException extends WsSecurityException public WsSecuritySecurementException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityValidationException.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityValidationException.java index 460ff929..13d03456 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityValidationException.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/WsSecurityValidationException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,8 +19,9 @@ package org.springframework.ws.soap.security; /** * Exception indicating that something went wrong during the validation of a message. *

- * This is a checked exception since we want it to be caught, logged and handled rather than cause the application to - * fail. Failure to validate a message is usually not a fatal problem. + * This is a checked exception since we want it to be caught, logged and handled rather + * than cause the application to fail. Failure to validate a message is usually not a + * fatal problem. * * @author Arjen Poutsma * @since 1.0.0 @@ -35,4 +36,5 @@ public abstract class WsSecurityValidationException extends WsSecurityException public WsSecurityValidationException(String msg, Throwable ex) { super(msg, ex); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/AbstractCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/AbstractCallbackHandler.java index b2c7803e..fd392236 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/AbstractCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/AbstractCallbackHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,11 +36,12 @@ public abstract class AbstractCallbackHandler implements CallbackHandler { /** Logger available to subclasses. */ protected final Log logger = LogFactory.getLog(getClass()); - protected AbstractCallbackHandler() {} + protected AbstractCallbackHandler() { + } /** - * Iterates over the given callbacks, and calls {@code handleInternal} for each of them. - * + * Iterates over the given callbacks, and calls {@code handleInternal} for each of + * them. * @param callbacks the callbacks * @see #handleInternal(javax.security.auth.callback.Callback) */ @@ -53,4 +54,5 @@ public abstract class AbstractCallbackHandler implements CallbackHandler { /** Template method that should be implemented by subclasses. */ protected abstract void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException; + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/CallbackHandlerChain.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/CallbackHandlerChain.java index 314642ea..fa07431f 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/CallbackHandlerChain.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/CallbackHandlerChain.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,9 @@ import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; /** - * Represents a chain of {@code CallbackHandler}s. For each callback, each of the handlers is called in term. If a - * handler throws a {@code UnsupportedCallbackException}, the next handler is tried. + * Represents a chain of {@code CallbackHandler}s. For each callback, each of the handlers + * is called in term. If a handler throws a {@code UnsupportedCallbackException}, the next + * handler is tried. * * @author Arjen Poutsma * @since 1.5.0 @@ -48,7 +49,8 @@ public class CallbackHandlerChain extends AbstractCallbackHandler { try { callbackHandler.handle(new Callback[] { callback }); allUnsupported = false; - } catch (UnsupportedCallbackException ex) { + } + catch (UnsupportedCallbackException ex) { // if an UnsupportedCallbackException occurs, go to the next handler } } @@ -56,4 +58,5 @@ public class CallbackHandlerChain extends AbstractCallbackHandler { throw new UnsupportedCallbackException(callback); } } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/CleanupCallback.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/CleanupCallback.java index 3a9a31f4..3c7afc80 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/CleanupCallback.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/callback/CleanupCallback.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,8 @@ import java.io.Serializable; import javax.security.auth.callback.Callback; /** - * Underlying security services instantiate and pass a {@code CleanupCallback} to the {@code handle} method of a - * {@code CallbackHandler} to clean up security state. + * Underlying security services instantiate and pass a {@code CleanupCallback} to the + * {@code handle} method of a {@code CallbackHandler} to clean up security state. * * @author Arjen Poutsma * @since 1.0.4 diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyManagersFactoryBean.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyManagersFactoryBean.java index bfed9f09..2ee401b0 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyManagersFactoryBean.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyManagersFactoryBean.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -49,8 +49,8 @@ public class KeyManagersFactoryBean implements FactoryBean, Initia private char[] password; /** - * Sets the password to use for integrity checking. If this property is not set, then integrity checking is not - * performed. + * Sets the password to use for integrity checking. If this property is not set, then + * integrity checking is not performed. */ public void setPassword(String password) { if (password != null) { @@ -59,15 +59,16 @@ public class KeyManagersFactoryBean implements FactoryBean, Initia } /** - * Sets the provider of the key manager to use. If this is not set, the default is used. + * Sets the provider of the key manager to use. If this is not set, the default is + * used. */ public void setProvider(String provider) { this.provider = provider; } /** - * Sets the algorithm of the {@code KeyManager} to use. If this is not set, the default is used. - * + * Sets the algorithm of the {@code KeyManager} to use. If this is not set, the + * default is used. * @see KeyManagerFactory#getDefaultAlgorithm() */ public void setAlgorithm(String algorithm) { @@ -76,7 +77,6 @@ public class KeyManagersFactoryBean implements FactoryBean, Initia /** * Sets the source of key material. - * * @see KeyManagerFactory#init(KeyStore, char[]) */ public void setKeyStore(KeyStore keyStore) { @@ -100,14 +100,15 @@ public class KeyManagersFactoryBean implements FactoryBean, Initia @Override public void afterPropertiesSet() throws Exception { - String algorithm = StringUtils.hasLength(this.algorithm) ? this.algorithm : KeyManagerFactory.getDefaultAlgorithm(); + String algorithm = StringUtils.hasLength(this.algorithm) ? this.algorithm + : KeyManagerFactory.getDefaultAlgorithm(); KeyManagerFactory keyManagerFactory = StringUtils.hasLength(this.provider) - ? KeyManagerFactory.getInstance(algorithm, this.provider) - : KeyManagerFactory.getInstance(algorithm); + ? KeyManagerFactory.getInstance(algorithm, this.provider) : KeyManagerFactory.getInstance(algorithm); keyManagerFactory.init(keyStore, password); this.keyManagers = keyManagerFactory.getKeyManagers(); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreFactoryBean.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreFactoryBean.java index 60b9c66f..f183d855 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreFactoryBean.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreFactoryBean.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,6 +23,7 @@ import java.security.KeyStore; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; @@ -31,8 +32,9 @@ import org.springframework.util.StringUtils; /** * Spring factory bean for a {@link KeyStore}. *

- * To load an existing key store, you must set the {@code location} property. If this property is not set, a new, empty - * key store is created, which is most likely not what you want. + * To load an existing key store, you must set the {@code location} property. If this + * property is not set, a new, empty key store is created, which is most likely not what + * you want. * * @author Arjen Poutsma * @see #setLocation(org.springframework.core.io.Resource) @@ -54,8 +56,8 @@ public class KeyStoreFactoryBean implements FactoryBean, InitializingB private char[] password; /** - * Sets the location of the key store to use. If this is not set, a new, empty key store will be used. - * + * Sets the location of the key store to use. If this is not set, a new, empty key + * store will be used. * @see KeyStore#load(java.io.InputStream,char[]) */ public void setLocation(Resource location) { @@ -63,8 +65,8 @@ public class KeyStoreFactoryBean implements FactoryBean, InitializingB } /** - * Sets the password to use for integrity checking. If this property is not set, then integrity checking is not - * performed. + * Sets the password to use for integrity checking. If this property is not set, then + * integrity checking is not performed. */ public void setPassword(String password) { if (password != null) { @@ -72,14 +74,16 @@ public class KeyStoreFactoryBean implements FactoryBean, InitializingB } } - /** Sets the provider of the key store to use. If this is not set, the default is used. */ + /** + * Sets the provider of the key store to use. If this is not set, the default is used. + */ public void setProvider(String provider) { this.provider = provider; } /** - * Sets the type of the {@code KeyStore} to use. If this is not set, the default is used. - * + * Sets the type of the {@code KeyStore} to use. If this is not set, the default is + * used. * @see KeyStore#getDefaultType() */ public void setType(String type) { @@ -105,9 +109,11 @@ public class KeyStoreFactoryBean implements FactoryBean, InitializingB public final void afterPropertiesSet() throws GeneralSecurityException, IOException { if (StringUtils.hasLength(provider) && StringUtils.hasLength(type)) { keyStore = KeyStore.getInstance(type, provider); - } else if (StringUtils.hasLength(type)) { + } + else if (StringUtils.hasLength(type)) { keyStore = KeyStore.getInstance(type); - } else { + } + else { keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); } InputStream is = null; @@ -117,14 +123,17 @@ public class KeyStoreFactoryBean implements FactoryBean, InitializingB if (logger.isInfoEnabled()) { logger.info("Loading key store from " + location); } - } else if (logger.isWarnEnabled()) { + } + else if (logger.isWarnEnabled()) { logger.warn("Creating empty key store"); } keyStore.load(is, password); - } finally { + } + finally { if (is != null) { is.close(); } } } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreUtils.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreUtils.java index d642af56..e47973d1 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreUtils.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,17 +34,18 @@ import org.springframework.util.StringUtils; public abstract class KeyStoreUtils { /** - * Loads the key store indicated by system properties. This method tries to load a key store by consulting the - * following system properties:{@code javax.net.ssl.keyStore}, {@code javax.net.ssl.keyStorePassword}, and - * {@code javax.net.ssl.keyStoreType}. + * Loads the key store indicated by system properties. This method tries to load a key + * store by consulting the following system properties:{@code javax.net.ssl.keyStore}, + * {@code javax.net.ssl.keyStorePassword}, and {@code javax.net.ssl.keyStoreType}. *

- * If these properties specify a file with an appropriate password, the factory uses this file for the key store. If - * that file does not exist, then a default, empty keystore is created. + * If these properties specify a file with an appropriate password, the factory uses + * this file for the key store. If that file does not exist, then a default, empty + * keystore is created. *

* This behavior corresponds to the standard J2SDK behavior for SSL key stores. - * - * @see The - * standard J2SDK SSL key store mechanism + * @see The + * standard J2SDK SSL key store mechanism */ public static KeyStore loadDefaultKeyStore() throws GeneralSecurityException, IOException { Resource location = null; @@ -74,21 +75,24 @@ public abstract class KeyStoreUtils { /** * Loads a default trust store. This method uses the following algorithm: *

    - *
  1. If the system property {@code javax.net.ssl.trustStore} is defined, its value is loaded. If the - * {@code javax.net.ssl.trustStorePassword} system property is also defined, its value is used as a password. If the - * {@code javax.net.ssl.trustStoreType} system property is defined, its value is used as a key store type. + *
  2. If the system property {@code javax.net.ssl.trustStore} is defined, its value + * is loaded. If the {@code javax.net.ssl.trustStorePassword} system property is also + * defined, its value is used as a password. If the + * {@code javax.net.ssl.trustStoreType} system property is defined, its value is used + * as a key store type. *

    - * If {@code javax.net.ssl.trustStore} is defined but the specified file does not exist, then a default, empty trust - * store is created.

  3. - *
  4. If the {@code javax.net.ssl.trustStore} system property was not specified, but if the file - * {@code $JAVA_HOME/lib/security/jssecacerts} exists, that file is used.
  5. Otherwise, + * If {@code javax.net.ssl.trustStore} is defined but the specified file does not + * exist, then a default, empty trust store is created. + *
  6. If the {@code javax.net.ssl.trustStore} system property was not specified, but + * if the file {@code $JAVA_HOME/lib/security/jssecacerts} exists, that file is + * used.
  7. Otherwise, *
  8. If the file {@code $JAVA_HOME/lib/security/cacerts} exists, that file is used. *
*

* This behavior corresponds to the standard J2SDK behavior for SSL trust stores. - * - * @see The - * standard J2SDK SSL trust store mechanism + * @see The + * standard J2SDK SSL trust store mechanism */ public static KeyStore loadDefaultTrustStore() throws GeneralSecurityException, IOException { Resource location = null; @@ -105,7 +109,8 @@ public abstract class KeyStoreUtils { password = passwordProperty; } type = System.getProperty("javax.net.ssl.trustStoreType"); - } else { + } + else { String javaHome = System.getProperty("java.home"); location = new FileSystemResource(javaHome + "/lib/security/jssecacerts"); if (!location.exists()) { diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/SpringSecurityUtils.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/SpringSecurityUtils.java index 220fa85a..00d51cfe 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/SpringSecurityUtils.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/SpringSecurityUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,7 +32,6 @@ public abstract class SpringSecurityUtils { /** * Checks the validity of a user's account and credentials. - * * @param user the user to check * @throws AccountExpiredException if the account has expired * @throws CredentialsExpiredException if the credentials have expired @@ -57,4 +56,5 @@ public abstract class SpringSecurityUtils { throw new CredentialsExpiredException("Credentials for user '" + user + "' have expired"); } } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/TrustManagersFactoryBean.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/TrustManagersFactoryBean.java index 2c6c68bf..cbba66d7 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/TrustManagersFactoryBean.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/support/TrustManagersFactoryBean.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -46,15 +46,16 @@ public class TrustManagersFactoryBean implements FactoryBean, In private String provider; /** - * Sets the provider of the trust manager to use. If this is not set, the default is used. + * Sets the provider of the trust manager to use. If this is not set, the default is + * used. */ public void setProvider(String provider) { this.provider = provider; } /** - * Sets the algorithm of the {@code TrustManager} to use. If this is not set, the default is used. - * + * Sets the algorithm of the {@code TrustManager} to use. If this is not set, the + * default is used. * @see TrustManagerFactory#getDefaultAlgorithm() */ public void setAlgorithm(String algorithm) { @@ -63,7 +64,6 @@ public class TrustManagersFactoryBean implements FactoryBean, In /** * Sets the source of certificate authorities and related trust material. - * * @see TrustManagerFactory#init(KeyStore) */ public void setKeyStore(KeyStore keyStore) { @@ -98,4 +98,5 @@ public class TrustManagersFactoryBean implements FactoryBean, In this.trustManagers = trustManagerFactory.getTrustManagers(); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jHandler.java index f8018ebc..0238a21b 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor.SECUREMENT_PASSWORD_PROPERTY_NAME; - import java.util.List; import java.util.Properties; @@ -28,9 +26,12 @@ import org.apache.wss4j.dom.engine.WSSecurityEngineResult; import org.apache.wss4j.dom.handler.HandlerAction; import org.apache.wss4j.dom.handler.RequestData; import org.apache.wss4j.dom.handler.WSHandler; +import org.w3c.dom.Document; + import org.springframework.util.StringUtils; import org.springframework.ws.context.MessageContext; -import org.w3c.dom.Document; + +import static org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor.SECUREMENT_PASSWORD_PROPERTY_NAME; /** * @author Tareq Abed Rabbo @@ -94,7 +95,7 @@ class Wss4jHandler extends WSHandler { @Override public String getPassword(Object msgContext) { - String contextPassword = (String)getProperty(msgContext, SECUREMENT_PASSWORD_PROPERTY_NAME); + String contextPassword = (String) getProperty(msgContext, SECUREMENT_PASSWORD_PROPERTY_NAME); if (StringUtils.hasLength(contextPassword)) { return contextPassword; } @@ -125,4 +126,5 @@ class Wss4jHandler extends WSHandler { public void setProperty(Object msgContext, String key, Object value) { ((MessageContext) msgContext).setProperty(key, value); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityFaultException.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityFaultException.java index 5727b40e..a726be59 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityFaultException.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityFaultException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public class Wss4jSecurityFaultException extends WsSecurityFaultException { public Wss4jSecurityFaultException(QName faultCode, String faultString, String faultActor) { super(faultCode, faultString, faultActor); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java index 3b457cf4..2229e4c8 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -44,6 +44,9 @@ import org.apache.wss4j.dom.util.WSSecurityUtil; import org.apache.wss4j.dom.validate.Credential; import org.apache.wss4j.dom.validate.SignatureTrustValidator; import org.apache.wss4j.dom.validate.TimestampValidator; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; @@ -56,16 +59,16 @@ import org.springframework.ws.soap.security.WsSecurityValidationException; import org.springframework.ws.soap.security.callback.CallbackHandlerChain; import org.springframework.ws.soap.security.callback.CleanupCallback; import org.springframework.ws.soap.security.wss4j2.callback.UsernameTokenPrincipalCallback; -import org.w3c.dom.Document; -import org.w3c.dom.Element; /** - * A WS-Security endpoint interceptor based on Apache's WSS4J. This interceptor supports messages created by the + * A WS-Security endpoint interceptor based on Apache's WSS4J. This interceptor supports + * messages created by the * {@link org.springframework.ws.soap.axiom.AxiomSoapMessageFactory} and the * {@link org.springframework.ws.soap.saaj.SaajSoapMessageFactory}. *

- * The validation and securement actions executed by this interceptor are configured via {@code validationActions} and - * {@code securementActions} properties, respectively. Actions should be passed as a space-separated strings. + * The validation and securement actions executed by this interceptor are configured via + * {@code validationActions} and {@code securementActions} properties, respectively. + * Actions should be passed as a space-separated strings. *

* Valid validation actions are:

*
@@ -129,8 +132,8 @@ import org.w3c.dom.Element; *
*
*

- * The order of the actions that the client performed to secure the messages is significant and is enforced by the - * interceptor. + * The order of the actions that the client performed to secure the messages is + * significant and is enforced by the interceptor. * * @author Tareq Abed Rabbo * @author Arjen Poutsma @@ -144,7 +147,7 @@ import org.w3c.dom.Element; public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor implements InitializingBean { public static final String SECUREMENT_USER_PROPERTY_NAME = "Wss4jSecurityInterceptor.securementUser"; - + public static final String SECUREMENT_PASSWORD_PROPERTY_NAME = "Wss4jSecurityInterceptor.securementPassword"; private String securementActions; @@ -184,6 +187,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl private boolean bspCompliant; private boolean addInclusivePrefixes = true; + private boolean securementUseDerivedKey; private CallbackHandler samlCallbackHandler; @@ -203,7 +207,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Inject a customize {@link WSSecurityEngine}. - * * @param securityEngine */ public Wss4jSecurityInterceptor(WSSecurityEngine securityEngine) { @@ -219,7 +222,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl *

* If this parameter is omitted, the actor name is not set. *

- * The value of the actor or role has to match the receiver's setting or may contain standard values. + * The value of the actor or role has to match the receiver's setting or may contain + * standard values. */ public void setSecurementActor(String securementActor) { handler.setOption(WSHandlerConstants.ACTOR, securementActor); @@ -230,10 +234,12 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Defines which key identifier type to use. The WS-Security specifications recommends to use the identifier type - * {@code IssuerSerial}. For possible encryption key identifier types refer to - * {@link org.apache.ws.security.handler.WSHandlerConstants#keyIdentifier}. For encryption {@code IssuerSerial}, - * {@code X509KeyIdentifier}, {@code DirectReference}, {@code Thumbprint}, {@code SKIKeyIdentifier}, and + * Defines which key identifier type to use. The WS-Security specifications recommends + * to use the identifier type {@code IssuerSerial}. For possible encryption key + * identifier types refer to + * {@link org.apache.ws.security.handler.WSHandlerConstants#keyIdentifier}. For + * encryption {@code IssuerSerial}, {@code X509KeyIdentifier}, + * {@code DirectReference}, {@code Thumbprint}, {@code SKIKeyIdentifier}, and * {@code EmbeddedKeyName} are valid only. */ public void setSecurementEncryptionKeyIdentifier(String securementEncryptionKeyIdentifier) { @@ -241,8 +247,9 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Defines which algorithm to use to encrypt the generated symmetric key. Currently WSS4J supports - * {@link WSConstants#KEYTRANSPORT_RSA15} and {@link WSConstants#KEYTRANSPORT_RSAOEP}. + * Defines which algorithm to use to encrypt the generated symmetric key. Currently + * WSS4J supports {@link WSConstants#KEYTRANSPORT_RSA15} and + * {@link WSConstants#KEYTRANSPORT_RSAOEP}. */ public void setSecurementEncryptionKeyTransportAlgorithm(String securementEncryptionKeyTransportAlgorithm) { handler.setOption(WSHandlerConstants.ENC_KEY_TRANSPORT, securementEncryptionKeyTransportAlgorithm); @@ -251,13 +258,15 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Property to define which parts of the request shall be encrypted. *

- * The value of this property is a list of semicolon separated element names that identify the elements to encrypt. An - * encryption mode specifier and a namespace identification, each inside a pair of curly brackets, may precede each - * element name. + * The value of this property is a list of semicolon separated element names that + * identify the elements to encrypt. An encryption mode specifier and a namespace + * identification, each inside a pair of curly brackets, may precede each element + * name. *

- * The encryption mode specifier is either {@code {Content}} or {@code {Element}}. Please refer to the W3C XML - * Encryption specification about the differences between Element and Content encryption. The encryption mode defaults - * to {@code Content} if it is omitted. Example of a list: + * The encryption mode specifier is either {@code {Content}} or {@code {Element}}. + * Please refer to the W3C XML Encryption specification about the differences between + * Element and Content encryption. The encryption mode defaults to {@code Content} if + * it is omitted. Example of a list: * *

 	 * <property name="securementEncryptionParts"
@@ -265,31 +274,35 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl
 	 *			   {Element}{}UserName" />
 	 * 
* - * The first entry of the list identifies the element {@code CreditCard} in the namespace - * {@code http://example.org/paymentv2}, and will encrypt its content. Be aware that the element name, the namespace - * identifier, and the encryption modifier are case sensitive. + * The first entry of the list identifies the element {@code CreditCard} in the + * namespace {@code http://example.org/paymentv2}, and will encrypt its content. Be + * aware that the element name, the namespace identifier, and the encryption modifier + * are case sensitive. *

- * The encryption modifier and the namespace identifier can be omitted. In this case the encryption mode defaults to - * {@code Content} and the namespace is set to the SOAP namespace. - *

- * An empty encryption mode defaults to {@code Content}, an empty namespace identifier defaults to the SOAP namespace. - * The second line of the example defines {@code Element} as encryption mode for an {@code UserName} element in the + * The encryption modifier and the namespace identifier can be omitted. In this case + * the encryption mode defaults to {@code Content} and the namespace is set to the * SOAP namespace. *

- * To specify an element without a namespace use the string {@code Null} as the namespace name (this is a case - * sensitive string) + * An empty encryption mode defaults to {@code Content}, an empty namespace identifier + * defaults to the SOAP namespace. The second line of the example defines + * {@code Element} as encryption mode for an {@code UserName} element in the SOAP + * namespace. *

- * If no list is specified, the handler encrypts the SOAP Body in {@code Content} mode by default. + * To specify an element without a namespace use the string {@code Null} as the + * namespace name (this is a case sensitive string) + *

+ * If no list is specified, the handler encrypts the SOAP Body in {@code Content} mode + * by default. */ public void setSecurementEncryptionParts(String securementEncryptionParts) { handler.setOption(WSHandlerConstants.ENCRYPTION_PARTS, securementEncryptionParts); } /** - * Defines which symmetric encryption algorithm to use. WSS4J supports the following alorithms: - * {@link WSConstants#TRIPLE_DES}, {@link WSConstants#AES_128}, {@link WSConstants#AES_256}, and - * {@link WSConstants#AES_192}. Except for AES 192 all of these algorithms are required by the XML Encryption - * specification. + * Defines which symmetric encryption algorithm to use. WSS4J supports the following + * alorithms: {@link WSConstants#TRIPLE_DES}, {@link WSConstants#AES_128}, + * {@link WSConstants#AES_256}, and {@link WSConstants#AES_192}. Except for AES 192 + * all of these algorithms are required by the XML Encryption specification. */ public void setSecurementEncryptionSymAlgorithm(String securementEncryptionSymAlgorithm) { this.handler.setOption(WSHandlerConstants.ENC_SYM_ALGO, securementEncryptionSymAlgorithm); @@ -298,19 +311,24 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * The user's name for encryption. *

- * The encryption functions uses the public key of this user's certificate to encrypt the generated symmetric key. + * The encryption functions uses the public key of this user's certificate to encrypt + * the generated symmetric key. *

* If this parameter is not set, then the encryption function falls back to the - * {@link org.apache.ws.security.handler.WSHandlerConstants#USER} parameter to get the certificate. + * {@link org.apache.ws.security.handler.WSHandlerConstants#USER} parameter to get the + * certificate. *

- * If only encryption of the SOAP body data is requested, it is recommended to use this parameter to define the - * username. The application can then use the standard user and password functions (see example at - * {@link org.apache.ws.security.handler.WSHandlerConstants#USER} to enable HTTP authentication functions. + * If only encryption of the SOAP body data is requested, it is recommended to + * use this parameter to define the username. The application can then use the + * standard user and password functions (see example at + * {@link org.apache.ws.security.handler.WSHandlerConstants#USER} to enable HTTP + * authentication functions. *

- * Encryption only does not authenticate a user / sender, therefore it does not need a password. + * Encryption only does not authenticate a user / sender, therefore it does not need a + * password. *

- * Placing the username of the encryption certificate in the configuration file is not a security risk, because the - * public key of that certificate is used only. + * Placing the username of the encryption certificate in the configuration file is not + * a security risk, because the public key of that certificate is used only. */ public void setSecurementEncryptionUser(String securementEncryptionUser) { handler.setOption(WSHandlerConstants.ENCRYPTION_USER, securementEncryptionUser); @@ -323,7 +341,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Specific parameter for UsernameToken action to define the encoding of the passowrd. *

- * The parameter can be set to either {@link WSConstants#PW_DIGEST} or to {@link WSConstants#PW_TEXT}. + * The parameter can be set to either {@link WSConstants#PW_DIGEST} or to + * {@link WSConstants#PW_TEXT}. *

* The default setting is PW_DIGEST. */ @@ -333,7 +352,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Defines which signature algorithm to use. - * * @see WSConstants#RSA * @see WSConstants#DSA */ @@ -353,10 +371,11 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Defines which key identifier type to use. The WS-Security specifications recommends to use the identifier type - * {@code IssuerSerial}. For possible signature key identifier types refer to - * {@link org.apache.ws.security.handler.WSHandlerConstants#keyIdentifier}. For signature {@code IssuerSerial} and - * {@code DirectReference} are valid only. + * Defines which key identifier type to use. The WS-Security specifications recommends + * to use the identifier type {@code IssuerSerial}. For possible signature key + * identifier types refer to + * {@link org.apache.ws.security.handler.WSHandlerConstants#keyIdentifier}. For + * signature {@code IssuerSerial} and {@code DirectReference} are valid only. */ public void setSecurementSignatureKeyIdentifier(String securementSignatureKeyIdentifier) { handler.setOption(WSHandlerConstants.SIG_KEY_ID, securementSignatureKeyIdentifier); @@ -365,27 +384,28 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Property to define which parts of the request shall be signed. *

- * Refer to {@link #setSecurementEncryptionParts(String)} for a detailed description of the format of the value - * string. + * Refer to {@link #setSecurementEncryptionParts(String)} for a detailed description + * of the format of the value string. *

* If this property is not specified the handler signs the SOAP Body by default. *

- * The WS Security specifications define several formats to transfer the signature tokens (certificates) or references - * to these tokens. Thus, the plain element name {@code Token} signs the token and takes care of the different - * formats. + * The WS Security specifications define several formats to transfer the signature + * tokens (certificates) or references to these tokens. Thus, the plain element name + * {@code Token} signs the token and takes care of the different formats. *

- * To sign the SOAP body and the signature token the value of this parameter must contain: + * To sign the SOAP body and the signature token the value of this parameter + * must contain: * *

 	 * <property name="securementSignatureParts"
 	 *	 value="{}{http://schemas.xmlsoap.org/soap/envelope/}Body; Token" />
 	 * 
* - * To specify an element without a namespace use the string {@code Null} as the namespace name (this is a case - * sensitive string) + * To specify an element without a namespace use the string {@code Null} as the + * namespace name (this is a case sensitive string) *

- * If there is no other element in the request with a local name of {@code Body} then the SOAP namespace identifier - * can be empty ({@code {}}). + * If there is no other element in the request with a local name of {@code Body} then + * the SOAP namespace identifier can be empty ({@code {}}). */ public void setSecurementSignatureParts(String securementSignatureParts) { handler.setOption(WSHandlerConstants.SIGNATURE_PARTS, securementSignatureParts); @@ -394,16 +414,20 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * The user's name for signature. *

- * This name is used as the alias name in the keystore to get user's certificate and private key to perform signing. + * This name is used as the alias name in the keystore to get user's certificate and + * private key to perform signing. *

- * If this parameter is not set, then the signature function falls back to the alias specified by - * {@link #setSecurementUsername(String)}. + * If this parameter is not set, then the signature function falls back to the alias + * specified by {@link #setSecurementUsername(String)}. */ public void setSecurementSignatureUser(String securementSignatureUser) { handler.setOption(WSHandlerConstants.SIGNATURE_USER, securementSignatureUser); } - /** Sets the username for securement username token or/and the alias of the private key for securement signature */ + /** + * Sets the username for securement username token or/and the alias of the private key + * for securement signature + */ public void setSecurementUsername(String securementUsername) { this.securementUsername = securementUsername; } @@ -418,7 +442,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Enables the derivation of keys as per the UsernameTokenProfile 1.1 spec. Default is {@code true}. + * Enables the derivation of keys as per the UsernameTokenProfile 1.1 spec. Default is + * {@code true}. */ public void setSecurementUseDerivedKey(boolean securementUseDerivedKey) { this.securementUseDerivedKey = securementUseDerivedKey; @@ -426,7 +451,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Sets the SAML Callback used for generating SAML tokens. - * * @param samlCallback */ public void setSecurementSamlCallbackHandler(CallbackHandler samlCallbackHandler) { @@ -448,7 +472,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl this.validationActions = actions; try { validationActionsVector = WSSecurityUtil.decodeAction(actions); - } catch (WSSecurityException ex) { + } + catch (WSSecurityException ex) { throw new IllegalArgumentException(ex); } } @@ -459,7 +484,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Sets the {@link CallbackHandler} to use when validating messages. - * * @see #setValidationCallbackHandlers(CallbackHandler[]) */ public void setValidationCallbackHandler(CallbackHandler callbackHandler) { @@ -468,7 +492,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Sets the {@link CallbackHandler}s to use when validating messages. - * * @see #setValidationCallbackHandler(CallbackHandler) */ public void setValidationCallbackHandlers(CallbackHandler[] callbackHandler) { @@ -485,7 +508,10 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl this.validationSignatureCrypto = signatureCrypto; } - /** Whether to enable signatureConfirmation or not. By default signatureConfirmation is enabled */ + /** + * Whether to enable signatureConfirmation or not. By default signatureConfirmation is + * enabled + */ public void setEnableSignatureConfirmation(boolean enableSignatureConfirmation) { handler.setOption(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, enableSignatureConfirmation); @@ -497,27 +523,33 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl handler.setOption(WSHandlerConstants.TIMESTAMP_PRECISION, timestampPrecisionInMilliseconds); } - /** Sets whether or not timestamp verification is done with the server-side time to live */ + /** + * Sets whether or not timestamp verification is done with the server-side time to + * live + */ public void setTimestampStrict(boolean timestampStrict) { this.timestampStrict = timestampStrict; } /** - * Enables the {@code mustUnderstand} attribute on WS-Security headers on outgoing messages. Default is {@code true}. + * Enables the {@code mustUnderstand} attribute on WS-Security headers on outgoing + * messages. Default is {@code true}. */ public void setSecurementMustUnderstand(boolean securementMustUnderstand) { handler.setOption(WSHandlerConstants.MUST_UNDERSTAND, securementMustUnderstand); } /** - * Sets whether or not a {@code Nonce} element is added to the {@code UsernameToken}s. Default is {@code false}. + * Sets whether or not a {@code Nonce} element is added to the {@code UsernameToken}s. + * Default is {@code false}. */ public void setSecurementUsernameTokenNonce(boolean securementUsernameTokenNonce) { handler.setOption(ConfigurationConstants.ADD_USERNAMETOKEN_NONCE, securementUsernameTokenNonce); } /** - * Sets whether or not a {@code Created} element is added to the {@code UsernameToken}s. Default is {@code false}. + * Sets whether or not a {@code Created} element is added to the + * {@code UsernameToken}s. Default is {@code false}. */ public void setSecurementUsernameTokenCreated(boolean securementUsernameTokenCreated) { handler.setOption(ConfigurationConstants.ADD_USERNAMETOKEN_CREATED, securementUsernameTokenCreated); @@ -526,9 +558,10 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Sets the web service specification settings. *

- * The default settings follow the latest OASIS and changing anything might violate the OASIS specs. - * - * @param config web service security configuration or {@code null} to use default settings + * The default settings follow the latest OASIS and changing anything might violate + * the OASIS specs. + * @param config web service security configuration or {@code null} to use default + * settings */ public void setWssConfig(WSSConfig config) { @@ -553,8 +586,9 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Sets whether to add an InclusiveNamespaces PrefixList as a CanonicalizationMethod child when generating Signatures - * using WSConstants.C14N_EXCL_OMIT_COMMENTS. Default is {@code true}. + * Sets whether to add an InclusiveNamespaces PrefixList as a CanonicalizationMethod + * child when generating Signatures using WSConstants.C14N_EXCL_OMIT_COMMENTS. Default + * is {@code true}. */ public void setAddInclusivePrefixes(boolean addInclusivePrefixes) { @@ -570,8 +604,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Sets the time in seconds in the future within which the Created time of an incoming Timestamp is valid. The default - * is 60 seconds. + * Sets the time in seconds in the future within which the Created time of an incoming + * Timestamp is valid. The default is 60 seconds. */ public void setFutureTimeToLive(int futureTimeToLive) { @@ -614,7 +648,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl List securementActionsVector = new ArrayList(); try { securementActionsVector = WSSecurityUtil.decodeHandlerAction(securementActions, wssConfig); - } catch (WSSecurityException ex) { + } + catch (WSSecurityException ex) { throw new Wss4jSecuritySecurementException(ex.getMessage(), ex); } @@ -629,7 +664,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl Document envelopeAsDocument = soapMessage.getDocument(); try { handler.doSenderAction(envelopeAsDocument, requestData, securementActionsVector, false); - } catch (WSSecurityException ex) { + } + catch (WSSecurityException ex) { throw new Wss4jSecuritySecurementException(ex.getMessage(), ex); } @@ -638,7 +674,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Creates and initializes a request data for the given message context. - * * @param messageContext the message context * @return the request data */ @@ -651,7 +686,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl String contextUsername = (String) messageContext.getProperty(SECUREMENT_USER_PROPERTY_NAME); if (StringUtils.hasLength(contextUsername)) { requestData.setUsername(contextUsername); - } else { + } + else { requestData.setUsername(securementUsername); } @@ -675,7 +711,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Creates and initializes a request data for the given message context. - * * @param messageContext the message context * @return the request data */ @@ -756,7 +791,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl verifyTimestamp(result); processPrincipal(result); - } catch (WSSecurityException ex) { + } + catch (WSSecurityException ex) { throw new Wss4jSecurityValidationException(ex.getMessage(), ex); } @@ -768,9 +804,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Checks whether the received headers match the configured validation actions. Subclasses could override this method - * for custom verification behavior. - * + * Checks whether the received headers match the configured validation actions. + * Subclasses could override this method for custom verification behavior. * @param results the results of the validation function * @param validationActions the decoded validation actions * @throws Wss4jSecurityValidationException if the results are deemed invalid @@ -784,27 +819,26 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Puts the results of WS-Security headers processing in the message context. Some actions like Signature Confirmation - * require this. + * Puts the results of WS-Security headers processing in the message context. Some + * actions like Signature Confirmation require this. */ @SuppressWarnings("unchecked") private void updateContextWithResults(MessageContext messageContext, List results) { List handlerResults; if ((handlerResults = (List) messageContext - .getProperty(WSHandlerConstants.RECV_RESULTS)) == null) { + .getProperty(WSHandlerConstants.RECV_RESULTS)) == null) { handlerResults = new ArrayList(); messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults); } WSHandlerResult rResult = new WSHandlerResult(validationActor, results, - Collections.> emptyMap()); + Collections.>emptyMap()); handlerResults.add(0, rResult); messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults); } /** * Verifies the trust of a certificate. - * * @param result */ protected void verifyCertificateTrust(WSHandlerResult result) throws WSSecurityException { @@ -813,7 +847,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl if (!CollectionUtils.isEmpty(results)) { WSSecurityEngineResult actionResult = results.get(0); - X509Certificate returnCert = (X509Certificate) actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE); + X509Certificate returnCert = (X509Certificate) actionResult + .get(WSSecurityEngineResult.TAG_X509_CERTIFICATE); Credential credential = new Credential(); credential.setCertificates(new X509Certificate[] { returnCert }); @@ -828,7 +863,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Verifies the timestamp. - * * @param result */ protected void verifyTimestamp(WSHandlerResult result) throws WSSecurityException { @@ -865,9 +899,11 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl UsernameTokenPrincipalCallback callback = new UsernameTokenPrincipalCallback(usernameTokenPrincipal); try { validationCallbackHandler.handle(new Callback[] { callback }); - } catch (IOException ex) { + } + catch (IOException ex) { logger.warn("Principal callback resulted in IOException", ex); - } catch (UnsupportedCallbackException ex) { + } + catch (UnsupportedCallbackException ex) { // ignore } } @@ -881,11 +917,14 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl try { CleanupCallback cleanupCallback = new CleanupCallback(); validationCallbackHandler.handle(new Callback[] { cleanupCallback }); - } catch (IOException ex) { + } + catch (IOException ex) { logger.warn("Cleanup callback resulted in IOException", ex); - } catch (UnsupportedCallbackException ex) { + } + catch (UnsupportedCallbackException ex) { // ignore } } } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/AbstractWsPasswordCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/AbstractWsPasswordCallbackHandler.java index 57ebcd58..f6ff2094 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/AbstractWsPasswordCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/AbstractWsPasswordCallbackHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,12 +22,13 @@ import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.wss4j.common.ext.WSPasswordCallback; + import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; import org.springframework.ws.soap.security.callback.CleanupCallback; /** - * Abstract base class for {@link javax.security.auth.callback.CallbackHandler} implementations that handle - * {@link WSPasswordCallback} callbacks. + * Abstract base class for {@link javax.security.auth.callback.CallbackHandler} + * implementations that handle {@link WSPasswordCallback} callbacks. * * @author Arjen Poutsma * @author Jamin Hitchcock @@ -36,9 +37,9 @@ import org.springframework.ws.soap.security.callback.CleanupCallback; public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallbackHandler { /** - * Handles {@link WSPasswordCallback} callbacks. Inspects the callback {@link WSPasswordCallback#getUsage() usage} - * code, and calls the various {@code handle*} template methods. - * + * Handles {@link WSPasswordCallback} callbacks. Inspects the callback + * {@link WSPasswordCallback#getUsage() usage} code, and calls the various + * {@code handle*} template methods. * @param callback the callback * @throws IOException in case of I/O errors * @throws UnsupportedCallbackException when the callback is not supported @@ -67,13 +68,17 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback handleSecretKey(passwordCallback); break; default: - throw new UnsupportedCallbackException(callback, "Unknown usage [" + passwordCallback.getUsage() + "]"); + throw new UnsupportedCallbackException(callback, + "Unknown usage [" + passwordCallback.getUsage() + "]"); } - } else if (callback instanceof CleanupCallback) { + } + else if (callback instanceof CleanupCallback) { handleCleanup((CleanupCallback) callback); - } else if (callback instanceof UsernameTokenPrincipalCallback) { + } + else if (callback instanceof UsernameTokenPrincipalCallback) { handleUsernameTokenPrincipal((UsernameTokenPrincipalCallback) callback); - } else { + } + else { throw new UnsupportedCallbackException(callback); } } @@ -82,9 +87,10 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback * Invoked when the callback has a {@link WSPasswordCallback#DECRYPT} usage. *

* This method is invoked when WSS4J needs a password to get the private key of the - * {@link WSPasswordCallback#getIdentifier() identifier} (username) from the keystore. WSS4J uses this private key to - * decrypt the session (symmetric) key. Because the encryption method uses the public key to encrypt the session key - * it needs no password (a public key is usually not protected by a password). + * {@link WSPasswordCallback#getIdentifier() identifier} (username) from the keystore. + * WSS4J uses this private key to decrypt the session (symmetric) key. Because the + * encryption method uses the public key to encrypt the session key it needs no + * password (a public key is usually not protected by a password). *

* Default implementation throws an {@link UnsupportedCallbackException}. */ @@ -95,7 +101,8 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback /** * Invoked when the callback has a {@link WSPasswordCallback#USERNAME_TOKEN} usage. *

- * This method is invoked when WSS4J needs the password to fill in or to verify a UsernameToken. + * This method is invoked when WSS4J needs the password to fill in or to verify a + * UsernameToken. *

* Default implementation throws an {@link UnsupportedCallbackException}. */ @@ -107,8 +114,9 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback * Invoked when the callback has a {@link WSPasswordCallback#SIGNATURE} usage. *

* This method is invoked when WSS4J needs the password to get the private key of the - * {@link WSPasswordCallback#getIdentifier() identifier} (username) from the keystore. WSS4J uses this private key to - * produce a signature. The signature verfication uses the public key to verfiy the signature. + * {@link WSPasswordCallback#getIdentifier() identifier} (username) from the keystore. + * WSS4J uses this private key to produce a signature. The signature verfication uses + * the public key to verfiy the signature. *

* Default implementation throws an {@link UnsupportedCallbackException}. */ @@ -117,9 +125,11 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback } /** - * Invoked when the callback has a {@link WSPasswordCallback#SECURITY_CONTEXT_TOKEN} usage. + * Invoked when the callback has a {@link WSPasswordCallback#SECURITY_CONTEXT_TOKEN} + * usage. *

- * This method is invoked when WSS4J needs the key to to be associated with a SecurityContextToken. + * This method is invoked when WSS4J needs the key to to be associated with a + * SecurityContextToken. *

* Default implementation throws an {@link UnsupportedCallbackException}. */ @@ -156,7 +166,8 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback } /** - * Invoked when a {@link UsernameTokenPrincipalCallback} is passed to {@link #handle(Callback[])}. + * Invoked when a {@link UsernameTokenPrincipalCallback} is passed to + * {@link #handle(Callback[])}. *

* Default implementation throws an {@link UnsupportedCallbackException}. */ @@ -164,4 +175,5 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/KeyStoreCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/KeyStoreCallbackHandler.java index b6986aab..8c0b80ff 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/KeyStoreCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/KeyStoreCallbackHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -17,17 +17,23 @@ package org.springframework.ws.soap.security.wss4j2.callback; import java.io.IOException; -import java.security.*; +import java.security.Key; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.wss4j.common.ext.WSPasswordCallback; + import org.springframework.beans.factory.InitializingBean; import org.springframework.ws.soap.security.support.KeyStoreUtils; /** - * Callback handler that uses Java Security {@code KeyStore}s to handle cryptographic callbacks. Allows for specific key - * stores to be set for various cryptographic operations. + * Callback handler that uses Java Security {@code KeyStore}s to handle cryptographic + * callbacks. Allows for specific key stores to be set for various cryptographic + * operations. * * @author Tareq Abed Rabbo * @author Arjen Poutsma @@ -47,9 +53,10 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i * Invoked when the callback has a {@link WSPasswordCallback#DECRYPT} usage. *

* This method is invoked when WSS4J needs a password to get the private key of the - * {@link WSPasswordCallback#getIdentifier() identifier} (username) from the keystore. WSS4J uses this private key to - * decrypt the session (symmetric) key. Because the encryption method uses the public key to encrypt the session key - * it needs no password (a public key is usually not protected by a password). + * {@link WSPasswordCallback#getIdentifier() identifier} (username) from the keystore. + * WSS4J uses this private key to decrypt the session (symmetric) key. Because the + * encryption method uses the public key to encrypt the session key it needs no + * password (a public key is usually not protected by a password). *

* Default implementation throws an {@link UnsupportedCallbackException}. */ @@ -67,8 +74,10 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i Key key; try { - key = keyStore.getKey(id, symmetricKeyPassword != null ? symmetricKeyPassword : privateKeyPassword.toCharArray()); - } catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) { + key = keyStore.getKey(id, + symmetricKeyPassword != null ? symmetricKeyPassword : privateKeyPassword.toCharArray()); + } + catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) { throw new IOException("Could not get key", e); } @@ -81,8 +90,8 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i } /** - * Sets the password used to retrieve private keys from the keystore. This property is required for decryption based - * on private keys, and signing. + * Sets the password used to retrieve private keys from the keystore. This property is + * required for decryption based on private keys, and signing. */ public void setPrivateKeyPassword(String privateKeyPassword) { if (privateKeyPassword != null) { @@ -91,9 +100,8 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i } /** - * Sets the password used to retrieve keys from the symmetric keystore. If this property is not set, it defaults to - * the private key password. - * + * Sets the password used to retrieve keys from the symmetric keystore. If this + * property is not set, it defaults to the private key password. * @see #setPrivateKeyPassword(String) */ public void setSymmetricKeyPassword(String symmetricKeyPassword) { @@ -112,14 +120,18 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i } } - /** Loads the key store indicated by system properties. Delegates to {@link KeyStoreUtils#loadDefaultKeyStore()}. */ + /** + * Loads the key store indicated by system properties. Delegates to + * {@link KeyStoreUtils#loadDefaultKeyStore()}. + */ protected void loadDefaultKeyStore() { try { keyStore = KeyStoreUtils.loadDefaultKeyStore(); if (logger.isDebugEnabled()) { logger.debug("Loaded default key store"); } - } catch (Exception ex) { + } + catch (Exception ex) { logger.warn("Could not open default key store", ex); } } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/SimplePasswordValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/SimplePasswordValidationCallbackHandler.java index 7bcd36dd..425a058f 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/SimplePasswordValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/SimplePasswordValidationCallbackHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,12 +24,13 @@ import java.util.Properties; import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.wss4j.common.ext.WSPasswordCallback; + import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; /** - * Simple callback handler that validates passwords against a in-memory {@code Properties} object. Password validation - * is done on a case-sensitive basis. + * Simple callback handler that validates passwords against a in-memory {@code Properties} + * object. Password validation is done on a case-sensitive basis. * * @author Tareq Abed Rabbo * @author Arjen Poutsma @@ -42,7 +43,10 @@ public class SimplePasswordValidationCallbackHandler extends AbstractWsPasswordC private Map users = new HashMap(); - /** Sets the users to validate against. Property names are usernames, property values are passwords. */ + /** + * Sets the users to validate against. Property names are usernames, property values + * are passwords. + */ public void setUsers(Properties users) { for (Map.Entry entry : users.entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String) { @@ -66,4 +70,5 @@ public class SimplePasswordValidationCallbackHandler extends AbstractWsPasswordC String passwd = users.get(username); callback.setPassword(passwd); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandler.java index 7b4a5a5a..c0601fd3 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,6 +22,7 @@ import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.wss4j.common.ext.WSPasswordCallback; import org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl; + import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -36,10 +37,12 @@ import org.springframework.ws.soap.security.callback.CleanupCallback; import org.springframework.ws.soap.security.support.SpringSecurityUtils; /** - * Callback handler that validates a plain text or digest password using an Spring Security {@code UserDetailsService}. + * Callback handler that validates a plain text or digest password using an Spring + * Security {@code UserDetailsService}. *

- * An Spring Security {@link UserDetailsService} is used to load {@link UserDetails} from. The digest of the password - * contained in this details object is then compared with the digest in the message. + * An Spring Security {@link UserDetailsService} is used to load {@link UserDetails} from. + * The digest of the password contained in this details object is then compared with the + * digest in the message. * * @author Arjen Poutsma * @author Jamin Hitchcock @@ -70,7 +73,8 @@ public class SpringSecurityPasswordValidationCallbackHandler extends AbstractWsP /** * Invoked when the callback has a {@link WSPasswordCallback#USERNAME_TOKEN} usage. *

- * This method is invoked when WSS4J needs the password to fill in or to verify a UsernameToken. + * This method is invoked when WSS4J needs the password to fill in or to verify a + * UsernameToken. *

* Default implementation throws an {@link UnsupportedCallbackException}. */ @@ -107,7 +111,8 @@ public class SpringSecurityPasswordValidationCallbackHandler extends AbstractWsP if (user == null) { try { user = userDetailsService.loadUserByUsername(username); - } catch (UsernameNotFoundException notFound) { + } + catch (UsernameNotFoundException notFound) { if (logger.isDebugEnabled()) { logger.debug("Username '" + username + "' not found"); } @@ -117,4 +122,5 @@ public class SpringSecurityPasswordValidationCallbackHandler extends AbstractWsP } return user; } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/UsernameTokenPrincipalCallback.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/UsernameTokenPrincipalCallback.java index 07ca45d9..e12a279a 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/UsernameTokenPrincipalCallback.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/callback/UsernameTokenPrincipalCallback.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,9 @@ import javax.security.auth.callback.Callback; import org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl; /** - * Underlying security services instantiate and pass a {@code UsernameTokenPrincipalCallback} to the {@code handle} - * method of a {@code CallbackHandler} to pass a security {@code WSUsernameTokenPrincipal}. + * Underlying security services instantiate and pass a + * {@code UsernameTokenPrincipalCallback} to the {@code handle} method of a + * {@code CallbackHandler} to pass a security {@code WSUsernameTokenPrincipal}. * * @author Arjen Poutsma * @author Jamin Hitchcock @@ -46,4 +47,5 @@ public class UsernameTokenPrincipalCallback implements Callback, Serializable { public WSUsernameTokenPrincipalImpl getPrincipal() { return principal; } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/support/CryptoFactoryBean.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/support/CryptoFactoryBean.java index c677ecd4..08b010c6 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/support/CryptoFactoryBean.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/support/CryptoFactoryBean.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,6 +22,7 @@ import java.util.Properties; import org.apache.wss4j.common.crypto.Crypto; import org.apache.wss4j.common.crypto.CryptoFactory; import org.apache.wss4j.common.crypto.Merlin; + import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.ClassPathResource; @@ -29,11 +30,11 @@ import org.springframework.core.io.Resource; import org.springframework.util.Assert; /** - * Spring factory bean for a WSS4J {@link Crypto}. Allows for strong-typed property configuration, or configuration - * through {@link Properties}. + * Spring factory bean for a WSS4J {@link Crypto}. Allows for strong-typed property + * configuration, or configuration through {@link Properties}. *

- * Requires either individual properties, or the {@link #setConfiguration(java.util.Properties) configuration} property - * to be set. + * Requires either individual properties, or the + * {@link #setConfiguration(java.util.Properties) configuration} property to be set. * * @author Tareq Abed Rabbo * @author Arjen Poutsma @@ -50,9 +51,8 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean private static final String CRYPTO_PROVIDER_PROPERTY = "org.apache.wss4j.crypto.provider"; /** - * Sets the configuration of the Crypto. Setting this property overrides all previously set configuration, through the - * type-safe properties - * + * Sets the configuration of the Crypto. Setting this property overrides all + * previously set configuration, through the type-safe properties * @see org.apache.ws.security.components.crypto.CryptoFactory#getInstance(java.util.Properties) */ public void setConfiguration(Properties properties) { @@ -61,11 +61,11 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean } /** - * Sets the {@link org.apache.ws.security.components.crypto.Crypto} provider name. Defaults to - * {@link org.apache.ws.security.components.crypto.Merlin}. + * Sets the {@link org.apache.ws.security.components.crypto.Crypto} provider name. + * Defaults to {@link org.apache.ws.security.components.crypto.Merlin}. *

- * This property maps to the WSS4J {@code org.apache.ws.security.crypto.provider} property. - * + * This property maps to the WSS4J {@code org.apache.ws.security.crypto.provider} + * property. * @param cryptoProviderClass the crypto provider class */ public void setCryptoProvider(Class cryptoProviderClass) { @@ -73,11 +73,11 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean } /** - * Sets the location of the key store to be loaded in the {@link org.apache.ws.security.components.crypto.Crypto} - * instance. + * Sets the location of the key store to be loaded in the + * {@link org.apache.ws.security.components.crypto.Crypto} instance. *

- * This property maps to the WSS4J {@code org.apache.ws.security.crypto.merlin.file} property. - * + * This property maps to the WSS4J {@code org.apache.ws.security.crypto.merlin.file} + * property. * @param location the key store location * @throws java.io.IOException when the resource cannot be opened */ @@ -89,11 +89,13 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean private String getResourcePath(Resource resource) throws IOException { try { return resource.getFile().getAbsolutePath(); - } catch (IOException ex) { + } + catch (IOException ex) { if (resource instanceof ClassPathResource) { ClassPathResource classPathResource = (ClassPathResource) resource; return classPathResource.getPath(); - } else { + } + else { throw ex; } } @@ -102,8 +104,8 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean /** * Sets the key store provider. *

- * This property maps to the WSS4J {@code org.apache.ws.security.crypto.merlin.keystore.provider} property. - * + * This property maps to the WSS4J + * {@code org.apache.ws.security.crypto.merlin.keystore.provider} property. * @param provider the key store provider */ public void setKeyStoreProvider(String provider) { @@ -113,8 +115,8 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean /** * Sets the key store password. Defaults to {@code security}. *

- * This property maps to the WSS4J {@code org.apache.ws.security.crypto.merlin.keystore.password} property. - * + * This property maps to the WSS4J + * {@code org.apache.ws.security.crypto.merlin.keystore.password} property. * @param password the key store password */ public void setKeyStorePassword(String password) { @@ -122,10 +124,11 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean } /** - * Sets the key store type. Defaults to {@link java.security.KeyStore#getDefaultType()}. + * Sets the key store type. Defaults to + * {@link java.security.KeyStore#getDefaultType()}. *

- * This property maps to the WSS4J {@code org.apache.ws.security.crypto.merlin.keystore.type} property. - * + * This property maps to the WSS4J + * {@code org.apache.ws.security.crypto.merlin.keystore.type} property. * @param type the key store type */ public void setKeyStoreType(String type) { @@ -135,10 +138,11 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean /** * Sets the trust store password. Defaults to {@code changeit}. *

- * WSS4J crypto uses the standard J2SE trust store, i.e. {@code $JAVA_HOME/lib/security/cacerts}. + * WSS4J crypto uses the standard J2SE trust store, i.e. + * {@code $JAVA_HOME/lib/security/cacerts}. *

- * This property maps to the WSS4J {@code org.apache.ws.security.crypto.merlin.cacerts.password} property. - * + * This property maps to the WSS4J + * {@code org.apache.ws.security.crypto.merlin.cacerts.password} property. * @param password the trust store password */ public void setTrustStorePassword(String password) { @@ -146,12 +150,13 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean } /** - * Sets the alias name of the default certificate which has been specified as a property. This should be the - * certificate that is used for signature and encryption. This alias corresponds to the certificate that should be - * used whenever KeyInfo is not present in a signed or an encrypted message. + * Sets the alias name of the default certificate which has been specified as a + * property. This should be the certificate that is used for signature and encryption. + * This alias corresponds to the certificate that should be used whenever KeyInfo is + * not present in a signed or an encrypted message. *

- * This property maps to the WSS4J {@code org.apache.ws.security.crypto.merlin.keystore.alias} property. - * + * This property maps to the WSS4J + * {@code org.apache.ws.security.crypto.merlin.keystore.alias} property. * @param defaultX509Alias alias name of the default X509 certificate */ public void setDefaultX509Alias(String defaultX509Alias) { diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationProvider.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationProvider.java index 85d36f28..f63371de 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationProvider.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationProvider.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,6 +20,7 @@ import java.security.cert.X509Certificate; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.InitializingBean; import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceAware; @@ -44,17 +45,23 @@ import org.springframework.ws.soap.security.x509.cache.X509UserCache; * @version $Id: X509AuthenticationProvider.java 3256 2008-08-18 18:20:48Z luke_t $ */ public class X509AuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware { - // ~ Static fields/initializers ===================================================================================== + + // ~ Static fields/initializers + // ===================================================================================== private static final Log logger = LogFactory.getLog(X509AuthenticationProvider.class); - // ~ Instance fields ================================================================================================ + // ~ Instance fields + // ================================================================================================ protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor(); + private X509AuthoritiesPopulator x509AuthoritiesPopulator; + private X509UserCache userCache = new NullX509UserCache(); - // ~ Methods ======================================================================================================== + // ~ Methods + // ======================================================================================================== @Override public void afterPropertiesSet() throws Exception { @@ -64,18 +71,21 @@ public class X509AuthenticationProvider implements AuthenticationProvider, Initi } /** - * If the supplied authentication token contains a certificate then this will be passed to the configured - * {@link X509AuthoritiesPopulator} to obtain the user details and authorities for the user identified by the - * certificate. + * If the supplied authentication token contains a certificate then this will be + * passed to the configured {@link X509AuthoritiesPopulator} to obtain the user + * details and authorities for the user identified by the certificate. *

- * If no certificate is present (for example, if the filter is applied to an HttpRequest for which client - * authentication hasn't been configured in the container) then a BadCredentialsException will be raised. + * If no certificate is present (for example, if the filter is applied to an + * HttpRequest for which client authentication hasn't been configured in the + * container) then a BadCredentialsException will be raised. *

- * * @param authentication the authentication request. - * @return an X509AuthenticationToken containing the authorities of the principal represented by the certificate. - * @throws AuthenticationException if the {@link X509AuthoritiesPopulator} rejects the certficate. - * @throws BadCredentialsException if no certificate was presented in the authentication request. + * @return an X509AuthenticationToken containing the authorities of the principal + * represented by the certificate. + * @throws AuthenticationException if the {@link X509AuthoritiesPopulator} rejects the + * certficate. + * @throws BadCredentialsException if no certificate was presented in the + * authentication request. */ @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { @@ -128,4 +138,5 @@ public class X509AuthenticationProvider implements AuthenticationProvider, Initi public boolean supports(Class authentication) { return X509AuthenticationToken.class.isAssignableFrom(authentication); } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationToken.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationToken.java index 18d37bd6..6ae2edff 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationToken.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationToken.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,18 +31,23 @@ import org.springframework.security.core.GrantedAuthority; * @author Luke Taylor */ public class X509AuthenticationToken extends AbstractAuthenticationToken { - // ~ Instance fields ================================================================================================ + + // ~ Instance fields + // ================================================================================================ private static final long serialVersionUID = 1L; + private Object principal; + private X509Certificate credentials; - // ~ Constructors =================================================================================================== + // ~ Constructors + // =================================================================================================== /** - * Used for an authentication request. The {@link org.springframework.security.core.Authentication#isAuthenticated()} - * will return {@code false}. - * + * Used for an authentication request. The + * {@link org.springframework.security.core.Authentication#isAuthenticated()} will + * return {@code false}. * @param credentials the certificate */ public X509AuthenticationToken(X509Certificate credentials) { @@ -52,8 +57,8 @@ public class X509AuthenticationToken extends AbstractAuthenticationToken { /** * Used for an authentication response object. The - * {@link org.springframework.security.core.Authentication#isAuthenticated()} will return {@code true}. - * + * {@link org.springframework.security.core.Authentication#isAuthenticated()} will + * return {@code true}. * @param principal the principal, which is generally a {@code UserDetails} * @param credentials the certificate * @param authorities the authorities @@ -66,7 +71,8 @@ public class X509AuthenticationToken extends AbstractAuthenticationToken { setAuthenticated(true); } - // ~ Methods ======================================================================================================== + // ~ Methods + // ======================================================================================================== @Override public Object getCredentials() { @@ -77,4 +83,5 @@ public class X509AuthenticationToken extends AbstractAuthenticationToken { public Object getPrincipal() { return principal; } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthoritiesPopulator.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthoritiesPopulator.java index 024c6e75..fce29abb 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthoritiesPopulator.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthoritiesPopulator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,11 +22,14 @@ import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.userdetails.UserDetails; /** - * Populates the {@code UserDetails} associated with the X.509 certificate presented by a client. + * Populates the {@code UserDetails} associated with the X.509 certificate presented by a + * client. *

- * Although the certificate will already have been validated by the web container, implementations may choose to perform - * additional application-specific checks on the certificate content here. If an implementation chooses to reject the - * certificate, it should throw a {@link org.springframework.security.authentication.BadCredentialsException}. + * Although the certificate will already have been validated by the web container, + * implementations may choose to perform additional application-specific checks on the + * certificate content here. If an implementation chooses to reject the certificate, it + * should throw a + * {@link org.springframework.security.authentication.BadCredentialsException}. *

*

* Migrated from Spring Security 2 since it has been removed in Spring Security 3. @@ -35,18 +38,22 @@ import org.springframework.security.core.userdetails.UserDetails; * @author Luke Taylor */ public interface X509AuthoritiesPopulator { - // ~ Methods ======================================================================================================== + + // ~ Methods + // ======================================================================================================== /** * Obtains the granted authorities for the specified user. *

- * May throw any {@code AuthenticationException} or return {@code null} if the authorities are unavailable. + * May throw any {@code AuthenticationException} or return {@code null} if the + * authorities are unavailable. *

- * * @param userCertificate the X.509 certificate supplied - * @return the details of the indicated user (at minimum the granted authorities and the username) - * @throws AuthenticationException if the user details are not available or the certificate isn't valid for the - * application's purpose. + * @return the details of the indicated user (at minimum the granted authorities and + * the username) + * @throws AuthenticationException if the user details are not available or the + * certificate isn't valid for the application's purpose. */ UserDetails getUserDetails(X509Certificate userCertificate) throws AuthenticationException; + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/EhCacheBasedX509UserCache.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/EhCacheBasedX509UserCache.java index 5ed1ed5b..8e318265 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/EhCacheBasedX509UserCache.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/EhCacheBasedX509UserCache.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,22 @@ package org.springframework.ws.soap.security.x509.cache; +import java.security.cert.X509Certificate; + import net.sf.ehcache.CacheException; import net.sf.ehcache.Ehcache; import net.sf.ehcache.Element; - -import java.security.cert.X509Certificate; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.util.Assert; /** - * Caches {@code User} objects using a Spring IoC defined EHCACHE. + * Caches {@code User} objects using a Spring IoC defined + * EHCACHE. *

* Migrated from Spring Security 2 since it has been removed in Spring Security 3. *

@@ -38,20 +39,24 @@ import org.springframework.util.Assert; * @author Luke Taylor * @author Ben Alex * @author Greg Turnquist - * @deprecated Migrate to {@link SpringBasedX509UserCache} and inject a platform neutral Spring-based - * {@link org.springframework.cache.Cache}. + * @deprecated Migrate to {@link SpringBasedX509UserCache} and inject a platform neutral + * Spring-based {@link org.springframework.cache.Cache}. */ @Deprecated public class EhCacheBasedX509UserCache implements X509UserCache, InitializingBean { - // ~ Static fields/initializers ===================================================================================== + + // ~ Static fields/initializers + // ===================================================================================== private static final Log logger = LogFactory.getLog(EhCacheBasedX509UserCache.class); - // ~ Instance fields ================================================================================================ + // ~ Instance fields + // ================================================================================================ private Ehcache cache; - // ~ Methods ======================================================================================================== + // ~ Methods + // ======================================================================================================== @Override public void afterPropertiesSet() throws Exception { @@ -64,7 +69,8 @@ public class EhCacheBasedX509UserCache implements X509UserCache, InitializingBea try { element = cache.get(userCert); - } catch (CacheException cacheException) { + } + catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } @@ -80,7 +86,8 @@ public class EhCacheBasedX509UserCache implements X509UserCache, InitializingBea if (element == null) { return null; - } else { + } + else { return (UserDetails) element.getObjectValue(); } } @@ -108,4 +115,5 @@ public class EhCacheBasedX509UserCache implements X509UserCache, InitializingBea public void setCache(Ehcache cache) { this.cache = cache; } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/NullX509UserCache.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/NullX509UserCache.java index 883e73a3..15c47b97 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/NullX509UserCache.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/NullX509UserCache.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,7 +29,9 @@ import org.springframework.security.core.userdetails.UserDetails; * @author Luke Taylor */ public class NullX509UserCache implements X509UserCache { - // ~ Methods ======================================================================================================== + + // ~ Methods + // ======================================================================================================== @Override public UserDetails getUserFromCache(X509Certificate certificate) { @@ -37,8 +39,11 @@ public class NullX509UserCache implements X509UserCache { } @Override - public void putUserInCache(X509Certificate certificate, UserDetails user) {} + public void putUserInCache(X509Certificate certificate, UserDetails user) { + } @Override - public void removeUserFromCache(X509Certificate certificate) {} + public void removeUserFromCache(X509Certificate certificate) { + } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/SpringBasedX509UserCache.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/SpringBasedX509UserCache.java index ba3c09eb..89125af3 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/SpringBasedX509UserCache.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/SpringBasedX509UserCache.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,6 +20,7 @@ import java.security.cert.X509Certificate; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.InitializingBean; import org.springframework.cache.Cache; import org.springframework.security.core.userdetails.UserDetails; @@ -86,4 +87,5 @@ public class SpringBasedX509UserCache implements X509UserCache, InitializingBean public void setCache(Cache cache) { this.cache = cache; } + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/X509UserCache.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/X509UserCache.java index addb2c0b..f42fdb3f 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/X509UserCache.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/cache/X509UserCache.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,8 +24,9 @@ import org.springframework.security.core.userdetails.UserDetails; * Provides a cache of {@link UserDetails} objects for the * {@link org.springframework.ws.soap.security.x509.X509AuthenticationProvider}. *

- * Similar in function to the {@link org.springframework.security.core.userdetails.UserCache} used by the Dao provider, - * but the cache is keyed with the user's certificate rather than the user name. + * Similar in function to the + * {@link org.springframework.security.core.userdetails.UserCache} used by the Dao + * provider, but the cache is keyed with the user's certificate rather than the user name. *

*

* Migrated from Spring Security 2 since it has been removed in Spring Security 3. @@ -34,11 +35,14 @@ import org.springframework.security.core.userdetails.UserDetails; * @author Luke Taylor */ public interface X509UserCache { - // ~ Methods ======================================================================================================== + + // ~ Methods + // ======================================================================================================== UserDetails getUserFromCache(X509Certificate userCertificate); void putUserInCache(X509Certificate key, UserDetails user); void removeUserFromCache(X509Certificate key); + } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/populator/DaoX509AuthoritiesPopulator.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/populator/DaoX509AuthoritiesPopulator.java index 796972fc..a8427caa 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/populator/DaoX509AuthoritiesPopulator.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/x509/populator/DaoX509AuthoritiesPopulator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,7 +34,8 @@ import org.springframework.util.Assert; import org.springframework.ws.soap.security.x509.X509AuthoritiesPopulator; /** - * Populates the X509 authorities via an {@link org.springframework.security.core.userdetails.UserDetailsService}. + * Populates the X509 authorities via an + * {@link org.springframework.security.core.userdetails.UserDetailsService}. *

* Migrated from Spring Security 2 since it has been removed in Spring Security 3. *

@@ -44,14 +45,19 @@ import org.springframework.ws.soap.security.x509.X509AuthoritiesPopulator; */ public class DaoX509AuthoritiesPopulator implements X509AuthoritiesPopulator, InitializingBean, MessageSourceAware { - // ~ Instance fields ================================================================================================ + // ~ Instance fields + // ================================================================================================ protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor(); + private Pattern subjectDNPattern; + private String subjectDNRegex = "CN=(.*?),"; + private UserDetailsService userDetailsService; - // ~ Methods ======================================================================================================== + // ~ Methods + // ======================================================================================================== @Override public void afterPropertiesSet() throws Exception { @@ -94,16 +100,17 @@ public class DaoX509AuthoritiesPopulator implements X509AuthoritiesPopulator, In } /** - * Sets the regular expression which will by used to extract the user name from the certificate's Subject DN. + * Sets the regular expression which will by used to extract the user name from the + * certificate's Subject DN. *

- * It should contain a single group; for example the default expression "CN=(.?)," matches the common name field. So - * "CN=Jimi Hendrix, OU=..." will give a user name of "Jimi Hendrix". + * It should contain a single group; for example the default expression "CN=(.?)," + * matches the common name field. So "CN=Jimi Hendrix, OU=..." will give a user name + * of "Jimi Hendrix". *

*

- * The matches are case insensitive. So "emailAddress=(.?)," will match "EMAILADDRESS=jimi@hendrix.org, CN=..." giving - * a user name "jimi@hendrix.org" + * The matches are case insensitive. So "emailAddress=(.?)," will match + * "EMAILADDRESS=jimi@hendrix.org, CN=..." giving a user name "jimi@hendrix.org" *

- * * @param subjectDNRegex the regular expression to find in the subject */ public void setSubjectDNRegex(String subjectDNRegex) { @@ -113,4 +120,5 @@ public class DaoX509AuthoritiesPopulator implements X509AuthoritiesPopulator, In public void setUserDetailsService(UserDetailsService userDetailsService) { this.userDetailsService = userDetailsService; } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/SkipValidationWsSecurityInterceptorTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/SkipValidationWsSecurityInterceptorTest.java index 23ab81b1..7f4abb6e 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/SkipValidationWsSecurityInterceptorTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/SkipValidationWsSecurityInterceptorTest.java @@ -1,16 +1,30 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.soap.security; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.MimeHeaders; -import jakarta.xml.soap.SOAPException; - import java.io.IOException; import java.io.InputStream; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.MimeHeaders; +import jakarta.xml.soap.SOAPException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.ws.context.DefaultMessageContext; @@ -19,10 +33,15 @@ import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; + public class SkipValidationWsSecurityInterceptorTest { private MessageFactory messageFactory; + private AbstractWsSecurityInterceptor interceptor; + private SaajSoapMessageFactory soapMessageFactory; @BeforeEach @@ -40,10 +59,12 @@ public class SkipValidationWsSecurityInterceptorTest { @Override protected void secureMessage(SoapMessage soapMessage, MessageContext messageContext) - throws WsSecuritySecurementException {} + throws WsSecuritySecurementException { + } @Override - protected void cleanUp() {} + protected void cleanUp() { + } }; interceptor.setSkipValidationIfNoHeaderPresent(true); } @@ -83,4 +104,5 @@ public class SkipValidationWsSecurityInterceptorTest { return new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, is)); } } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/callback/CallbackHandlerChainTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/callback/CallbackHandlerChainTest.java index 8a619241..305f60ce 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/callback/CallbackHandlerChainTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/callback/CallbackHandlerChainTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,23 +16,25 @@ package org.springframework.ws.soap.security.callback; -import static org.assertj.core.api.Assertions.*; - import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public class CallbackHandlerChainTest { - private CallbackHandler supported = callbacks -> {}; + private CallbackHandler supported = callbacks -> { + }; private CallbackHandler unsupported = callbacks -> { throw new UnsupportedCallbackException(callbacks[0]); }; - private Callback callback = new Callback() {}; + private Callback callback = new Callback() { + }; @Test public void testSupported() throws Exception { @@ -57,4 +59,5 @@ public class CallbackHandlerChainTest { chain.handle(new Callback[] { callback }); }); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/support/KeyManagersFactoryBeanTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/support/KeyManagersFactoryBeanTest.java index 31f2eb19..46bba03e 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/support/KeyManagersFactoryBeanTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/support/KeyManagersFactoryBeanTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.soap.security.support; -import static org.assertj.core.api.Assertions.*; - import javax.net.ssl.KeyManager; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class KeyManagersFactoryBeanTest { @Test @@ -46,4 +46,5 @@ public class KeyManagersFactoryBeanTest { assertThat(keyManagers).isNotNull(); assertThat(keyManagers).hasSize(1); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/support/TrustManagersFactoryBeanTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/support/TrustManagersFactoryBeanTest.java index 56fb3ce7..6fb8e712 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/support/TrustManagersFactoryBeanTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/support/TrustManagersFactoryBeanTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.soap.security.support; -import static org.assertj.core.api.Assertions.*; - import javax.net.ssl.TrustManager; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class TrustManagersFactoryBeanTest { @Test @@ -46,4 +46,5 @@ public class TrustManagersFactoryBeanTest { assertThat(trustManagers).isNotNull(); assertThat(trustManagers).hasSize(1); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorSignTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorSignTest.java index 1c2e94cd..a2f4bc61 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorSignTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorSignTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,6 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MimeHeaders; -import jakarta.xml.soap.SOAPHeader; -import jakarta.xml.soap.SOAPHeaderElement; -import jakarta.xml.soap.SOAPMessage; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Iterator; @@ -31,7 +24,12 @@ import javax.xml.namespace.QName; import javax.xml.transform.Transformer; import javax.xml.transform.dom.DOMResult; +import jakarta.xml.soap.MimeHeaders; +import jakarta.xml.soap.SOAPHeader; +import jakarta.xml.soap.SOAPHeaderElement; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.Test; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; @@ -40,6 +38,8 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; +import static org.assertj.core.api.Assertions.assertThat; + public class SaajWss4jMessageInterceptorSignTest extends Wss4jMessageInterceptorSignTestCase { private static final String PAYLOAD = "QQQ"; @@ -61,8 +61,8 @@ public class SaajWss4jMessageInterceptorSignTest extends Wss4jMessageInterceptor interceptor.secureMessage(message, messageContext); SOAPHeader header = ((SaajSoapMessage) message).getSaajMessage().getSOAPHeader(); - Iterator iterator = header.getChildElements( - new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security")); + Iterator iterator = header.getChildElements(new QName( + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security")); assertThat(iterator.hasNext()).isTrue(); @@ -103,8 +103,8 @@ public class SaajWss4jMessageInterceptorSignTest extends Wss4jMessageInterceptor interceptor.secureMessage(message, messageContext); SOAPHeader header = ((SaajSoapMessage) message).getSaajMessage().getSOAPHeader(); - Iterator iterator = header.getChildElements( - new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security")); + Iterator iterator = header.getChildElements(new QName( + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security")); assertThat(iterator.hasNext()).isTrue(); @@ -126,4 +126,5 @@ public class SaajWss4jMessageInterceptorSignTest extends Wss4jMessageInterceptor interceptor.validateMessage(message, messageContext); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorX509Test.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorX509Test.java index 5cdd929c..4c70bb29 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorX509Test.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorX509Test.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,7 +16,9 @@ package org.springframework.ws.soap.security.wss4j2; -/** @author tareq */ +/** + * @author tareq + */ public class SaajWss4jMessageInterceptorX509Test extends Wss4jMessageInterceptorX509TestCase { } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jSecurityInterceptorDefaultsTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jSecurityInterceptorDefaultsTest.java index 934686da..9a0b8588 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jSecurityInterceptorDefaultsTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jSecurityInterceptorDefaultsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,19 +16,15 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.springframework.test.util.AssertionErrors.assertEquals; - -import jakarta.xml.soap.SOAPException; -import jakarta.xml.soap.SOAPMessage; - import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPMessage; import org.apache.wss4j.dom.handler.RequestData; import org.junit.jupiter.api.Test; + import org.springframework.test.util.ReflectionTestUtils; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; @@ -38,6 +34,10 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.springframework.test.util.AssertionErrors.assertEquals; + public class SaajWss4jSecurityInterceptorDefaultsTest extends Wss4jTestCase { private static final String PAYLOAD = "QQQ"; @@ -92,4 +92,5 @@ public class SaajWss4jSecurityInterceptorDefaultsTest extends Wss4jTestCase { assertFalse(validationData.isAddInclusivePrefixes()); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jInterceptorTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jInterceptorTestCase.java index 01c69c2c..38942f61 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jInterceptorTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jInterceptorTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,9 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; - import org.apache.wss4j.dom.engine.WSSecurityEngine; import org.junit.jupiter.api.Test; + import org.springframework.test.util.ReflectionTestUtils; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; @@ -27,6 +26,9 @@ import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.WsSecuritySecurementException; import org.springframework.ws.soap.security.WsSecurityValidationException; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; + public abstract class Wss4jInterceptorTestCase extends Wss4jTestCase { @Test @@ -98,4 +100,5 @@ public abstract class Wss4jInterceptorTestCase extends Wss4jTestCase { assertThat(ReflectionTestUtils.getField(interceptor, "securityEngine")).isEqualTo(engine); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorEncryptionTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorEncryptionTestCase.java index 9b8a2b74..c79b01bc 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorEncryptionTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorEncryptionTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,12 +19,13 @@ package org.springframework.ws.soap.security.wss4j2; import java.util.Properties; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j2.callback.KeyStoreCallbackHandler; import org.springframework.ws.soap.security.wss4j2.support.CryptoFactoryBean; -import org.w3c.dom.Document; public abstract class Wss4jMessageInterceptorEncryptionTestCase extends Wss4jTestCase { @@ -85,4 +86,5 @@ public abstract class Wss4jMessageInterceptorEncryptionTestCase extends Wss4jTes assertXpathExists("Encryption error", "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/xenc:EncryptedKey", document); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorHeaderTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorHeaderTestCase.java index aeec4931..2468a577 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorHeaderTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorHeaderTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; - import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; import java.util.Iterator; @@ -26,6 +24,7 @@ import java.util.Properties; import javax.xml.namespace.QName; import org.junit.jupiter.api.Test; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapHeaderElement; @@ -33,6 +32,10 @@ import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.WsSecurityValidationException; import org.springframework.ws.soap.security.wss4j2.callback.SimplePasswordValidationCallbackHandler; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.fail; + /** * @author Arjen Poutsma * @author Tareq Abedrabbo @@ -41,6 +44,7 @@ import org.springframework.ws.soap.security.wss4j2.callback.SimplePasswordValida public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCase { private Wss4jSecurityInterceptor interceptor; + private Wss4jSecurityInterceptor interceptorThatKeepsSecurityHeader; @Override @@ -76,12 +80,13 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas assertThat(result).isNotNull(); - for (Iterator i = message.getEnvelope().getHeader().examineAllHeaderElements(); i.hasNext();) { + for (Iterator i = message.getEnvelope().getHeader().examineAllHeaderElements(); i + .hasNext();) { SoapHeaderElement element = i.next(); QName name = element.getName(); if (name.getNamespaceURI() - .equals("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")) { + .equals("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")) { fail("Security Header not removed"); } } @@ -103,12 +108,13 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas assertThat(result).isNotNull(); boolean foundSecurityHeader = false; - for (Iterator i = message.getEnvelope().getHeader().examineAllHeaderElements(); i.hasNext();) { + for (Iterator i = message.getEnvelope().getHeader().examineAllHeaderElements(); i + .hasNext();) { SoapHeaderElement element = i.next(); QName name = element.getName(); if (name.getNamespaceURI() - .equals("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")) { + .equals("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")) { foundSecurityHeader = true; } @@ -170,4 +176,5 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas assertXpathEvaluatesTo("Header 2 does not exist", "test2", "/SOAP-ENV:Envelope/SOAP-ENV:Header/test:header2", document); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSamlTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSamlTestCase.java index 939d2509..eda08983 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSamlTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSamlTestCase.java @@ -1,3 +1,19 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.soap.security.wss4j2; import java.security.cert.X509Certificate; @@ -14,11 +30,12 @@ import org.apache.wss4j.common.saml.bean.SubjectBean; import org.apache.wss4j.common.saml.bean.Version; import org.apache.wss4j.common.saml.builder.SAML2Constants; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.core.io.ClassPathResource; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j2.support.CryptoFactoryBean; -import org.w3c.dom.Document; public abstract class Wss4jMessageInterceptorSamlTestCase extends Wss4jTestCase { @@ -103,5 +120,7 @@ public abstract class Wss4jMessageInterceptorSamlTestCase extends Wss4jTestCase } } } + } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSignTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSignTestCase.java index 0e8490af..6da38a6a 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSignTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSignTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,18 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; - import java.util.Properties; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j2.support.CryptoFactoryBean; -import org.w3c.dom.Document; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase { @@ -121,4 +122,5 @@ public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase assertXpathExists("Absent SignatureConfirmation element", "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/ds:Signature", document); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSoapActionTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSoapActionTestCase.java index 00c90091..f3f886c1 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSoapActionTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSoapActionTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,19 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; - import java.util.Properties; import org.apache.wss4j.dom.WSConstants; import org.junit.jupiter.api.Test; + import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j2.callback.SimplePasswordValidationCallbackHandler; +import static org.assertj.core.api.Assertions.assertThat; + public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTestCase { private static final String SOAP_ACTION = "\"http://test\""; @@ -101,4 +102,5 @@ public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTes assertThat(message.getSoapAction()).isNotNull(); assertThat(message.getSoapAction()).isEqualTo(SOAP_ACTION); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java index c27e573d..3a433d94 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,12 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.util.Properties; import org.apache.wss4j.dom.WSConstants; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; + import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.provisioning.InMemoryUserDetailsManager; @@ -33,6 +31,11 @@ import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j2.callback.SpringSecurityPasswordValidationCallbackHandler; +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase extends Wss4jTestCase { private Properties users = new Properties(); @@ -112,7 +115,8 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa if (validating) { interceptor.setValidationActions(actions); - } else { + } + else { interceptor.setSecurementActions(actions); } @@ -122,7 +126,8 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa if (digest) { interceptor.setSecurementPasswordType(WSConstants.PW_DIGEST); - } else { + } + else { interceptor.setSecurementPasswordType(WSConstants.PW_TEXT); } @@ -132,4 +137,5 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa return interceptor; } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorTimestampTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorTimestampTestCase.java index e8a1c34c..9559c43e 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorTimestampTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorTimestampTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,19 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; - import java.text.DateFormat; import java.text.SimpleDateFormat; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.WsSecurityValidationException; -import org.w3c.dom.Document; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTestCase { @@ -41,8 +43,8 @@ public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTest interceptor.secureMessage(message, context); Document document = getDocument(message); - assertXpathExists("timestamp header not found", "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsu:Timestamp", - document); + assertXpathExists("timestamp header not found", + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsu:Timestamp", document); } @Test @@ -128,4 +130,5 @@ public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTest return message; } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorUsernameTokenSignatureTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorUsernameTokenSignatureTestCase.java index 5d124285..dd555ebe 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorUsernameTokenSignatureTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorUsernameTokenSignatureTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -17,9 +17,10 @@ package org.springframework.ws.soap.security.wss4j2; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; -import org.w3c.dom.Document; public abstract class Wss4jMessageInterceptorUsernameTokenSignatureTestCase extends Wss4jTestCase { @@ -43,4 +44,5 @@ public abstract class Wss4jMessageInterceptorUsernameTokenSignatureTestCase exte "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Password[@Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest']/text()", doc); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorUsernameTokenTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorUsernameTokenTestCase.java index 1dc3e9cc..fe0df23b 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorUsernameTokenTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorUsernameTokenTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,18 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; - import java.util.Properties; import org.apache.wss4j.dom.WSConstants; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j2.callback.SimplePasswordValidationCallbackHandler; -import org.w3c.dom.Document; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4jTestCase { @@ -104,7 +105,7 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j interceptor.secureMessage(message, messageContext); - assertAddUsernameTokenPlainText(message, "Bibo","Elmo"); + assertAddUsernameTokenPlainText(message, "Bibo", "Elmo"); } @Test @@ -130,7 +131,8 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j getDocument(message)); } - protected void assertAddUsernameTokenPlainText(SoapMessage message, String expectedUsername, String expectedPassword) { + protected void assertAddUsernameTokenPlainText(SoapMessage message, String expectedUsername, + String expectedPassword) { Object result = getMessage(message); @@ -164,14 +166,16 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor(); if (validating) { interceptor.setValidationActions(actions); - } else { + } + else { interceptor.setSecurementActions(actions); } SimplePasswordValidationCallbackHandler callbackHandler = new SimplePasswordValidationCallbackHandler(); callbackHandler.setUsers(users); if (digest) { interceptor.setSecurementPasswordType(WSConstants.PW_DIGEST); - } else { + } + else { interceptor.setSecurementPasswordType(WSConstants.PW_TEXT); } interceptor.setValidationCallbackHandler(callbackHandler); @@ -181,4 +185,5 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j interceptor.afterPropertiesSet(); return interceptor; } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorX509TestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorX509TestCase.java index e6838f56..e96afc74 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorX509TestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorX509TestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,11 +18,12 @@ package org.springframework.ws.soap.security.wss4j2; import org.apache.wss4j.common.crypto.Merlin; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.core.io.ClassPathResource; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j2.support.CryptoFactoryBean; -import org.w3c.dom.Document; public abstract class Wss4jMessageInterceptorX509TestCase extends Wss4jTestCase { @@ -65,4 +66,5 @@ public abstract class Wss4jMessageInterceptorX509TestCase extends Wss4jTestCase // lets verify the signature that we've just generated interceptor.validateMessage(message, messageContext); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jTestCase.java index f8bf9afe..2d61927c 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,20 +16,20 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.assertj.core.api.Assertions.*; - -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.MimeHeaders; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPMessage; - import java.io.InputStream; import java.util.HashMap; import java.util.Map; import javax.xml.transform.dom.DOMSource; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.MimeHeaders; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.BeforeEach; +import org.w3c.dom.Document; +import org.w3c.dom.Node; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.ws.WebServiceMessage; @@ -42,8 +42,8 @@ import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.xml.transform.StringSource; import org.springframework.xml.xpath.Jaxp13XPathTemplate; -import org.w3c.dom.Document; -import org.w3c.dom.Node; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class Wss4jTestCase { @@ -89,7 +89,8 @@ public abstract class Wss4jTestCase { assertThat(actualValue).isEqualTo(expectedValue); } - protected void assertXpathEvaluatesTo(String message, String expectedValue, String xpathExpression, String document) { + protected void assertXpathEvaluatesTo(String message, String expectedValue, String xpathExpression, + String document) { String actualValue = xpathTemplate.evaluateAsString(xpathExpression, new StringSource(document)); @@ -125,7 +126,8 @@ public abstract class Wss4jTestCase { assertThat(resource.exists()).isTrue(); try (InputStream is = resource.getInputStream()) { - return new SaajSoapMessage(saajSoap11MessageFactory.createMessage(mimeHeaders, is), saajSoap11MessageFactory); + return new SaajSoapMessage(saajSoap11MessageFactory.createMessage(mimeHeaders, is), + saajSoap11MessageFactory); } } @@ -138,7 +140,8 @@ public abstract class Wss4jTestCase { assertThat(resource.exists()).isTrue(); try (InputStream is = resource.getInputStream()) { - return new SaajSoapMessage(saajSoap12MessageFactory.createMessage(mimeHeaders, is), saajSoap12MessageFactory); + return new SaajSoapMessage(saajSoap12MessageFactory.createMessage(mimeHeaders, is), + saajSoap12MessageFactory); } } @@ -161,7 +164,8 @@ public abstract class Wss4jTestCase { throw new IllegalArgumentException("Illegal message: " + message); } - protected void onSetup() throws Exception {} + protected void onSetup() throws Exception { + } protected SoapMessage loadSoap11Message(String fileName) throws Exception { @@ -195,7 +199,8 @@ public abstract class Wss4jTestCase { SoapMessageFactory messageFactory; if (saajTest) { messageFactory = new SaajSoapMessageFactory(saajSoap12MessageFactory); - } else + } + else throw new IllegalArgumentException(); messageFactory.setSoapVersion(SoapVersion.SOAP_12); return messageFactory; @@ -230,4 +235,5 @@ public abstract class Wss4jTestCase { } }; } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandlerTest.java index 3a59afc1..60fe2ec2 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandlerTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.soap.security.wss4j2.callback; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.util.Collection; import java.util.Collections; @@ -26,6 +23,7 @@ import org.apache.wss4j.common.ext.WSPasswordCallback; import org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; @@ -36,7 +34,15 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; -/** @author tareq */ +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + +/** + * @author tareq + */ public class SpringSecurityPasswordValidationCallbackHandlerTest { private SpringSecurityPasswordValidationCallbackHandler callbackHandler; @@ -51,7 +57,8 @@ public class SpringSecurityPasswordValidationCallbackHandlerTest { @BeforeEach public void setUp() { - // add clearContext() at the beginning of each method in case {@code SecurityContextHolder} isn't clean + // add clearContext() at the beginning of each method in case {@code + // SecurityContextHolder} isn't clean SecurityContextHolder.clearContext(); callbackHandler = new SpringSecurityPasswordValidationCallbackHandler(); @@ -89,7 +96,7 @@ public class SpringSecurityPasswordValidationCallbackHandlerTest { callbackHandler.setUserDetailsService(userDetailsService); expect(userDetailsService.loadUserByUsername("Ernie")) - .andThrow(new UsernameNotFoundException("User 'Ernie' not found")); + .andThrow(new UsernameNotFoundException("User 'Ernie' not found")); replay(userDetailsService); @@ -129,4 +136,5 @@ public class SpringSecurityPasswordValidationCallbackHandlerTest { verify(userDetailsService); } + } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/support/CryptoFactoryBeanTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/support/CryptoFactoryBeanTest.java index 2406ea14..179418bd 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/support/CryptoFactoryBeanTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/support/CryptoFactoryBeanTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,16 @@ package org.springframework.ws.soap.security.wss4j2.support; -import static org.assertj.core.api.Assertions.*; - import java.util.Properties; import org.apache.wss4j.common.crypto.Merlin; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.io.ClassPathResource; +import static org.assertj.core.api.Assertions.assertThat; + public class CryptoFactoryBeanTest { private CryptoFactoryBean factoryBean; @@ -65,4 +66,5 @@ public class CryptoFactoryBeanTest { assertThat(result).isNotNull(); assertThat(result).isInstanceOf(Merlin.class); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java index a422d8fc..d6901ddb 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.transport.http; -import jakarta.xml.soap.SOAPConstants; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -30,6 +28,9 @@ import java.util.List; import javax.xml.namespace.QName; +import com.sun.net.httpserver.HttpExchange; +import jakarta.xml.soap.SOAPConstants; + import org.springframework.util.Assert; import org.springframework.util.FileCopyUtils; import org.springframework.ws.WebServiceMessage; @@ -38,10 +39,9 @@ import org.springframework.ws.transport.EndpointAwareWebServiceConnection; import org.springframework.ws.transport.FaultAwareWebServiceConnection; import org.springframework.ws.transport.WebServiceConnection; -import com.sun.net.httpserver.HttpExchange; - /** - * Implementation of {@link WebServiceConnection} that is based on the Java 6 HttpServer {@link HttpExchange}. + * Implementation of {@link WebServiceConnection} that is based on the Java 6 HttpServer + * {@link HttpExchange}. * * @author Arjen Poutsma * @author Greg Turnquist @@ -131,7 +131,8 @@ public class HttpExchangeConnection extends AbstractReceiverConnection if (chunkedEncoding) { httpExchange.sendResponseHeaders(responseStatusCode, 0); return httpExchange.getResponseBody(); - } else { + } + else { if (responseBuffer == null) { responseBuffer = new ByteArrayOutputStream(); } @@ -173,7 +174,8 @@ public class HttpExchangeConnection extends AbstractReceiverConnection public void setFault(boolean fault) throws IOException { if (fault) { responseStatusCode = HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR; - } else { + } + else { responseStatusCode = HttpTransportConstants.STATUS_OK; } } @@ -183,11 +185,14 @@ public class HttpExchangeConnection extends AbstractReceiverConnection if (faultCode != null) { if (SOAPConstants.SOAP_SENDER_FAULT.equals(faultCode)) { responseStatusCode = HttpTransportConstants.STATUS_BAD_REQUEST; - } else { + } + else { responseStatusCode = HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR; } - } else { + } + else { responseStatusCode = HttpTransportConstants.STATUS_OK; } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsTransportException.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsTransportException.java index 8dbe5139..4e8aa71d 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsTransportException.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsTransportException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,4 +32,5 @@ public class HttpsTransportException extends HttpTransportException { public HttpsTransportException(String msg, Throwable cause) { super(msg, cause); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsUrlConnectionMessageSender.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsUrlConnectionMessageSender.java index 54ea7b8d..430bd73c 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsUrlConnectionMessageSender.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsUrlConnectionMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,7 +23,12 @@ import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SecureRandom; -import javax.net.ssl.*; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManager; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; @@ -31,7 +36,8 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** - * Extension of {@link HttpUrlConnectionMessageSender} that adds support for (self-signed) HTTPS certificates. + * Extension of {@link HttpUrlConnectionMessageSender} that adds support for (self-signed) + * HTTPS certificates. * * @author Alex Marshall * @author Arjen Poutsma @@ -58,7 +64,6 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen /** * Sets the SSL protocol to use. Default is {@code ssl}. - * * @see SSLContext#getInstance(String, String) */ public void setSslProtocol(String sslProtocol) { @@ -68,7 +73,6 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen /** * Sets the SSL provider to use. Default is empty, to use the default provider. - * * @see SSLContext#getInstance(String, String) */ public void setSslProvider(String sslProvider) { @@ -78,8 +82,8 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen /** * Specifies the key managers to use for this message sender. *

- * Setting either this property or {@link #setTrustManagers(TrustManager[]) trustManagers} is required. - * + * Setting either this property or {@link #setTrustManagers(TrustManager[]) + * trustManagers} is required. * @see SSLContext#init(KeyManager[], TrustManager[], SecureRandom) */ public void setKeyManagers(KeyManager[] keyManagers) { @@ -89,8 +93,8 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen /** * Specifies the trust managers to use for this message sender. *

- * Setting either this property or {@link #setKeyManagers(KeyManager[]) keyManagers} is required. - * + * Setting either this property or {@link #setKeyManagers(KeyManager[]) keyManagers} + * is required. * @see SSLContext#init(KeyManager[], TrustManager[], SecureRandom) */ public void setTrustManagers(TrustManager[] trustManagers) { @@ -99,7 +103,6 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen /** * Specifies the host name verifier to use for this message sender. - * * @see HttpsURLConnection#setHostnameVerifier(HostnameVerifier) */ public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { @@ -108,7 +111,6 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen /** * Specifies the secure random to use for this message sender. - * * @see SSLContext#init(KeyManager[], TrustManager[], SecureRandom) */ public void setSecureRandom(SecureRandom rnd) { @@ -117,7 +119,6 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen /** * Specifies the SSLSocketFactory to use for this message sender. - * * @see HttpsURLConnection#setSSLSocketFactory(SSLSocketFactory sf) */ public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) { @@ -149,8 +150,8 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen return this.sslSocketFactory; } try { - SSLContext sslContext = StringUtils.hasLength(sslProvider) ? SSLContext.getInstance(sslProtocol, sslProvider) - : SSLContext.getInstance(sslProtocol); + SSLContext sslContext = StringUtils.hasLength(sslProvider) + ? SSLContext.getInstance(sslProtocol, sslProvider) : SSLContext.getInstance(sslProtocol); sslContext.init(keyManagers, trustManagers, rnd); if (logger.isDebugEnabled()) { logger.debug("Initialized SSL Context with key managers [" @@ -158,9 +159,11 @@ public class HttpsUrlConnectionMessageSender extends HttpUrlConnectionMessageSen + StringUtils.arrayToCommaDelimitedString(trustManagers) + "] secure random [" + rnd + "]"); } return sslContext.getSocketFactory(); - } catch (NoSuchAlgorithmException | NoSuchProviderException ex) { + } + catch (NoSuchAlgorithmException | NoSuchProviderException ex) { throw new HttpsTransportException("Could not create SSLContext: " + ex.getMessage(), ex); - } catch (KeyManagementException ex) { + } + catch (KeyManagementException ex) { throw new HttpsTransportException("Could not initialize SSLContext: " + ex.getMessage(), ex); } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHttpHandler.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHttpHandler.java index 524b58fe..01a899a4 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHttpHandler.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHttpHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,19 +18,21 @@ package org.springframework.ws.transport.http; import java.io.IOException; -import org.springframework.ws.transport.support.SimpleWebServiceMessageReceiverObjectSupport; - import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; +import org.springframework.ws.transport.support.SimpleWebServiceMessageReceiverObjectSupport; + /** - * {@link HttpHandler} that can be used to handle incoming {@link HttpExchange} service requests. Designed for Sun's JRE - * 1.6 HTTP server. + * {@link HttpHandler} that can be used to handle incoming {@link HttpExchange} service + * requests. Designed for Sun's JRE 1.6 HTTP server. *

- * Requires a {@link org.springframework.ws.WebServiceMessageFactory} which is used to convert the incoming - * {@link HttpExchange} into a {@link org.springframework.ws.WebServiceMessage}, and passes that to the + * Requires a {@link org.springframework.ws.WebServiceMessageFactory} which is used to + * convert the incoming {@link HttpExchange} into a + * {@link org.springframework.ws.WebServiceMessage}, and passes that to the * {@link org.springframework.ws.transport.WebServiceMessageReceiver} - * {@link #setMessageReceiver(org.springframework.ws.transport.WebServiceMessageReceiver) registered}. + * {@link #setMessageReceiver(org.springframework.ws.transport.WebServiceMessageReceiver) + * registered}. * * @author Arjen Poutsma * @see org.springframework.remoting.support.SimpleHttpServerFactoryBean @@ -53,12 +55,15 @@ public class WebServiceMessageReceiverHttpHandler extends SimpleWebServiceMessag connection.setChunkedEncoding(chunkedEncoding); try { handleConnection(connection); - } catch (Exception ex) { + } + catch (Exception ex) { logger.error(ex); } - } else { + } + else { httpExchange.sendResponseHeaders(HttpTransportConstants.STATUS_METHOD_NOT_ALLOWED, -1); httpExchange.close(); } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHttpHandler.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHttpHandler.java index 9c3f73f4..ce082759 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHttpHandler.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHttpHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,16 +22,16 @@ import java.io.IOException; import javax.xml.transform.TransformerException; import javax.xml.transform.stream.StreamResult; +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; + import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.util.FileCopyUtils; import org.springframework.ws.wsdl.WsdlDefinition; import org.springframework.xml.transform.TransformerObjectSupport; -import com.sun.net.httpserver.Headers; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; - /** * @author Arjen Poutsma * @since 1.5.0 @@ -42,7 +42,8 @@ public class WsdlDefinitionHttpHandler extends TransformerObjectSupport implemen private WsdlDefinition definition; - public WsdlDefinitionHttpHandler() {} + public WsdlDefinitionHttpHandler() { + } public WsdlDefinitionHttpHandler(WsdlDefinition definition) { this.definition = definition; @@ -68,13 +69,17 @@ public class WsdlDefinitionHttpHandler extends TransformerObjectSupport implemen byte[] buf = os.toByteArray(); httpExchange.sendResponseHeaders(HttpTransportConstants.STATUS_OK, buf.length); FileCopyUtils.copy(buf, httpExchange.getResponseBody()); - } else { + } + else { httpExchange.sendResponseHeaders(HttpTransportConstants.STATUS_METHOD_NOT_ALLOWED, -1); } - } catch (TransformerException ex) { + } + catch (TransformerException ex) { logger.error(ex, ex); - } finally { + } + finally { httpExchange.close(); } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/BytesMessageInputStream.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/BytesMessageInputStream.java index a063b3bf..834d95b6 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/BytesMessageInputStream.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/BytesMessageInputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,13 @@ package org.springframework.ws.transport.jms; +import java.io.IOException; +import java.io.InputStream; + import jakarta.jms.BytesMessage; import jakarta.jms.JMSException; import jakarta.jms.MessageEOFException; -import java.io.IOException; -import java.io.InputStream; - import org.springframework.util.Assert; /** @@ -44,7 +44,8 @@ class BytesMessageInputStream extends InputStream { public int read(byte b[]) throws IOException { try { return message.readBytes(b); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); } } @@ -54,10 +55,12 @@ class BytesMessageInputStream extends InputStream { if (off == 0) { try { return message.readBytes(b, len); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); } - } else { + } + else { return super.read(b, off, len); } } @@ -66,10 +69,13 @@ class BytesMessageInputStream extends InputStream { public int read() throws IOException { try { return message.readByte(); - } catch (MessageEOFException ex) { + } + catch (MessageEOFException ex) { return -1; - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/BytesMessageOutputStream.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/BytesMessageOutputStream.java index b7afd7cd..a7d4282e 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/BytesMessageOutputStream.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/BytesMessageOutputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.transport.jms; -import jakarta.jms.BytesMessage; -import jakarta.jms.JMSException; - import java.io.IOException; import java.io.OutputStream; +import jakarta.jms.BytesMessage; +import jakarta.jms.JMSException; + import org.springframework.util.Assert; /** @@ -43,7 +43,8 @@ class BytesMessageOutputStream extends OutputStream { public void write(byte b[]) throws IOException { try { message.writeBytes(b); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); } } @@ -52,7 +53,8 @@ class BytesMessageOutputStream extends OutputStream { public void write(byte b[], int off, int len) throws IOException { try { message.writeBytes(b, off, len); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); } } @@ -61,8 +63,10 @@ class BytesMessageOutputStream extends OutputStream { public void write(int b) throws IOException { try { message.writeByte((byte) b); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsMessageReceiver.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsMessageReceiver.java index 3a7c3974..ab21a704 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsMessageReceiver.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsMessageReceiver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,10 +26,11 @@ import org.springframework.ws.transport.WebServiceMessageReceiver; import org.springframework.ws.transport.support.SimpleWebServiceMessageReceiverObjectSupport; /** - * Convenience base class for JMS server-side transport objects. Contains a {@link WebServiceMessageReceiver}, and has - * methods for handling incoming JMS {@link BytesMessage} and {@link TextMessage} requests. Also contains a - * {@code textMessageEncoding} property, which determines the encoding used to read from and write to - * {@code TextMessages}. This property defaults to {@code UTF-8}. + * Convenience base class for JMS server-side transport objects. Contains a + * {@link WebServiceMessageReceiver}, and has methods for handling incoming JMS + * {@link BytesMessage} and {@link TextMessage} requests. Also contains a + * {@code textMessageEncoding} property, which determines the encoding used to read from + * and write to {@code TextMessages}. This property defaults to {@code UTF-8}. *

* Used by {@link WebServiceMessageListener}. * @@ -45,14 +46,17 @@ public class JmsMessageReceiver extends SimpleWebServiceMessageReceiverObjectSup private MessagePostProcessor postProcessor; - /** Sets the encoding used to read from and write to {@link TextMessage} messages. Defaults to {@code UTF-8}. */ + /** + * Sets the encoding used to read from and write to {@link TextMessage} messages. + * Defaults to {@code UTF-8}. + */ public void setTextMessageEncoding(String textMessageEncoding) { this.textMessageEncoding = textMessageEncoding; } /** - * Sets the optional {@link MessagePostProcessor} to further modify outgoing messages after the XML contents has been - * set. + * Sets the optional {@link MessagePostProcessor} to further modify outgoing messages + * after the XML contents has been set. */ public void setPostProcessor(MessagePostProcessor postProcessor) { this.postProcessor = postProcessor; @@ -60,7 +64,6 @@ public class JmsMessageReceiver extends SimpleWebServiceMessageReceiverObjectSup /** * Handles an incoming message. Uses the given session to create a response message. - * * @param request the incoming message * @param session the JMS session used to create a response * @throws IllegalArgumentException when request is not a {@link BytesMessage} @@ -69,14 +72,17 @@ public class JmsMessageReceiver extends SimpleWebServiceMessageReceiverObjectSup JmsReceiverConnection connection; if (request instanceof BytesMessage) { connection = new JmsReceiverConnection((BytesMessage) request, session); - } else if (request instanceof TextMessage) { + } + else if (request instanceof TextMessage) { connection = new JmsReceiverConnection((TextMessage) request, textMessageEncoding, session); - } else { - throw new IllegalArgumentException( - "Wrong message type: [" + request.getClass() + "]. Only BytesMessages or TextMessages can be handled."); + } + else { + throw new IllegalArgumentException("Wrong message type: [" + request.getClass() + + "]. Only BytesMessages or TextMessages can be handled."); } connection.setPostProcessor(postProcessor); handleConnection(connection); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsMessageSender.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsMessageSender.java index de49a536..8d70b069 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsMessageSender.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,6 +25,8 @@ import jakarta.jms.Destination; import jakarta.jms.JMSException; import jakarta.jms.Message; import jakarta.jms.Session; +import jakarta.jms.Topic; + import org.springframework.jms.connection.ConnectionFactoryUtils; import org.springframework.jms.core.MessagePostProcessor; import org.springframework.jms.support.JmsUtils; @@ -35,14 +37,16 @@ import org.springframework.ws.transport.WebServiceMessageSender; import org.springframework.ws.transport.jms.support.JmsTransportUtils; /** - * {@link WebServiceMessageSender} implementation that uses JMS {@link Message}s. Requires a JMS - * {@link ConnectionFactory} to operate. + * {@link WebServiceMessageSender} implementation that uses JMS {@link Message}s. Requires + * a JMS {@link ConnectionFactory} to operate. *

* This message sender supports URI's of the following format:

* jms:destination[?param-name=param-value][&param-name=param-value]* - *
where the characters :, ?, and & stand for - * themselves. The destination represents the name of the {@link Queue} or {@link Topic} that will be resolved by - * the {@link #getDestinationResolver() destination resolver}. Valid param-name include:
+ *
where the characters :, ?, and + * & stand for themselves. The destination represents the name + * of the {@link Queue} or {@link Topic} that will be resolved by the + * {@link #getDestinationResolver() destination resolver}. Valid param-name + * include:
* * * @@ -50,34 +54,40 @@ import org.springframework.ws.transport.jms.support.JmsTransportUtils; * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * *
param-name
deliveryModeIndicates whether the request message is persistent or not. This may be PERSISTENT or - * NON_PERSISTENT. See {@link jakarta.jms.MessageProducer#setDeliveryMode(int)}Indicates whether the request message is persistent or not. This may be + * PERSISTENT or NON_PERSISTENT. See + * {@link jakarta.jms.MessageProducer#setDeliveryMode(int)}
messageTypeThe message type. This may be BINARY_MESSAGE (the default) or TEXT_MESSAGEThe message type. This may be BINARY_MESSAGE (the default) or + * TEXT_MESSAGE
priorityThe JMS priority (0-9) associated with the request message. See {@link jakarta.jms.MessageProducer#setPriority(int)}The JMS priority (0-9) associated with the request message. See + * {@link jakarta.jms.MessageProducer#setPriority(int)}
replyToNameThe name of the destination to which the response message must be sent, that will be resolved by the - * {@link #getDestinationResolver() destination resolver}.The name of the destination to which the response message must be sent, that will + * be resolved by the {@link #getDestinationResolver() destination resolver}.
timeToLiveThe lifetime, in milliseconds, of the request message. See {@link jakarta.jms.MessageProducer#setTimeToLive(long)}The lifetime, in milliseconds, of the request message. See + * {@link jakarta.jms.MessageProducer#setTimeToLive(long)}
*
*

- * If the replyToName is not set, a {@link Session#createTemporaryQueue() temporary queue} is used. + * If the replyToName is not set, a {@link Session#createTemporaryQueue() + * temporary queue} is used. *

- * This class uses {@link jakarta.jms.BytesMessage} messages by default, but can be configured to send {@link jakarta.jms.TextMessage} messages - * instead. Note that {@code BytesMessages} are preferred, since {@code TextMessages} do not support attachments - * and character encodings reliably. + * This class uses {@link jakarta.jms.BytesMessage} messages by default, but can be + * configured to send {@link jakarta.jms.TextMessage} messages instead. Note that + * {@code BytesMessages} are preferred, since {@code TextMessages} do not support + * attachments and character encodings reliably. *

* Some examples of JMS URIs are:

jms:SomeQueue
* jms:SomeTopic?priority=3&deliveryMode=NON_PERSISTENT
@@ -85,15 +95,22 @@ import org.springframework.ws.transport.jms.support.JmsTransportUtils; * jms:Queue?messageType=TEXT_MESSAGE
* * @author Arjen Poutsma - * @see IRI Scheme for Java(tm) Message Service 1.0 + * @see IRI Scheme for + * Java(tm) Message Service 1.0 * @since 1.5.0 */ public class JmsMessageSender extends JmsDestinationAccessor implements WebServiceMessageSender { - /** Default timeout for receive operations: -1 indicates a blocking receive without timeout. */ + /** + * Default timeout for receive operations: -1 indicates a blocking receive without + * timeout. + */ public static final long DEFAULT_RECEIVE_TIMEOUT = -1; - /** Default encoding used to read fromn and write to {@link jakarta.jms.TextMessage} messages. */ + /** + * Default encoding used to read fromn and write to {@link jakarta.jms.TextMessage} + * messages. + */ public static final String DEFAULT_TEXT_MESSAGE_ENCODING = "UTF-8"; private long receiveTimeout = DEFAULT_RECEIVE_TIMEOUT; @@ -105,17 +122,16 @@ public class JmsMessageSender extends JmsDestinationAccessor implements WebServi /** * Create a new {@code JmsMessageSender} *

- * Note: The ConnectionFactory has to be set before using the instance. This constructor can be used to prepare - * a JmsTemplate via a BeanFactory, typically setting the ConnectionFactory via - * {@link #setConnectionFactory(ConnectionFactory)}. - * + * Note: The ConnectionFactory has to be set before using the instance. This + * constructor can be used to prepare a JmsTemplate via a BeanFactory, typically + * setting the ConnectionFactory via {@link #setConnectionFactory(ConnectionFactory)}. * @see #setConnectionFactory(ConnectionFactory) */ - public JmsMessageSender() {} + public JmsMessageSender() { + } /** * Create a new {@code JmsMessageSender}, given a ConnectionFactory. - * * @param connectionFactory the ConnectionFactory to obtain Connections from */ public JmsMessageSender(ConnectionFactory connectionFactory) { @@ -123,22 +139,25 @@ public class JmsMessageSender extends JmsDestinationAccessor implements WebServi } /** - * Set the timeout to use for receive calls. The default is -1, which means no timeout. - * + * Set the timeout to use for receive calls. The default is -1, which means no + * timeout. * @see jakarta.jms.MessageConsumer#receive(long) */ public void setReceiveTimeout(long receiveTimeout) { this.receiveTimeout = receiveTimeout; } - /** Sets the encoding used to read from {@link jakarta.jms.TextMessage} messages. Defaults to {@code UTF-8}. */ + /** + * Sets the encoding used to read from {@link jakarta.jms.TextMessage} messages. + * Defaults to {@code UTF-8}. + */ public void setTextMessageEncoding(String textMessageEncoding) { this.textMessageEncoding = textMessageEncoding; } /** - * Sets the optional {@link MessagePostProcessor} to further modify outgoing messages after the XML contents has been - * set. + * Sets the optional {@link MessagePostProcessor} to further modify outgoing messages + * after the XML contents has been set. */ public void setPostProcessor(MessagePostProcessor postProcessor) { this.postProcessor = postProcessor; @@ -153,8 +172,8 @@ public class JmsMessageSender extends JmsDestinationAccessor implements WebServi jmsSession = createSession(jmsConnection); Destination requestDestination = resolveRequestDestination(jmsSession, uri); Message requestMessage = createRequestMessage(jmsSession, uri); - JmsSenderConnection wsConnection = new JmsSenderConnection(getConnectionFactory(), jmsConnection, jmsSession, - requestDestination, requestMessage); + JmsSenderConnection wsConnection = new JmsSenderConnection(getConnectionFactory(), jmsConnection, + jmsSession, requestDestination, requestMessage); wsConnection.setDeliveryMode(JmsTransportUtils.getDeliveryMode(uri)); wsConnection.setPriority(JmsTransportUtils.getPriority(uri)); wsConnection.setReceiveTimeout(receiveTimeout); @@ -164,7 +183,8 @@ public class JmsMessageSender extends JmsDestinationAccessor implements WebServi wsConnection.setSessionTransacted(isSessionTransacted()); wsConnection.setPostProcessor(postProcessor); return wsConnection; - } catch (JMSException ex) { + } + catch (JMSException ex) { JmsUtils.closeSession(jmsSession); ConnectionFactoryUtils.releaseConnection(jmsConnection, getConnectionFactory(), true); throw new JmsTransportException(ex); @@ -189,9 +209,11 @@ public class JmsMessageSender extends JmsDestinationAccessor implements WebServi int messageType = JmsTransportUtils.getMessageType(uri); if (messageType == JmsTransportConstants.BYTES_MESSAGE_TYPE) { return session.createBytesMessage(); - } else if (messageType == JmsTransportConstants.TEXT_MESSAGE_TYPE) { + } + else if (messageType == JmsTransportConstants.TEXT_MESSAGE_TYPE) { return session.createTextMessage(); - } else { + } + else { throw new IllegalArgumentException("Invalid message type [" + messageType + "]."); } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsReceiverConnection.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsReceiverConnection.java index 4d67a1d4..e84e6a00 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsReceiverConnection.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsReceiverConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,6 +29,7 @@ import jakarta.jms.Message; import jakarta.jms.MessageProducer; import jakarta.jms.Session; import jakarta.jms.TextMessage; + import org.springframework.jms.core.MessagePostProcessor; import org.springframework.jms.support.JmsUtils; import org.springframework.util.Assert; @@ -38,12 +39,13 @@ import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.jms.support.JmsTransportUtils; /** - * Implementation of {@link WebServiceConnection} that is used for server-side JMS access. Exposes a - * {@link BytesMessage} or {@link TextMessage} request and response message. + * Implementation of {@link WebServiceConnection} that is used for server-side JMS access. + * Exposes a {@link BytesMessage} or {@link TextMessage} request and response message. *

- * The response message type is equal to the request message type, i.e. if a {@code BytesMessage} is received as - * request, a {@code BytesMessage} is created as response, and if a {@code TextMessage} is received, a - * {@code TextMessage} response is created. + * The response message type is equal to the request message type, i.e. if a + * {@code BytesMessage} is received as request, a {@code BytesMessage} is created as + * response, and if a {@code TextMessage} is received, a {@code TextMessage} response is + * created. * * @author Arjen Poutsma * @author Greg Turnquist @@ -70,7 +72,6 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { /** * Constructs a new JMS connection with the given {@link BytesMessage}. - * * @param requestMessage the JMS request message * @param session the JMS session */ @@ -80,7 +81,6 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { /** * Constructs a new JMS connection with the given {@link TextMessage}. - * * @param requestMessage the JMS request message * @param session the JMS session */ @@ -94,15 +94,16 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { } /** - * Returns the request message for this connection. Returns either a {@link BytesMessage} or a {@link TextMessage}. + * Returns the request message for this connection. Returns either a + * {@link BytesMessage} or a {@link TextMessage}. */ public Message getRequestMessage() { return requestMessage; } /** - * Returns the response message, if any, for this connection. Returns either a {@link BytesMessage} or a - * {@link TextMessage}. + * Returns the response message, if any, for this connection. Returns either a + * {@link BytesMessage} or a {@link TextMessage}. */ public Message getResponseMessage() { return responseMessage; @@ -116,7 +117,8 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { public URI getUri() throws URISyntaxException { try { return JmsTransportUtils.toUri(requestMessage.getJMSDestination()); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new URISyntaxException("", ex.getMessage()); } } @@ -143,7 +145,8 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { public Iterator getRequestHeaderNames() throws IOException { try { return JmsTransportUtils.getHeaderNames(requestMessage); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException("Could not get property names", ex); } } @@ -152,7 +155,8 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { public Iterator getRequestHeaders(String name) throws IOException { try { return JmsTransportUtils.getHeaders(requestMessage, name); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException("Could not get property value", ex); } } @@ -161,9 +165,11 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { protected InputStream getRequestInputStream() throws IOException { if (requestMessage instanceof BytesMessage) { return new BytesMessageInputStream((BytesMessage) requestMessage); - } else if (requestMessage instanceof TextMessage) { + } + else if (requestMessage instanceof TextMessage) { return new TextMessageInputStream((TextMessage) requestMessage, textMessageEncoding); - } else { + } + else { throw new IllegalStateException("Unknown request message type [" + requestMessage + "]"); } } @@ -177,9 +183,11 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { try { if (requestMessage instanceof BytesMessage) { responseMessage = session.createBytesMessage(); - } else if (requestMessage instanceof TextMessage) { + } + else if (requestMessage instanceof TextMessage) { responseMessage = session.createTextMessage(); - } else { + } + else { throw new IllegalStateException("Unknown request message type [" + requestMessage + "]"); } String correlation = requestMessage.getJMSCorrelationID(); @@ -187,7 +195,8 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { correlation = requestMessage.getJMSMessageID(); } responseMessage.setJMSCorrelationID(correlation); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException("Could not create response message", ex); } } @@ -196,7 +205,8 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { public void addResponseHeader(String name, String value) throws IOException { try { JmsTransportUtils.addHeader(responseMessage, name, value); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException("Could not set property", ex); } } @@ -205,9 +215,11 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { protected OutputStream getResponseOutputStream() throws IOException { if (responseMessage instanceof BytesMessage) { return new BytesMessageOutputStream((BytesMessage) responseMessage); - } else if (responseMessage instanceof TextMessage) { + } + else if (responseMessage instanceof TextMessage) { return new TextMessageOutputStream((TextMessage) responseMessage, textMessageEncoding); - } else { + } + else { throw new IllegalStateException("Unknown response message type [" + responseMessage + "]"); } } @@ -225,9 +237,11 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { } messageProducer.send(responseMessage); } - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); - } finally { + } + finally { JmsUtils.closeMessageProducer(messageProducer); } } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsSenderConnection.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsSenderConnection.java index e999d230..c3d5e69a 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsSenderConnection.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsSenderConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,25 @@ package org.springframework.ws.transport.jms; -import jakarta.jms.*; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.lang.IllegalStateException; import java.net.URI; import java.net.URISyntaxException; import java.util.Iterator; +import jakarta.jms.BytesMessage; +import jakarta.jms.Connection; +import jakarta.jms.ConnectionFactory; +import jakarta.jms.Destination; +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.MessageConsumer; +import jakarta.jms.MessageProducer; +import jakarta.jms.Session; +import jakarta.jms.TemporaryQueue; +import jakarta.jms.TextMessage; + import org.springframework.jms.connection.ConnectionFactoryUtils; import org.springframework.jms.core.MessagePostProcessor; import org.springframework.jms.support.JmsUtils; @@ -36,8 +45,8 @@ import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.jms.support.JmsTransportUtils; /** - * Implementation of {@link WebServiceConnection} that is used for client-side JMS access. Exposes a - * {@link BytesMessage} request and response message. + * Implementation of {@link WebServiceConnection} that is used for client-side JMS access. + * Exposes a {@link BytesMessage} request and response message. * * @author Arjen Poutsma * @author Greg Turnquist @@ -91,15 +100,16 @@ public class JmsSenderConnection extends AbstractSenderConnection { } /** - * Returns the request message for this connection. Returns either a {@link BytesMessage} or a {@link TextMessage}. + * Returns the request message for this connection. Returns either a + * {@link BytesMessage} or a {@link TextMessage}. */ public Message getRequestMessage() { return requestMessage; } /** - * Returns the response message, if any, for this connection. Returns either a {@link BytesMessage} or a - * {@link TextMessage}. + * Returns the response message, if any, for this connection. Returns either a + * {@link BytesMessage} or a {@link TextMessage}. */ public Message getResponseMessage() { return responseMessage; @@ -149,7 +159,8 @@ public class JmsSenderConnection extends AbstractSenderConnection { public URI getUri() throws URISyntaxException { try { return JmsTransportUtils.toUri(requestDestination); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new URISyntaxException("", ex.getMessage()); } } @@ -176,7 +187,8 @@ public class JmsSenderConnection extends AbstractSenderConnection { public void addRequestHeader(String name, String value) throws IOException { try { JmsTransportUtils.addHeader(requestMessage, name, value); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException("Could not set property", ex); } } @@ -185,9 +197,11 @@ public class JmsSenderConnection extends AbstractSenderConnection { protected OutputStream getRequestOutputStream() throws IOException { if (requestMessage instanceof BytesMessage) { return new BytesMessageOutputStream((BytesMessage) requestMessage); - } else if (requestMessage instanceof TextMessage) { + } + else if (requestMessage instanceof TextMessage) { return new TextMessageOutputStream((TextMessage) requestMessage, textMessageEncoding); - } else { + } + else { throw new IllegalStateException("Unknown request message type [" + requestMessage + "]"); } @@ -214,21 +228,26 @@ public class JmsSenderConnection extends AbstractSenderConnection { if (session.getTransacted() && isSessionLocallyTransacted(session)) { JmsUtils.commitIfNecessary(session); } - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); - } finally { + } + finally { JmsUtils.closeMessageProducer(messageProducer); } } - /** @see org.springframework.jms.core.JmsTemplate#isSessionLocallyTransacted(Session) (Session) */ + /* + * * @see org.springframework.jms.core.JmsTemplate#isSessionLocallyTransacted(Session) + * (Session) + */ private boolean isSessionLocallyTransacted(Session session) { return sessionTransacted && !ConnectionFactoryUtils.isSessionTransactional(session, connectionFactory); } /* - * Receiving - */ + * Receiving + */ @Override protected void onReceiveBeforeRead() throws IOException { @@ -236,7 +255,8 @@ public class JmsSenderConnection extends AbstractSenderConnection { try { if (temporaryResponseQueueCreated) { messageConsumer = session.createConsumer(responseDestination); - } else { + } + else { String messageId = requestMessage.getJMSMessageID().replaceAll("'", "''"); String messageSelector = "JMSCorrelationID = '" + messageId + "'"; messageConsumer = session.createConsumer(responseDestination, messageSelector); @@ -244,18 +264,22 @@ public class JmsSenderConnection extends AbstractSenderConnection { Message message = receiveTimeout >= 0 ? messageConsumer.receive(receiveTimeout) : messageConsumer.receive(); if (message instanceof BytesMessage || message instanceof TextMessage) { responseMessage = message; - } else if (message != null) { + } + else if (message != null) { throw new IllegalArgumentException("Wrong message type: [" + message.getClass() + "]. " + "Only BytesMessages or TextMessages can be handled."); } - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); - } finally { + } + finally { JmsUtils.closeMessageConsumer(messageConsumer); if (temporaryResponseQueueCreated) { try { ((TemporaryQueue) responseDestination).delete(); - } catch (JMSException ex) { + } + catch (JMSException ex) { // ignore } } @@ -271,7 +295,8 @@ public class JmsSenderConnection extends AbstractSenderConnection { public Iterator getResponseHeaderNames() throws IOException { try { return JmsTransportUtils.getHeaderNames(responseMessage); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException("Could not get property names", ex); } } @@ -280,7 +305,8 @@ public class JmsSenderConnection extends AbstractSenderConnection { public Iterator getResponseHeaders(String name) throws IOException { try { return JmsTransportUtils.getHeaders(responseMessage, name); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException("Could not get property value", ex); } } @@ -289,9 +315,11 @@ public class JmsSenderConnection extends AbstractSenderConnection { protected InputStream getResponseInputStream() throws IOException { if (responseMessage instanceof BytesMessage) { return new BytesMessageInputStream((BytesMessage) responseMessage); - } else if (responseMessage instanceof TextMessage) { + } + else if (responseMessage instanceof TextMessage) { return new TextMessageInputStream((TextMessage) responseMessage, textMessageEncoding); - } else { + } + else { throw new IllegalStateException("Unknown response message type [" + responseMessage + "]"); } @@ -302,4 +330,5 @@ public class JmsSenderConnection extends AbstractSenderConnection { JmsUtils.closeSession(session); ConnectionFactoryUtils.releaseConnection(connection, connectionFactory, true); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsTransportException.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsTransportException.java index 03342130..f21c6145 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsTransportException.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/JmsTransportException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -46,4 +46,5 @@ public class JmsTransportException extends TransportException { public JMSException getJmsException() { return jmsException; } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/TextMessageInputStream.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/TextMessageInputStream.java index 9c900160..c5b61f0e 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/TextMessageInputStream.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/TextMessageInputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,14 @@ package org.springframework.ws.transport.jms; -import jakarta.jms.JMSException; -import jakarta.jms.TextMessage; - import java.io.ByteArrayInputStream; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; +import jakarta.jms.JMSException; +import jakarta.jms.TextMessage; + import org.springframework.util.Assert; /** @@ -45,8 +45,10 @@ class TextMessageInputStream extends FilterInputStream { String text = message.getText(); byte[] contents = text != null ? text.getBytes(encoding) : new byte[0]; return new ByteArrayInputStream(contents); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/TextMessageOutputStream.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/TextMessageOutputStream.java index 15c2214a..f31bfdcf 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/TextMessageOutputStream.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/TextMessageOutputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,13 @@ package org.springframework.ws.transport.jms; -import jakarta.jms.JMSException; -import jakarta.jms.TextMessage; - import java.io.ByteArrayOutputStream; import java.io.FilterOutputStream; import java.io.IOException; +import jakarta.jms.JMSException; +import jakarta.jms.TextMessage; + import org.springframework.util.Assert; /** @@ -52,8 +52,10 @@ class TextMessageOutputStream extends FilterOutputStream { ByteArrayOutputStream baos = (ByteArrayOutputStream) out; String text = baos.toString(encoding); message.setText(text); - } catch (JMSException ex) { + } + catch (JMSException ex) { throw new JmsTransportException(ex); } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/WebServiceMessageListener.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/WebServiceMessageListener.java index e7777f3a..da84568e 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/WebServiceMessageListener.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/WebServiceMessageListener.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,11 +26,13 @@ import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.transport.WebServiceMessageReceiver; /** - * Spring {@link SessionAwareMessageListener} that can be used to handle incoming {@link Message} service requests. + * Spring {@link SessionAwareMessageListener} that can be used to handle incoming + * {@link Message} service requests. *

* Requires a {@link WebServiceMessageFactory} which is used to convert the incoming JMS - * {@link jakarta.jms.BytesMessage} into a {@link WebServiceMessage}, and passes that to the - * {@link WebServiceMessageReceiver} {@link #setMessageReceiver(WebServiceMessageReceiver) registered}. + * {@link jakarta.jms.BytesMessage} into a {@link WebServiceMessage}, and passes that to + * the {@link WebServiceMessageReceiver} + * {@link #setMessageReceiver(WebServiceMessageReceiver) registered}. * * @author Arjen Poutsma * @see #setMessageFactory(org.springframework.ws.WebServiceMessageFactory) @@ -43,9 +45,11 @@ public class WebServiceMessageListener extends JmsMessageReceiver implements Ses public void onMessage(Message message, Session session) throws JMSException { try { handleMessage(message, session); - } catch (JmsTransportException ex) { + } + catch (JmsTransportException ex) { throw ex.getJmsException(); - } catch (Exception ex) { + } + catch (Exception ex) { JMSException jmsException = new JMSException(ex.getMessage()); jmsException.setLinkedException(ex); throw jmsException; diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/support/JmsTransportUtils.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/support/JmsTransportUtils.java index 15ce2f0a..216f5dc9 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/support/JmsTransportUtils.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/jms/support/JmsTransportUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,6 @@ package org.springframework.ws.transport.jms.support; -import jakarta.jms.DeliveryMode; -import jakarta.jms.Destination; -import jakarta.jms.JMSException; -import jakarta.jms.Message; -import jakarta.jms.Queue; -import jakarta.jms.Topic; - import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; @@ -33,11 +26,18 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import jakarta.jms.DeliveryMode; +import jakarta.jms.Destination; +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.Queue; +import jakarta.jms.Topic; + import org.springframework.ws.transport.jms.JmsTransportConstants; /** - * Collection of utility methods to work with JMS transports. Includes methods to retrieve JMS properties from an - * {@link URI}. + * Collection of utility methods to work with JMS transports. Includes methods to retrieve + * JMS properties from an {@link URI}. * * @author Arjen Poutsma * @since 1.5.0 @@ -62,11 +62,12 @@ public abstract class JmsTransportUtils { private static final Pattern REPLY_TO_NAME_PATTERN = Pattern.compile("replyToName=([^&]+)"); - private JmsTransportUtils() {} + private JmsTransportUtils() { + } /** - * Converts the given transport header to a JMS property name. Returns the given header name if no match is found. - * + * Converts the given transport header to a JMS property name. Returns the given + * header name if no match is found. * @param headerName the header name to transform * @return the JMS property name */ @@ -80,9 +81,8 @@ public abstract class JmsTransportUtils { } /** - * Converts the given JMS property name to a transport header name. Returns the given property name if no match is - * found. - * + * Converts the given JMS property name to a transport header name. Returns the given + * property name if no match is found. * @param propertyName the JMS property name to transform * @return the transport header name */ @@ -97,7 +97,6 @@ public abstract class JmsTransportUtils { /** * Converts the given JMS destination into a {@code jms} URI. - * * @param destination the destination * @return a jms URI */ @@ -108,10 +107,12 @@ public abstract class JmsTransportUtils { String destinationName; if (destination instanceof Queue) { destinationName = ((Queue) destination).getQueueName(); - } else if (destination instanceof Topic) { + } + else if (destination instanceof Topic) { Topic topic = (Topic) destination; destinationName = topic.getTopicName(); - } else { + } + else { throw new IllegalArgumentException("Destination [ " + destination + "] is neither Queue nor Topic"); } return new URI(JmsTransportConstants.JMS_URI_SCHEME, destinationName, null); @@ -129,7 +130,8 @@ public abstract class JmsTransportUtils { } /** - * Returns an iterator over all header names in the given message. Delegates to {@link #jmsPropertyToHeader(String)}. + * Returns an iterator over all header names in the given message. Delegates to + * {@link #jmsPropertyToHeader(String)}. */ public static Iterator getHeaderNames(Message message) throws JMSException { Enumeration properties = message.getPropertyNames(); @@ -145,22 +147,22 @@ public abstract class JmsTransportUtils { } /** - * Returns an iterator over all the header values of the given message and header name. Delegates to - * {@link #headerToJmsProperty(String)}. + * Returns an iterator over all the header values of the given message and header + * name. Delegates to {@link #headerToJmsProperty(String)}. */ public static Iterator getHeaders(Message message, String name) throws JMSException { String propertyName = headerToJmsProperty(name); String value = message.getStringProperty(propertyName); if (value != null) { return Collections.singletonList(value).iterator(); - } else { + } + else { return Collections.emptyIterator(); } } /** * Returns the delivery mode of the given URI. - * * @see DeliveryMode#NON_PERSISTENT * @see DeliveryMode#PERSISTENT * @see Message#DEFAULT_DELIVERY_MODE @@ -169,16 +171,18 @@ public abstract class JmsTransportUtils { String deliveryMode = getStringParameter(DELIVERY_MODE_PATTERN, uri); if ("NON_PERSISTENT".equals(deliveryMode)) { return DeliveryMode.NON_PERSISTENT; - } else if ("PERSISTENT".equals(deliveryMode)) { + } + else if ("PERSISTENT".equals(deliveryMode)) { return DeliveryMode.PERSISTENT; - } else { + } + else { return Message.DEFAULT_DELIVERY_MODE; } } /** - * Returns the message type of the given URI. Defaults to {@link JmsTransportConstants#BYTES_MESSAGE_TYPE}. - * + * Returns the message type of the given URI. Defaults to + * {@link JmsTransportConstants#BYTES_MESSAGE_TYPE}. * @see JmsTransportConstants#BYTES_MESSAGE_TYPE * @see JmsTransportConstants#TEXT_MESSAGE_TYPE */ @@ -186,14 +190,14 @@ public abstract class JmsTransportUtils { String deliveryMode = getStringParameter(MESSAGE_TYPE_PATTERN, uri); if ("TEXT_MESSAGE".equals(deliveryMode)) { return JmsTransportConstants.TEXT_MESSAGE_TYPE; - } else { + } + else { return JmsTransportConstants.BYTES_MESSAGE_TYPE; } } /** * Returns the lifetime, in milliseconds, of the given URI. - * * @see Message#DEFAULT_TIME_TO_LIVE */ public static long getTimeToLive(URI uri) { @@ -202,7 +206,6 @@ public abstract class JmsTransportUtils { /** * Returns the priority of the given URI. - * * @see Message#DEFAULT_PRIORITY */ public static int getPriority(URI uri) { @@ -211,7 +214,6 @@ public abstract class JmsTransportUtils { /** * Returns the reply-to name of the given URI. - * * @see Message#setJMSReplyTo(Destination) */ public static String getReplyToName(URI uri) { @@ -231,7 +233,8 @@ public abstract class JmsTransportUtils { if (matcher.find() && matcher.groupCount() == 1) { try { return Integer.parseInt(matcher.group(1)); - } catch (NumberFormatException ex) { + } + catch (NumberFormatException ex) { // fall through to default value } } @@ -243,7 +246,8 @@ public abstract class JmsTransportUtils { if (matcher.find() && matcher.groupCount() == 1) { try { return Long.parseLong(matcher.group(1)); - } catch (NumberFormatException ex) { + } + catch (NumberFormatException ex) { // fall through to default value } } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageReceiver.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageReceiver.java index 7c8e0da1..52cc9736 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageReceiver.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageReceiver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,6 +16,8 @@ package org.springframework.ws.transport.mail; +import java.util.Properties; + import jakarta.mail.Folder; import jakarta.mail.FolderClosedException; import jakarta.mail.Message; @@ -26,8 +28,6 @@ import jakarta.mail.URLName; import jakarta.mail.internet.AddressException; import jakarta.mail.internet.InternetAddress; -import java.util.Properties; - import org.springframework.scheduling.SchedulingAwareRunnable; import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessageFactory; @@ -39,13 +39,16 @@ import org.springframework.ws.transport.mail.support.MailTransportUtils; import org.springframework.ws.transport.support.AbstractAsyncStandaloneMessageReceiver; /** - * Server-side component for receiving email messages using JavaMail. Requires a {@link #setTransportUri(String) - * transport} URI, {@link #setStoreUri(String) store} URI, and {@link #setMonitoringStrategy(MonitoringStrategy) - * monitoringStrategy} to be set, in addition to the {@link #setMessageFactory(WebServiceMessageFactory) messageFactory} - * and {@link #setMessageReceiver(WebServiceMessageReceiver) messageReceiver} required by the base class. + * Server-side component for receiving email messages using JavaMail. Requires a + * {@link #setTransportUri(String) transport} URI, {@link #setStoreUri(String) store} URI, + * and {@link #setMonitoringStrategy(MonitoringStrategy) monitoringStrategy} to be set, in + * addition to the {@link #setMessageFactory(WebServiceMessageFactory) messageFactory} and + * {@link #setMessageReceiver(WebServiceMessageReceiver) messageReceiver} required by the + * base class. *

- * The {@link MonitoringStrategy} is used to detect new incoming email request. If the {@code monitoringStrategy} is not - * explicitly set, this receiver will use the {@link Pop3PollingMonitoringStrategy} for POP3 servers, and the + * The {@link MonitoringStrategy} is used to detect new incoming email request. If the + * {@code monitoringStrategy} is not explicitly set, this receiver will use the + * {@link Pop3PollingMonitoringStrategy} for POP3 servers, and the * {@link PollingMonitoringStrategy} for IMAP servers. * * @author Arjen Poutsma @@ -75,8 +78,8 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver /** * Set JavaMail properties for the {@link Session}. *

- * A new {@link Session} will be created with those properties. Use either this method or {@link #setSession}, but not - * both. + * A new {@link Session} will be created with those properties. Use either this method + * or {@link #setSession}, but not both. *

* Non-default properties in this instance will override given JavaMail properties. */ @@ -87,11 +90,11 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver /** * Set the JavaMail {@code Session}, possibly pulled from JNDI. *

- * Default is a new {@code Session} without defaults, that is completely configured via this instance's properties. + * Default is a new {@code Session} without defaults, that is completely configured + * via this instance's properties. *

- * If using a pre-configured {@code Session}, non-default properties in this instance will override the settings in - * the {@code Session}. - * + * If using a pre-configured {@code Session}, non-default properties in this instance + * will override the settings in the {@code Session}. * @see #setJavaMailProperties */ public void setSession(Session session) { @@ -100,11 +103,11 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver } /** - * Sets the JavaMail Store URI to be used for retrieving request messages. Typically takes the form of - * {@code [imap|pop3]://user:password@host:port/INBOX}. Setting this property is required. + * Sets the JavaMail Store URI to be used for retrieving request messages. Typically + * takes the form of {@code [imap|pop3]://user:password@host:port/INBOX}. Setting this + * property is required. *

* For example, {@code imap://john:secret@imap.example.com/INBOX} - * * @see Session#getStore(URLName) */ public void setStoreUri(String storeUri) { @@ -112,11 +115,11 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver } /** - * Sets the JavaMail Transport URI to be used for sending response messages. Typically takes the form of - * {@code smtp://user:password@host:port}. Setting this property is required. + * Sets the JavaMail Transport URI to be used for sending response messages. Typically + * takes the form of {@code smtp://user:password@host:port}. Setting this property is + * required. *

* For example, {@code smtp://john:secret@smtp.example.com} - * * @see Session#getTransport(URLName) */ public void setTransportUri(String transportUri) { @@ -124,7 +127,8 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver } /** - * Sets the monitoring strategy to use for retrieving new requests. Default is the {@link PollingMonitoringStrategy}. + * Sets the monitoring strategy to use for retrieving new requests. Default is the + * {@link PollingMonitoringStrategy}. */ public void setMonitoringStrategy(MonitoringStrategy monitoringStrategy) { this.monitoringStrategy = monitoringStrategy; @@ -138,9 +142,11 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver String protocol = storeUri.getProtocol(); if ("pop3".equals(protocol)) { monitoringStrategy = new Pop3PollingMonitoringStrategy(); - } else if ("imap".equals(protocol)) { + } + else if ("imap".equals(protocol)) { monitoringStrategy = new PollingMonitoringStrategy(); - } else { + } + else { throw new IllegalArgumentException("Cannot determine monitoring strategy for \"" + protocol + "\". " + "Set the 'monitoringStrategy' explicitly."); } @@ -222,19 +228,23 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver MessageHandler handler = new MessageHandler(message); execute(handler); } - } catch (FolderClosedException ex) { + } + catch (FolderClosedException ex) { logger.debug("Folder closed, reopening"); if (isRunning()) { openFolder(); } - } catch (MessagingException ex) { + } + catch (MessagingException ex) { logger.warn(ex); } } - } catch (InterruptedException ex) { + } + catch (InterruptedException ex) { // Restore the interrupted status Thread.currentThread().interrupt(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { logger.error(ex); } } @@ -243,6 +253,7 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver public boolean isLongLived() { return true; } + } private class MessageHandler implements SchedulingAwareRunnable { @@ -260,7 +271,8 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver connection.setFrom(from); try { handleConnection(connection); - } catch (Exception ex) { + } + catch (Exception ex) { logger.error("Could not handle incoming mail connection", ex); } } @@ -269,6 +281,7 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver public boolean isLongLived() { return false; } + } } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageSender.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageSender.java index 8938fa7b..4565e9a1 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageSender.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,15 @@ package org.springframework.ws.transport.mail; +import java.io.IOException; +import java.net.URI; +import java.util.Properties; + import jakarta.mail.Session; import jakarta.mail.URLName; import jakarta.mail.internet.AddressException; import jakarta.mail.internet.InternetAddress; -import java.io.IOException; -import java.net.URI; -import java.util.Properties; - import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessageFactory; @@ -34,20 +34,24 @@ import org.springframework.ws.transport.mail.monitor.PollingMonitoringStrategy; import org.springframework.ws.transport.mail.support.MailTransportUtils; /** - * {@link WebServiceMessageSender} implementation that uses Mail {@link MimeMessage}s. Requires a - * {@link #setTransportUri(String) transport} and {@link #setStoreUri(String) store} URI to be set. + * {@link WebServiceMessageSender} implementation that uses Mail {@link MimeMessage}s. + * Requires a {@link #setTransportUri(String) transport} and {@link #setStoreUri(String) + * store} URI to be set. *

- * Calling {@link WebServiceConnection#receive(WebServiceMessageFactory)} on connections created by this message sender - * will result in a blocking call, for the amount of milliseconds specified by the {@link #setReceiveSleepTime(long) - * receiveSleepTime} property. This will give the server time to formulate a response message. By default, this propery - * is set to 1 minute. For a proper request-response conversation to work, this property value must not be smaller the - * {@link PollingMonitoringStrategy#setPollingInterval(long) pollingInterval} property of the server-side message - * receiver polling strategy. + * Calling {@link WebServiceConnection#receive(WebServiceMessageFactory)} on connections + * created by this message sender will result in a blocking call, for the amount of + * milliseconds specified by the {@link #setReceiveSleepTime(long) receiveSleepTime} + * property. This will give the server time to formulate a response message. By default, + * this propery is set to 1 minute. For a proper request-response conversation to work, + * this property value must not be smaller the + * {@link PollingMonitoringStrategy#setPollingInterval(long) pollingInterval} property of + * the server-side message receiver polling strategy. *

* This message sender supports URI's of the following format:

* mailto:to[?param-name=param-value][&param-name=param-value]* - *
where the characters :, ?, and & stand for - * themselves. The to represents a RFC 822 mailbox. Valid param-name include:
+ *
where the characters :, ?, and + * & stand for themselves. The to represents a RFC 822 mailbox. + * Valid param-name include:
* * * @@ -71,7 +75,8 @@ import org.springframework.ws.transport.mail.support.MailTransportUtils; public class MailMessageSender implements WebServiceMessageSender, InitializingBean { /** - * Default timeout for receive operations. Set to 1000 * 60 milliseconds (i.e. 1 minute). + * Default timeout for receive operations. Set to 1000 * 60 milliseconds (i.e. 1 + * minute). */ public static final long DEFAULT_RECEIVE_TIMEOUT = 1000 * 60; @@ -95,8 +100,8 @@ public class MailMessageSender implements WebServiceMessageSender, InitializingB /** * Set JavaMail properties for the {@link Session}. *

- * A new {@link Session} will be created with those properties. Use either this method or {@link #setSession}, but not - * both. + * A new {@link Session} will be created with those properties. Use either this method + * or {@link #setSession}, but not both. *

* Non-default properties in this instance will override given JavaMail properties. */ @@ -105,8 +110,8 @@ public class MailMessageSender implements WebServiceMessageSender, InitializingB } /** - * Set the sleep time to use for receive calls, in milliseconds. The default is 1000 * 60 ms, that is - * 1 minute. + * Set the sleep time to use for receive calls, in milliseconds. The + * default is 1000 * 60 ms, that is 1 minute. */ public void setReceiveSleepTime(long receiveSleepTime) { this.receiveSleepTime = receiveSleepTime; @@ -115,11 +120,11 @@ public class MailMessageSender implements WebServiceMessageSender, InitializingB /** * Set the JavaMail {@code Session}, possibly pulled from JNDI. *

- * Default is a new {@code Session} without defaults, that is completely configured via this instance's properties. + * Default is a new {@code Session} without defaults, that is completely configured + * via this instance's properties. *

- * If using a pre-configured {@code Session}, non-default properties in this instance will override the settings in - * the {@code Session}. - * + * If using a pre-configured {@code Session}, non-default properties in this instance + * will override the settings in the {@code Session}. * @see #setJavaMailProperties */ public void setSession(Session session) { @@ -128,11 +133,11 @@ public class MailMessageSender implements WebServiceMessageSender, InitializingB } /** - * Sets the JavaMail Store URI to be used for retrieving response messages. Typically takes the form of - * {@code [imap|pop3]://user:password@host:port/INBOX}. Setting this property is required. + * Sets the JavaMail Store URI to be used for retrieving response messages. Typically + * takes the form of {@code [imap|pop3]://user:password@host:port/INBOX}. Setting this + * property is required. *

* For example, {@code imap://john:secret@imap.example.com/INBOX} - * * @see Session#getStore(URLName) */ public void setStoreUri(String storeUri) { @@ -140,11 +145,11 @@ public class MailMessageSender implements WebServiceMessageSender, InitializingB } /** - * Sets the JavaMail Transport URI to be used for sending response messages. Typically takes the form of - * {@code smtp://user:password@host:port}. Setting this property is required. + * Sets the JavaMail Transport URI to be used for sending response messages. Typically + * takes the form of {@code smtp://user:password@host:port}. Setting this property is + * required. *

* For example, {@code smtp://john:secret@smtp.example.com} - * * @see Session#getTransport(URLName) */ public void setTransportUri(String transportUri) { @@ -160,7 +165,8 @@ public class MailMessageSender implements WebServiceMessageSender, InitializingB @Override public WebServiceConnection createConnection(URI uri) throws IOException { InternetAddress to = MailTransportUtils.getTo(uri); - MailSenderConnection connection = new MailSenderConnection(session, transportUri, storeUri, to, receiveSleepTime); + MailSenderConnection connection = new MailSenderConnection(session, transportUri, storeUri, to, + receiveSleepTime); if (from != null) { connection.setFrom(from); } @@ -175,4 +181,5 @@ public class MailMessageSender implements WebServiceMessageSender, InitializingB public boolean supports(URI uri) { return uri.getScheme().equals(MailTransportConstants.MAIL_URI_SCHEME); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailReceiverConnection.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailReceiverConnection.java index dc47a49b..fe1ee5b5 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailReceiverConnection.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailReceiverConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,6 @@ package org.springframework.ws.transport.mail; -import jakarta.activation.DataHandler; -import jakarta.activation.DataSource; -import jakarta.mail.Address; -import jakarta.mail.Header; -import jakarta.mail.Message; -import jakarta.mail.MessagingException; -import jakarta.mail.Session; -import jakarta.mail.Transport; -import jakarta.mail.URLName; -import jakarta.mail.internet.InternetAddress; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -40,6 +29,17 @@ import java.util.Enumeration; import java.util.Iterator; import java.util.List; +import jakarta.activation.DataHandler; +import jakarta.activation.DataSource; +import jakarta.mail.Address; +import jakarta.mail.Header; +import jakarta.mail.Message; +import jakarta.mail.MessagingException; +import jakarta.mail.Session; +import jakarta.mail.Transport; +import jakarta.mail.URLName; +import jakarta.mail.internet.InternetAddress; + import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.ws.WebServiceMessage; @@ -49,8 +49,8 @@ import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.mail.support.MailTransportUtils; /** - * Implementation of {@link WebServiceConnection} that is used for server-side Mail access. Exposes a {@link Message} - * request and response message. + * Implementation of {@link WebServiceConnection} that is used for server-side Mail + * access. Exposes a {@link Message} request and response message. * * @author Arjen Poutsma * @author Greg Turnquist @@ -111,16 +111,18 @@ public class MailReceiverConnection extends AbstractReceiverConnection { Address[] recipients = requestMessage.getRecipients(Message.RecipientType.TO); if (!ObjectUtils.isEmpty(recipients) && recipients[0] instanceof InternetAddress) { return MailTransportUtils.toUri((InternetAddress) recipients[0], requestMessage.getSubject()); - } else { + } + else { throw new URISyntaxException("", "Could not determine To header"); } - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new URISyntaxException("", ex.getMessage()); } } /* - * Errors - */ + * Errors + */ @Override public String getErrorMessage() throws IOException { @@ -133,8 +135,8 @@ public class MailReceiverConnection extends AbstractReceiverConnection { } /* - * Receiving - */ + * Receiving + */ @Override public Iterator getRequestHeaderNames() throws IOException { @@ -146,7 +148,8 @@ public class MailReceiverConnection extends AbstractReceiverConnection { headers.add(header.getName()); } return headers.iterator(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new IOException(ex.getMessage()); } } @@ -156,7 +159,8 @@ public class MailReceiverConnection extends AbstractReceiverConnection { try { String[] headers = requestMessage.getHeader(name); return Arrays.asList(headers).iterator(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -165,7 +169,8 @@ public class MailReceiverConnection extends AbstractReceiverConnection { protected InputStream getRequestInputStream() throws IOException { try { return requestMessage.getInputStream(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -177,7 +182,8 @@ public class MailReceiverConnection extends AbstractReceiverConnection { if (TransportConstants.HEADER_CONTENT_TYPE.equals(name)) { responseContentType = value; } - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -198,7 +204,8 @@ public class MailReceiverConnection extends AbstractReceiverConnection { responseMessage.setFrom(from); responseBuffer = new ByteArrayOutputStream(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -207,15 +214,17 @@ public class MailReceiverConnection extends AbstractReceiverConnection { protected void onSendAfterWrite(WebServiceMessage message) throws IOException { Transport transport = null; try { - responseMessage - .setDataHandler(new DataHandler(new ByteArrayDataSource(responseContentType, responseBuffer.toByteArray()))); + responseMessage.setDataHandler( + new DataHandler(new ByteArrayDataSource(responseContentType, responseBuffer.toByteArray()))); transport = session.getTransport(transportUri); transport.connect(); responseMessage.saveChanges(); transport.sendMessage(responseMessage, responseMessage.getAllRecipients()); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); - } finally { + } + finally { MailTransportUtils.closeService(transport); } } @@ -250,5 +259,7 @@ public class MailReceiverConnection extends AbstractReceiverConnection { public OutputStream getOutputStream() throws IOException { throw new UnsupportedOperationException(); } + } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailSenderConnection.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailSenderConnection.java index 2ff50457..9486f1f9 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailSenderConnection.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailSenderConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,6 +16,20 @@ package org.springframework.ws.transport.mail; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; + import jakarta.activation.DataHandler; import jakarta.activation.DataSource; import jakarta.mail.Flags; @@ -31,23 +45,9 @@ import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.MimeMessage; import jakarta.mail.search.HeaderTerm; import jakarta.mail.search.SearchTerm; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.AbstractSenderConnection; @@ -56,8 +56,8 @@ import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.mail.support.MailTransportUtils; /** - * Implementation of {@link WebServiceConnection} that is used for client-side Mail access. Exposes a {@link Message} - * request and response message. + * Implementation of {@link WebServiceConnection} that is used for client-side Mail + * access. Exposes a {@link Message} request and response message. * * @author Arjen Poutsma * @author Greg Turnquist @@ -141,8 +141,8 @@ public class MailSenderConnection extends AbstractSenderConnection { } /* - * Sending - */ + * Sending + */ @Override protected void onSendBeforeWrite(WebServiceMessage message) throws IOException { try { @@ -156,7 +156,8 @@ public class MailSenderConnection extends AbstractSenderConnection { requestMessage.setSubject(subject); } requestBuffer = new ByteArrayOutputStream(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -168,7 +169,8 @@ public class MailSenderConnection extends AbstractSenderConnection { if (TransportConstants.HEADER_CONTENT_TYPE.equals(name)) { requestContentType = value; } - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -182,15 +184,17 @@ public class MailSenderConnection extends AbstractSenderConnection { protected void onSendAfterWrite(WebServiceMessage message) throws IOException { Transport transport = null; try { - requestMessage - .setDataHandler(new DataHandler(new ByteArrayDataSource(requestContentType, requestBuffer.toByteArray()))); + requestMessage.setDataHandler( + new DataHandler(new ByteArrayDataSource(requestContentType, requestBuffer.toByteArray()))); transport = session.getTransport(transportUri); transport.connect(); requestMessage.saveChanges(); transport.sendMessage(requestMessage, requestMessage.getAllRecipients()); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); - } finally { + } + finally { MailTransportUtils.closeService(transport); } } @@ -206,7 +210,8 @@ public class MailSenderConnection extends AbstractSenderConnection { Assert.hasLength(requestMessageId, "No Message-ID found on request message [" + requestMessage + "]"); try { Thread.sleep(receiveTimeout); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { // Re-interrupt current thread, to allow other threads to react. Thread.currentThread().interrupt(); } @@ -222,7 +227,8 @@ public class MailSenderConnection extends AbstractSenderConnection { if (deleteAfterReceive) { responseMessage.setFlag(Flags.Flag.DELETED, true); } - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -236,7 +242,8 @@ public class MailSenderConnection extends AbstractSenderConnection { } if (deleteAfterReceive) { folder.open(Folder.READ_WRITE); - } else { + } + else { folder.open(Folder.READ_ONLY); } } @@ -256,7 +263,8 @@ public class MailSenderConnection extends AbstractSenderConnection { headers.add(header.getName()); } return headers.iterator(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -266,7 +274,8 @@ public class MailSenderConnection extends AbstractSenderConnection { try { String[] headers = responseMessage.getHeader(name); return Arrays.asList(headers).iterator(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } @@ -276,7 +285,8 @@ public class MailSenderConnection extends AbstractSenderConnection { protected InputStream getResponseInputStream() throws IOException { try { return responseMessage.getDataHandler().getInputStream(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -327,6 +337,7 @@ public class MailSenderConnection extends AbstractSenderConnection { public String getName() { return "ByteArrayDataSource"; } + } } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailTransportConstants.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailTransportConstants.java index 1e3c6351..c684a969 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailTransportConstants.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailTransportConstants.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -35,4 +35,5 @@ public interface MailTransportConstants extends TransportConstants { * The "In-Reply-To" header. */ String HEADER_IN_REPLY_TO = "In-Reply-To"; + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailTransportException.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailTransportException.java index 26393d71..869c6c77 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailTransportException.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailTransportException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -45,4 +45,5 @@ public class MailTransportException extends TransportException { public MessagingException getMessagingException() { return messagingException; } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/AbstractMonitoringStrategy.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/AbstractMonitoringStrategy.java index 680047ec..814b4315 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/AbstractMonitoringStrategy.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/AbstractMonitoringStrategy.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,13 +24,13 @@ import jakarta.mail.MessagingException; import jakarta.mail.search.AndTerm; import jakarta.mail.search.FlagTerm; import jakarta.mail.search.SearchTerm; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * Abstract base class for the {@link MonitoringStrategy} interface. Exposes a {@link #setDeleteMessages(boolean) - * deleteMessages} property, and includes a basic workflow for message monitoring. + * Abstract base class for the {@link MonitoringStrategy} interface. Exposes a + * {@link #setDeleteMessages(boolean) deleteMessages} property, and includes a basic + * workflow for message monitoring. * * @author Arjen Poutsma * @since 1.5.0 @@ -43,8 +43,8 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { private boolean deleteMessages = true; /** - * Sets whether messages should be marked as {@link jakarta.mail.Flags.Flag#DELETED DELETED} after they have been - * read. Default is {@code true}. + * Sets whether messages should be marked as {@link jakarta.mail.Flags.Flag#DELETED + * DELETED} after they have been read. Default is {@code true}. */ public void setDeleteMessages(boolean deleteMessages) { this.deleteMessages = deleteMessages; @@ -56,12 +56,12 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { } /** - * Monitors the given folder, and returns any new messages when they arrive. This implementation calls - * {@link #waitForNewMessages(Folder)}, then searches for new messages using {@link #searchForNewMessages(Folder)}, - * fetches the messages using {@link #fetchMessages(Folder, Message[])}, and finally - * {@link #setDeleteMessages(boolean) deletes} the messages, if {@link #setDeleteMessages(boolean) deleteMessages} is - * {@code true}. - * + * Monitors the given folder, and returns any new messages when they arrive. This + * implementation calls {@link #waitForNewMessages(Folder)}, then searches for new + * messages using {@link #searchForNewMessages(Folder)}, fetches the messages using + * {@link #fetchMessages(Folder, Message[])}, and finally + * {@link #setDeleteMessages(boolean) deletes} the messages, if + * {@link #setDeleteMessages(boolean) deleteMessages} is {@code true}. * @param folder the folder to monitor * @return the new messages * @throws MessagingException in case of JavaMail errors @@ -84,9 +84,8 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { } /** - * Template method that blocks until new messages arrive in the given folder. Typical implementations use - * {@link Thread#sleep(long)} or the IMAP IDLE command. - * + * Template method that blocks until new messages arrive in the given folder. Typical + * implementations use {@link Thread#sleep(long)} or the IMAP IDLE command. * @param folder the folder to monitor * @throws MessagingException in case of JavaMail errors * @throws InterruptedException when a thread is interrupted @@ -94,11 +93,12 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { protected abstract void waitForNewMessages(Folder folder) throws MessagingException, InterruptedException; /** - * Retrieves new messages from the given folder. This implementation creates a {@link SearchTerm} that searches for - * all messages in the folder that are {@link jakarta.mail.Flags.Flag#RECENT RECENT}, not - * {@link jakarta.mail.Flags.Flag#ANSWERED ANSWERED}, and not {@link jakarta.mail.Flags.Flag#DELETED DELETED}. The - * search term is used to {@link Folder#search(SearchTerm) search} for new messages. - * + * Retrieves new messages from the given folder. This implementation creates a + * {@link SearchTerm} that searches for all messages in the folder that are + * {@link jakarta.mail.Flags.Flag#RECENT RECENT}, not + * {@link jakarta.mail.Flags.Flag#ANSWERED ANSWERED}, and not + * {@link jakarta.mail.Flags.Flag#DELETED DELETED}. The search term is used to + * {@link Folder#search(SearchTerm) search} for new messages. * @param folder the folder to retrieve new messages from * @return the new messages * @throws MessagingException in case of JavaMail errors @@ -117,7 +117,8 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { FlagTerm answeredTerm = new FlagTerm(new Flags(Flags.Flag.ANSWERED), false); if (searchTerm == null) { searchTerm = answeredTerm; - } else { + } + else { searchTerm = new AndTerm(searchTerm, answeredTerm); } } @@ -125,7 +126,8 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { FlagTerm deletedTerm = new FlagTerm(new Flags(Flags.Flag.DELETED), false); if (searchTerm == null) { searchTerm = deletedTerm; - } else { + } + else { searchTerm = new AndTerm(searchTerm, deletedTerm); } } @@ -135,8 +137,8 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { /** * Fetches the specified messages from the specified folder. Default implementation - * {@link Folder#fetch(Message[], FetchProfile) fetches} every {@link javax.mail.FetchProfile.Item}. - * + * {@link Folder#fetch(Message[], FetchProfile) fetches} every + * {@link javax.mail.FetchProfile.Item}. * @param folder the folder to fetch messages from * @param messages the messages to fetch * @throws MessagingException in case of JavMail errors @@ -150,9 +152,8 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { } /** - * Deletes the given messages from the given folder. Only invoked when {@link #setDeleteMessages(boolean)} is - * {@code true}. - * + * Deletes the given messages from the given folder. Only invoked when + * {@link #setDeleteMessages(boolean)} is {@code true}. * @param folder the folder to delete messages from * @param messages the messages to delete * @throws MessagingException in case of JavaMail errors @@ -162,4 +163,5 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { message.setFlag(Flags.Flag.DELETED, true); } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/ImapIdleMonitoringStrategy.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/ImapIdleMonitoringStrategy.java index 67fa84f1..83f35e72 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/ImapIdleMonitoringStrategy.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/ImapIdleMonitoringStrategy.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,6 +16,7 @@ package org.springframework.ws.transport.mail.monitor; +import com.sun.mail.imap.IMAPFolder; import jakarta.mail.Folder; import jakarta.mail.Message; import jakarta.mail.MessagingException; @@ -25,14 +26,12 @@ import jakarta.mail.event.MessageCountListener; import org.springframework.util.Assert; -import com.sun.mail.imap.IMAPFolder; - /** - * Implementation of the {@link MonitoringStrategy} interface that uses the IMAP IDLE command for asynchronous message - * detection. + * Implementation of the {@link MonitoringStrategy} interface that uses the IMAP IDLE + * command for asynchronous message detection. *

- * Note that this implementation is only suitable for use with IMAP servers which support the IDLE command. - * Additionally, this strategy requires JavaMail version 1.4.1. + * Note that this implementation is only suitable for use with IMAP servers which + * support the IDLE command. Additionally, this strategy requires JavaMail version 1.4.1. * * @author Arjen Poutsma * @since 1.5.0 @@ -55,7 +54,8 @@ public class ImapIdleMonitoringStrategy extends AbstractMonitoringStrategy { folder.addMessageCountListener(messageCountListener); try { imapFolder.idle(); - } finally { + } + finally { folder.removeMessageCountListener(messageCountListener); } } @@ -69,11 +69,13 @@ public class ImapIdleMonitoringStrategy extends AbstractMonitoringStrategy { try { // this will return the flow to the idle call, above message.getLineCount(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { // ignore } } } }; } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/MonitoringStrategy.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/MonitoringStrategy.java index 6a25384c..d1ceb093 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/MonitoringStrategy.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/MonitoringStrategy.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,9 @@ import jakarta.mail.Message; import jakarta.mail.MessagingException; /** - * Defines the contract for objects that monitor a given folder for new messages. Allows for multiple implementation - * strategies, including polling, or event-driven techniques such as IMAP's {@code IDLE} command. + * Defines the contract for objects that monitor a given folder for new messages. Allows + * for multiple implementation strategies, including polling, or event-driven techniques + * such as IMAP's {@code IDLE} command. * * @author Arjen Poutsma */ @@ -30,7 +31,6 @@ public interface MonitoringStrategy { /** * Monitors the given folder, and returns any new messages when they arrive. - * * @param folder the folder in which to look for new messages * @return the new messages * @throws MessagingException in case of JavaMail errors @@ -39,8 +39,8 @@ public interface MonitoringStrategy { Message[] monitor(Folder folder) throws MessagingException, InterruptedException; /** - * Returns the folder open mode to be used by this strategy. Can be either {@link Folder#READ_ONLY} or - * {@link Folder#READ_WRITE}. + * Returns the folder open mode to be used by this strategy. Can be either + * {@link Folder#READ_ONLY} or {@link Folder#READ_WRITE}. */ int getFolderOpenMode(); diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/PollingMonitoringStrategy.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/PollingMonitoringStrategy.java index 6ff23fec..9e0ed999 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/PollingMonitoringStrategy.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/PollingMonitoringStrategy.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,8 +20,9 @@ import jakarta.mail.Folder; import jakarta.mail.MessagingException; /** - * Implementation of the {@link MonitoringStrategy} interface that uses a simple polling mechanism. Defines a - * {@link #setPollingInterval(long) polling interval} property which defines the interval in between message polls. + * Implementation of the {@link MonitoringStrategy} interface that uses a simple polling + * mechanism. Defines a {@link #setPollingInterval(long) polling interval} property which + * defines the interval in between message polls. *

* Note that this implementation is not suitable for use with POP3 servers. Use the * {@link Pop3PollingMonitoringStrategy} instead. @@ -31,14 +32,17 @@ import jakarta.mail.MessagingException; */ public class PollingMonitoringStrategy extends AbstractMonitoringStrategy { - /** Defines the default polling frequency. Set to 1000 * 60 milliseconds (i.e. 1 minute). */ + /** + * Defines the default polling frequency. Set to 1000 * 60 milliseconds (i.e. 1 + * minute). + */ public static final long DEFAULT_POLLING_FREQUENCY = 1000 * 60; private long pollingInterval = DEFAULT_POLLING_FREQUENCY; /** - * Sets the interval used in between message polls, in milliseconds. The default is 1000 * 60 ms, - * that is 1 minute. + * Sets the interval used in between message polls, in milliseconds. + * The default is 1000 * 60 ms, that is 1 minute. */ public void setPollingInterval(long pollingInterval) { this.pollingInterval = pollingInterval; @@ -51,9 +55,9 @@ public class PollingMonitoringStrategy extends AbstractMonitoringStrategy { } /** - * Invoked after the {@link Thread#sleep(long)} method has been invoked. This implementation calls - * {@link Folder#getMessageCount()}, to force new messages to be seen. - * + * Invoked after the {@link Thread#sleep(long)} method has been invoked. This + * implementation calls {@link Folder#getMessageCount()}, to force new messages to be + * seen. * @param folder the folder to check for new messages * @throws MessagingException in case of JavaMail errors */ diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/Pop3PollingMonitoringStrategy.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/Pop3PollingMonitoringStrategy.java index 68a73be9..5b4eec66 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/Pop3PollingMonitoringStrategy.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/monitor/Pop3PollingMonitoringStrategy.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,13 +24,14 @@ import jakarta.mail.internet.MimeMessage; import org.springframework.ws.transport.mail.support.MailTransportUtils; /** - * Implementation of the {@link MonitoringStrategy} interface that uses a simple polling mechanism suitable for POP3 - * servers. Since POP3 does not have a native mechanism to determine which messages are "new", this implementation - * simply retrieves all messages in the {@link Folder}, and delete them afterwards. All messages in the POP3 mailbox are + * Implementation of the {@link MonitoringStrategy} interface that uses a simple polling + * mechanism suitable for POP3 servers. Since POP3 does not have a native mechanism to + * determine which messages are "new", this implementation simply retrieves all messages + * in the {@link Folder}, and delete them afterwards. All messages in the POP3 mailbox are * therefore, by definition, new. *

- * Setting the {@link #setDeleteMessages(boolean) deleteMessages} property is therefore ignored: messages are always - * deleted. + * Setting the {@link #setDeleteMessages(boolean) deleteMessages} property is therefore + * ignored: messages are always deleted. * * @author Arjen Poutsma * @since 1.5.0 @@ -42,7 +43,8 @@ public class Pop3PollingMonitoringStrategy extends PollingMonitoringStrategy { } @Override - public void setDeleteMessages(boolean deleteMessages) {} + public void setDeleteMessages(boolean deleteMessages) { + } /** * Re-opens the folder, if it closed. @@ -63,8 +65,8 @@ public class Pop3PollingMonitoringStrategy extends PollingMonitoringStrategy { } /** - * Deletes the given messages from the given folder, and closes it to expunge deleted messages. - * + * Deletes the given messages from the given folder, and closes it to expunge deleted + * messages. * @param folder the folder to delete messages from * @param messages the messages to delete * @throws MessagingException in case of JavaMail errors @@ -72,10 +74,12 @@ public class Pop3PollingMonitoringStrategy extends PollingMonitoringStrategy { @Override protected void deleteMessages(Folder folder, Message[] messages) throws MessagingException { super.deleteMessages(folder, messages); - // expunge deleted mails, and make sure we've retrieved them before closing the folder + // expunge deleted mails, and make sure we've retrieved them before closing the + // folder for (Message message : messages) { new MimeMessage((MimeMessage) message); } MailTransportUtils.closeFolder(folder, true); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/support/MailTransportUtils.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/support/MailTransportUtils.java index ac76b73d..da776287 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/support/MailTransportUtils.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/mail/support/MailTransportUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,20 +16,20 @@ package org.springframework.ws.transport.mail.support; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import jakarta.mail.Folder; import jakarta.mail.MessagingException; import jakarta.mail.Service; import jakarta.mail.URLName; import jakarta.mail.internet.AddressException; import jakarta.mail.internet.InternetAddress; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.util.StringUtils; import org.springframework.ws.transport.mail.MailTransportConstants; @@ -47,7 +47,8 @@ public abstract class MailTransportUtils { private static final Log logger = LogFactory.getLog(MailTransportUtils.class); - private MailTransportUtils() {} + private MailTransportUtils() { + } public static InternetAddress getTo(URI uri) { Matcher matcher = TO_PATTERN.matcher(uri.getSchemeSpecificPart()); @@ -57,7 +58,8 @@ public abstract class MailTransportUtils { if (group != null) { try { return new InternetAddress(group); - } catch (AddressException e) { + } + catch (AddressException e) { // try next group } } @@ -75,9 +77,8 @@ public abstract class MailTransportUtils { } /** - * Close the given JavaMail Service and ignore any thrown exception. This is useful for typical {@code finally} blocks - * in manual JavaMail code. - * + * Close the given JavaMail Service and ignore any thrown exception. This is useful + * for typical {@code finally} blocks in manual JavaMail code. * @param service the JavaMail Service to close (may be {@code null}) * @see jakarta.mail.Transport * @see jakarta.mail.Store @@ -86,16 +87,16 @@ public abstract class MailTransportUtils { if (service != null) { try { service.close(); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { logger.debug("Could not close JavaMail Service", ex); } } } /** - * Close the given JavaMail Folder and ignore any thrown exception. This is useful for typical {@code finally} blocks - * in manual JavaMail code. - * + * Close the given JavaMail Folder and ignore any thrown exception. This is useful for + * typical {@code finally} blocks in manual JavaMail code. * @param folder the JavaMail Folder to close (may be {@code null}) */ @@ -104,9 +105,8 @@ public abstract class MailTransportUtils { } /** - * Close the given JavaMail Folder and ignore any thrown exception. This is useful for typical {@code finally} blocks - * in manual JavaMail code. - * + * Close the given JavaMail Folder and ignore any thrown exception. This is useful for + * typical {@code finally} blocks in manual JavaMail code. * @param folder the JavaMail Folder to close (may be {@code null}) * @param expunge whether all deleted messages should be expunged from the folder */ @@ -114,13 +114,17 @@ public abstract class MailTransportUtils { if (folder != null && folder.isOpen()) { try { folder.close(expunge); - } catch (MessagingException ex) { + } + catch (MessagingException ex) { logger.debug("Could not close JavaMail Folder", ex); } } } - /** Returns a string representation of the given {@link URLName}, where the password has been protected. */ + /** + * Returns a string representation of the given {@link URLName}, where the password + * has been protected. + */ public static String toPasswordProtectedString(URLName name) { String protocol = name.getProtocol(); String username = name.getUsername(); @@ -164,7 +168,6 @@ public abstract class MailTransportUtils { /** * Converts the given internet address into a {@code mailto} URI. - * * @param to the To: address * @param subject the subject, may be {@code null} * @return a mailto URI @@ -172,7 +175,8 @@ public abstract class MailTransportUtils { public static URI toUri(InternetAddress to, String subject) throws URISyntaxException { if (StringUtils.hasLength(subject)) { return new URI(MailTransportConstants.MAIL_URI_SCHEME, to.getAddress() + "?subject=" + subject, null); - } else { + } + else { return new URI(MailTransportConstants.MAIL_URI_SCHEME, to.getAddress(), null); } } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/support/AbstractAsyncStandaloneMessageReceiver.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/support/AbstractAsyncStandaloneMessageReceiver.java index 46ca9ff3..a077d35d 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/support/AbstractAsyncStandaloneMessageReceiver.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/support/AbstractAsyncStandaloneMessageReceiver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,8 +22,8 @@ import org.springframework.core.task.TaskExecutor; import org.springframework.util.ClassUtils; /** - * Abstract base class for asynchronous standalone, server-side transport objects. Contains a Spring - * {@link TaskExecutor}, and various lifecycle callbacks. + * Abstract base class for asynchronous standalone, server-side transport objects. + * Contains a Spring {@link TaskExecutor}, and various lifecycle callbacks. * * @author Arjen Poutsma */ @@ -38,11 +38,12 @@ public abstract class AbstractAsyncStandaloneMessageReceiver extends AbstractSta private String beanName; /** - * Set the Spring {@link TaskExecutor} to use for running the listener threads. Default is - * {@link SimpleAsyncTaskExecutor}, starting up a number of new threads. + * Set the Spring {@link TaskExecutor} to use for running the listener threads. + * Default is {@link SimpleAsyncTaskExecutor}, starting up a number of new threads. *

- * Specify an alternative task executor for integration with an existing thread pool, such as the - * {@link org.springframework.scheduling.commonj.WorkManagerTaskExecutor} to integrate with WebSphere or WebLogic. + * Specify an alternative task executor for integration with an existing thread pool, + * such as the {@link org.springframework.scheduling.commonj.WorkManagerTaskExecutor} + * to integrate with WebSphere or WebLogic. */ public void setTaskExecutor(TaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; @@ -62,11 +63,12 @@ public abstract class AbstractAsyncStandaloneMessageReceiver extends AbstractSta } /** - * Create a default TaskExecutor. Called if no explicit TaskExecutor has been specified. + * Create a default TaskExecutor. Called if no explicit TaskExecutor has been + * specified. *

- * The default implementation builds a {@link org.springframework.core.task.SimpleAsyncTaskExecutor} with the - * specified bean name (or the class name, if no bean name specified) as thread name prefix. - * + * The default implementation builds a + * {@link org.springframework.core.task.SimpleAsyncTaskExecutor} with the specified + * bean name (or the class name, if no bean name specified) as thread name prefix. * @see org.springframework.core.task.SimpleAsyncTaskExecutor#SimpleAsyncTaskExecutor(String) */ protected TaskExecutor createDefaultTaskExecutor() { @@ -76,10 +78,10 @@ public abstract class AbstractAsyncStandaloneMessageReceiver extends AbstractSta /** * Executes the given {@link Runnable} via this receiver's {@link TaskExecutor}. - * * @see #setTaskExecutor(TaskExecutor) */ protected void execute(Runnable runnable) { taskExecutor.execute(runnable); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/support/AbstractStandaloneMessageReceiver.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/support/AbstractStandaloneMessageReceiver.java index 78f50483..7ae44338 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/support/AbstractStandaloneMessageReceiver.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/support/AbstractStandaloneMessageReceiver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,8 +20,9 @@ import org.springframework.beans.factory.DisposableBean; import org.springframework.context.Lifecycle; /** - * Abstract base class for standalone, server-side transport objects. Provides a basic, thread-safe implementation of - * the {@link Lifecycle} interface, and various template methods to be implemented by concrete sub classes. + * Abstract base class for standalone, server-side transport objects. Provides a basic, + * thread-safe implementation of the {@link Lifecycle} interface, and various template + * methods to be implemented by concrete sub classes. * * @author Arjen Poutsma * @since 1.5.0 @@ -37,14 +38,20 @@ public abstract class AbstractStandaloneMessageReceiver extends SimpleWebService private final Object lifecycleMonitor = new Object(); - /** Return whether this server is currently active, that is, whether it has been set up but not shut down yet. */ + /** + * Return whether this server is currently active, that is, whether it has been set up + * but not shut down yet. + */ public final boolean isActive() { synchronized (lifecycleMonitor) { return active; } } - /** Return whether this server is currently running, that is, whether it has been started and not stopped yet. */ + /** + * Return whether this server is currently running, that is, whether it has been + * started and not stopped yet. + */ @Override public final boolean isRunning() { synchronized (lifecycleMonitor) { @@ -61,7 +68,9 @@ public abstract class AbstractStandaloneMessageReceiver extends SimpleWebService this.autoStartup = autoStartup; } - /** Calls {@link #activate()} when the BeanFactory initializes the receiver instance. */ + /** + * Calls {@link #activate()} when the BeanFactory initializes the receiver instance. + */ @Override public void afterPropertiesSet() throws Exception { activate(); @@ -74,7 +83,8 @@ public abstract class AbstractStandaloneMessageReceiver extends SimpleWebService } /** - * Initialize this server. Starts the server if {@link #setAutoStartup(boolean) autoStartup} hasn't been turned off. + * Initialize this server. Starts the server if {@link #setAutoStartup(boolean) + * autoStartup} hasn't been turned off. */ public final void activate() throws Exception { synchronized (lifecycleMonitor) { @@ -115,7 +125,6 @@ public abstract class AbstractStandaloneMessageReceiver extends SimpleWebService /** * Template method invoked when {@link #activate()} is invoked. - * * @throws Exception in case of errors */ protected abstract void onActivate() throws Exception; @@ -128,4 +137,5 @@ public abstract class AbstractStandaloneMessageReceiver extends SimpleWebService /** Template method invoked when {@link #shutdown()} is invoked. */ protected abstract void onShutdown(); + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/support/SimpleWebServiceMessageReceiverObjectSupport.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/support/SimpleWebServiceMessageReceiverObjectSupport.java index 91533aed..b360977e 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/support/SimpleWebServiceMessageReceiverObjectSupport.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/support/SimpleWebServiceMessageReceiverObjectSupport.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,7 +22,8 @@ import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.WebServiceMessageReceiver; /** - * Base class for server-side transport objects which have a predefined {@link WebServiceMessageReceiver}. + * Base class for server-side transport objects which have a predefined + * {@link WebServiceMessageReceiver}. * * @author Arjen Poutsma * @see #handleConnection(WebServiceConnection) diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/MessageOutputStream.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/MessageOutputStream.java index 67a45650..08a25b6e 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/MessageOutputStream.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/MessageOutputStream.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,6 +21,7 @@ import java.io.FilterOutputStream; import java.io.IOException; import org.jivesoftware.smack.packet.Message; + import org.springframework.util.Assert; /** @@ -51,4 +52,5 @@ class MessageOutputStream extends FilterOutputStream { String text = bos.toString(encoding); message.setBody(text); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppMessageReceiver.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppMessageReceiver.java index 89f19d5d..3f52ed11 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppMessageReceiver.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppMessageReceiver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,12 +27,15 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.tcp.XMPPTCPConnection; + import org.springframework.ws.transport.support.AbstractStandaloneMessageReceiver; /** - * Server-side component for receiving XMPP (Jabber) messages. Requires a {@linkplain #setConnection(XMPPConnection) - * connection} to be set, in addition to the {@link #setMessageFactory(org.springframework.ws.WebServiceMessageFactory) - * messageFactory} and {@link #setMessageReceiver(org.springframework.ws.transport.WebServiceMessageReceiver) + * Server-side component for receiving XMPP (Jabber) messages. Requires a + * {@linkplain #setConnection(XMPPConnection) connection} to be set, in addition to the + * {@link #setMessageFactory(org.springframework.ws.WebServiceMessageFactory) + * messageFactory} and + * {@link #setMessageReceiver(org.springframework.ws.transport.WebServiceMessageReceiver) * messageReceiver} required by the base class. * * @author Gildas Cuisinier @@ -43,7 +46,10 @@ import org.springframework.ws.transport.support.AbstractStandaloneMessageReceive */ public class XmppMessageReceiver extends AbstractStandaloneMessageReceiver { - /** Default encoding used to read from and write to {@link org.jivesoftware.smack.packet.Message} messages. */ + /** + * Default encoding used to read from and write to + * {@link org.jivesoftware.smack.packet.Message} messages. + */ public static final String DEFAULT_MESSAGE_ENCODING = "UTF-8"; private XMPPTCPConnection connection; @@ -52,7 +58,8 @@ public class XmppMessageReceiver extends AbstractStandaloneMessageReceiver { private String messageEncoding = DEFAULT_MESSAGE_ENCODING; - public XmppMessageReceiver() {} + public XmppMessageReceiver() { + } /** Sets the {@code XMPPConnection} to use. Setting this property is required. */ public void setConnection(XMPPTCPConnection connection) { @@ -64,7 +71,8 @@ public class XmppMessageReceiver extends AbstractStandaloneMessageReceiver { if (!connection.isConnected()) { try { connection.connect(); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { throw new IOException(e); } } @@ -110,11 +118,13 @@ public class XmppMessageReceiver extends AbstractStandaloneMessageReceiver { XmppReceiverConnection wsConnection = new XmppReceiverConnection(connection, message); wsConnection.setMessageEncoding(messageEncoding); handleConnection(wsConnection); - } catch (Exception ex) { + } + catch (Exception ex) { logger.error(ex); } } } + } } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppMessageSender.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppMessageSender.java index dcc7f249..de97901d 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppMessageSender.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,6 +21,7 @@ import java.net.URI; import java.util.UUID; import org.jivesoftware.smack.XMPPConnection; + import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.ws.transport.WebServiceConnection; @@ -28,11 +29,12 @@ import org.springframework.ws.transport.WebServiceMessageSender; import org.springframework.ws.transport.xmpp.support.XmppTransportUtils; /** - * {@link WebServiceMessageSender} implementation that uses XMPP {@link org.jivesoftware.smack.packet.Message}s. - * Requires a {@link #setConnection(org.jivesoftware.smack.XMPPConnection) connection}to be set. + * {@link WebServiceMessageSender} implementation that uses XMPP + * {@link org.jivesoftware.smack.packet.Message}s. Requires a + * {@link #setConnection(org.jivesoftware.smack.XMPPConnection) connection}to be set. *

- * This message sender supports URI's of the following format:

xmpp:to
- * The to represents a Jabber ID. + * This message sender supports URI's of the following format:
+ * xmpp:to
The to represents a Jabber ID. * * @author Gildas Cuisinier * @author Arjen Poutsma @@ -40,10 +42,16 @@ import org.springframework.ws.transport.xmpp.support.XmppTransportUtils; */ public class XmppMessageSender implements WebServiceMessageSender, InitializingBean { - /** Default timeout for receive operations: -1 indicates a blocking receive without timeout. */ + /** + * Default timeout for receive operations: -1 indicates a blocking receive without + * timeout. + */ public static final long DEFAULT_RECEIVE_TIMEOUT = -1; - /** Default encoding used to read from and write to {@link org.jivesoftware.smack.packet.Message} messages. */ + /** + * Default encoding used to read from and write to + * {@link org.jivesoftware.smack.packet.Message} messages. + */ public static final String DEFAULT_MESSAGE_ENCODING = "UTF-8"; private long receiveTimeout = DEFAULT_RECEIVE_TIMEOUT; @@ -58,8 +66,8 @@ public class XmppMessageSender implements WebServiceMessageSender, InitializingB } /** - * Set the timeout to use for receive calls. The default is -1, which means no timeout. - * + * Set the timeout to use for receive calls. The default is -1, which means no + * timeout. * @see org.jivesoftware.smack.PacketCollector#nextResult(long) */ public void setReceiveTimeout(long receiveTimeout) { @@ -67,8 +75,8 @@ public class XmppMessageSender implements WebServiceMessageSender, InitializingB } /** - * Sets the encoding used to read from {@link org.jivesoftware.smack.packet.Message} object. Defaults to - * {@code UTF-8}. + * Sets the encoding used to read from {@link org.jivesoftware.smack.packet.Message} + * object. Defaults to {@code UTF-8}. */ public void setMessageEncoding(String messageEncoding) { this.messageEncoding = messageEncoding; @@ -97,4 +105,5 @@ public class XmppMessageSender implements WebServiceMessageSender, InitializingB protected String createThread() { return UUID.randomUUID().toString(); } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppReceiverConnection.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppReceiverConnection.java index 94d1ba06..be065d75 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppReceiverConnection.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppReceiverConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,14 +26,16 @@ import java.util.Iterator; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.packet.Message; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.AbstractReceiverConnection; import org.springframework.ws.transport.xmpp.support.XmppTransportUtils; /** - * Implementation of {@link org.springframework.ws.transport.WebServiceConnection} that is used for server-side XMPP - * access. Exposes a {@link Message} request and response message. + * Implementation of {@link org.springframework.ws.transport.WebServiceConnection} that is + * used for server-side XMPP access. Exposes a {@link Message} request and response + * message. * * @author Gildas Cuisinier * @author Arjen Poutsma @@ -76,8 +78,8 @@ public class XmppReceiverConnection extends AbstractReceiverConnection { } /* - * URI - */ + * URI + */ @Override public URI getUri() throws URISyntaxException { @@ -85,8 +87,8 @@ public class XmppReceiverConnection extends AbstractReceiverConnection { } /* - * Errors - */ + * Errors + */ @Override public boolean hasError() { @@ -142,8 +144,10 @@ public class XmppReceiverConnection extends AbstractReceiverConnection { protected void onSendAfterWrite(WebServiceMessage message) throws IOException { try { connection.sendStanza(responseMessage); - } catch (SmackException.NotConnectedException | InterruptedException e) { + } + catch (SmackException.NotConnectedException | InterruptedException e) { throw new IOException(e); } } + } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppSenderConnection.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppSenderConnection.java index 9fd72936..8ab4fad0 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppSenderConnection.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppSenderConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,14 +34,16 @@ import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.stringprep.XmppStringprepException; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.transport.AbstractSenderConnection; import org.springframework.ws.transport.xmpp.support.XmppTransportUtils; /** - * Implementation of {@link org.springframework.ws.transport.WebServiceConnection} that is used for client-side XMPP - * access. Exposes a {@link Message} request and response message. + * Implementation of {@link org.springframework.ws.transport.WebServiceConnection} that is + * used for client-side XMPP access. Exposes a {@link Message} request and response + * message. * * @author Gildas Cuisinier * @author Arjen Poutsma @@ -67,7 +69,8 @@ public class XmppSenderConnection extends AbstractSenderConnection { this.connection = connection; try { this.requestMessage = new Message(JidCreate.from(to), Message.Type.chat); - } catch (XmppStringprepException e) { + } + catch (XmppStringprepException e) { throw new RuntimeException(e); } this.requestMessage.setThread(thread); @@ -96,8 +99,8 @@ public class XmppSenderConnection extends AbstractSenderConnection { } /* - * URI - */ + * URI + */ @Override public URI getUri() throws URISyntaxException { @@ -137,7 +140,8 @@ public class XmppSenderConnection extends AbstractSenderConnection { requestMessage.setFrom(connection.getUser()); try { connection.sendStanza(requestMessage); - } catch (SmackException.NotConnectedException | InterruptedException e) { + } + catch (SmackException.NotConnectedException | InterruptedException e) { throw new IOException(e); } } @@ -155,11 +159,13 @@ public class XmppSenderConnection extends AbstractSenderConnection { Stanza packet = receiveTimeout >= 0 ? collector.nextResult(receiveTimeout) : collector.nextResult(); if (packet instanceof Message) { responseMessage = (Message) packet; - } else if (packet != null) { + } + else if (packet != null) { throw new IllegalArgumentException( "Wrong packet type: [" + packet.getClass() + "]. Only Messages can be handled."); } - } catch (InterruptedException e) { + } + catch (InterruptedException e) { throw new IOException(e); } } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/support/XmppConnectionFactoryBean.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/support/XmppConnectionFactoryBean.java index 2b53c5e9..71dc94fb 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/support/XmppConnectionFactoryBean.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/support/XmppConnectionFactoryBean.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,6 +24,7 @@ import org.jivesoftware.smack.tcp.XMPPTCPConnection; import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; import org.jxmpp.jid.parts.Resourcepart; import org.jxmpp.stringprep.XmppStringprepException; + import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; @@ -31,7 +32,8 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; /** - * Factory to make {@link org.jivesoftware.smack.XMPPConnection} and perform connection and login on the XMPP server + * Factory to make {@link org.jivesoftware.smack.XMPPConnection} and perform connection + * and login on the XMPP server * * @author Gildas Cuisinier * @author Arjen Poutsma @@ -99,10 +101,12 @@ public class XmppConnectionFactoryBean implements FactoryBean connection.connect(); if (StringUtils.hasText(resource)) { connection.login(username, password, Resourcepart.from(resource)); - } else { + } + else { connection.login(username, password); } - } catch (InterruptedException e) { + } + catch (InterruptedException e) { throw new IOException(e); } } @@ -129,7 +133,6 @@ public class XmppConnectionFactoryBean implements FactoryBean /** * Creates the {@code ConnectionConfiguration} from the given parameters. - * * @param host the host to connect to * @param port the port to connect to * @param serviceName the name of the service to connect to. May be {@code null} @@ -138,8 +141,13 @@ public class XmppConnectionFactoryBean implements FactoryBean throws XmppStringprepException { Assert.hasText(host, "'host' must not be empty"); if (StringUtils.hasText(serviceName)) { - return XMPPTCPConnectionConfiguration.builder().setHost(host).setPort(port).setXmppDomain(serviceName).build(); - } else { + return XMPPTCPConnectionConfiguration.builder() + .setHost(host) + .setPort(port) + .setXmppDomain(serviceName) + .build(); + } + else { return XMPPTCPConnectionConfiguration.builder().setHost(host).setPort(port).build(); } } diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/support/XmppTransportUtils.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/support/XmppTransportUtils.java index 9e7989af..6e730804 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/support/XmppTransportUtils.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/support/XmppTransportUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,6 +23,7 @@ import java.util.Iterator; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager; + import org.springframework.util.Assert; import org.springframework.ws.transport.xmpp.XmppTransportConstants; @@ -34,7 +35,8 @@ import org.springframework.ws.transport.xmpp.XmppTransportConstants; */ public abstract class XmppTransportUtils { - private XmppTransportUtils() {} + private XmppTransportUtils() { + } /** * Converts the given XMPP destination into a {@code xmpp} URI. @@ -54,7 +56,8 @@ public abstract class XmppTransportUtils { public static String getErrorMessage(Message message) { if (message == null || !Message.Type.error.equals(message.getType())) { return null; - } else { + } + else { return message.getBody(); } } @@ -73,7 +76,8 @@ public abstract class XmppTransportUtils { String value = JivePropertiesManager.getProperty(message, name).toString(); if (value != null) { return Collections.singletonList(value).iterator(); - } else { + } + else { return Collections.emptyIterator(); } } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/SimpleTestingMessageReceiver.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/SimpleTestingMessageReceiver.java index 87971c4f..269823da 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/SimpleTestingMessageReceiver.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/SimpleTestingMessageReceiver.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -35,4 +35,5 @@ public class SimpleTestingMessageReceiver extends TransformerObjectSupport imple transformer.transform(messageContext.getRequest().getPayloadSource(), messageContext.getResponse().getPayloadResult()); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java index 58d79bf3..29b7cc5a 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,4 +30,5 @@ public class FaultEndpoint implements MessageEndpoint { SoapMessage response = (SoapMessage) messageContext.getResponse(); response.getSoapBody().addServerOrReceiverFault("Something went wrong", Locale.ENGLISH); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java index 066cd2be..030522c8 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,9 +19,13 @@ package org.springframework.ws.transport.http; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MessageEndpoint; -/** @author Arjen Poutsma */ +/** + * @author Arjen Poutsma + */ public class NoResponseEndpoint implements MessageEndpoint { @Override - public void invoke(MessageContext messageContext) {} + public void invoke(MessageContext messageContext) { + } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java index 702815d0..3bffe340 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,11 +19,14 @@ package org.springframework.ws.transport.http; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MessageEndpoint; -/** @author Arjen Poutsma */ +/** + * @author Arjen Poutsma + */ public class ResponseEndpoint implements MessageEndpoint { @Override public void invoke(MessageContext messageContext) { messageContext.getResponse(); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/SimpleHttpServerFactoryBean.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/SimpleHttpServerFactoryBean.java index ef9c934b..5b3d4d70 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/SimpleHttpServerFactoryBean.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/SimpleHttpServerFactoryBean.java @@ -1,3 +1,19 @@ +/* + * Copyright 2005-2025 the original author or authors. + * + * Licensed 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 + * + * https://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. + */ + package org.springframework.ws.transport.http; import java.io.IOException; @@ -6,20 +22,21 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Executor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.InitializingBean; - import com.sun.net.httpserver.Authenticator; import com.sun.net.httpserver.Filter; import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; /** - * Utility class ONLY used for testing SOAP interactions through the JRE's built-in {@link HttpServer}. + * Utility class ONLY used for testing SOAP interactions through the JRE's built-in + * {@link HttpServer}. */ class SimpleHttpServerFactoryBean implements FactoryBean, InitializingBean, DisposableBean { @@ -51,23 +68,24 @@ class SimpleHttpServerFactoryBean implements FactoryBean, Initializi } /** - * Specify the HTTP server's hostname to bind to. Default is localhost; can be overridden with a specific network - * address to bind to. + * Specify the HTTP server's hostname to bind to. Default is localhost; can be + * overridden with a specific network address to bind to. */ public void setHostname(String hostname) { this.hostname = hostname; } /** - * Specify the HTTP server's TCP backlog. Default is -1, indicating the system's default value. + * Specify the HTTP server's TCP backlog. Default is -1, indicating the system's + * default value. */ public void setBacklog(int backlog) { this.backlog = backlog; } /** - * Specify the number of seconds to wait until HTTP exchanges have completed when shutting down the HTTP server. - * Default is 0. + * Specify the number of seconds to wait until HTTP exchanges have completed when + * shutting down the HTTP server. Default is 0. */ public void setShutdownDelay(int shutdownDelay) { this.shutdownDelay = shutdownDelay; @@ -75,7 +93,6 @@ class SimpleHttpServerFactoryBean implements FactoryBean, Initializi /** * Set the JDK concurrent executor to use for dispatching incoming requests. - * * @see HttpServer#setExecutor */ public void setExecutor(Executor executor) { @@ -84,7 +101,6 @@ class SimpleHttpServerFactoryBean implements FactoryBean, Initializi /** * Register {@link HttpHandler HttpHandlers} for specific context paths. - * * @param contexts a Map with context paths as keys and HttpHandler objects as values */ public void setContexts(Map contexts) { @@ -92,14 +108,16 @@ class SimpleHttpServerFactoryBean implements FactoryBean, Initializi } /** - * Register common {@link Filter Filters} to be applied to all locally registered {@link #setContexts contexts}. + * Register common {@link Filter Filters} to be applied to all locally registered + * {@link #setContexts contexts}. */ public void setFilters(List filters) { this.filters = filters; } /** - * Register a common {@link Authenticator} to be applied to all locally registered {@link #setContexts contexts}. + * Register a common {@link Authenticator} to be applied to all locally registered + * {@link #setContexts contexts}. */ public void setAuthenticator(Authenticator authenticator) { this.authenticator = authenticator; @@ -150,4 +168,5 @@ class SimpleHttpServerFactoryBean implements FactoryBean, Initializi logger.info("Stopping HttpServer"); this.server.stop(this.shutdownDelay); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/WebServiceHttpHandlerIntegrationTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/WebServiceHttpHandlerIntegrationTest.java index 6b154970..afa351fb 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/http/WebServiceHttpHandlerIntegrationTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/http/WebServiceHttpHandlerIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.transport.http; -import static org.assertj.core.api.Assertions.*; - import java.io.IOException; import org.apache.commons.httpclient.HttpClient; @@ -27,6 +25,7 @@ import org.apache.commons.httpclient.methods.PostMethod; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -34,13 +33,16 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.ws.transport.TransportConstants; +import static org.assertj.core.api.Assertions.assertThat; + @ExtendWith(SpringExtension.class) @ContextConfiguration("httpserver-applicationContext.xml") public class WebServiceHttpHandlerIntegrationTest { private HttpClient client; - @Autowired private int port; + @Autowired + private int port; private String url; @@ -82,7 +84,8 @@ public class WebServiceHttpHandlerIntegrationTest { PostMethod postMethod = new PostMethod(url); postMethod.addRequestHeader(HttpTransportConstants.HEADER_CONTENT_TYPE, "text/xml"); - postMethod.addRequestHeader(TransportConstants.HEADER_SOAP_ACTION, "http://springframework.org/spring-ws/Response"); + postMethod.addRequestHeader(TransportConstants.HEADER_SOAP_ACTION, + "http://springframework.org/spring-ws/Response"); Resource soapRequest = new ClassPathResource("soapRequest.xml", WebServiceHttpHandlerIntegrationTest.class); postMethod.setRequestEntity(new InputStreamRequestEntity(soapRequest.getInputStream())); client.executeMethod(postMethod); @@ -112,7 +115,8 @@ public class WebServiceHttpHandlerIntegrationTest { PostMethod postMethod = new PostMethod(url); postMethod.addRequestHeader(HttpTransportConstants.HEADER_CONTENT_TYPE, "text/xml"); - postMethod.addRequestHeader(TransportConstants.HEADER_SOAP_ACTION, "http://springframework.org/spring-ws/Fault"); + postMethod.addRequestHeader(TransportConstants.HEADER_SOAP_ACTION, + "http://springframework.org/spring-ws/Fault"); Resource soapRequest = new ClassPathResource("soapRequest.xml", WebServiceHttpHandlerIntegrationTest.class); postMethod.setRequestEntity(new InputStreamRequestEntity(soapRequest.getInputStream())); @@ -120,4 +124,5 @@ public class WebServiceHttpHandlerIntegrationTest { assertThat(postMethod.getStatusCode()).isEqualTo(HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsIntegrationTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsIntegrationTest.java index 6ef94484..d456bf4e 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsIntegrationTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -15,62 +15,63 @@ */ package org.springframework.ws.transport.jms; -import static org.xmlunit.assertj.XmlAssert.*; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.ws.client.core.WebServiceTemplate; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.AfterAll; + +import static org.xmlunit.assertj.XmlAssert.assertThat; @ExtendWith(SpringExtension.class) @ContextConfiguration("jms-applicationContext.xml") public class JmsIntegrationTest { - @Autowired - private WebServiceTemplate webServiceTemplate; + @Autowired + private WebServiceTemplate webServiceTemplate; - private static EmbeddedActiveMQ server; + private static EmbeddedActiveMQ server; - @BeforeAll - static void setUp() throws Exception { - Configuration config = new ConfigurationImpl(); - config.addAcceptorConfiguration("vm", "vm://0"); - config.addAcceptorConfiguration("tcp", "tcp://127.0.0.1:61616"); - config.setSecurityEnabled(false); - server = new EmbeddedActiveMQ(); - server.setConfiguration(config); - server.start(); - } + @BeforeAll + static void setUp() throws Exception { + Configuration config = new ConfigurationImpl(); + config.addAcceptorConfiguration("vm", "vm://0"); + config.addAcceptorConfiguration("tcp", "tcp://127.0.0.1:61616"); + config.setSecurityEnabled(false); + server = new EmbeddedActiveMQ(); + server.setConfiguration(config); + server.start(); + } - @AfterAll - static void tearDown() throws Exception { - server.stop(); - } + @AfterAll + static void tearDown() throws Exception { + server.stop(); + } - @Test - public void testTemporaryQueue() { - String content = ""; - StringResult result = new StringResult(); - webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result); - assertThat(result.toString()).and(content).ignoreWhitespace().areSimilar(); - } + @Test + public void testTemporaryQueue() { + String content = ""; + StringResult result = new StringResult(); + webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result); + assertThat(result.toString()).and(content).ignoreWhitespace().areSimilar(); + } + + @Test + public void testPermanentQueue() { + String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue"; + String content = ""; + StringResult result = new StringResult(); + webServiceTemplate.sendSourceAndReceiveToResult(url, new StringSource(content), result); + assertThat(result.toString()).and(content).ignoreWhitespace().areSimilar(); + } - @Test - public void testPermanentQueue() { - String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue"; - String content = ""; - StringResult result = new StringResult(); - webServiceTemplate.sendSourceAndReceiveToResult(url, new StringSource(content), result); - assertThat(result.toString()).and(content).ignoreWhitespace().areSimilar(); - } } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsMessageSenderIntegrationTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsMessageSenderIntegrationTest.java index c9209889..2ff12233 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsMessageSenderIntegrationTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsMessageSenderIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,14 @@ package org.springframework.ws.transport.jms; -import static org.assertj.core.api.Assertions.*; +import java.io.ByteArrayOutputStream; +import java.net.URI; +import java.nio.charset.StandardCharsets; import jakarta.jms.BytesMessage; import jakarta.jms.TextMessage; import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.SOAPConstants; - -import java.io.ByteArrayOutputStream; -import java.net.URI; -import java.nio.charset.StandardCharsets; - import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; @@ -34,6 +31,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.MessagePostProcessor; @@ -45,13 +43,17 @@ import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.transport.WebServiceConnection; +import static org.assertj.core.api.Assertions.assertThat; + @ExtendWith(SpringExtension.class) @ContextConfiguration("jms-sender-applicationContext.xml") public class JmsMessageSenderIntegrationTest { - @Autowired private JmsMessageSender messageSender; + @Autowired + private JmsMessageSender messageSender; - @Autowired private JmsTemplate jmsTemplate; + @Autowired + private JmsTemplate jmsTemplate; private MessageFactory messageFactory; @@ -101,7 +103,8 @@ public class JmsMessageSenderIntegrationTest { BytesMessage response = session.createBytesMessage(); response.setStringProperty(JmsTransportConstants.PROPERTY_SOAP_ACTION, SOAP_ACTION); - response.setStringProperty(JmsTransportConstants.PROPERTY_CONTENT_TYPE, SoapVersion.SOAP_11.getContentType()); + response.setStringProperty(JmsTransportConstants.PROPERTY_CONTENT_TYPE, + SoapVersion.SOAP_11.getContentType()); response.writeBytes(buf); return response; }); @@ -140,7 +143,8 @@ public class JmsMessageSenderIntegrationTest { BytesMessage response = session.createBytesMessage(); response.setJMSCorrelationID(request.getJMSMessageID()); response.setStringProperty(JmsTransportConstants.PROPERTY_SOAP_ACTION, SOAP_ACTION); - response.setStringProperty(JmsTransportConstants.PROPERTY_CONTENT_TYPE, SoapVersion.SOAP_11.getContentType()); + response.setStringProperty(JmsTransportConstants.PROPERTY_CONTENT_TYPE, + SoapVersion.SOAP_11.getContentType()); response.writeBytes(buf); return response; }); @@ -177,7 +181,8 @@ public class JmsMessageSenderIntegrationTest { TextMessage response = session.createTextMessage(); response.setStringProperty(JmsTransportConstants.PROPERTY_SOAP_ACTION, SOAP_ACTION); - response.setStringProperty(JmsTransportConstants.PROPERTY_CONTENT_TYPE, SoapVersion.SOAP_11.getContentType()); + response.setStringProperty(JmsTransportConstants.PROPERTY_CONTENT_TYPE, + SoapVersion.SOAP_11.getContentType()); response.setText(text); return response; }); @@ -236,4 +241,5 @@ public class JmsMessageSenderIntegrationTest { assertThat(request.getBooleanProperty("processed")).isTrue(); } } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/WebServiceMessageListenerIntegrationTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/WebServiceMessageListenerIntegrationTest.java index dc2856c4..82adf18e 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/WebServiceMessageListenerIntegrationTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/WebServiceMessageListenerIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,13 @@ package org.springframework.ws.transport.jms; -import static org.assertj.core.api.Assertions.*; +import java.nio.charset.StandardCharsets; import jakarta.annotation.Resource; import jakarta.jms.BytesMessage; import jakarta.jms.Queue; import jakarta.jms.TextMessage; import jakarta.jms.Topic; - -import java.nio.charset.StandardCharsets; - import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; @@ -33,11 +30,14 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.core.JmsTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; +import static org.assertj.core.api.Assertions.assertThat; + @ExtendWith(SpringExtension.class) @ContextConfiguration("jms-receiver-applicationContext.xml") public class WebServiceMessageListenerIntegrationTest { @@ -46,13 +46,17 @@ public class WebServiceMessageListenerIntegrationTest { + "\n" + "\n" + "DIS\n" + "\n" + ""; - @Autowired private JmsTemplate jmsTemplate; + @Autowired + private JmsTemplate jmsTemplate; - @Resource private Queue responseQueue; + @Resource + private Queue responseQueue; - @Resource private Queue requestQueue; + @Resource + private Queue requestQueue; - @Autowired private Topic requestTopic; + @Autowired + private Topic requestTopic; private EmbeddedActiveMQ server; @@ -119,4 +123,5 @@ public class WebServiceMessageListenerIntegrationTest { Thread.sleep(100); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/support/JmsTransportUtilsTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/support/JmsTransportUtilsTest.java index 0b97d49a..c5bf231d 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/support/JmsTransportUtilsTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/support/JmsTransportUtilsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,16 @@ package org.springframework.ws.transport.jms.support; -import static org.assertj.core.api.Assertions.*; +import java.net.URI; import jakarta.jms.DeliveryMode; import jakarta.jms.Message; - -import java.net.URI; - import org.junit.jupiter.api.Test; + import org.springframework.ws.transport.jms.JmsTransportConstants; +import static org.assertj.core.api.Assertions.assertThat; + public class JmsTransportUtilsTest { @Test @@ -134,4 +134,5 @@ public class JmsTransportUtilsTest { assertThat(replyTo).isEqualTo("jms/REPLY_QUEUE"); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/MailIntegrationTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/MailIntegrationTest.java index 1a6624fc..e5e51851 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/MailIntegrationTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/MailIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,14 @@ package org.springframework.ws.transport.mail; -import static org.assertj.core.api.Assertions.*; - +import com.icegreen.greenmail.spring.GreenMailBean; +import com.icegreen.greenmail.util.GreenMailUtil; import jakarta.mail.MessagingException; import jakarta.mail.internet.MimeMessage; - import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -31,19 +31,20 @@ import org.springframework.ws.client.core.WebServiceTemplate; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import com.icegreen.greenmail.spring.GreenMailBean; -import com.icegreen.greenmail.util.GreenMailUtil; +import static org.assertj.core.api.Assertions.assertThat; @ExtendWith(SpringExtension.class) @ContextConfiguration("mail-applicationContext.xml") public class MailIntegrationTest { - @Autowired private GreenMailBean greenMailBean; + @Autowired + private GreenMailBean greenMailBean; - @Autowired private WebServiceTemplate webServiceTemplate; + @Autowired + private WebServiceTemplate webServiceTemplate; @Disabled("doesn't run under Spring Framework 6.0.1-SNAPSHOT") - @Test + @Test public void testMailTransport() throws MessagingException { String content = ""; @@ -55,8 +56,9 @@ public class MailIntegrationTest { assertThat(receivedMessages).hasSize(1); assertThat(GreenMailUtil.getAddressList(receivedMessages[0].getFrom())) - .isEqualTo("Spring-WS SOAP Client "); + .isEqualTo("Spring-WS SOAP Client "); assertThat(GreenMailUtil.getAddressList(receivedMessages[0].getAllRecipients())).isEqualTo("server@localhost"); assertThat(GreenMailUtil.getBody(receivedMessages[0])).contains(content); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/MailMessageSenderIntegrationTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/MailMessageSenderIntegrationTest.java index a32c0f29..e6780c61 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/MailMessageSenderIntegrationTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/MailMessageSenderIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,28 +16,27 @@ package org.springframework.ws.transport.mail; -import static org.assertj.core.api.Assertions.*; - -import jakarta.mail.Address; -import jakarta.mail.internet.MimeMessage; -import jakarta.xml.soap.MessageFactory; -import jakarta.xml.soap.SOAPConstants; -import jakarta.xml.soap.SOAPMessage; - import java.net.URI; import java.util.Collections; import javax.xml.namespace.QName; +import com.icegreen.greenmail.spring.GreenMailBean; +import jakarta.mail.Address; +import jakarta.mail.internet.MimeMessage; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPConstants; +import jakarta.xml.soap.SOAPMessage; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; + import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.transport.WebServiceConnection; -import com.icegreen.greenmail.spring.GreenMailBean; +import static org.assertj.core.api.Assertions.assertThat; public class MailMessageSenderIntegrationTest { @@ -88,7 +87,9 @@ public class MailMessageSenderIntegrationTest { MimeMessage[] receivedMessages = greenMailBean.getGreenMail().getReceivedMessages(); assertThat(receivedMessages).hasSize(1); - assertThat(receivedMessages[0].getAllRecipients()).extracting(Address::toString).contains("server@localhost"); + assertThat(receivedMessages[0].getAllRecipients()).extracting(Address::toString) + .contains("server@localhost"); } } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/support/MailTransportUtilsTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/support/MailTransportUtilsTest.java index 6ad92656..017d8176 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/support/MailTransportUtilsTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/mail/support/MailTransportUtilsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,14 @@ package org.springframework.ws.transport.mail.support; -import static org.assertj.core.api.Assertions.*; +import java.net.URI; import jakarta.mail.URLName; import jakarta.mail.internet.InternetAddress; - -import java.net.URI; - import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class MailTransportUtilsTest { @Test @@ -63,4 +62,5 @@ public class MailTransportUtilsTest { assertThat(subject).isNull(); } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/support/EchoPayloadEndpoint.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/support/EchoPayloadEndpoint.java index 97956490..af41173f 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/support/EchoPayloadEndpoint.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/support/EchoPayloadEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,4 +26,5 @@ public class EchoPayloadEndpoint implements PayloadEndpoint { public Source invoke(Source request) { return request; } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/support/FreePortScanner.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/support/FreePortScanner.java index 2d0d863a..be0dcfd7 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/support/FreePortScanner.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/support/FreePortScanner.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -62,7 +62,8 @@ public abstract class FreePortScanner { String.format("There were no ports available in the range %d to %d", minPort, maxPort)); } candidatePort = getRandomPort(minPort, portRange); - } while (!isPortAvailable(candidatePort)); + } + while (!isPortAvailable(candidatePort)); return candidatePort; } @@ -77,7 +78,8 @@ public abstract class FreePortScanner { try { serverSocket = new ServerSocket(); - } catch (IOException ex) { + } + catch (IOException ex) { throw new IllegalStateException("Unable to create ServerSocket.", ex); } @@ -85,14 +87,18 @@ public abstract class FreePortScanner { InetSocketAddress sa = new InetSocketAddress(port); serverSocket.bind(sa); return true; - } catch (IOException ex) { + } + catch (IOException ex) { return false; - } finally { + } + finally { try { serverSocket.close(); - } catch (IOException ex) { + } + catch (IOException ex) { // ignore } } } + } diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/xmpp/support/XmppConnectionFactoryBeanTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/xmpp/support/XmppConnectionFactoryBeanTest.java index 330a5fbe..6dc6a7cd 100644 --- a/spring-ws-support/src/test/java/org/springframework/ws/transport/xmpp/support/XmppConnectionFactoryBeanTest.java +++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/xmpp/support/XmppConnectionFactoryBeanTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,14 @@ package org.springframework.ws.transport.xmpp.support; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -/** @author Arjen Poutsma */ +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + +/** + * @author Arjen Poutsma + */ public class XmppConnectionFactoryBeanTest { private XmppConnectionFactoryBean factoryBean; @@ -50,4 +52,5 @@ public class XmppConnectionFactoryBeanTest { public void wrongPort() { assertThatIllegalArgumentException().isThrownBy(() -> factoryBean.setPort(-10)); } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/AbstractResponseCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/AbstractResponseCreator.java index e55a2a7c..7d6de933 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/AbstractResponseCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/AbstractResponseCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,8 +25,8 @@ import org.springframework.ws.WebServiceMessageFactory; /** * Abstract base class for the {@link ResponseCreator} interface. *

- * Creates a response using the given {@link WebServiceMessageFactory}, and passes it on to - * {@link #doWithResponse(URI, WebServiceMessage, WebServiceMessage)}. + * Creates a response using the given {@link WebServiceMessageFactory}, and passes it on + * to {@link #doWithResponse(URI, WebServiceMessage, WebServiceMessage)}. * * @author Arjen Poutsma * @since 2.0 @@ -42,8 +42,8 @@ abstract class AbstractResponseCreator implements ResponseCreator { } /** - * Execute any number of operations on the supplied response, given the request and URI. - * + * Execute any number of operations on the supplied response, given the request and + * URI. * @param uri the URI * @param request the request message * @param response the response message diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ErrorResponseCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ErrorResponseCreator.java index ba84e4eb..9b62e8b5 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ErrorResponseCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ErrorResponseCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -47,4 +47,5 @@ class ErrorResponseCreator implements ResponseCreator { String getErrorMessage() { return errorMessage; } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ExceptionResponseCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ExceptionResponseCreator.java index 6fc04c0f..1bf1a638 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ExceptionResponseCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ExceptionResponseCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,8 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; /** - * Implementation of {@link ResponseCreator} that responds by throwing either an {@link IOException} or a - * {@link RuntimeException}. + * Implementation of {@link ResponseCreator} that responds by throwing either an + * {@link IOException} or a {@link RuntimeException}. * * @author Arjen Poutsma * @since 2.0 @@ -46,8 +46,10 @@ class ExceptionResponseCreator implements ResponseCreator { throws IOException { if (exception instanceof IOException) { throw (IOException) exception; - } else { + } + else { throw (RuntimeException) exception; } } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockSenderConnection.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockSenderConnection.java index 20801d1e..ff820091 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockSenderConnection.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockSenderConnection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,7 +27,8 @@ import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.transport.WebServiceConnection; /** - * Mock implementation of {@link WebServiceConnection}. Implements {@link ResponseActions} to form a fluent API. + * Mock implementation of {@link WebServiceConnection}. Implements {@link ResponseActions} + * to form a fluent API. * * @author Arjen Poutsma * @author Lukas Krecan @@ -75,7 +76,8 @@ class MockSenderConnection implements WebServiceConnection, ResponseActions { for (RequestMatcher requestMatcher : requestMatchers) { requestMatcher.match(uri, message); } - } else { + } + else { throw new AssertionError("Unexpected send() for [" + message + "]"); } this.request = message; @@ -85,7 +87,8 @@ class MockSenderConnection implements WebServiceConnection, ResponseActions { public WebServiceMessage receive(WebServiceMessageFactory messageFactory) throws IOException { if (responseCreator != null) { return responseCreator.createResponse(uri, request, messageFactory); - } else { + } + else { return null; } } @@ -104,7 +107,8 @@ class MockSenderConnection implements WebServiceConnection, ResponseActions { public String getErrorMessage() throws IOException { if (responseCreator instanceof ErrorResponseCreator) { return ((ErrorResponseCreator) responseCreator).getErrorMessage(); - } else { + } + else { return null; } } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockWebServiceMessageSender.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockWebServiceMessageSender.java index 5da9b623..b61b35e0 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockWebServiceMessageSender.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockWebServiceMessageSender.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,8 +26,8 @@ import org.springframework.util.Assert; import org.springframework.ws.transport.WebServiceMessageSender; /** - * Mock implementation of {@link WebServiceMessageSender}. Contains a list of expected {@link MockSenderConnection}s, - * and iterates over those. + * Mock implementation of {@link WebServiceMessageSender}. Contains a list of expected + * {@link MockSenderConnection}s, and iterates over those. * * @author Arjen Poutsma * @author Lukas Krecan diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockWebServiceServer.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockWebServiceServer.java index 27d5c3de..6c998a66 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockWebServiceServer.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/MockWebServiceServer.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,24 +23,31 @@ import org.springframework.ws.client.core.support.WebServiceGatewaySupport; import org.springframework.ws.test.support.MockStrategiesHelper; /** - * Main entry point for client-side Web service testing. Typically used to test a - * {@link WebServiceTemplate}, set up expectations on request messages, and create response messages. + * Main entry point for client-side Web service testing. Typically used + * to test a {@link WebServiceTemplate}, set up expectations on request messages, and + * create response messages. *

* The typical usage of this class is: *

    - *
  1. Create a {@code MockWebServiceServer} instance by calling {@link #createServer(WebServiceTemplate)}, - * {@link #createServer(WebServiceGatewaySupport)}, or {@link #createServer(ApplicationContext)}. - *
  2. Set up request expectations by calling {@link #expect(RequestMatcher)}, possibly by using the default - * {@link RequestMatcher} implementations provided in {@link RequestMatchers} (which can be statically imported). - * Multiple expectations can be set up by chaining {@link ResponseActions#andExpect(RequestMatcher)} calls.
  3. - *
  4. Create an appropriate response message by calling {@link ResponseActions#andRespond(ResponseCreator) - * andRespond(ResponseCreator)}, possibly by using the default {@link ResponseCreator} implementations provided in + *
  5. Create a {@code MockWebServiceServer} instance by calling + * {@link #createServer(WebServiceTemplate)}, + * {@link #createServer(WebServiceGatewaySupport)}, or + * {@link #createServer(ApplicationContext)}. + *
  6. Set up request expectations by calling {@link #expect(RequestMatcher)}, possibly by + * using the default {@link RequestMatcher} implementations provided in + * {@link RequestMatchers} (which can be statically imported). Multiple expectations can + * be set up by chaining {@link ResponseActions#andExpect(RequestMatcher)} calls.
  7. + *
  8. Create an appropriate response message by calling + * {@link ResponseActions#andRespond(ResponseCreator) andRespond(ResponseCreator)}, + * possibly by using the default {@link ResponseCreator} implementations provided in * {@link ResponseCreators} (which can be statically imported).
  9. - *
  10. Use the {@code WebServiceTemplate} as normal, either directly of through client code.
  11. + *
  12. Use the {@code WebServiceTemplate} as normal, either directly of through client + * code.
  13. *
  14. Call {@link #verify()}. *
- * Note that because of the 'fluent' API offered by this class (and related classes), you can typically use the Code - * Completion features (i.e. ctrl-space) in your IDE to set up the mocks. + * Note that because of the 'fluent' API offered by this class (and related classes), you + * can typically use the Code Completion features (i.e. ctrl-space) in your IDE to set up + * the mocks. *

* For example:

* @@ -105,8 +112,8 @@ public class MockWebServiceServer { } /** - * Creates a {@code MockWebServiceServer} instance based on the given {@link WebServiceTemplate}. - * + * Creates a {@code MockWebServiceServer} instance based on the given + * {@link WebServiceTemplate}. * @param webServiceTemplate the web service template * @return the created server */ @@ -120,8 +127,8 @@ public class MockWebServiceServer { } /** - * Creates a {@code MockWebServiceServer} instance based on the given {@link WebServiceGatewaySupport}. - * + * Creates a {@code MockWebServiceServer} instance based on the given + * {@link WebServiceGatewaySupport}. * @param gatewaySupport the client class * @return the created server */ @@ -131,16 +138,17 @@ public class MockWebServiceServer { } /** - * Creates a {@code MockWebServiceServer} instance based on the given {@link ApplicationContext}. + * Creates a {@code MockWebServiceServer} instance based on the given + * {@link ApplicationContext}. *

- * This factory method will try and find a configured {@link WebServiceTemplate} in the given application context. If - * no template can be found, it will try and find a {@link WebServiceGatewaySupport}, and use its configured template. - * If neither can be found, an exception is thrown. - * + * This factory method will try and find a configured {@link WebServiceTemplate} in + * the given application context. If no template can be found, it will try and find a + * {@link WebServiceGatewaySupport}, and use its configured template. If neither can + * be found, an exception is thrown. * @param applicationContext the application context to base the client on * @return the created server - * @throws IllegalArgumentException if the given application context contains neither a {@link WebServiceTemplate} nor - * a {@link WebServiceGatewaySupport}. + * @throws IllegalArgumentException if the given application context contains neither + * a {@link WebServiceTemplate} nor a {@link WebServiceGatewaySupport}. */ public static MockWebServiceServer createServer(ApplicationContext applicationContext) { MockStrategiesHelper strategiesHelper = new MockStrategiesHelper(applicationContext); @@ -157,9 +165,9 @@ public class MockWebServiceServer { } /** - * Records an expectation specified by the given {@link RequestMatcher}. Returns a {@link ResponseActions} object that - * allows for creating the response, or to set up more expectations. - * + * Records an expectation specified by the given {@link RequestMatcher}. Returns a + * {@link ResponseActions} object that allows for creating the response, or to set up + * more expectations. * @param requestMatcher the request matcher expected * @return the response actions */ @@ -170,8 +178,8 @@ public class MockWebServiceServer { } /** - * Verifies that all of the {@link MockWebServiceMessageSender}'s expectations were met. - * + * Verifies that all of the {@link MockWebServiceMessageSender}'s expectations were + * met. * @throws AssertionError in case of unmet expectations */ public void verify() { diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestMatcher.java index 4a64c798..38715253 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,9 +31,8 @@ import org.springframework.ws.WebServiceMessage; public interface RequestMatcher { /** - * Matches the given request message against the expectations. Implementations typically make use of JUnit-based - * assertions. - * + * Matches the given request message against the expectations. Implementations + * typically make use of JUnit-based assertions. * @param uri the uri connected to * @param request the request message to make assertions on * @throws IOException in case of I/O errors diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestMatchers.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestMatchers.java index 1c71d36a..392c78db 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestMatchers.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestMatchers.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -40,22 +40,22 @@ import org.springframework.xml.transform.ResourceSource; */ public abstract class RequestMatchers { - private RequestMatchers() {} + private RequestMatchers() { + } /** * Expects any request. - * * @return the request matcher */ public static RequestMatcher anything() { - return (uri, request) -> {}; + return (uri, request) -> { + }; } // Payload /** * Expects the given {@link javax.xml.transform.Source} XML payload. - * * @param payload the XML payload * @return the request matcher */ @@ -66,7 +66,6 @@ public abstract class RequestMatchers { /** * Expects the given {@link org.springframework.core.io.Resource} XML payload. - * * @param payload the XML payload * @return the request matcher */ @@ -77,7 +76,6 @@ public abstract class RequestMatchers { /** * Expects the payload to validate against the given XSD schema(s). - * * @param schema the schema * @param furtherSchemas further schemas, if necessary * @return the request matcher @@ -88,7 +86,6 @@ public abstract class RequestMatchers { /** * Expects the given XPath expression to (not) exist or be evaluated to a value. - * * @param xpathExpression the XPath expression * @return the XPath expectations, to be further configured */ @@ -98,7 +95,6 @@ public abstract class RequestMatchers { /** * Expects the given XPath expression to (not) exist or be evaluated to a value. - * * @param xpathExpression the XPath expression * @param namespaceMapping the namespaces * @return the XPath expectations, to be further configured @@ -111,7 +107,6 @@ public abstract class RequestMatchers { /** * Expects the given {@link javax.xml.transform.Source} XML SOAP envelope. - * * @param soapEnvelope the XML SOAP envelope * @return the request matcher * @since 2.1.1 @@ -123,7 +118,6 @@ public abstract class RequestMatchers { /** * Expects the given {@link org.springframework.core.io.Resource} XML SOAP envelope. - * * @param soapEnvelope the XML SOAP envelope * @return the request matcher * @since 2.1.1 @@ -135,7 +129,6 @@ public abstract class RequestMatchers { /** * Expects the given SOAP header in the outgoing message. - * * @param soapHeaderName the qualified name of the SOAP header to expect * @return the request matcher */ @@ -148,7 +141,6 @@ public abstract class RequestMatchers { /** * Expects a connection to the given URI. - * * @param uri the String uri expected to connect to * @return the request matcher */ @@ -159,7 +151,6 @@ public abstract class RequestMatchers { /** * Expects a connection to the given URI. - * * @param uri the String uri expected to connect to * @return the request matcher */ diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestXPathExpectations.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestXPathExpectations.java index a20e34c4..4a976756 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestXPathExpectations.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/RequestXPathExpectations.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,9 +19,9 @@ package org.springframework.ws.test.client; /** * Allows for setting up expectations on XPath expressions. *

- * Implementations of this interface are returned by {@link RequestMatchers#xpath(String)} and - * {@link RequestMatchers#xpath(String, java.util.Map)}, as part of the fluent API. As such, it is not typical to - * implement this interface yourself. + * Implementations of this interface are returned by {@link RequestMatchers#xpath(String)} + * and {@link RequestMatchers#xpath(String, java.util.Map)}, as part of the fluent API. As + * such, it is not typical to implement this interface yourself. * * @author Lukas Krecan * @author Arjen Poutsma @@ -33,21 +33,18 @@ public interface RequestXPathExpectations { /** * Expects the XPath expression to exist. - * * @return the request matcher */ RequestMatcher exists(); /** * Expects the XPath expression to not exist. - * * @return the request matcher */ RequestMatcher doesNotExist(); /** * Expects the XPath expression to evaluate to the given boolean. - * * @param expectedValue the expected value * @return the request matcher */ @@ -55,7 +52,6 @@ public interface RequestXPathExpectations { /** * Expects the XPath expression to evaluate to the given integer. - * * @param expectedValue the expected value * @return the request matcher */ @@ -63,7 +59,6 @@ public interface RequestXPathExpectations { /** * Expects the XPath expression to evaluate to the given double. - * * @param expectedValue the expected value * @return the request matcher */ @@ -71,7 +66,6 @@ public interface RequestXPathExpectations { /** * Expects the XPath expression to evaluate to the given string. - * * @param expectedValue the expected value * @return the request matcher */ diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseActions.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseActions.java index e744e180..0112e433 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseActions.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseActions.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -17,24 +17,23 @@ package org.springframework.ws.test.client; /** - * Allows for setting up responses and additional expectations. Implementations of this interface are returned by - * {@link MockWebServiceServer#expect(RequestMatcher)}. + * Allows for setting up responses and additional expectations. Implementations of this + * interface are returned by {@link MockWebServiceServer#expect(RequestMatcher)}. * * @author Arjen Poutsma * @author Lukas Krecan * @since 2.0 */ public interface ResponseActions { + /** * Allows for further expectations to be set on the request. - * * @return the request expectations */ ResponseActions andExpect(RequestMatcher requestMatcher); /** * Sets the {@link ResponseCreator} for this mock. - * * @param responseCreator the response creator */ void andRespond(ResponseCreator responseCreator); diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseCreator.java index 58cac04b..cfd54af8 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,7 +23,8 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; /** - * Allows for creating up responses. Implementations of this interface are returned by {@link ResponseCreators}. + * Allows for creating up responses. Implementations of this interface are returned by + * {@link ResponseCreators}. * * @author Arjen Poutsma * @author Lukas Krecan @@ -33,7 +34,6 @@ public interface ResponseCreator { /** * Create a response for the given the request and URI. - * * @param uri the URI * @param request the request message * @param messageFactory the message that can be used to create responses diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseCreators.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseCreators.java index a08dbcd6..e2472fde 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseCreators.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/ResponseCreators.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -33,21 +33,21 @@ import org.springframework.ws.test.support.creator.WebServiceMessageCreator; import org.springframework.xml.transform.ResourceSource; /** - * Factory methods for {@link ResponseCreator} classes. Typically used to provide input for - * {@link ResponseActions#andRespond(ResponseCreator)}. + * Factory methods for {@link ResponseCreator} classes. Typically used to provide input + * for {@link ResponseActions#andRespond(ResponseCreator)}. * * @author Arjen Poutsma * @since 2.0 */ public abstract class ResponseCreators { - private ResponseCreators() {} + private ResponseCreators() { + } // Payload /** * Respond with the given {@link javax.xml.transform.Source} XML as payload response. - * * @param payload the response payload * @return the response callback */ @@ -57,8 +57,8 @@ public abstract class ResponseCreators { } /** - * Respond with the given {@link org.springframework.core.io.Resource} XML as payload response. - * + * Respond with the given {@link org.springframework.core.io.Resource} XML as payload + * response. * @param payload the response payload * @return the response callback */ @@ -71,7 +71,6 @@ public abstract class ResponseCreators { /** * Respond with an error. - * * @param errorMessage the error message * @return the response callback * @see org.springframework.ws.transport.WebServiceConnection#hasError() @@ -84,7 +83,6 @@ public abstract class ResponseCreators { /** * Respond with an {@link java.io.IOException}. - * * @param ioException the exception to be thrown * @return the response callback */ @@ -95,7 +93,6 @@ public abstract class ResponseCreators { /** * Respond with an {@link RuntimeException}. - * * @param ex the runtime exception to be thrown * @return the response callback */ @@ -107,8 +104,8 @@ public abstract class ResponseCreators { // SOAP /** - * Respond with the given {@link javax.xml.transform.Source} XML as SOAP envelope response. - * + * Respond with the given {@link javax.xml.transform.Source} XML as SOAP envelope + * response. * @param soapEnvelope the response SOAP envelope * @return the response callback * @since 2.1.1 @@ -119,8 +116,8 @@ public abstract class ResponseCreators { } /** - * Respond with the given {@link org.springframework.core.io.Resource} XML as SOAP envelope response. - * + * Respond with the given {@link org.springframework.core.io.Resource} XML as SOAP + * envelope response. * @param soapEnvelope the response SOAP envelope * @return the response callback * @since 2.1.1 @@ -132,7 +129,6 @@ public abstract class ResponseCreators { /** * Respond with a {@code MustUnderstand} fault. - * * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @see SoapBody#addMustUnderstandFault(String, java.util.Locale) @@ -149,7 +145,6 @@ public abstract class ResponseCreators { /** * Respond with a {@code Client} (SOAP 1.1) or {@code Sender} (SOAP 1.2) fault. - * * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale) @@ -166,7 +161,6 @@ public abstract class ResponseCreators { /** * Respond with a {@code Server} (SOAP 1.1) or {@code Receiver} (SOAP 1.2) fault. - * * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @see org.springframework.ws.soap.SoapBody#addServerOrReceiverFault(String, Locale) @@ -183,7 +177,6 @@ public abstract class ResponseCreators { /** * Respond with a {@code VersionMismatch} fault. - * * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @see org.springframework.ws.soap.SoapBody#addVersionMismatchFault(String, Locale) @@ -210,10 +203,11 @@ public abstract class ResponseCreators { } @Override - public WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory messageFactory) - throws IOException { + public WebServiceMessage createResponse(URI uri, WebServiceMessage request, + WebServiceMessageFactory messageFactory) throws IOException { return adaptee.createMessage(messageFactory); } + } } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/SoapFaultResponseCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/SoapFaultResponseCreator.java index c940ff97..b94b8e04 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/SoapFaultResponseCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/SoapFaultResponseCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.test.client; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import java.net.URI; @@ -25,6 +23,8 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapMessage; +import static org.springframework.ws.test.support.AssertionErrors.fail; + /** * Implementation of {@link ResponseCreator} that responds with a SOAP fault. * @@ -48,9 +48,10 @@ abstract class SoapFaultResponseCreator extends AbstractResponseCreator { } /** - * Abstract template method that allows subclasses to add a SOAP Fault to the given Body. - * + * Abstract template method that allows subclasses to add a SOAP Fault to the given + * Body. * @param soapBody the body to attach a fault to */ protected abstract void addSoapFault(SoapBody soapBody); + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/UriMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/UriMatcher.java index 67048484..35813ee7 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/UriMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/UriMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.test.client; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.net.URI; import org.springframework.ws.WebServiceMessage; +import static org.springframework.ws.test.support.AssertionErrors.assertEquals; + /** * Matches {@link URI}s. * @@ -40,4 +40,5 @@ class UriMatcher implements RequestMatcher { public void match(URI actual, WebServiceMessage request) { assertEquals("Unexpected connection", expected, actual, "Payload", request.getPayloadSource()); } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapter.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapter.java index b6e7a1c8..2b8372ca 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapter.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -42,4 +42,5 @@ class WebServiceMessageMatcherAdapter implements RequestMatcher { public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError { adaptee.match(request); } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/XPathExpectationsHelperAdapter.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/XPathExpectationsHelperAdapter.java index c05e5969..685003ec 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/XPathExpectationsHelperAdapter.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/XPathExpectationsHelperAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,7 +21,8 @@ import java.util.Map; import org.springframework.ws.test.support.matcher.XPathExpectationsHelper; /** - * Adapts {@link XPathExpectationsHelper} into the {@link RequestXPathExpectations} contract. + * Adapts {@link XPathExpectationsHelper} into the {@link RequestXPathExpectations} + * contract. * * @author Arjen Poutsma * @since 2.0 diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/client/package-info.java b/spring-ws-test/src/main/java/org/springframework/ws/test/client/package-info.java index ba5dc106..a3eedc4a 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/client/package-info.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/client/package-info.java @@ -15,7 +15,8 @@ */ /** - * Provides a testing framework for client-side Web service testing. This package contains the - * {@link org.springframework.ws.test.client.MockWebServiceServer}, and various related test interfaces. + * Provides a testing framework for client-side Web service testing. This package contains + * the {@link org.springframework.ws.test.client.MockWebServiceServer}, and various + * related test interfaces. */ package org.springframework.ws.test.client; diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/MockWebServiceClient.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/MockWebServiceClient.java index 4715e3ab..166fbb8c 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/MockWebServiceClient.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/MockWebServiceClient.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,11 @@ package org.springframework.ws.test.server; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.context.ApplicationContext; import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; @@ -33,24 +32,31 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher; import org.springframework.ws.test.support.MockStrategiesHelper; import org.springframework.ws.transport.WebServiceMessageReceiver; +import static org.springframework.ws.test.support.AssertionErrors.fail; + /** - * Main entry point for server-side Web service testing. Typically used to test a - * {@link org.springframework.ws.server.MessageDispatcher MessageDispatcher} (including its endpoints, mappings, etc) by - * creating request messages, and setting up expectations about response messages. + * Main entry point for server-side Web service testing. Typically used + * to test a {@link org.springframework.ws.server.MessageDispatcher MessageDispatcher} + * (including its endpoints, mappings, etc) by creating request messages, and setting up + * expectations about response messages. *

* The typical usage of this class is: *

    - *
  1. Create a {@code MockWebServiceClient} instance by using {@link #createClient(ApplicationContext)} or + *
  2. Create a {@code MockWebServiceClient} instance by using + * {@link #createClient(ApplicationContext)} or * {@link #createClient(WebServiceMessageReceiver, WebServiceMessageFactory)}
  3. - *
  4. Send request messages by calling {@link #sendRequest(RequestCreator)}, possibly by using the default - * {@link RequestCreator} implementations provided in {@link RequestCreators} (which can be statically imported).
  5. - *
  6. Set up response expectations by calling {@link ResponseActions#andExpect(ResponseMatcher) - * andExpect(ResponseMatcher)}, possibly by using the default {@link ResponseMatcher} implementations provided in - * {@link ResponseMatchers} (which can be statically imported). Multiple expectations can be set up by chaining - * {@code andExpect()} calls.
  7. + *
  8. Send request messages by calling {@link #sendRequest(RequestCreator)}, possibly by + * using the default {@link RequestCreator} implementations provided in + * {@link RequestCreators} (which can be statically imported).
  9. + *
  10. Set up response expectations by calling + * {@link ResponseActions#andExpect(ResponseMatcher) andExpect(ResponseMatcher)}, possibly + * by using the default {@link ResponseMatcher} implementations provided in + * {@link ResponseMatchers} (which can be statically imported). Multiple expectations can + * be set up by chaining {@code andExpect()} calls.
  11. *
- * Note that because of the 'fluent' API offered by this class (and related classes), you can typically use the Code - * Completion features (i.e. ctrl-space) in your IDE to set up the mocks. + * Note that because of the 'fluent' API offered by this class (and related classes), you + * can typically use the Code Completion features (i.e. ctrl-space) in your IDE to set up + * the mocks. *

* For example:

* @@ -124,10 +130,10 @@ public class MockWebServiceClient { // Factory methods /** - * Creates a {@code MockWebServiceClient} instance based on the given {@link WebServiceMessageReceiver} and - * {@link WebServiceMessageFactory}. - * - * @param messageReceiver the message receiver, typically a {@link SoapMessageDispatcher} + * Creates a {@code MockWebServiceClient} instance based on the given + * {@link WebServiceMessageReceiver} and {@link WebServiceMessageFactory}. + * @param messageReceiver the message receiver, typically a + * {@link SoapMessageDispatcher} * @param messageFactory the message factory * @return the created client */ @@ -137,16 +143,18 @@ public class MockWebServiceClient { } /** - * Creates a {@code MockWebServiceClient} instance based on the given {@link ApplicationContext}. This factory method - * works in a similar fashion as the standard {@link org.springframework.ws.transport.http.MessageDispatcherServlet + * Creates a {@code MockWebServiceClient} instance based on the given + * {@link ApplicationContext}. This factory method works in a similar fashion as the + * standard {@link org.springframework.ws.transport.http.MessageDispatcherServlet * MessageDispatcherServlet}. That is: *
    - *
  • If a {@link WebServiceMessageReceiver} is configured in the given application context, it will use that. If no - * message receiver is configured, it will create a default {@link SoapMessageDispatcher}.
  • - *
  • If a {@link WebServiceMessageFactory} is configured in the given application context, it will use that. If no - * message factory is configured, it will create a default {@link SaajSoapMessageFactory}.
  • + *
  • If a {@link WebServiceMessageReceiver} is configured in the given application + * context, it will use that. If no message receiver is configured, it will create a + * default {@link SoapMessageDispatcher}.
  • + *
  • If a {@link WebServiceMessageFactory} is configured in the given application + * context, it will use that. If no message factory is configured, it will create a + * default {@link SaajSoapMessageFactory}.
  • *
- * * @param applicationContext the application context to base the client on * @return the created client */ @@ -165,9 +173,8 @@ public class MockWebServiceClient { // Sending /** - * Sends a request message by using the given {@link RequestCreator}. Typically called by using the default request - * creators provided by {@link RequestCreators}. - * + * Sends a request message by using the given {@link RequestCreator}. Typically called + * by using the default request creators provided by {@link RequestCreators}. * @param requestCreator the request creator * @return the response actions * @see RequestCreators @@ -181,7 +188,8 @@ public class MockWebServiceClient { messageReceiver.receive(messageContext); return new MockWebServiceClientResponseActions(messageContext); - } catch (Exception ex) { + } + catch (Exception ex) { logger.error("Could not send request", ex); fail(ex.getMessage()); return null; @@ -210,12 +218,14 @@ public class MockWebServiceClient { try { responseMatcher.match(request, response); return this; - } catch (IOException ex) { + } + catch (IOException ex) { logger.error("Could not match request", ex); fail(ex.getMessage()); return null; } } + } } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/RequestCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/RequestCreator.java index 376fe6b9..530db02c 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/RequestCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/RequestCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,7 +22,8 @@ import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; /** - * Creates request messages. Implementations of this interface are returned by {@link RequestCreators}. + * Creates request messages. Implementations of this interface are returned by + * {@link RequestCreators}. * * @author Arjen Poutsma * @see RequestCreators @@ -32,7 +33,6 @@ public interface RequestCreator { /** * Create a request. - * * @param messageFactory the message that can be used to create responses * @throws IOException in case of I/O errors */ diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/RequestCreators.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/RequestCreators.java index eab52895..db7e8dba 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/RequestCreators.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/RequestCreators.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -38,13 +38,13 @@ import org.springframework.xml.transform.ResourceSource; */ public abstract class RequestCreators { - private RequestCreators() {} + private RequestCreators() { + } // Payload /** * Create a request with the given {@link Source} XML as payload. - * * @param payload the request payload * @return the request creator */ @@ -55,7 +55,6 @@ public abstract class RequestCreators { /** * Create a request with the given {@link Resource} XML as payload. - * * @param payload the request payload * @return the request creator */ @@ -68,7 +67,6 @@ public abstract class RequestCreators { /** * Create a request with the given {@link Source} XML as SOAP envelope. - * * @param soapEnvelope the request SOAP envelope * @return the request creator * @since 2.1.1 @@ -80,7 +78,6 @@ public abstract class RequestCreators { /** * Create a request with the given {@link Resource} XML as SOAP envelope. - * * @param soapEnvelope the request SOAP envelope * @return the request creator * @since 2.1.1 @@ -105,6 +102,7 @@ public abstract class RequestCreators { public WebServiceMessage createRequest(WebServiceMessageFactory messageFactory) throws IOException { return adaptee.createMessage(messageFactory); } + } } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseActions.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseActions.java index a477462e..72790317 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseActions.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseActions.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -17,8 +17,8 @@ package org.springframework.ws.test.server; /** - * Allows for setting up expectation about response messages. Implementations of this interface are returned by - * {@link MockWebServiceClient#sendRequest(RequestCreator)}. + * Allows for setting up expectation about response messages. Implementations of this + * interface are returned by {@link MockWebServiceClient#sendRequest(RequestCreator)}. * * @author Arjen Poutsma * @since 2.0 @@ -27,7 +27,6 @@ public interface ResponseActions { /** * Sets up an expectation about the response message. - * * @param responseMatcher the response matcher that defines expectations * @return an instance of {@link ResponseActions}, to set up further expectations */ diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseMatcher.java index a83f5a37..20c77781 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,8 @@ import java.io.IOException; import org.springframework.ws.WebServiceMessage; /** - * Defines the contract for matching response messages to expectations. Implementations of this interface are returned - * by {@link ResponseMatchers}. + * Defines the contract for matching response messages to expectations. Implementations of + * this interface are returned by {@link ResponseMatchers}. * * @author Arjen Poutsma * @since 2.0 @@ -30,9 +30,8 @@ import org.springframework.ws.WebServiceMessage; public interface ResponseMatcher { /** - * Matches the given response message against the expectations. Implementations typically make use of JUnit-based - * assertions. - * + * Matches the given response message against the expectations. Implementations + * typically make use of JUnit-based assertions. * @param request the request message * @param response the response message to make assertions on * @throws IOException in case of I/O errors diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseMatchers.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseMatchers.java index 43b056dd..edd84d0c 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseMatchers.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseMatchers.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.test.server; -import static org.springframework.ws.test.support.AssertionErrors.fail; - import java.io.IOException; import java.util.Locale; import java.util.Map; @@ -36,22 +34,24 @@ import org.springframework.ws.test.support.matcher.xmlunit2.PayloadDiffMatcher; import org.springframework.ws.test.support.matcher.xmlunit2.SoapEnvelopeDiffMatcher; import org.springframework.xml.transform.ResourceSource; +import static org.springframework.ws.test.support.AssertionErrors.fail; + /** - * Factory methods for {@link ResponseMatcher} classes. Typically used to provide input for - * {@link ResponseActions#andExpect(ResponseMatcher)}. + * Factory methods for {@link ResponseMatcher} classes. Typically used to provide input + * for {@link ResponseActions#andExpect(ResponseMatcher)}. * * @author Arjen Poutsma * @since 2.0 */ public abstract class ResponseMatchers { - private ResponseMatchers() {} + private ResponseMatchers() { + } // Payload /** * Expects the given {@link Source} XML payload. - * * @param payload the XML payload * @return the response matcher */ @@ -61,7 +61,6 @@ public abstract class ResponseMatchers { /** * Expects the given {@link Resource} XML payload. - * * @param payload the XML payload * @return the response matcher */ @@ -71,7 +70,6 @@ public abstract class ResponseMatchers { /** * Expects the payload to validate against the given XSD schema(s). - * * @param schema the schema * @param furtherSchemas further schemas, if necessary * @return the response matcher @@ -82,7 +80,6 @@ public abstract class ResponseMatchers { /** * Expects the given XPath expression to (not) exist or be evaluated to a value. - * * @param xpathExpression the XPath expression * @return the XPath expectations, to be further configured */ @@ -92,7 +89,6 @@ public abstract class ResponseMatchers { /** * Expects the given XPath expression to (not) exist or be evaluated to a value. - * * @param xpathExpression the XPath expression * @param namespaceMapping the namespaces * @return the XPath expectations, to be further configured @@ -105,7 +101,6 @@ public abstract class ResponseMatchers { /** * Expects the given {@link Source} XML SOAP envelope. - * * @param soapEnvelope the XML SOAP envelope * @return the response matcher * @since 2.1.1 @@ -116,7 +111,6 @@ public abstract class ResponseMatchers { /** * Expects the given {@link Resource} XML SOAP envelope. - * * @param soapEnvelope the XML SOAP envelope * @return the response matcher * @since 2.1.1 @@ -127,7 +121,6 @@ public abstract class ResponseMatchers { /** * Expects the given SOAP header in the outgoing message. - * * @param soapHeaderName the qualified name of the SOAP header to expect * @return the request matcher */ @@ -138,12 +131,12 @@ public abstract class ResponseMatchers { /** * Expects the response not to contain a SOAP fault. - * * @return the response matcher */ public static ResponseMatcher noFault() { return new ResponseMatcher() { - public void match(WebServiceMessage request, WebServiceMessage response) throws IOException, AssertionError { + public void match(WebServiceMessage request, WebServiceMessage response) + throws IOException, AssertionError { if (response instanceof FaultAwareWebServiceMessage) { FaultAwareWebServiceMessage faultMessage = (FaultAwareWebServiceMessage) response; if (faultMessage.hasFault()) { @@ -157,7 +150,6 @@ public abstract class ResponseMatchers { /** * Expects a {@code MustUnderstand} fault. - * * @see org.springframework.ws.soap.SoapBody#addMustUnderstandFault(String, Locale) */ public static ResponseMatcher mustUnderstandFault() { @@ -166,9 +158,8 @@ public abstract class ResponseMatchers { /** * Expects a {@code MustUnderstand} fault with a particular fault string or reason. - * - * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If {@code null} the fault string or - * reason text will not be verified + * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If + * {@code null} the fault string or reason text will not be verified * @see org.springframework.ws.soap.SoapBody#addMustUnderstandFault(String, Locale) */ public static ResponseMatcher mustUnderstandFault(String faultStringOrReason) { @@ -182,7 +173,6 @@ public abstract class ResponseMatchers { /** * Expects a {@code Client} (SOAP 1.1) or {@code Sender} (SOAP 1.2) fault. - * * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale) */ public static ResponseMatcher clientOrSenderFault() { @@ -190,10 +180,10 @@ public abstract class ResponseMatchers { } /** - * Expects a {@code Client} (SOAP 1.1) or {@code Sender} (SOAP 1.2) fault with a particular fault string or reason. - * - * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If {@code null} the fault string or - * reason text will not be verified + * Expects a {@code Client} (SOAP 1.1) or {@code Sender} (SOAP 1.2) fault with a + * particular fault string or reason. + * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If + * {@code null} the fault string or reason text will not be verified * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale) */ public static ResponseMatcher clientOrSenderFault(String faultStringOrReason) { @@ -207,18 +197,18 @@ public abstract class ResponseMatchers { /** * Expects a {@code Server} (SOAP 1.1) or {@code Receiver} (SOAP 1.2) fault. - * - * @see org.springframework.ws.soap.SoapBody#addServerOrReceiverFault(String, java.util.Locale) + * @see org.springframework.ws.soap.SoapBody#addServerOrReceiverFault(String, + * java.util.Locale) */ public static ResponseMatcher serverOrReceiverFault() { return serverOrReceiverFault(null); } /** - * Expects a {@code Server} (SOAP 1.1) or {@code Receiver} (SOAP 1.2) fault with a particular fault string or reason. - * - * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If {@code null} the fault string or - * reason text will not be verified + * Expects a {@code Server} (SOAP 1.1) or {@code Receiver} (SOAP 1.2) fault with a + * particular fault string or reason. + * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If + * {@code null} the fault string or reason text will not be verified * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale) */ public static ResponseMatcher serverOrReceiverFault(String faultStringOrReason) { @@ -232,8 +222,8 @@ public abstract class ResponseMatchers { /** * Expects a {@code VersionMismatch} fault. - * - * @see org.springframework.ws.soap.SoapBody#addVersionMismatchFault(String, java.util.Locale) + * @see org.springframework.ws.soap.SoapBody#addVersionMismatchFault(String, + * java.util.Locale) */ public static ResponseMatcher versionMismatchFault() { return versionMismatchFault(null); @@ -241,9 +231,8 @@ public abstract class ResponseMatchers { /** * Expects a {@code VersionMismatch} fault with a particular fault string or reason. - * - * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If {@code null} the fault string or - * reason text will not be verified + * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If + * {@code null} the fault string or reason text will not be verified * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale) */ public static ResponseMatcher versionMismatchFault(String faultStringOrReason) { diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseXPathExpectations.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseXPathExpectations.java index d44e1325..8935077c 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseXPathExpectations.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/ResponseXPathExpectations.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,9 @@ package org.springframework.ws.test.server; *

* Implementations of this interface are returned by * {@link org.springframework.ws.test.client.RequestMatchers#xpath(String)} and - * {@link org.springframework.ws.test.client.RequestMatchers#xpath(String, java.util.Map)}, as part of the fluent API. - * As such, it is not typical to implement this interface yourself. + * {@link org.springframework.ws.test.client.RequestMatchers#xpath(String, java.util.Map)}, + * as part of the fluent API. As such, it is not typical to implement this interface + * yourself. * * @author Lukas Krecan * @author Arjen Poutsma @@ -34,21 +35,18 @@ public interface ResponseXPathExpectations { /** * Expects the XPath expression to exist. - * * @return the request matcher */ ResponseMatcher exists(); /** * Expects the XPath expression to not exist. - * * @return the request matcher */ ResponseMatcher doesNotExist(); /** * Expects the XPath expression to evaluate to the given boolean. - * * @param expectedValue the expected value * @return the request matcher */ @@ -56,7 +54,6 @@ public interface ResponseXPathExpectations { /** * Expects the XPath expression to evaluate to the given integer. - * * @param expectedValue the expected value * @return the request matcher */ @@ -64,7 +61,6 @@ public interface ResponseXPathExpectations { /** * Expects the XPath expression to evaluate to the given double. - * * @param expectedValue the expected value * @return the request matcher */ @@ -72,7 +68,6 @@ public interface ResponseXPathExpectations { /** * Expects the XPath expression to evaluate to the given string. - * * @param expectedValue the expected value * @return the request matcher */ diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/SoapFaultResponseMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/SoapFaultResponseMatcher.java index 80e9dfa3..91fc17b2 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/SoapFaultResponseMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/SoapFaultResponseMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.test.server; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import javax.xml.namespace.QName; @@ -28,6 +26,9 @@ import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.SoapVersion; +import static org.springframework.ws.test.support.AssertionErrors.assertEquals; +import static org.springframework.ws.test.support.AssertionErrors.assertTrue; + /** * Abstract Implementation of {@link ResponseMatcher} that checks for a SOAP fault. * @@ -53,7 +54,8 @@ abstract class SoapFaultResponseMatcher implements ResponseMatcher { QName expectedFaultCode = getExpectedFaultCode(soapResponse.getVersion()); assertEquals("Invalid SOAP Fault code", expectedFaultCode, soapFault.getFaultCode()); if (expectedFaultStringOrReason != null) { - assertEquals("Invalid SOAP Fault string/reason", expectedFaultStringOrReason, soapFault.getFaultStringOrReason()); + assertEquals("Invalid SOAP Fault string/reason", expectedFaultStringOrReason, + soapFault.getFaultStringOrReason()); } } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapter.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapter.java index 6ee498e4..f2f8cab3 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapter.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -41,4 +41,5 @@ class WebServiceMessageMatcherAdapter implements ResponseMatcher { public void match(WebServiceMessage request, WebServiceMessage response) throws IOException, AssertionError { adaptee.match(response); } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/XPathExpectationsHelperAdapter.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/XPathExpectationsHelperAdapter.java index 78598553..95d74170 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/XPathExpectationsHelperAdapter.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/XPathExpectationsHelperAdapter.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,7 +21,8 @@ import java.util.Map; import org.springframework.ws.test.support.matcher.XPathExpectationsHelper; /** - * Adapts {@link XPathExpectationsHelper} into the {@link ResponseXPathExpectations} contract. + * Adapts {@link XPathExpectationsHelper} into the {@link ResponseXPathExpectations} + * contract. * * @author Arjen Poutsma * @since 2.0 diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/server/package-info.java b/spring-ws-test/src/main/java/org/springframework/ws/test/server/package-info.java index 6dacfb42..d0b38c0f 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/server/package-info.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/server/package-info.java @@ -15,7 +15,8 @@ */ /** - * Provides a testing framework for server-side Web service testing. This package contains the - * {@link org.springframework.ws.test.server.MockWebServiceClient}, and various related test interfaces. + * Provides a testing framework for server-side Web service testing. This package contains + * the {@link org.springframework.ws.test.server.MockWebServiceClient}, and various + * related test interfaces. */ package org.springframework.ws.test.server; diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/AssertionErrors.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/AssertionErrors.java index 39271d99..4f89ce50 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/AssertionErrors.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/AssertionErrors.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,11 +27,11 @@ import javax.xml.transform.Source; */ public abstract class AssertionErrors { - private AssertionErrors() {} + private AssertionErrors() { + } /** * Fails a test with the given message. - * * @param message the message */ public static void fail(String message) { @@ -40,21 +40,21 @@ public abstract class AssertionErrors { /** * Fails a test with the given message and source. - * * @param message the message * @param source the source */ public static void fail(String message, String sourceLabel, Source source) { if (source != null) { throw new SourceAssertionError(message, sourceLabel, source); - } else { + } + else { fail(message); } } /** - * Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message. - * + * Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} + * with the given message. * @param message the message * @param condition the condition to test for */ @@ -63,9 +63,8 @@ public abstract class AssertionErrors { } /** - * Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message and - * source. - * + * Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} + * with the given message and source. * @param message the message * @param condition the condition to test for */ @@ -76,8 +75,8 @@ public abstract class AssertionErrors { } /** - * Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message. - * + * Asserts that two objects are equal. If not, an {@link AssertionError} is thrown + * with the given message. * @param message the message * @param expected the expected value * @param actual the actual value @@ -87,8 +86,8 @@ public abstract class AssertionErrors { } /** - * Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message. - * + * Asserts that two objects are equal. If not, an {@link AssertionError} is thrown + * with the given message. * @param message the message * @param expected the expected value * @param actual the actual value diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/MockStrategiesHelper.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/MockStrategiesHelper.java index 4460cfe3..a04910e9 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/MockStrategiesHelper.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/MockStrategiesHelper.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,6 +20,7 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanInitializationException; @@ -42,8 +43,8 @@ public class MockStrategiesHelper { private final ApplicationContext applicationContext; /** - * Creates a new instance of the {@code MockStrategiesHelper} with the given application context. - * + * Creates a new instance of the {@code MockStrategiesHelper} with the given + * application context. * @param applicationContext the application context */ public MockStrategiesHelper(ApplicationContext applicationContext) { @@ -60,7 +61,6 @@ public class MockStrategiesHelper { /** * Returns a single strategy found in the given application context. - * * @param type the type of bean to be found in the application context * @return the bean, or {@code null} if no bean of the given type can be found * @throws BeanInitializationException if there is more than 1 beans of the given type @@ -70,25 +70,28 @@ public class MockStrategiesHelper { Map map = applicationContext.getBeansOfType(type); if (map.isEmpty()) { return null; - } else if (map.size() == 1) { + } + else if (map.size() == 1) { Map.Entry entry = map.entrySet().iterator().next(); if (logger.isDebugEnabled()) { logger.debug("Using " + ClassUtils.getShortName(type) + " [" + entry.getKey() + "]"); } return entry.getValue(); - } else { + } + else { throw new BeanInitializationException( "Could not find exactly 1 " + ClassUtils.getShortName(type) + " in application context"); } } /** - * Returns a single strategy found in the given application context, or instantiates a default strategy if no - * applicable strategy was found. - * + * Returns a single strategy found in the given application context, or instantiates a + * default strategy if no applicable strategy was found. * @param type the type of bean to be found in the application context - * @param defaultType the type to instantiate and return when no bean of the specified type could be found - * @return the bean found in the application context, or the default type if no bean of the given type can be found + * @param defaultType the type to instantiate and return when no bean of the specified + * type could be found + * @return the bean found in the application context, or the default type if no bean + * of the given type can be found * @throws BeanInitializationException if there is more than 1 beans of the given type */ public T getStrategy(Class type, Class defaultType) { @@ -96,10 +99,11 @@ public class MockStrategiesHelper { T t = getStrategy(type); if (t != null) { return t; - } else { + } + else { if (logger.isDebugEnabled()) { - logger.debug( - "No " + ClassUtils.getShortName(type) + " found, using default " + ClassUtils.getShortName(defaultType)); + logger.debug("No " + ClassUtils.getShortName(type) + " found, using default " + + ClassUtils.getShortName(defaultType)); } T defaultStrategy = BeanUtils.instantiateClass(defaultType); if (defaultStrategy instanceof ApplicationContextAware) { @@ -110,7 +114,8 @@ public class MockStrategiesHelper { InitializingBean initializingBean = (InitializingBean) defaultStrategy; try { initializingBean.afterPropertiesSet(); - } catch (Exception ex) { + } + catch (Exception ex) { throw new BeanCreationException("Invocation of init method failed", ex); } } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/SourceAssertionError.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/SourceAssertionError.java index fa7ec613..e8bc430d 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/SourceAssertionError.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/SourceAssertionError.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,7 +26,8 @@ import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.TransformerHelper; /** - * Subclass of {@link AssertionError} that also contains a {@link Source} for more context. + * Subclass of {@link AssertionError} that also contains a {@link Source} for more + * context. * * @author Lukas Krecan * @author Arjen Poutsma @@ -42,7 +43,8 @@ public class SourceAssertionError extends AssertionError { private final TransformerHelper transformerHelper = new TransformerHelper(); /** - * Creates a new instance of the {@code SourceAssertionError} class with the given parameters. + * Creates a new instance of the {@code SourceAssertionError} class with the given + * parameters. */ public SourceAssertionError(String detailMessage, String sourceLabel, Source source) { super(detailMessage); @@ -52,7 +54,6 @@ public class SourceAssertionError extends AssertionError { /** * Returns the source context of this error. - * * @return the source */ public Source getSource() { @@ -82,7 +83,8 @@ public class SourceAssertionError extends AssertionError { Transformer transformer = createNonIndentingTransformer(); transformer.transform(source, result); return result.toString(); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { // Ignore } } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/AbstractMessageCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/AbstractMessageCreator.java index 92c58e14..97bc1712 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/AbstractMessageCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/AbstractMessageCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -40,9 +40,8 @@ public abstract class AbstractMessageCreator implements WebServiceMessageCreator } /** - * Abstract template method, invoked by {@link #createMessage(WebServiceMessageFactory)} after a message has been - * created. - * + * Abstract template method, invoked by + * {@link #createMessage(WebServiceMessageFactory)} after a message has been created. * @param message the message * @throws IOException in case of I/O errors */ diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/PayloadMessageCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/PayloadMessageCreator.java index ce32a39a..b5f97248 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/PayloadMessageCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/PayloadMessageCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.test.support.creator; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import javax.xml.transform.Source; @@ -27,8 +25,11 @@ import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.xml.transform.TransformerHelper; +import static org.springframework.ws.test.support.AssertionErrors.fail; + /** - * Implementation of {@link WebServiceMessageCreator} that creates a request based on a {@link Source}. + * Implementation of {@link WebServiceMessageCreator} that creates a request based on a + * {@link Source}. * * @author Arjen Poutsma * @since 2.0 @@ -40,8 +41,8 @@ public class PayloadMessageCreator extends AbstractMessageCreator { private TransformerHelper transformerHelper = new TransformerHelper(); /** - * Creates a new instance of the {@code PayloadMessageCreator} with the given payload source. - * + * Creates a new instance of the {@code PayloadMessageCreator} with the given payload + * source. * @param payload the payload source */ public PayloadMessageCreator(Source payload) { @@ -53,8 +54,10 @@ public class PayloadMessageCreator extends AbstractMessageCreator { protected void doWithMessage(WebServiceMessage message) throws IOException { try { transformerHelper.transform(payload, message.getPayloadResult()); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { fail("Could not transform request payload to message: " + ex.getMessage()); } } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/SoapEnvelopeMessageCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/SoapEnvelopeMessageCreator.java index 485fab86..83ec33a2 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/SoapEnvelopeMessageCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/SoapEnvelopeMessageCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,22 +16,25 @@ package org.springframework.ws.test.support.creator; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; +import org.w3c.dom.Document; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapMessage; import org.springframework.xml.transform.TransformerHelper; -import org.w3c.dom.Document; + +import static org.springframework.ws.test.support.AssertionErrors.assertTrue; +import static org.springframework.ws.test.support.AssertionErrors.fail; /** - * Implementation of {@link WebServiceMessageCreator} that creates a request based on a SOAP envelope {@link Source}. + * Implementation of {@link WebServiceMessageCreator} that creates a request based on a + * SOAP envelope {@link Source}. * * @author Alexander Shutyaev * @since 2.1.1 @@ -43,8 +46,8 @@ public class SoapEnvelopeMessageCreator extends AbstractMessageCreator { private final TransformerHelper transformerHelper = new TransformerHelper(); /** - * Creates a new instance of the {@code SoapEnvelopeMessageCreator} with the given SOAP envelope source. - * + * Creates a new instance of the {@code SoapEnvelopeMessageCreator} with the given + * SOAP envelope source. * @param soapEnvelope the SOAP envelope source */ public SoapEnvelopeMessageCreator(Source soapEnvelope) { @@ -60,7 +63,8 @@ public class SoapEnvelopeMessageCreator extends AbstractMessageCreator { DOMResult result = new DOMResult(); transformerHelper.transform(soapEnvelope, result); soapMessage.setDocument((Document) result.getNode()); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { fail("Could not transform request SOAP envelope to message: " + ex.getMessage()); } } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/WebServiceMessageCreator.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/WebServiceMessageCreator.java index 55b85984..d286eac8 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/WebServiceMessageCreator.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/WebServiceMessageCreator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,7 +31,6 @@ public interface WebServiceMessageCreator { /** * Create a message. - * * @param messageFactory the message that can be used to create the message * @throws IOException in case of I/O errors */ diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/package-info.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/package-info.java index 87b0cd4b..ebc12066 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/package-info.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/creator/package-info.java @@ -15,7 +15,8 @@ */ /** - * Provides the generic {@link org.springframework.ws.test.support.creator.WebServiceMessageCreator + * Provides the generic + * {@link org.springframework.ws.test.support.creator.WebServiceMessageCreator * WebServiceMessageCreator} interface, and implementations. */ package org.springframework.ws.test.support.creator; diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/AbstractSoapMessageMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/AbstractSoapMessageMatcher.java index 370db3a5..412313f2 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/AbstractSoapMessageMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/AbstractSoapMessageMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,18 @@ package org.springframework.ws.test.support.matcher; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapMessage; +import static org.springframework.ws.test.support.AssertionErrors.assertTrue; + /** * Abstract base class for SOAP-specific {@link WebServiceMessageMatcher} implementations. *

- * Asserts that the message given to {@link #match(WebServiceMessage)} is a {@link SoapMessage}, and invokes - * {@link #match(SoapMessage)} with it if so. + * Asserts that the message given to {@link #match(WebServiceMessage)} is a + * {@link SoapMessage}, and invokes {@link #match(SoapMessage)} with it if so. * * @author Arjen Poutsma * @since 2.0 @@ -41,12 +41,12 @@ public abstract class AbstractSoapMessageMatcher implements WebServiceMessageMat } /** - * Abstract template method that gets invoked from {@link #match(WebServiceMessage)} if the given message is a - * {@link SoapMessage}. - * + * Abstract template method that gets invoked from {@link #match(WebServiceMessage)} + * if the given message is a {@link SoapMessage}. * @param soapMessage the soap message * @throws IOException in case of I/O errors * @throws AssertionError if expectations are not met */ protected abstract void match(SoapMessage soapMessage) throws IOException, AssertionError; + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/DiffMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/DiffMatcher.java index 128dd72e..9d9fe6ea 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/DiffMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/DiffMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,19 @@ package org.springframework.ws.test.support.matcher; -import static org.springframework.ws.test.support.AssertionErrors.assertTrue; - import org.custommonkey.xmlunit.Diff; + import org.springframework.ws.WebServiceMessage; +import static org.springframework.ws.test.support.AssertionErrors.assertTrue; + /** * Implementation of {@link WebServiceMessageMatcher} based on XMLUnit's {@link Diff}. * * @author Arjen Poutsma * @since 2.0 - * @deprecated Migrate to {@link org.springframework.ws.test.support.matcher.xmlunit2.DiffMatcher}. + * @deprecated Migrate to + * {@link org.springframework.ws.test.support.matcher.xmlunit2.DiffMatcher}. */ public abstract class DiffMatcher implements WebServiceMessageMatcher { @@ -39,7 +41,6 @@ public abstract class DiffMatcher implements WebServiceMessageMatcher { /** * Creates a {@link Diff} for the given message. - * * @param message the message * @return the diff * @throws Exception in case of errors diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/PayloadDiffMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/PayloadDiffMatcher.java index d3ab35ff..8172e519 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/PayloadDiffMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/PayloadDiffMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,18 @@ package org.springframework.ws.test.support.matcher; -import static org.springframework.ws.test.support.AssertionErrors.fail; - import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; import org.custommonkey.xmlunit.Diff; +import org.w3c.dom.Document; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.xml.transform.TransformerHelper; -import org.w3c.dom.Document; + +import static org.springframework.ws.test.support.AssertionErrors.fail; /** * Matches {@link Source} payloads. @@ -34,7 +35,8 @@ import org.w3c.dom.Document; * @author Arjen Poutsma * @author Lukas Krecan * @since 2.0 - * @deprecated Migrate to {@link org.springframework.ws.test.support.matcher.xmlunit2.PayloadDiffMatcher}.s + * @deprecated Migrate to + * {@link org.springframework.ws.test.support.matcher.xmlunit2.PayloadDiffMatcher}.s */ public class PayloadDiffMatcher extends DiffMatcher { @@ -67,9 +69,11 @@ public class PayloadDiffMatcher extends DiffMatcher { DOMResult result = new DOMResult(); transformerHelper.transform(source, result); return (Document) result.getNode(); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { fail("Could not transform source to DOMResult" + ex.getMessage()); return null; } } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SchemaValidatingMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SchemaValidatingMatcher.java index 9bcee3de..e118c91a 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SchemaValidatingMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SchemaValidatingMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,19 @@ package org.springframework.ws.test.support.matcher; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import java.util.Arrays; +import org.xml.sax.SAXParseException; + import org.springframework.core.io.Resource; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.ws.WebServiceMessage; import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.validation.XmlValidatorFactory; -import org.xml.sax.SAXParseException; + +import static org.springframework.ws.test.support.AssertionErrors.fail; /** * Uses the {@link XmlValidator} to validate request payload. @@ -42,7 +43,6 @@ public class SchemaValidatingMatcher implements WebServiceMessageMatcher { /** * Creates a {@code SchemaValidatingMatcher} based on the given schema resource(s). - * * @param schema the schema * @param furtherSchemas further schemas, if necessary * @throws IOException in case of I/O errors @@ -63,4 +63,5 @@ public class SchemaValidatingMatcher implements WebServiceMessageMatcher { fail("XML is not valid: " + Arrays.toString(exceptions), "Payload", message.getPayloadSource()); } } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SoapEnvelopeDiffMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SoapEnvelopeDiffMatcher.java index 06725310..389e06e8 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SoapEnvelopeDiffMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SoapEnvelopeDiffMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.ws.test.support.matcher; -import static org.springframework.ws.test.support.AssertionErrors.assertTrue; -import static org.springframework.ws.test.support.AssertionErrors.fail; - import java.io.IOException; import javax.xml.transform.Source; @@ -27,17 +24,22 @@ import javax.xml.transform.dom.DOMResult; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; +import org.w3c.dom.Document; + import org.springframework.util.Assert; import org.springframework.ws.soap.SoapMessage; import org.springframework.xml.transform.TransformerHelper; -import org.w3c.dom.Document; + +import static org.springframework.ws.test.support.AssertionErrors.assertTrue; +import static org.springframework.ws.test.support.AssertionErrors.fail; /** * Matches {@link Source} SOAP envelopes. * * @author Alexander Shutyaev * @since 2.1.1 - * @deprecated Migrate to {@link org.springframework.ws.test.support.matcher.xmlunit2.SoapEnvelopeDiffMatcher}. + * @deprecated Migrate to + * {@link org.springframework.ws.test.support.matcher.xmlunit2.SoapEnvelopeDiffMatcher}. */ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher { @@ -70,7 +72,8 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher { DOMResult result = new DOMResult(); transformerHelper.transform(source, result); return (Document) result.getNode(); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { fail("Could not transform source to DOMResult" + ex.getMessage()); return null; } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SoapHeaderMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SoapHeaderMatcher.java index fcf2a445..1b475413 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SoapHeaderMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/SoapHeaderMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.test.support.matcher; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import java.util.Iterator; @@ -28,6 +26,8 @@ import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapMessage; +import static org.springframework.ws.test.support.AssertionErrors.assertTrue; + /** * Matches SOAP headers. * @@ -39,8 +39,8 @@ public class SoapHeaderMatcher extends AbstractSoapMessageMatcher { private final QName soapHeaderName; /** - * Creates a new instance of the {@code SoapHeaderMatcher} that checks for the presence of the given SOAP header name. - * + * Creates a new instance of the {@code SoapHeaderMatcher} that checks for the + * presence of the given SOAP header name. * @param soapHeaderName the header name to check for */ public SoapHeaderMatcher(QName soapHeaderName) { @@ -66,4 +66,5 @@ public class SoapHeaderMatcher extends AbstractSoapMessageMatcher { assertTrue("SOAP header [" + soapHeaderName + "] not found", found, "Envelope", soapMessage.getEnvelope().getSource()); } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/WebServiceMessageMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/WebServiceMessageMatcher.java index 8bdc575e..8ecca0f7 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/WebServiceMessageMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/WebServiceMessageMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,11 +29,12 @@ import org.springframework.ws.WebServiceMessage; public interface WebServiceMessageMatcher { /** - * Matches the given message against the expectations. Implementations typically make use of JUnit-based assertions. - * + * Matches the given message against the expectations. Implementations typically make + * use of JUnit-based assertions. * @param message the message * @throws IOException in case of I/O errors * @throws AssertionError if expectations are not met */ void match(WebServiceMessage message) throws IOException, AssertionError; + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/XPathExpectationsHelper.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/XPathExpectationsHelper.java index 18ccdc17..394cfcb6 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/XPathExpectationsHelper.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/XPathExpectationsHelper.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,20 +16,22 @@ package org.springframework.ws.test.support.matcher; -import static org.springframework.ws.test.support.AssertionErrors.*; - import java.io.IOException; import java.util.Map; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; +import org.w3c.dom.Node; + import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.xml.transform.TransformerHelper; import org.springframework.xml.xpath.XPathExpression; import org.springframework.xml.xpath.XPathExpressionFactory; -import org.w3c.dom.Node; + +import static org.springframework.ws.test.support.AssertionErrors.assertEquals; +import static org.springframework.ws.test.support.AssertionErrors.fail; /** * Helper class for dealing with XPath expectations. @@ -47,8 +49,8 @@ public class XPathExpectationsHelper { private final TransformerHelper transformerHelper = new TransformerHelper(); /** - * Creates a new instance of the {@code XPathExpectationsSupport} with the given XPath expression. - * + * Creates a new instance of the {@code XPathExpectationsSupport} with the given XPath + * expression. * @param expression the XPath expression */ public XPathExpectationsHelper(String expression) { @@ -56,8 +58,8 @@ public class XPathExpectationsHelper { } /** - * Creates a new instance of the {@code XPathExpectationsSupport} with the given XPath expression and namespaces. - * + * Creates a new instance of the {@code XPathExpectationsSupport} with the given XPath + * expression and namespaces. * @param expression the XPath expression * @param namespaces the namespaces, can be empty or {@code null} */ @@ -96,8 +98,8 @@ public class XPathExpectationsHelper { public void match(WebServiceMessage message) throws IOException, AssertionError { Node payload = transformToNode(message); boolean result = expression.evaluateAsBoolean(payload); - assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, result, - "Payload", message.getPayloadSource()); + assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, + result, "Payload", message.getPayloadSource()); } }; @@ -112,8 +114,8 @@ public class XPathExpectationsHelper { public void match(WebServiceMessage message) throws IOException, AssertionError { Node payload = transformToNode(message); double result = expression.evaluateAsNumber(payload); - assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, result, - "Payload", message.getPayloadSource()); + assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, + result, "Payload", message.getPayloadSource()); } }; @@ -125,8 +127,8 @@ public class XPathExpectationsHelper { public void match(WebServiceMessage message) throws IOException, AssertionError { Node payload = transformToNode(message); String result = expression.evaluateAsString(payload); - assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, result, - "Payload", message.getPayloadSource()); + assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, + result, "Payload", message.getPayloadSource()); } }; } @@ -136,7 +138,8 @@ public class XPathExpectationsHelper { try { transformerHelper.transform(request.getPayloadSource(), domResult); return domResult.getNode(); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { fail("Could not transform request payload: " + ex.getMessage()); return null; } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/package-info.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/package-info.java index 12ad101e..29deada1 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/package-info.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/package-info.java @@ -15,7 +15,8 @@ */ /** - * Provides the generic {@link org.springframework.ws.test.support.matcher.WebServiceMessageMatcher + * Provides the generic + * {@link org.springframework.ws.test.support.matcher.WebServiceMessageMatcher * WebServiceMessageMatcher} interface, and implementations. */ package org.springframework.ws.test.support.matcher; diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/DiffMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/DiffMatcher.java index db39f897..7632da39 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/DiffMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/DiffMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,11 +16,12 @@ package org.springframework.ws.test.support.matcher.xmlunit2; -import static org.springframework.ws.test.support.AssertionErrors.assertTrue; +import org.xmlunit.diff.Diff; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher; -import org.xmlunit.diff.Diff; + +import static org.springframework.ws.test.support.AssertionErrors.assertTrue; /** * Implementation of {@link WebServiceMessageMatcher} based on XMLUnit's {@link Diff}. @@ -40,7 +41,6 @@ public abstract class DiffMatcher implements WebServiceMessageMatcher { /** * Creates a {@link Diff} for the given message. - * * @param message the message * @return the diff * @throws Exception in case of errors diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcher.java index 7e4cf68d..0f8cb8cc 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,21 +16,22 @@ package org.springframework.ws.test.support.matcher.xmlunit2; -import static org.springframework.ws.test.support.AssertionErrors.*; - import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; -import org.springframework.util.Assert; -import org.springframework.ws.WebServiceMessage; -import org.springframework.xml.transform.TransformerHelper; import org.w3c.dom.Document; import org.xmlunit.builder.DiffBuilder; import org.xmlunit.diff.Diff; import org.xmlunit.diff.DifferenceEvaluators; import org.xmlunit.placeholder.PlaceholderDifferenceEvaluator; +import org.springframework.util.Assert; +import org.springframework.ws.WebServiceMessage; +import org.springframework.xml.transform.TransformerHelper; + +import static org.springframework.ws.test.support.AssertionErrors.fail; + /** * Matches {@link Source} payloads. * @@ -68,12 +69,12 @@ public class PayloadDiffMatcher extends DiffMatcher { Document actualDocument = createDocumentFromSource(payload); return DiffBuilder.compare(expectedDocument) // - .withTest(actualDocument) // - .ignoreWhitespace() // - .withDifferenceEvaluator( - DifferenceEvaluators.chain(new PlaceholderDifferenceEvaluator(), DifferenceEvaluators.Default)) - .checkForSimilar() // - .build(); + .withTest(actualDocument) // + .ignoreWhitespace() // + .withDifferenceEvaluator( + DifferenceEvaluators.chain(new PlaceholderDifferenceEvaluator(), DifferenceEvaluators.Default)) + .checkForSimilar() // + .build(); } private Document createDocumentFromSource(Source source) { @@ -83,10 +84,12 @@ public class PayloadDiffMatcher extends DiffMatcher { DOMResult result = new DOMResult(); transformerHelper.transform(source, result); return (Document) result.getNode(); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { fail("Could not transform source to DOMResult" + ex.getMessage()); return null; } } + } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/SoapEnvelopeDiffMatcher.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/SoapEnvelopeDiffMatcher.java index ed613773..a72c16dd 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/SoapEnvelopeDiffMatcher.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/SoapEnvelopeDiffMatcher.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,25 +16,26 @@ package org.springframework.ws.test.support.matcher.xmlunit2; -import static org.springframework.ws.test.support.AssertionErrors.assertTrue; -import static org.springframework.ws.test.support.AssertionErrors.fail; - import java.io.IOException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; -import org.springframework.util.Assert; -import org.springframework.ws.soap.SoapMessage; -import org.springframework.ws.test.support.matcher.AbstractSoapMessageMatcher; -import org.springframework.xml.transform.TransformerHelper; import org.w3c.dom.Document; import org.xmlunit.builder.DiffBuilder; import org.xmlunit.diff.Diff; import org.xmlunit.diff.DifferenceEvaluators; import org.xmlunit.placeholder.PlaceholderDifferenceEvaluator; +import org.springframework.util.Assert; +import org.springframework.ws.soap.SoapMessage; +import org.springframework.ws.test.support.matcher.AbstractSoapMessageMatcher; +import org.springframework.xml.transform.TransformerHelper; + +import static org.springframework.ws.test.support.AssertionErrors.assertTrue; +import static org.springframework.ws.test.support.AssertionErrors.fail; + /** * Matches {@link Source} SOAP envelopes. * @@ -59,12 +60,12 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher { Document actualDocument = soapMessage.getDocument(); Document expectedDocument = createDocumentFromSource(expected); Diff diff = DiffBuilder.compare(expectedDocument) - .ignoreWhitespace() - .withTest(actualDocument) - .withDifferenceEvaluator( - DifferenceEvaluators.chain(new PlaceholderDifferenceEvaluator(), DifferenceEvaluators.Default)) - .checkForSimilar() - .build(); + .ignoreWhitespace() + .withTest(actualDocument) + .withDifferenceEvaluator( + DifferenceEvaluators.chain(new PlaceholderDifferenceEvaluator(), DifferenceEvaluators.Default)) + .checkForSimilar() + .build(); assertTrue("Envelopes are different, " + diff.toString(), !diff.hasDifferences()); } @@ -74,7 +75,8 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher { DOMResult result = new DOMResult(); transformerHelper.transform(source, result); return (Document) result.getNode(); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { fail("Could not transform source to DOMResult" + ex.getMessage()); return null; } diff --git a/spring-ws-test/src/main/java/org/springframework/ws/test/support/package-info.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/package-info.java index b57c648f..45e988ba 100644 --- a/spring-ws-test/src/main/java/org/springframework/ws/test/support/package-info.java +++ b/spring-ws-test/src/main/java/org/springframework/ws/test/support/package-info.java @@ -15,7 +15,8 @@ */ /** - * Support classes for the testing framework, used by the classes in the {@link org.springframework.ws.test.client} and + * Support classes for the testing framework, used by the classes in the + * {@link org.springframework.ws.test.client} and * {@link org.springframework.ws.test.server} packages. */ package org.springframework.ws.test.support; diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/ErrorResponseCreatorTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/ErrorResponseCreatorTest.java index cdf91ed5..f4e33436 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/ErrorResponseCreatorTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/ErrorResponseCreatorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,12 @@ package org.springframework.ws.test.client; -import static org.assertj.core.api.Assertions.*; - import java.io.IOException; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class ErrorResponseCreatorTest { @Test @@ -33,4 +33,5 @@ public class ErrorResponseCreatorTest { assertThat(callback.getErrorMessage()).isEqualTo(errorMessage); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/ExceptionResponseCreatorTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/ExceptionResponseCreatorTest.java index bf36a3d1..68dc8746 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/ExceptionResponseCreatorTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/ExceptionResponseCreatorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,13 @@ package org.springframework.ws.test.client; -import static org.assertj.core.api.Assertions.*; - import java.io.IOException; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIOException; + public class ExceptionResponseCreatorTest { @Test @@ -43,4 +44,5 @@ public class ExceptionResponseCreatorTest { callback.createResponse(null, null, null); }); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockSenderConnectionTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockSenderConnectionTest.java index f4401cbc..2c2e52cc 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockSenderConnectionTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockSenderConnectionTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,17 @@ package org.springframework.ws.test.client; -import static org.assertj.core.api.Assertions.*; -import static org.springframework.ws.test.client.ResponseCreators.*; - import java.io.IOException; import org.junit.jupiter.api.Test; + import org.springframework.xml.transform.StringSource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.springframework.ws.test.client.ResponseCreators.withError; +import static org.springframework.ws.test.client.ResponseCreators.withPayload; + public class MockSenderConnectionTest { @Test @@ -57,4 +60,5 @@ public class MockSenderConnectionTest { connection.send(null); }); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockWebServiceMessageSenderTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockWebServiceMessageSenderTest.java index 35927d45..3816db5e 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockWebServiceMessageSenderTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockWebServiceMessageSenderTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,13 @@ package org.springframework.ws.test.client; -import static org.assertj.core.api.Assertions.*; - import java.net.URI; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public class MockWebServiceMessageSenderTest { private MockWebServiceMessageSender sender; @@ -36,7 +36,7 @@ public class MockWebServiceMessageSenderTest { public void noMoreExpectedConnections() { assertThatExceptionOfType(AssertionError.class) - .isThrownBy(() -> sender.createConnection(URI.create("http://localhost"))); + .isThrownBy(() -> sender.createConnection(URI.create("http://localhost"))); } @Test @@ -60,4 +60,5 @@ public class MockWebServiceMessageSenderTest { sender.verifyConnections(); }); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockWebServiceServerTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockWebServiceServerTest.java index 0028f3c5..55f5895d 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockWebServiceServerTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/MockWebServiceServerTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,6 +16,33 @@ package org.springframework.ws.test.client; +import java.net.URI; +import java.util.Collections; +import java.util.Locale; +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.transform.Source; + +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.soap.MessageFactory; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + +import org.springframework.context.support.StaticApplicationContext; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.core.io.Resource; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; +import org.springframework.ws.client.core.WebServiceTemplate; +import org.springframework.ws.client.core.support.WebServiceGatewaySupport; +import org.springframework.ws.soap.SoapMessage; +import org.springframework.ws.soap.client.SoapFaultClientException; +import org.springframework.ws.soap.saaj.SaajSoapMessage; +import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; +import org.springframework.xml.transform.StringResult; +import org.springframework.xml.transform.StringSource; + import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -37,33 +64,6 @@ import static org.springframework.ws.test.client.ResponseCreators.withClientOrSe import static org.springframework.ws.test.client.ResponseCreators.withPayload; import static org.springframework.ws.test.client.ResponseCreators.withSoapEnvelope; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.soap.MessageFactory; - -import java.net.URI; -import java.util.Collections; -import java.util.Locale; -import java.util.Map; - -import javax.xml.namespace.QName; -import javax.xml.transform.Source; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.context.support.StaticApplicationContext; -import org.springframework.core.io.ByteArrayResource; -import org.springframework.core.io.Resource; -import org.springframework.oxm.jaxb.Jaxb2Marshaller; -import org.springframework.ws.client.core.WebServiceTemplate; -import org.springframework.ws.client.core.support.WebServiceGatewaySupport; -import org.springframework.ws.soap.SoapMessage; -import org.springframework.ws.soap.client.SoapFaultClientException; -import org.springframework.ws.soap.saaj.SaajSoapMessage; -import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; -import org.springframework.xml.transform.StringResult; -import org.springframework.xml.transform.StringSource; -import org.xmlunit.assertj.XmlAssert; - public class MockWebServiceServerTest { private WebServiceTemplate template; @@ -149,7 +149,7 @@ public class MockWebServiceServerTest { requestMatcher1.match(eq(uri), isA(SaajSoapMessage.class)); requestMatcher2.match(eq(uri), isA(SaajSoapMessage.class)); expect(responseCreator.createResponse(eq(uri), isA(SaajSoapMessage.class), isA(SaajSoapMessageFactory.class))) - .andReturn(response); + .andReturn(response); replay(requestMatcher1, requestMatcher2, responseCreator); @@ -261,7 +261,7 @@ public class MockWebServiceServerTest { Resource schema = new ByteArrayResource( "" - .getBytes()); + .getBytes()); server.expect(validPayload(schema)); @@ -277,7 +277,7 @@ public class MockWebServiceServerTest { Resource schema = new ByteArrayResource( "" - .getBytes()); + .getBytes()); server.expect(validPayload(schema)); @@ -430,6 +430,7 @@ public class MockWebServiceServerTest { public void setMyData(String myData) { this.myData = myData; } + } @XmlRootElement(name = "EnvelopeMatcherResponse") @@ -444,5 +445,7 @@ public class MockWebServiceServerTest { public void setMyData(String myData) { this.myData = myData; } + } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/ResponseCreatorsTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/ResponseCreatorsTest.java index 0767841a..1a3e9e78 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/ResponseCreatorsTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/ResponseCreatorsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.ws.test.client; -import static org.assertj.core.api.Assertions.*; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Locale; @@ -29,6 +27,8 @@ import javax.xml.transform.dom.DOMSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.io.ByteArrayResource; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapMessage; @@ -38,7 +38,8 @@ import org.springframework.ws.soap.soap11.Soap11Fault; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerHelper; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public class ResponseCreatorsTest { @@ -68,7 +69,8 @@ public class ResponseCreatorsTest { public void withPayloadResource() throws Exception { String payload = ""; - ResponseCreator responseCreator = ResponseCreators.withPayload(new ByteArrayResource(payload.getBytes(StandardCharsets.UTF_8))); + ResponseCreator responseCreator = ResponseCreators + .withPayload(new ByteArrayResource(payload.getBytes(StandardCharsets.UTF_8))); WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory); @@ -88,7 +90,10 @@ public class ResponseCreatorsTest { ResponseCreator responseCreator = ResponseCreators.withSoapEnvelope(new StringSource(envelope)); WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory); - XmlAssert.assertThat(getSoapEnvelopeAsString((SoapMessage) response)).and(envelope).ignoreWhitespace().areSimilar(); + XmlAssert.assertThat(getSoapEnvelopeAsString((SoapMessage) response)) + .and(envelope) + .ignoreWhitespace() + .areSimilar(); } @Test @@ -102,10 +107,13 @@ public class ResponseCreatorsTest { xmlBuilder.append(""); String envelope = xmlBuilder.toString(); ResponseCreator responseCreator = ResponseCreators - .withSoapEnvelope(new ByteArrayResource(envelope.getBytes(StandardCharsets.UTF_8))); + .withSoapEnvelope(new ByteArrayResource(envelope.getBytes(StandardCharsets.UTF_8))); WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory); - XmlAssert.assertThat(getSoapEnvelopeAsString((SoapMessage) response)).and(envelope).ignoreWhitespace().areSimilar(); + XmlAssert.assertThat(getSoapEnvelopeAsString((SoapMessage) response)) + .and(envelope) + .ignoreWhitespace() + .areSimilar(); } @Test @@ -116,7 +124,8 @@ public class ResponseCreatorsTest { try { responseCreator.createResponse(null, null, null); - } catch (IOException actual) { + } + catch (IOException actual) { assertThat(actual).isSameAs(expected); } } @@ -129,7 +138,8 @@ public class ResponseCreatorsTest { try { responseCreator.createResponse(null, null, null); - } catch (RuntimeException actual) { + } + catch (RuntimeException actual) { assertThat(actual).isSameAs(expected); } } @@ -197,4 +207,5 @@ public class ResponseCreatorsTest { transformerHelper.transform(source, result); return result.toString(); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/UriMatcherTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/UriMatcherTest.java index 0f614bee..0f317eaf 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/UriMatcherTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/UriMatcherTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,17 @@ package org.springframework.ws.test.client; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.net.URI; import org.junit.jupiter.api.Test; + import org.springframework.ws.WebServiceMessage; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; + public class UriMatcherTest { private static final URI GOOD_URI = URI.create("http://localhost"); @@ -53,4 +56,5 @@ public class UriMatcherTest { matcher.match(URI.create("http://www.example.org"), message); }); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapterTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapterTest.java index a54b61dd..a5c8d6a8 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapterTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,18 @@ package org.springframework.ws.test.client; -import static org.easymock.EasyMock.*; - import java.io.IOException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + /** * @author Arjen Poutsma */ @@ -55,4 +58,5 @@ public class WebServiceMessageMatcherAdapterTest { verify(message, adaptee); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/integration/ClientIntegrationTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/integration/ClientIntegrationTest.java index b99196d4..e3644d58 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/integration/ClientIntegrationTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/integration/ClientIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,24 +16,25 @@ package org.springframework.ws.test.client.integration; -import static org.assertj.core.api.Assertions.*; -import static org.springframework.ws.test.client.RequestMatchers.*; -import static org.springframework.ws.test.client.ResponseCreators.*; - import javax.xml.transform.Source; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.ws.test.client.MockWebServiceServer; import org.springframework.xml.transform.StringSource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.ws.test.client.RequestMatchers.payload; +import static org.springframework.ws.test.client.ResponseCreators.withPayload; + /** - * Integration test for client-side WebService testing. In different package so we can't use the package-protected - * classes. + * Integration test for client-side WebService testing. In different package so we can't + * use the package-protected classes. * * @author Arjen Poutsma */ @@ -41,7 +42,8 @@ import org.springframework.xml.transform.StringSource; @ContextConfiguration("integration-test.xml") public class ClientIntegrationTest { - @Autowired private CustomerClient client; + @Autowired + private CustomerClient client; private MockWebServiceServer mockServer; @@ -54,8 +56,8 @@ public class ClientIntegrationTest { public void basic() { Source expectedRequestPayload = new StringSource( - "" + "John Doe" - + ""); + "" + + "John Doe" + ""); Source responsePayload = new StringSource("" + "10" + ""); @@ -67,4 +69,5 @@ public class ClientIntegrationTest { mockServer.verify(); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/integration/CustomerCountRequest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/integration/CustomerCountRequest.java index 572e0cce..de3d0d01 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/integration/CustomerCountRequest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/integration/CustomerCountRequest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,4 +32,5 @@ public class CustomerCountRequest { public void setCustomerName(String name) { this.customerName = name; } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/integration/CustomerCountResponse.java b/spring-ws-test/src/test/java/org/springframework/ws/test/integration/CustomerCountResponse.java index d52effd0..9c313fa6 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/integration/CustomerCountResponse.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/integration/CustomerCountResponse.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,4 +32,5 @@ public class CustomerCountResponse { public void setCustomerCount(int customerCount) { this.customerCount = customerCount; } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/server/MockWebServiceClientTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/server/MockWebServiceClientTest.java index fa11a238..0313dc06 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/server/MockWebServiceClientTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/server/MockWebServiceClientTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,14 @@ package org.springframework.ws.test.server; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.Test; + import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.server.SoapMessageDispatcher; +import static org.assertj.core.api.Assertions.assertThat; + public class MockWebServiceClientTest { @Test @@ -48,4 +49,5 @@ public class MockWebServiceClientTest { assertThat(client).isNotNull(); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapterTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapterTest.java index e007f4e8..be0b53a1 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapterTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapterTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,18 @@ package org.springframework.ws.test.server; -import static org.easymock.EasyMock.*; - import java.io.IOException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + /** * @author Arjen Poutsma */ @@ -55,4 +58,5 @@ public class WebServiceMessageMatcherAdapterTest { verify(message, adaptee); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/server/integration/CustomerEndpoint.java b/spring-ws-test/src/test/java/org/springframework/ws/test/server/integration/CustomerEndpoint.java index 4b65499f..1cc7f33f 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/server/integration/CustomerEndpoint.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/server/integration/CustomerEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,4 +32,5 @@ public class CustomerEndpoint { response.setCustomerCount(42); return response; } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/server/integration/ServerIntegrationTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/server/integration/ServerIntegrationTest.java index 56127b68..faba6341 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/server/integration/ServerIntegrationTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/server/integration/ServerIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,14 +16,12 @@ package org.springframework.ws.test.server.integration; -import static org.springframework.ws.test.server.RequestCreators.*; -import static org.springframework.ws.test.server.ResponseMatchers.*; - import javax.xml.transform.Source; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -31,6 +29,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.ws.test.server.MockWebServiceClient; import org.springframework.xml.transform.StringSource; +import static org.springframework.ws.test.server.RequestCreators.withPayload; +import static org.springframework.ws.test.server.ResponseMatchers.payload; + /** * @author Arjen Poutsma */ @@ -38,7 +39,8 @@ import org.springframework.xml.transform.StringSource; @ContextConfiguration("integration-test.xml") public class ServerIntegrationTest { - @Autowired private ApplicationContext applicationContext; + @Autowired + private ApplicationContext applicationContext; private MockWebServiceClient mockClient; @@ -53,9 +55,10 @@ public class ServerIntegrationTest { Source requestPayload = new StringSource("" + "John Doe" + ""); Source expectedResponsePayload = new StringSource( - "" + "42" - + ""); + "" + + "42" + ""); mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(expectedResponsePayload)); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SchemaValidatingMatcherTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SchemaValidatingMatcherTest.java index 20e8260c..fcb6c923 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SchemaValidatingMatcherTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SchemaValidatingMatcherTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,18 +16,22 @@ package org.springframework.ws.test.support.matcher; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.io.IOException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.ws.WebServiceMessage; import org.springframework.xml.transform.StringSource; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class SchemaValidatingMatcherTest { private Resource schema; @@ -50,8 +54,8 @@ public class SchemaValidatingMatcherTest { @Test public void singleSchemaMatch() throws IOException, AssertionError { - expect(message.getPayloadSource()).andReturn( - new StringSource("0text")); + expect(message.getPayloadSource()).andReturn(new StringSource( + "0text")); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema); @@ -67,9 +71,10 @@ public class SchemaValidatingMatcherTest { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> { - expect(message.getPayloadSource()).andReturn( - new StringSource("atext")) - .times(2); + expect(message.getPayloadSource()) + .andReturn(new StringSource( + "atext")) + .times(2); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema); @@ -84,8 +89,8 @@ public class SchemaValidatingMatcherTest { @Test public void multipleSchemaMatch() throws IOException, AssertionError { - expect(message.getPayloadSource()).andReturn( - new StringSource("0text")); + expect(message.getPayloadSource()).andReturn(new StringSource( + "0text")); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema1, schema2); @@ -101,9 +106,10 @@ public class SchemaValidatingMatcherTest { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> { - expect(message.getPayloadSource()).andReturn( - new StringSource("atext")) - .times(2); + expect(message.getPayloadSource()) + .andReturn(new StringSource( + "atext")) + .times(2); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema1, schema2); @@ -120,9 +126,10 @@ public class SchemaValidatingMatcherTest { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> { - expect(message.getPayloadSource()).andReturn( - new StringSource("atext")) - .times(2); + expect(message.getPayloadSource()) + .andReturn(new StringSource( + "atext")) + .times(2); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema1, schema2); @@ -139,9 +146,10 @@ public class SchemaValidatingMatcherTest { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> { - expect(message.getPayloadSource()).andReturn( - new StringSource("atext")) - .times(2); + expect(message.getPayloadSource()) + .andReturn(new StringSource( + "atext")) + .times(2); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema); @@ -152,4 +160,5 @@ public class SchemaValidatingMatcherTest { verify(message); }); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SoapEnvelopeDiffMatcherTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SoapEnvelopeDiffMatcherTest.java index 890306f1..a7fbd724 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SoapEnvelopeDiffMatcherTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SoapEnvelopeDiffMatcherTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,20 @@ package org.springframework.ws.test.support.matcher; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import javax.xml.transform.dom.DOMResult; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.ws.soap.SoapMessage; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerHelper; -import org.w3c.dom.Document; + +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; public class SoapEnvelopeDiffMatcherTest { @@ -77,4 +81,5 @@ public class SoapEnvelopeDiffMatcherTest { matcher.match(message); }); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/XPathExpectationsHelperTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/XPathExpectationsHelperTest.java index 9756c5a3..a5bea887 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/XPathExpectationsHelperTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/XPathExpectationsHelperTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,17 +16,22 @@ package org.springframework.ws.test.support.matcher; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.io.IOException; import java.util.Collections; import java.util.Map; import org.junit.jupiter.api.Test; + import org.springframework.ws.WebServiceMessage; import org.springframework.xml.transform.StringSource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class XPathExpectationsHelperTest { @Test @@ -224,7 +229,8 @@ public class XPathExpectationsHelperTest { assertThat(matcher).isNotNull(); WebServiceMessage message = createMock(WebServiceMessage.class); - expect(message.getPayloadSource()).andReturn(new StringSource("")); + expect(message.getPayloadSource()) + .andReturn(new StringSource("")); replay(message); @@ -245,12 +251,14 @@ public class XPathExpectationsHelperTest { assertThat(matcher).isNotNull(); WebServiceMessage message = createMock(WebServiceMessage.class); - expect(message.getPayloadSource()).andReturn(new StringSource("")) - .times(2); + expect(message.getPayloadSource()) + .andReturn(new StringSource("")) + .times(2); replay(message); matcher.match(message); }); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcherTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcherTest.java index c922b2f6..7c9ddc4d 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcherTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcherTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,19 @@ package org.springframework.ws.test.support.matcher.xmlunit2; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import jakarta.xml.soap.MessageFactory; - import org.junit.jupiter.api.Test; + import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.xml.transform.StringSource; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class PayloadDiffMatcherTest { @Test @@ -103,4 +106,5 @@ public class PayloadDiffMatcherTest { matcher.createDiff(soapMessage); }); } + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/SoapEnvelopeDiffMatcherTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/SoapEnvelopeDiffMatcherTest.java index d473882d..b4303b30 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/SoapEnvelopeDiffMatcherTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/SoapEnvelopeDiffMatcherTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,22 +16,23 @@ package org.springframework.ws.test.support.matcher.xmlunit2; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; +import java.io.IOException; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + import org.springframework.ws.soap.SoapMessage; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerHelper; -import org.w3c.dom.Document; -import java.io.IOException; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; public class SoapEnvelopeDiffMatcherTest { @@ -82,12 +83,12 @@ public class SoapEnvelopeDiffMatcherTest { @Test public void matchWithXmlIgnore() throws TransformerException, IOException { - String xml = """ - - -

- %s - """; + String xml = """ + + +
+ %s + """; String actual = String.format(xml, "1"); DOMResult result = new DOMResult(); @@ -101,4 +102,5 @@ public class SoapEnvelopeDiffMatcherTest { SoapEnvelopeDiffMatcher matcher = new SoapEnvelopeDiffMatcher(new StringSource(expected)); matcher.match(message); } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/DocumentBuilderFactoryUtils.java b/spring-xml/src/main/java/org/springframework/xml/DocumentBuilderFactoryUtils.java index 295d34a0..7fc8da1c 100644 --- a/spring-xml/src/main/java/org/springframework/xml/DocumentBuilderFactoryUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/DocumentBuilderFactoryUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,8 +31,8 @@ public class DocumentBuilderFactoryUtils { private static final Log log = LogFactory.getLog(DocumentBuilderFactoryUtils.class); /** - * Build a {@link DocumentBuilderFactory} then set properties to prevent external entity access. - * + * Build a {@link DocumentBuilderFactory} then set properties to prevent external + * entity access. * @see DocumentBuilderFactory#newInstance() */ public static DocumentBuilderFactory newInstance() { @@ -40,16 +40,18 @@ public class DocumentBuilderFactoryUtils { try { factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - } catch (IllegalArgumentException e) { + } + catch (IllegalArgumentException e) { if (log.isWarnEnabled()) { - log.warn( - XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + factory.getClass().getCanonicalName()); + log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + + factory.getClass().getCanonicalName()); } } try { factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); - } catch (IllegalArgumentException e) { + } + catch (IllegalArgumentException e) { if (log.isWarnEnabled()) { log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + factory.getClass().getCanonicalName()); @@ -58,7 +60,8 @@ public class DocumentBuilderFactoryUtils { try { factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - } catch (ParserConfigurationException e) { + } + catch (ParserConfigurationException e) { if (log.isWarnEnabled()) { log.warn("FEATURE 'http://apache.org/xml/features/disallow-doctype-decl' is probably not supported by " + factory.getClass().getCanonicalName()); @@ -67,7 +70,8 @@ public class DocumentBuilderFactoryUtils { try { factory.setFeature("http://xml.org/sax/features/external-general-entities", false); - } catch (ParserConfigurationException e) { + } + catch (ParserConfigurationException e) { if (log.isWarnEnabled()) { log.warn("FEATURE 'http://xml.org/sax/features/external-general-entities' is probably not supported by " + factory.getClass().getCanonicalName()); @@ -76,16 +80,19 @@ public class DocumentBuilderFactoryUtils { try { factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - } catch (ParserConfigurationException e) { + } + catch (ParserConfigurationException e) { if (log.isWarnEnabled()) { - log.warn("FEATURE 'http://xml.org/sax/features/external-parameter-entities' is probably not supported by " - + factory.getClass().getCanonicalName()); + log.warn( + "FEATURE 'http://xml.org/sax/features/external-parameter-entities' is probably not supported by " + + factory.getClass().getCanonicalName()); } } try { factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); - } catch (ParserConfigurationException e) { + } + catch (ParserConfigurationException e) { if (log.isWarnEnabled()) { log.warn( "FEATURE 'http://apache.org/xml/features/nonvalidating/load-external-dtd' is probably not supported by " @@ -96,7 +103,8 @@ public class DocumentBuilderFactoryUtils { try { factory.setXIncludeAware(false); factory.setExpandEntityReferences(false); - } catch (Exception e) { + } + catch (Exception e) { if (log.isWarnEnabled()) { log.warn("Caught " + e.getMessage() + " attempting to configure your XML parser."); } @@ -104,4 +112,5 @@ public class DocumentBuilderFactoryUtils { return factory; } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/JaxpVersion.java b/spring-xml/src/main/java/org/springframework/xml/JaxpVersion.java index ed07fd3f..19ab7daa 100644 --- a/spring-xml/src/main/java/org/springframework/xml/JaxpVersion.java +++ b/spring-xml/src/main/java/org/springframework/xml/JaxpVersion.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,11 +19,11 @@ package org.springframework.xml; import org.springframework.util.ClassUtils; /** - * Helper class used to find the current version of JAXP. We cannot depend on the Java version, since JAXP can be - * upgraded independently of the Java version. + * Helper class used to find the current version of JAXP. We cannot depend on the Java + * version, since JAXP can be upgraded independently of the Java version. *

- * Only distinguishes between JAXP 1.0, 1.1, 1.3, 1.4, and 1.5, since JAXP 1.2 was a maintenance release with no new - * classes. + * Only distinguishes between JAXP 1.0, 1.1, 1.3, 1.4, and 1.5, since JAXP 1.2 was a + * maintenance release with no new classes. * * @author Arjen Poutsma * @author Greg Turnquist @@ -68,11 +68,13 @@ public abstract class JaxpVersion { try { ClassUtils.forName(JAXP_15_CLASS_NAME, classLoader); jaxpVersion = JAXP_15; - } catch (ClassNotFoundException ex) { + } + catch (ClassNotFoundException ex) { try { ClassUtils.forName(JAXP_14_CLASS_NAME, classLoader); jaxpVersion = JAXP_14; - } catch (ClassNotFoundException e) { + } + catch (ClassNotFoundException e) { // leave 1.3 as default (it's either 1.3 or unknown) jaxpVersion = JAXP_13; } @@ -80,8 +82,8 @@ public abstract class JaxpVersion { } /** - * Gets the JAXP version. This means we can do things like if {@code (getJaxpVersion() < JAXP_13)}. - * + * Gets the JAXP version. This means we can do things like if + * {@code (getJaxpVersion() < JAXP_13)}. * @return a code comparable to the JAXP_XX codes in this class * @see #JAXP_10 * @see #JAXP_11 @@ -94,8 +96,8 @@ public abstract class JaxpVersion { } /** - * Convenience method to determine if the current JAXP version is at least 1.4 (packaged with JDK 1.6). - * + * Convenience method to determine if the current JAXP version is at least 1.4 + * (packaged with JDK 1.6). * @return {@code true} if the current JAXP version is at least JAXP 1.4 * @see #getJaxpVersion() * @see #JAXP_14 diff --git a/spring-xml/src/main/java/org/springframework/xml/XMLInputFactoryUtils.java b/spring-xml/src/main/java/org/springframework/xml/XMLInputFactoryUtils.java index 1156d18a..5569a048 100644 --- a/spring-xml/src/main/java/org/springframework/xml/XMLInputFactoryUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/XMLInputFactoryUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,8 +23,8 @@ import javax.xml.stream.XMLInputFactory; public class XMLInputFactoryUtils { /** - * Build an {@link XMLInputFactory} and set properties to prevent external entities from accessing. - * + * Build an {@link XMLInputFactory} and set properties to prevent external entities + * from accessing. * @see XMLInputFactory#newInstance() */ public static XMLInputFactory newInstance() { diff --git a/spring-xml/src/main/java/org/springframework/xml/XmlException.java b/spring-xml/src/main/java/org/springframework/xml/XmlException.java index 95f9b6fb..690d38eb 100644 --- a/spring-xml/src/main/java/org/springframework/xml/XmlException.java +++ b/spring-xml/src/main/java/org/springframework/xml/XmlException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -28,8 +28,8 @@ import org.springframework.core.NestedRuntimeException; public abstract class XmlException extends NestedRuntimeException { /** - * Constructs a new instance of the {@code XmlException} with the specific detail message. - * + * Constructs a new instance of the {@code XmlException} with the specific detail + * message. * @param message the detail message */ protected XmlException(String message) { @@ -37,12 +37,13 @@ public abstract class XmlException extends NestedRuntimeException { } /** - * Constructs a new instance of the {@code XmlException} with the specific detail message and exception. - * + * Constructs a new instance of the {@code XmlException} with the specific detail + * message and exception. * @param message the detail message * @param throwable the wrapped exception */ protected XmlException(String message, Throwable throwable) { super(message, throwable); } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/dom/DomContentHandler.java b/spring-xml/src/main/java/org/springframework/xml/dom/DomContentHandler.java index 6251fc67..375c70f6 100644 --- a/spring-xml/src/main/java/org/springframework/xml/dom/DomContentHandler.java +++ b/spring-xml/src/main/java/org/springframework/xml/dom/DomContentHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -19,7 +19,6 @@ package org.springframework.xml.dom; import java.util.ArrayList; import java.util.List; -import org.springframework.util.Assert; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -30,6 +29,8 @@ import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; +import org.springframework.util.Assert; + /** * SAX {@code ContentHandler} that transforms callback calls to DOM {@code Node}s. * @@ -47,7 +48,6 @@ public class DomContentHandler implements ContentHandler { /** * Creates a new instance of the {@code DomContentHandler} with the given node. - * * @param node the node to publish events to */ public DomContentHandler(Node node) { @@ -55,7 +55,8 @@ public class DomContentHandler implements ContentHandler { this.node = node; if (node instanceof Document) { document = (Document) node; - } else { + } + else { document = node.getOwnerDocument(); } Assert.notNull(document, "document must not be null"); @@ -64,7 +65,8 @@ public class DomContentHandler implements ContentHandler { private Node getParent() { if (!elements.isEmpty()) { return elements.get(elements.size() - 1); - } else { + } + else { return node; } } @@ -97,7 +99,8 @@ public class DomContentHandler implements ContentHandler { Node lastChild = parent.getLastChild(); if (lastChild != null && lastChild.getNodeType() == Node.TEXT_NODE) { ((Text) lastChild).appendData(data); - } else { + } + else { Text text = document.createTextNode(data); parent.appendChild(text); } @@ -115,23 +118,31 @@ public class DomContentHandler implements ContentHandler { */ @Override - public void setDocumentLocator(Locator locator) {} + public void setDocumentLocator(Locator locator) { + } @Override - public void startDocument() throws SAXException {} + public void startDocument() throws SAXException { + } @Override - public void endDocument() throws SAXException {} + public void endDocument() throws SAXException { + } @Override - public void startPrefixMapping(String prefix, String uri) throws SAXException {} + public void startPrefixMapping(String prefix, String uri) throws SAXException { + } @Override - public void endPrefixMapping(String prefix) throws SAXException {} + public void endPrefixMapping(String prefix) throws SAXException { + } @Override - public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {} + public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { + } @Override - public void skippedEntity(String name) throws SAXException {} + public void skippedEntity(String name) throws SAXException { + } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/namespace/QNameEditor.java b/spring-xml/src/main/java/org/springframework/xml/namespace/QNameEditor.java index e367c51f..8cfca19a 100644 --- a/spring-xml/src/main/java/org/springframework/xml/namespace/QNameEditor.java +++ b/spring-xml/src/main/java/org/springframework/xml/namespace/QNameEditor.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,7 +23,8 @@ import javax.xml.namespace.QName; import org.springframework.util.StringUtils; /** - * PropertyEditor for {@code javax.xml.namespace.QName}, to populate a property of type QName from a String value. + * PropertyEditor for {@code javax.xml.namespace.QName}, to populate a property of type + * QName from a String value. *

* Expects the syntax * @@ -43,8 +44,8 @@ import org.springframework.util.StringUtils; * {namespace}prefix:localPart * * - * This resembles the {@code toString()} representation of {@code QName} itself, but allows for prefixes to be specified - * as well. + * This resembles the {@code toString()} representation of {@code QName} itself, but + * allows for prefixes to be specified as well. * * @author Arjen Poutsma * @see javax.xml.namespace.QName @@ -66,13 +67,17 @@ public class QNameEditor extends PropertyEditorSupport { String prefix = qName.getPrefix(); if (StringUtils.hasLength(qName.getNamespaceURI()) && StringUtils.hasLength(prefix)) { return "{" + qName.getNamespaceURI() + "}" + prefix + ":" + qName.getLocalPart(); - } else if (StringUtils.hasLength(qName.getNamespaceURI())) { + } + else if (StringUtils.hasLength(qName.getNamespaceURI())) { return "{" + qName.getNamespaceURI() + "}" + qName.getLocalPart(); - } else { + } + else { return qName.getLocalPart(); } - } else { + } + else { return ""; } } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/namespace/QNameUtils.java b/spring-xml/src/main/java/org/springframework/xml/namespace/QNameUtils.java index ac352d42..b7cd93ac 100644 --- a/spring-xml/src/main/java/org/springframework/xml/namespace/QNameUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/namespace/QNameUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -18,9 +18,10 @@ package org.springframework.xml.namespace; import javax.xml.namespace.QName; +import org.w3c.dom.Node; + import org.springframework.util.Assert; import org.springframework.util.StringUtils; -import org.w3c.dom.Node; /** * Helper class for using {@link QName}. @@ -32,10 +33,10 @@ import org.w3c.dom.Node; public abstract class QNameUtils { /** - * Creates a new {@code QName} with the given parameters. Sets the prefix if possible, i.e. if the - * {@code QName(String, String, String)} constructor can be found. If this constructor is not available (as is the - * case on older implementations of JAX-RPC), the prefix is ignored. - * + * Creates a new {@code QName} with the given parameters. Sets the prefix if possible, + * i.e. if the {@code QName(String, String, String)} constructor can be found. If this + * constructor is not available (as is the case on older implementations of JAX-RPC), + * the prefix is ignored. * @param namespaceUri namespace URI of the {@code QName} * @param localPart local part of the {@code QName} * @param prefix prefix of the {@code QName}. May be ignored. @@ -49,10 +50,10 @@ public abstract class QNameUtils { } /** - * Returns the prefix of the given {@code QName}. Returns the prefix if available, i.e. if the - * {@code QName.getPrefix()} method can be found. If this method is not available (as is the case on older - * implementations of JAX-RPC), an empty string is returned. - * + * Returns the prefix of the given {@code QName}. Returns the prefix if available, + * i.e. if the {@code QName.getPrefix()} method can be found. If this method is not + * available (as is the case on older implementations of JAX-RPC), an empty string is + * returned. * @param qName the {@code QName} to return the prefix from * @return the prefix, if available, or an empty string * @see javax.xml.namespace.QName#getPrefix() @@ -65,7 +66,6 @@ public abstract class QNameUtils { /** * Validates the given String as a QName - * * @param text the qualified name * @return {@code true} if valid, {@code false} otherwise */ @@ -85,27 +85,29 @@ public abstract class QNameUtils { /** * Returns the qualified name of the given DOM Node. - * * @param node the node * @return the qualified name of the node */ public static QName getQNameForNode(Node node) { if (node.getNamespaceURI() != null && node.getPrefix() != null && node.getLocalName() != null) { return new QName(node.getNamespaceURI(), node.getLocalName(), node.getPrefix()); - } else if (node.getNamespaceURI() != null && node.getLocalName() != null) { + } + else if (node.getNamespaceURI() != null && node.getLocalName() != null) { return new QName(node.getNamespaceURI(), node.getLocalName()); - } else if (node.getLocalName() != null) { + } + else if (node.getLocalName() != null) { return new QName(node.getLocalName()); - } else { + } + else { // as a last resort, use the node name return new QName(node.getNodeName()); } } /** - * Convert a {@code QName} to a qualified name, as used by DOM and SAX. The returned string has a format of - * {@code prefix:localName} if the prefix is set, or just {@code localName} if not. - * + * Convert a {@code QName} to a qualified name, as used by DOM and SAX. The returned + * string has a format of {@code prefix:localName} if the prefix is set, or just + * {@code localName} if not. * @param qName the {@code QName} * @return the qualified name */ @@ -113,15 +115,15 @@ public abstract class QNameUtils { String prefix = qName.getPrefix(); if (!StringUtils.hasLength(prefix)) { return qName.getLocalPart(); - } else { + } + else { return prefix + ":" + qName.getLocalPart(); } } /** - * Convert a namespace URI and DOM or SAX qualified name to a {@code QName}. The qualified name can have the form - * {@code prefix:localname} or {@code localName}. - * + * Convert a namespace URI and DOM or SAX qualified name to a {@code QName}. The + * qualified name can have the form {@code prefix:localname} or {@code localName}. * @param namespaceUri the namespace URI * @param qualifiedName the qualified name * @return a QName @@ -130,16 +132,18 @@ public abstract class QNameUtils { int idx = qualifiedName.indexOf(':'); if (idx == -1) { return new QName(namespaceUri, qualifiedName); - } else { + } + else { return new QName(namespaceUri, qualifiedName.substring(idx + 1), qualifiedName.substring(0, idx)); } } /** - * Parse the given qualified name string into a {@code QName}. Expects the syntax {@code localPart}, - * {@code {namespace}localPart}, or {@code {namespace}prefix:localPart}. This format resembles the {@code toString()} - * representation of {@code QName} itself, but allows for prefixes to be specified as well. - * + * Parse the given qualified name string into a {@code QName}. Expects the syntax + * {@code localPart}, {@code {namespace}localPart}, or + * {@code {namespace}prefix:localPart}. This format resembles the {@code toString()} + * representation of {@code QName} itself, but allows for prefixes to be specified as + * well. * @return a corresponding QName instance * @throws IllegalArgumentException when the given string is {@code null} or empty. */ @@ -147,16 +151,19 @@ public abstract class QNameUtils { Assert.hasLength(qNameString, "QName text may not be null or empty"); if (qNameString.charAt(0) != '{') { return new QName(qNameString); - } else { + } + else { int endOfNamespaceURI = qNameString.indexOf('}'); if (endOfNamespaceURI == -1) { - throw new IllegalArgumentException("Cannot create QName from \"" + qNameString + "\", missing closing \"}\""); + throw new IllegalArgumentException( + "Cannot create QName from \"" + qNameString + "\", missing closing \"}\""); } int prefixSeperator = qNameString.indexOf(':', endOfNamespaceURI + 1); String namespaceURI = qNameString.substring(1, endOfNamespaceURI); if (prefixSeperator == -1) { return new QName(namespaceURI, qNameString.substring(endOfNamespaceURI + 1)); - } else { + } + else { return new QName(namespaceURI, qNameString.substring(prefixSeperator + 1), qNameString.substring(endOfNamespaceURI + 1, prefixSeperator)); } diff --git a/spring-xml/src/main/java/org/springframework/xml/namespace/SimpleNamespaceContext.java b/spring-xml/src/main/java/org/springframework/xml/namespace/SimpleNamespaceContext.java index 8eb5b8e6..cd973a63 100644 --- a/spring-xml/src/main/java/org/springframework/xml/namespace/SimpleNamespaceContext.java +++ b/spring-xml/src/main/java/org/springframework/xml/namespace/SimpleNamespaceContext.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -30,8 +30,9 @@ import javax.xml.namespace.NamespaceContext; import org.springframework.util.Assert; /** - * Simple {@code javax.xml.namespace.NamespaceContext} implementation. Follows the standard {@code NamespaceContext} - * contract, and is loadable via a {@code java.util.Map} or {@code java.util.Properties} object + * Simple {@code javax.xml.namespace.NamespaceContext} implementation. Follows the + * standard {@code NamespaceContext} contract, and is loadable via a {@code java.util.Map} + * or {@code java.util.Properties} object * * @author Arjen Poutsma * @since 1.0.0 @@ -47,9 +48,11 @@ public class SimpleNamespaceContext implements NamespaceContext { Assert.notNull(prefix, "prefix is null"); if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { return XMLConstants.XML_NS_URI; - } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { + } + else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; - } else if (prefixToNamespaceUri.containsKey(prefix)) { + } + else if (prefixToNamespaceUri.containsKey(prefix)) { return prefixToNamespaceUri.get(prefix); } return XMLConstants.NULL_NS_URI; @@ -69,8 +72,8 @@ public class SimpleNamespaceContext implements NamespaceContext { } /** - * Sets the bindings for this namespace context. The supplied map must consist of string key value pairs. - * + * Sets the bindings for this namespace context. The supplied map must consist of + * string key value pairs. * @param bindings the bindings */ public void setBindings(Map bindings) { @@ -81,7 +84,6 @@ public class SimpleNamespaceContext implements NamespaceContext { /** * Binds the given namespace as default namespace. - * * @param namespaceUri the namespace uri */ public void bindDefaultNamespaceUri(String namespaceUri) { @@ -90,7 +92,6 @@ public class SimpleNamespaceContext implements NamespaceContext { /** * Binds the given prefix to the given namespace. - * * @param prefix the namespace prefix * @param namespaceUri the namespace uri */ @@ -98,13 +99,15 @@ public class SimpleNamespaceContext implements NamespaceContext { Assert.notNull(prefix, "No prefix given"); Assert.notNull(namespaceUri, "No namespaceUri given"); if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { - Assert.isTrue(XMLConstants.XML_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + "\" bound to namespace \"" - + namespaceUri + "\" (should be \"" + XMLConstants.XML_NS_URI + "\")"); - } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { + Assert.isTrue(XMLConstants.XML_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + XMLConstants.XML_NS_URI + "\")"); + } + else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { Assert.isTrue(XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + XMLConstants.XMLNS_ATTRIBUTE_NS_URI + "\")"); - } else { + } + else { prefixToNamespaceUri.put(prefix, namespaceUri); getPrefixesInternal(namespaceUri).add(prefix); } @@ -118,7 +121,6 @@ public class SimpleNamespaceContext implements NamespaceContext { /** * Returns all declared prefixes. - * * @return the declared prefixes */ public Iterator getBoundPrefixes() { @@ -131,7 +133,8 @@ public class SimpleNamespaceContext implements NamespaceContext { private Set getPrefixesInternal(String namespaceUri) { if (XMLConstants.XML_NS_URI.equals(namespaceUri)) { return Collections.singleton(XMLConstants.XML_NS_PREFIX); - } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceUri)) { + } + else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceUri)) { return Collections.singleton(XMLConstants.XMLNS_ATTRIBUTE); } return namespaceUriToPrefixes.computeIfAbsent(namespaceUri, k -> new LinkedHashSet<>()); @@ -139,7 +142,6 @@ public class SimpleNamespaceContext implements NamespaceContext { /** * Removes the given prefix from this context. - * * @param prefix the prefix to be removed */ public void removeBinding(String prefix) { @@ -153,4 +155,5 @@ public class SimpleNamespaceContext implements NamespaceContext { public boolean hasBinding(String prefix) { return prefixToNamespaceUri.containsKey(prefix); } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/sax/AbstractXmlReader.java b/spring-xml/src/main/java/org/springframework/xml/sax/AbstractXmlReader.java index 79f0e5e0..29b79850 100644 --- a/spring-xml/src/main/java/org/springframework/xml/sax/AbstractXmlReader.java +++ b/spring-xml/src/main/java/org/springframework/xml/sax/AbstractXmlReader.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,8 +26,8 @@ import org.xml.sax.XMLReader; import org.xml.sax.ext.LexicalHandler; /** - * Abstract base class for SAX {@code XMLReader} implementations. Contains properties as defined in {@link XMLReader}, - * and does not recognize any features + * Abstract base class for SAX {@code XMLReader} implementations. Contains properties as + * defined in {@link XMLReader}, and does not recognize any features * * @author Arjen Poutsma * @see #setContentHandler(org.xml.sax.ContentHandler) @@ -94,7 +94,6 @@ public abstract class AbstractXmlReader implements XMLReader { /** * Throws a {@code SAXNotRecognizedException} exception. - * * @throws org.xml.sax.SAXNotRecognizedException always */ @Override @@ -104,7 +103,6 @@ public abstract class AbstractXmlReader implements XMLReader { /** * Throws a {@code SAXNotRecognizedException} exception. - * * @throws SAXNotRecognizedException always */ @Override @@ -113,28 +111,33 @@ public abstract class AbstractXmlReader implements XMLReader { } /** - * Throws a {@code SAXNotRecognizedException} exception when the given property does not signify a lexical handler. - * The property name for a lexical handler is {@code http://xml.org/sax/properties/lexical-handler}. + * Throws a {@code SAXNotRecognizedException} exception when the given property does + * not signify a lexical handler. The property name for a lexical handler is + * {@code http://xml.org/sax/properties/lexical-handler}. */ @Override public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { if ("http://xml.org/sax/properties/lexical-handler".equals(name)) { return lexicalHandler; - } else { + } + else { throw new SAXNotRecognizedException(name); } } /** - * Throws a {@code SAXNotRecognizedException} exception when the given property does not signify a lexical handler. - * The property name for a lexical handler is {@code http://xml.org/sax/properties/lexical-handler}. + * Throws a {@code SAXNotRecognizedException} exception when the given property does + * not signify a lexical handler. The property name for a lexical handler is + * {@code http://xml.org/sax/properties/lexical-handler}. */ @Override public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { if ("http://xml.org/sax/properties/lexical-handler".equals(name)) { lexicalHandler = (LexicalHandler) value; - } else { + } + else { throw new SAXNotRecognizedException(name); } } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/sax/SaxUtils.java b/spring-xml/src/main/java/org/springframework/xml/sax/SaxUtils.java index 6711c83c..ecd2676b 100644 --- a/spring-xml/src/main/java/org/springframework/xml/sax/SaxUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/sax/SaxUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,9 +22,10 @@ import java.net.URISyntaxException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.core.io.Resource; import org.xml.sax.InputSource; +import org.springframework.core.io.Resource; + /** * Convenient utility methods for dealing with SAX. * @@ -36,9 +37,8 @@ public abstract class SaxUtils { private static final Log logger = LogFactory.getLog(SaxUtils.class); /** - * Creates a SAX {@code InputSource} from the given resource. Sets the system identifier to the resource's - * {@code URL}, if available. - * + * Creates a SAX {@code InputSource} from the given resource. Sets the system + * identifier to the resource's {@code URL}, if available. * @param resource the resource * @return the input source created from the resource * @throws IOException if an I/O exception occurs @@ -51,11 +51,15 @@ public abstract class SaxUtils { return inputSource; } - /** Retrieves the URL from the given resource as System ID. Returns {@code null} if it cannot be opened. */ + /** + * Retrieves the URL from the given resource as System ID. Returns {@code null} if it + * cannot be opened. + */ public static String getSystemId(Resource resource) { try { return new URI(resource.getURL().toExternalForm()).toString(); - } catch (IOException | URISyntaxException ex) { + } + catch (IOException | URISyntaxException ex) { logger.debug("Could not get System ID from [" + resource + "], ex"); return null; } diff --git a/spring-xml/src/main/java/org/springframework/xml/transform/ResourceSource.java b/spring-xml/src/main/java/org/springframework/xml/transform/ResourceSource.java index 8334c847..c9fb539b 100644 --- a/spring-xml/src/main/java/org/springframework/xml/transform/ResourceSource.java +++ b/spring-xml/src/main/java/org/springframework/xml/transform/ResourceSource.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,13 +20,14 @@ import java.io.IOException; import javax.xml.transform.sax.SAXSource; -import org.springframework.core.io.Resource; -import org.springframework.xml.sax.SaxUtils; import org.xml.sax.XMLReader; +import org.springframework.core.io.Resource; +import org.springframework.xml.sax.SaxUtils; + /** - * Convenient subclass of {@link SAXSource} that reads from a Spring {@link Resource}. The resource to be read can be - * set via the constructor. + * Convenient subclass of {@link SAXSource} that reads from a Spring {@link Resource}. The + * resource to be read can be set via the constructor. * * @author Arjen Poutsma * @since 1.0.0 @@ -35,7 +36,6 @@ public class ResourceSource extends SAXSource { /** * Initializes a new instance of the {@code ResourceSource} with the given resource. - * * @param content the content */ public ResourceSource(Resource content) throws IOException { @@ -43,11 +43,12 @@ public class ResourceSource extends SAXSource { } /** - * Initializes a new instance of the {@code ResourceSource} with the given {@link XMLReader} and resource. - * + * Initializes a new instance of the {@code ResourceSource} with the given + * {@link XMLReader} and resource. * @param content the content */ public ResourceSource(XMLReader reader, Resource content) throws IOException { super(reader, SaxUtils.createInputSource(content)); } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/transform/StringResult.java b/spring-xml/src/main/java/org/springframework/xml/transform/StringResult.java index 927f8677..e75b6e7d 100644 --- a/spring-xml/src/main/java/org/springframework/xml/transform/StringResult.java +++ b/spring-xml/src/main/java/org/springframework/xml/transform/StringResult.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,8 +21,8 @@ import java.io.StringWriter; import javax.xml.transform.stream.StreamResult; /** - * Convenient subclass of {@code StreamResult} that writes to a {@code StringWriter}. The resulting string can be - * retrieved via {@code toString()}. + * Convenient subclass of {@code StreamResult} that writes to a {@code StringWriter}. The + * resulting string can be retrieved via {@code toString()}. * * @author Arjen Poutsma * @see #toString() diff --git a/spring-xml/src/main/java/org/springframework/xml/transform/StringSource.java b/spring-xml/src/main/java/org/springframework/xml/transform/StringSource.java index 45283243..15deff31 100644 --- a/spring-xml/src/main/java/org/springframework/xml/transform/StringSource.java +++ b/spring-xml/src/main/java/org/springframework/xml/transform/StringSource.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,8 +25,8 @@ import javax.xml.transform.stream.StreamSource; import org.springframework.util.Assert; /** - * Convenient subclass of {@code StreamSource} that reads from a {@code StringReader}. The string to be read can be set - * via the constructor. + * Convenient subclass of {@code StreamSource} that reads from a {@code StringReader}. The + * string to be read can be set via the constructor. * * @author Arjen Poutsma * @since 1.0.0 @@ -36,8 +36,8 @@ public class StringSource extends StreamSource { private final String content; /** - * Initializes a new instance of the {@code StringSource} with the given string content. - * + * Initializes a new instance of the {@code StringSource} with the given string + * content. * @param content the content */ public StringSource(String content) { @@ -52,7 +52,6 @@ public class StringSource extends StreamSource { /** * Throws {@link UnsupportedOperationException}. - * * @throws UnsupportedOperationException always */ @Override @@ -62,7 +61,6 @@ public class StringSource extends StreamSource { /** * Returns {@code null}. - * * @return {@code null} */ @Override @@ -72,7 +70,6 @@ public class StringSource extends StreamSource { /** * Throws {@link UnsupportedOperationException}. - * * @throws UnsupportedOperationException always */ @Override @@ -84,4 +81,5 @@ public class StringSource extends StreamSource { public String toString() { return content; } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/transform/TransformerFactoryUtils.java b/spring-xml/src/main/java/org/springframework/xml/transform/TransformerFactoryUtils.java index e21be822..89001b9a 100644 --- a/spring-xml/src/main/java/org/springframework/xml/transform/TransformerFactoryUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/transform/TransformerFactoryUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -39,13 +39,13 @@ public class TransformerFactoryUtils { /** * Build an {@link TransformerFactory} and prevent external entities from accessing. - * * @see TransformerFactory#newInstance() */ public static TransformerFactory newInstance(Class transformerFactoryClass) { try { return defaultSettings(transformerFactoryClass.newInstance()); - } catch (InstantiationException | IllegalAccessException e) { + } + catch (InstantiationException | IllegalAccessException e) { throw new TransformerFactoryConfigurationError(e, "Could not instantiate TransformerFactory [" + transformerFactoryClass + "]"); } @@ -57,16 +57,18 @@ public class TransformerFactoryUtils { private static TransformerFactory defaultSettings(TransformerFactory factory) { try { factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - } catch (IllegalArgumentException e) { + } + catch (IllegalArgumentException e) { if (log.isWarnEnabled()) { - log.warn( - XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + factory.getClass().getCanonicalName()); + log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + + factory.getClass().getCanonicalName()); } } try { factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); - } catch (IllegalArgumentException e) { + } + catch (IllegalArgumentException e) { if (log.isWarnEnabled()) { log.warn(XMLConstants.ACCESS_EXTERNAL_STYLESHEET + " property not supported by " + factory.getClass().getCanonicalName()); @@ -75,4 +77,5 @@ public class TransformerFactoryUtils { return factory; } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/transform/TransformerHelper.java b/spring-xml/src/main/java/org/springframework/xml/transform/TransformerHelper.java index 7e2ae9da..3216ad00 100644 --- a/spring-xml/src/main/java/org/springframework/xml/transform/TransformerHelper.java +++ b/spring-xml/src/main/java/org/springframework/xml/transform/TransformerHelper.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -41,17 +41,20 @@ public class TransformerHelper { /** * Initializes a new instance of the {@code TransformerHelper}. */ - public TransformerHelper() {} + public TransformerHelper() { + } /** - * Initializes a new instance of the {@code TransformerHelper} with the specified {@link TransformerFactory}. + * Initializes a new instance of the {@code TransformerHelper} with the specified + * {@link TransformerFactory}. */ public TransformerHelper(TransformerFactory transformerFactory) { this.transformerFactory = transformerFactory; } /** - * Initializes a new instance of the {@code TransformerHelper} with the specified {@link TransformerFactory} class. + * Initializes a new instance of the {@code TransformerHelper} with the specified + * {@link TransformerFactory} class. */ public TransformerHelper(Class transformerFactoryClass) { setTransformerFactoryClass(transformerFactoryClass); @@ -68,12 +71,11 @@ public class TransformerHelper { /** * Instantiate a new TransformerFactory. *

- * The default implementation simply calls {@link TransformerFactory#newInstance()}. If a - * {@link #setTransformerFactoryClass transformerFactoryClass} has been specified explicitly, the default constructor - * of the specified class will be called instead. + * The default implementation simply calls {@link TransformerFactory#newInstance()}. + * If a {@link #setTransformerFactoryClass transformerFactoryClass} has been specified + * explicitly, the default constructor of the specified class will be called instead. *

* Can be overridden in subclasses. - * * @param transformerFactoryClass the specified factory class (if any) * @return the new TransactionFactory instance * @see #setTransformerFactoryClass @@ -82,14 +84,14 @@ public class TransformerHelper { protected TransformerFactory newTransformerFactory(Class transformerFactoryClass) { if (transformerFactoryClass != null) { return TransformerFactoryUtils.newInstance(transformerFactoryClass); - } else { + } + else { return TransformerFactoryUtils.newInstance(); } } /** * Returns the {@code TransformerFactory}. - * * @return the transformer factory */ public TransformerFactory getTransformerFactory() { @@ -106,8 +108,8 @@ public class TransformerHelper { } /** - * Creates a new {@code Transformer}. Must be called per thread, as transformers are not thread-safe. - * + * Creates a new {@code Transformer}. Must be called per thread, as transformers are + * not thread-safe. * @return the created transformer * @throws TransformerConfigurationException if thrown by JAXP methods */ @@ -116,9 +118,8 @@ public class TransformerHelper { } /** - * Transforms the given {@link Source} to the given {@link Result}. Creates a new {@link Transformer} for every call, - * as transformers are not thread-safe. - * + * Transforms the given {@link Source} to the given {@link Result}. Creates a new + * {@link Transformer} for every call, as transformers are not thread-safe. * @param source the source to transform from * @param result the result to transform to * @throws TransformerException if thrown by JAXP methods diff --git a/spring-xml/src/main/java/org/springframework/xml/transform/TransformerObjectSupport.java b/spring-xml/src/main/java/org/springframework/xml/transform/TransformerObjectSupport.java index 4b6b46f7..e9dab71e 100644 --- a/spring-xml/src/main/java/org/springframework/xml/transform/TransformerObjectSupport.java +++ b/spring-xml/src/main/java/org/springframework/xml/transform/TransformerObjectSupport.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,9 +27,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * Convenient base class for objects that use a {@code Transformer}. Subclasses can call {@link #createTransformer()} or - * {@link #transform(Source, Result)}. This should be done per thread (i.e. per incoming request), because - * {@code Transformer} instances are not thread-safe. + * Convenient base class for objects that use a {@code Transformer}. Subclasses can call + * {@link #createTransformer()} or {@link #transform(Source, Result)}. This should be done + * per thread (i.e. per incoming request), because {@code Transformer} instances are not + * thread-safe. * * @author Arjen Poutsma * @see Transformer @@ -54,12 +55,12 @@ public abstract class TransformerObjectSupport { /** * Instantiate a new TransformerFactory. *

- * The default implementation simply calls {@link TransformerFactory#newInstance()}. If a - * {@link #setTransformerFactoryClass "transformerFactoryClass"} has been specified explicitly, the default - * constructor of the specified class will be called instead. + * The default implementation simply calls {@link TransformerFactory#newInstance()}. + * If a {@link #setTransformerFactoryClass "transformerFactoryClass"} has been + * specified explicitly, the default constructor of the specified class will be called + * instead. *

* Can be overridden in subclasses. - * * @param transformerFactoryClass the specified factory class (if any) * @return the new TransactionFactory instance * @see #setTransformerFactoryClass @@ -77,8 +78,8 @@ public abstract class TransformerObjectSupport { } /** - * Creates a new {@code Transformer}. Must be called per request, as transformers are not thread-safe. - * + * Creates a new {@code Transformer}. Must be called per request, as transformers are + * not thread-safe. * @return the created transformer * @throws TransformerConfigurationException if thrown by JAXP methods */ @@ -87,9 +88,8 @@ public abstract class TransformerObjectSupport { } /** - * Transforms the given {@link Source} to the given {@link Result}. Creates a new {@link Transformer} for every call, - * as transformers are not thread-safe. - * + * Transforms the given {@link Source} to the given {@link Result}. Creates a new + * {@link Transformer} for every call, as transformers are not thread-safe. * @param source the source to transform from * @param result the result to transform to * @throws TransformerException if thrown by JAXP methods diff --git a/spring-xml/src/main/java/org/springframework/xml/transform/TraxUtils.java b/spring-xml/src/main/java/org/springframework/xml/transform/TraxUtils.java index 2d149ed5..b20b2ce8 100644 --- a/spring-xml/src/main/java/org/springframework/xml/transform/TraxUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/transform/TraxUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -36,8 +36,6 @@ import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.springframework.util.StringUtils; -import org.springframework.util.xml.StaxUtils; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.ContentHandler; @@ -45,6 +43,9 @@ import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import org.xml.sax.ext.LexicalHandler; +import org.springframework.util.StringUtils; +import org.springframework.util.xml.StaxUtils; + /** * Convenient utility methods for dealing with TrAX. * @@ -55,7 +56,6 @@ public abstract class TraxUtils { /** * Returns the {@link Document} of the given {@link DOMSource}. - * * @param source the DOM source * @return the document */ @@ -63,17 +63,19 @@ public abstract class TraxUtils { Node node = source.getNode(); if (node instanceof Document) { return (Document) node; - } else if (node != null) { + } + else if (node != null) { return node.getOwnerDocument(); - } else { + } + else { return null; } } /** - * Performs the given {@linkplain SourceCallback callback} operation on a {@link Source}. Supports both the JAXP 1.4 - * {@link StAXSource} and the Spring 3.0 {@link StaxUtils#createStaxSource StaxSource}. - * + * Performs the given {@linkplain SourceCallback callback} operation on a + * {@link Source}. Supports both the JAXP 1.4 {@link StAXSource} and the Spring 3.0 + * {@link StaxUtils#createStaxSource StaxSource}. * @param source source to look at * @param callback the callback to invoke for each kind of source */ @@ -81,28 +83,33 @@ public abstract class TraxUtils { if (source instanceof DOMSource) { callback.domSource(((DOMSource) source).getNode()); return; - } else if (StaxUtils.isStaxSource(source)) { + } + else if (StaxUtils.isStaxSource(source)) { XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(source); if (streamReader != null) { callback.staxSource(streamReader); return; - } else { + } + else { XMLEventReader eventReader = StaxUtils.getXMLEventReader(source); if (eventReader != null) { callback.staxSource(eventReader); return; } } - } else if (source instanceof SAXSource) { + } + else if (source instanceof SAXSource) { SAXSource saxSource = (SAXSource) source; callback.saxSource(saxSource.getXMLReader(), saxSource.getInputSource()); return; - } else if (source instanceof StreamSource) { + } + else if (source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; if (streamSource.getInputStream() != null) { callback.streamSource(streamSource.getInputStream()); return; - } else if (streamSource.getReader() != null) { + } + else if (streamSource.getReader() != null) { callback.streamSource(streamSource.getReader()); return; } @@ -110,16 +117,18 @@ public abstract class TraxUtils { if (StringUtils.hasLength(source.getSystemId())) { String systemId = source.getSystemId(); callback.source(systemId); - } else { + } + else { throw new IllegalArgumentException("Unknown Source type: " + source.getClass()); } } /** - * Performs the given {@linkplain org.springframework.xml.transform.TraxUtils.ResultCallback callback} operation on a - * {@link javax.xml.transform.Result}. Supports both the JAXP 1.4 {@link javax.xml.transform.stax.StAXResult} and the - * Spring 3.0 {@link org.springframework.util.xml.StaxUtils#createStaxResult StaxSource}. - * + * Performs the given + * {@linkplain org.springframework.xml.transform.TraxUtils.ResultCallback callback} + * operation on a {@link javax.xml.transform.Result}. Supports both the JAXP 1.4 + * {@link javax.xml.transform.stax.StAXResult} and the Spring 3.0 + * {@link org.springframework.util.xml.StaxUtils#createStaxResult StaxSource}. * @param result result to look at * @param callback the callback to invoke for each kind of result */ @@ -127,28 +136,33 @@ public abstract class TraxUtils { if (result instanceof DOMResult) { callback.domResult(((DOMResult) result).getNode()); return; - } else if (StaxUtils.isStaxResult(result)) { + } + else if (StaxUtils.isStaxResult(result)) { XMLStreamWriter streamWriter = StaxUtils.getXMLStreamWriter(result); if (streamWriter != null) { callback.staxResult(streamWriter); return; - } else { + } + else { XMLEventWriter eventWriter = StaxUtils.getXMLEventWriter(result); if (eventWriter != null) { callback.staxResult(eventWriter); return; } } - } else if (result instanceof SAXResult) { + } + else if (result instanceof SAXResult) { SAXResult saxSource = (SAXResult) result; callback.saxResult(saxSource.getHandler(), saxSource.getLexicalHandler()); return; - } else if (result instanceof StreamResult) { + } + else if (result instanceof StreamResult) { StreamResult streamSource = (StreamResult) result; if (streamSource.getOutputStream() != null) { callback.streamResult(streamSource.getOutputStream()); return; - } else if (streamSource.getWriter() != null) { + } + else if (streamSource.getWriter() != null) { callback.streamResult(streamSource.getWriter()); return; } @@ -156,7 +170,8 @@ public abstract class TraxUtils { if (StringUtils.hasLength(result.getSystemId())) { String systemId = result.getSystemId(); callback.result(systemId); - } else { + } + else { throw new IllegalArgumentException("Unknown Result type: " + result.getClass()); } } @@ -170,52 +185,47 @@ public abstract class TraxUtils { /** * Perform an operation on the node contained in a {@link DOMSource}. - * * @param node the node */ void domSource(Node node) throws Exception; /** - * Perform an operation on the {@code XMLReader} and {@code InputSource} contained in a {@link SAXSource}. - * + * Perform an operation on the {@code XMLReader} and {@code InputSource} contained + * in a {@link SAXSource}. * @param reader the reader, can be {@code null} * @param inputSource the input source, can be {@code null} */ void saxSource(XMLReader reader, InputSource inputSource) throws Exception; /** - * Perform an operation on the {@code XMLEventReader} contained in a JAXP 1.4 {@link StAXSource} or Spring - * {@link StaxUtils#createStaxSource StaxSource}. - * + * Perform an operation on the {@code XMLEventReader} contained in a JAXP 1.4 + * {@link StAXSource} or Spring {@link StaxUtils#createStaxSource StaxSource}. * @param eventReader the reader */ void staxSource(XMLEventReader eventReader) throws Exception; /** - * Perform an operation on the {@code XMLStreamReader} contained in a JAXP 1.4 {@link StAXSource} or Spring - * {@link StaxUtils#createStaxSource StaxSource}. - * + * Perform an operation on the {@code XMLStreamReader} contained in a JAXP 1.4 + * {@link StAXSource} or Spring {@link StaxUtils#createStaxSource StaxSource}. * @param streamReader the reader */ void staxSource(XMLStreamReader streamReader) throws Exception; /** - * Perform an operation on the {@code InputStream} contained in a {@link StreamSource}. - * + * Perform an operation on the {@code InputStream} contained in a + * {@link StreamSource}. * @param inputStream the input stream */ void streamSource(InputStream inputStream) throws Exception; /** * Perform an operation on the {@code Reader} contained in a {@link StreamSource}. - * * @param reader the reader */ void streamSource(Reader reader) throws Exception; /** * Perform an operation on the system identifier contained in any {@link Source}. - * * @param systemId the system identifier */ void source(String systemId) throws Exception; @@ -231,52 +241,47 @@ public abstract class TraxUtils { /** * Perform an operation on the node contained in a {@link DOMResult}. - * * @param node the node */ void domResult(Node node) throws Exception; /** - * Perform an operation on the {@code ContentHandler} and {@code LexicalHandler} contained in a {@link SAXResult}. - * + * Perform an operation on the {@code ContentHandler} and {@code LexicalHandler} + * contained in a {@link SAXResult}. * @param contentHandler the content handler * @param lexicalHandler the lexicalHandler, can be {@code null} */ void saxResult(ContentHandler contentHandler, LexicalHandler lexicalHandler) throws Exception; /** - * Perform an operation on the {@code XMLEventWriter} contained in a JAXP 1.4 {@link StAXResult} or Spring - * {@link StaxUtils#createStaxResult StaxResult}. - * + * Perform an operation on the {@code XMLEventWriter} contained in a JAXP 1.4 + * {@link StAXResult} or Spring {@link StaxUtils#createStaxResult StaxResult}. * @param eventWriter the writer */ void staxResult(XMLEventWriter eventWriter) throws Exception; /** - * Perform an operation on the {@code XMLStreamWriter} contained in a JAXP 1.4 {@link StAXResult} or Spring - * {@link StaxUtils#createStaxResult StaxResult}. - * + * Perform an operation on the {@code XMLStreamWriter} contained in a JAXP 1.4 + * {@link StAXResult} or Spring {@link StaxUtils#createStaxResult StaxResult}. * @param streamWriter the writer */ void staxResult(XMLStreamWriter streamWriter) throws Exception; /** - * Perform an operation on the {@code OutputStream} contained in a {@link StreamResult}. - * + * Perform an operation on the {@code OutputStream} contained in a + * {@link StreamResult}. * @param outputStream the output stream */ void streamResult(OutputStream outputStream) throws Exception; /** * Perform an operation on the {@code Writer} contained in a {@link StreamResult}. - * * @param writer the writer */ void streamResult(Writer writer) throws Exception; /** * Perform an operation on the system identifier contained in any {@link Result}. - * * @param systemId the system identifier */ void result(String systemId) throws Exception; diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/Jaxp13ValidatorFactory.java b/spring-xml/src/main/java/org/springframework/xml/validation/Jaxp13ValidatorFactory.java index 9e1d5a7e..444f48b8 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/Jaxp13ValidatorFactory.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/Jaxp13ValidatorFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,10 +24,11 @@ import javax.xml.transform.Source; import javax.xml.validation.Schema; import javax.xml.validation.Validator; -import org.springframework.core.io.Resource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; +import org.springframework.core.io.Resource; + /** * Internal class that uses JAXP 1.0 features to create {@code XmlValidator} instances. * @@ -41,7 +42,8 @@ abstract class Jaxp13ValidatorFactory { try { Schema schema = SchemaLoaderUtils.loadSchema(resources, schemaLanguage); return new Jaxp13Validator(schema); - } catch (SAXException ex) { + } + catch (SAXException ex) { throw new XmlValidationException("Could not create Schema: " + ex.getMessage(), ex); } } @@ -69,13 +71,17 @@ abstract class Jaxp13ValidatorFactory { try { validator.validate(source); return errorHandler.getErrors(); - } catch (SAXException ex) { + } + catch (SAXException ex) { throw new XmlValidationException("Could not validate source: " + ex.getMessage(), ex); } } + } - /** {@code ErrorHandler} implementation that stores errors and fatal errors in a list. */ + /** + * {@code ErrorHandler} implementation that stores errors and fatal errors in a list. + */ private static class DefaultValidationErrorHandler implements ValidationErrorHandler { private List errors = new ArrayList(); @@ -86,7 +92,8 @@ abstract class Jaxp13ValidatorFactory { } @Override - public void warning(SAXParseException ex) throws SAXException {} + public void warning(SAXParseException ex) throws SAXException { + } @Override public void error(SAXParseException ex) throws SAXException { @@ -97,5 +104,7 @@ abstract class Jaxp13ValidatorFactory { public void fatalError(SAXParseException ex) throws SAXException { errors.add(ex); } + } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/Jaxp15ValidatorFactory.java b/spring-xml/src/main/java/org/springframework/xml/validation/Jaxp15ValidatorFactory.java index 4549169a..eddbb40d 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/Jaxp15ValidatorFactory.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/Jaxp15ValidatorFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,15 +27,16 @@ import javax.xml.validation.Validator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.core.io.Resource; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; import org.xml.sax.SAXParseException; +import org.springframework.core.io.Resource; + /** - * Internal class that uses JAXP 1.5 features to create an {@code XmlValidator} with settings to prevent external entity - * access. + * Internal class that uses JAXP 1.5 features to create an {@code XmlValidator} with + * settings to prevent external entity access. * * @author Arjen Poutsma * @author Greg Turnquist @@ -49,7 +50,8 @@ abstract class Jaxp15ValidatorFactory { try { Schema schema = SchemaLoaderUtils.loadSchema(resources, schemaLanguage); return new Jaxp15Validator(schema); - } catch (SAXException ex) { + } + catch (SAXException ex) { throw new XmlValidationException("Could not create Schema: " + ex.getMessage(), ex); } } @@ -76,7 +78,8 @@ abstract class Jaxp15ValidatorFactory { try { validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - } catch (SAXNotRecognizedException | SAXNotSupportedException e) { + } + catch (SAXNotRecognizedException | SAXNotSupportedException e) { if (log.isWarnEnabled()) { log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + validator.getClass().getCanonicalName()); @@ -85,7 +88,8 @@ abstract class Jaxp15ValidatorFactory { try { validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); - } catch (SAXNotRecognizedException | SAXNotSupportedException e) { + } + catch (SAXNotRecognizedException | SAXNotSupportedException e) { if (log.isWarnEnabled()) { log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + validator.getClass().getCanonicalName()); @@ -96,13 +100,17 @@ abstract class Jaxp15ValidatorFactory { try { validator.validate(source); return errorHandler.getErrors(); - } catch (SAXException ex) { + } + catch (SAXException ex) { throw new XmlValidationException("Could not validate source: " + ex.getMessage(), ex); } } + } - /** {@code ErrorHandler} implementation that stores errors and fatal errors in a list. */ + /** + * {@code ErrorHandler} implementation that stores errors and fatal errors in a list. + */ private static class DefaultValidationErrorHandler implements ValidationErrorHandler { private List errors = new ArrayList(); @@ -113,7 +121,8 @@ abstract class Jaxp15ValidatorFactory { } @Override - public void warning(SAXParseException ex) throws SAXException {} + public void warning(SAXParseException ex) throws SAXException { + } @Override public void error(SAXParseException ex) throws SAXException { @@ -124,5 +133,7 @@ abstract class Jaxp15ValidatorFactory { public void fatalError(SAXParseException ex) throws SAXException { errors.add(ex); } + } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/SchemaFactoryUtils.java b/spring-xml/src/main/java/org/springframework/xml/validation/SchemaFactoryUtils.java index eb05313d..7fbf11ae 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/SchemaFactoryUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/SchemaFactoryUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,10 +20,11 @@ import javax.xml.validation.SchemaFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.util.ResourceUtils; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; +import org.springframework.util.ResourceUtils; + /** * @author Greg Turnquist * @since 3.0.5 @@ -33,8 +34,8 @@ public class SchemaFactoryUtils { private static final Log log = LogFactory.getLog(SchemaFactoryUtils.class); /** - * Build a {@link SchemaFactory} and set properties to prevent external entities from accessing. - * + * Build a {@link SchemaFactory} and set properties to prevent external entities from + * accessing. * @see SchemaFactory#newInstance(String) */ public static SchemaFactory newInstance(String schemaLanguage) { @@ -42,7 +43,8 @@ public class SchemaFactoryUtils { try { schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - } catch (SAXNotRecognizedException | SAXNotSupportedException e) { + } + catch (SAXNotRecognizedException | SAXNotSupportedException e) { if (log.isWarnEnabled()) { log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + schemaFactory.getClass().getCanonicalName()); @@ -51,9 +53,10 @@ public class SchemaFactoryUtils { } try { - schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, - ResourceUtils.URL_PROTOCOL_FILE + "," + "jar:file" + "," + "nested" + "," + ResourceUtils.URL_PROTOCOL_WSJAR); - } catch (SAXNotRecognizedException | SAXNotSupportedException e) { + schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ResourceUtils.URL_PROTOCOL_FILE + "," + + "jar:file" + "," + "nested" + "," + ResourceUtils.URL_PROTOCOL_WSJAR); + } + catch (SAXNotRecognizedException | SAXNotSupportedException e) { if (log.isWarnEnabled()) { log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + schemaFactory.getClass().getCanonicalName()); @@ -62,4 +65,5 @@ public class SchemaFactoryUtils { return schemaFactory; } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/SchemaLoaderUtils.java b/spring-xml/src/main/java/org/springframework/xml/validation/SchemaLoaderUtils.java index 7102203f..82976c83 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/SchemaLoaderUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/SchemaLoaderUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,14 +22,16 @@ import javax.xml.transform.Source; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; -import org.springframework.core.io.Resource; -import org.springframework.util.Assert; -import org.springframework.xml.transform.ResourceSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; +import org.springframework.core.io.Resource; +import org.springframework.util.Assert; +import org.springframework.xml.transform.ResourceSource; + /** - * Convenient utility methods for loading of {@link Schema} objects, performing standard handling of input streams. + * Convenient utility methods for loading of {@link Schema} objects, performing standard + * handling of input streams. * * @author Arjen Poutsma * @since 1.0.0 @@ -38,10 +40,9 @@ public abstract class SchemaLoaderUtils { /** * Load schema from the given resource. - * * @param resource the resource to load from - * @param schemaLanguage the language of the schema. Can be {@code XMLConstants.W3C_XML_SCHEMA_NS_URI} or - * {@code XMLConstants.RELAXNG_NS_URI}. + * @param schemaLanguage the language of the schema. Can be + * {@code XMLConstants.W3C_XML_SCHEMA_NS_URI} or {@code XMLConstants.RELAXNG_NS_URI}. * @throws IOException if loading failed * @throws SAXException if loading failed * @see javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI @@ -53,10 +54,9 @@ public abstract class SchemaLoaderUtils { /** * Load schema from the given resource. - * * @param resources the resources to load from - * @param schemaLanguage the language of the schema. Can be {@code XMLConstants.W3C_XML_SCHEMA_NS_URI} or - * {@code XMLConstants.RELAXNG_NS_URI}. + * @param schemaLanguage the language of the schema. Can be + * {@code XMLConstants.W3C_XML_SCHEMA_NS_URI} or {@code XMLConstants.RELAXNG_NS_URI}. * @throws IOException if loading failed * @throws SAXException if loading failed * @see javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI @@ -77,11 +77,15 @@ public abstract class SchemaLoaderUtils { return schemaFactory.newSchema(schemaSources); } - /** Retrieves the URL from the given resource as System ID. Returns {@code null} if it cannot be opened. */ + /** + * Retrieves the URL from the given resource as System ID. Returns {@code null} if it + * cannot be opened. + */ public static String getSystemId(Resource resource) { try { return resource.getURL().toString(); - } catch (IOException e) { + } + catch (IOException e) { return null; } } diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/ValidationErrorHandler.java b/spring-xml/src/main/java/org/springframework/xml/validation/ValidationErrorHandler.java index e9937f03..a5b15106 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/ValidationErrorHandler.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/ValidationErrorHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,8 +29,8 @@ public interface ValidationErrorHandler extends ErrorHandler { /** * Returns the errors collected by this error handler. - * * @return the errors */ SAXParseException[] getErrors(); + } diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/XMLReaderFactoryUtils.java b/spring-xml/src/main/java/org/springframework/xml/validation/XMLReaderFactoryUtils.java index fca47797..52e802c2 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/XMLReaderFactoryUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/XMLReaderFactoryUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -27,7 +27,6 @@ public class XMLReaderFactoryUtils { /** * Build a {@link XMLReader} and set properties to prevent external entity access. - * * @see XMLReaderFactory#createXMLReader() */ public static XMLReader createXMLReader() throws SAXException { @@ -40,4 +39,5 @@ public class XMLReaderFactoryUtils { return xmlReader; } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidationException.java b/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidationException.java index 5ca85c4f..a1024140 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidationException.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidationException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public class XmlValidationException extends XmlException { public XmlValidationException(String s, Throwable throwable) { super(s, throwable); } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidator.java b/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidator.java index c9c372b8..59d26f65 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidator.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidator.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,7 +23,8 @@ import javax.xml.transform.Source; import org.xml.sax.SAXParseException; /** - * Simple processor that validates a given {@link Source}. Can be created via the {@link XmlValidatorFactory}. + * Simple processor that validates a given {@link Source}. Can be created via the + * {@link XmlValidatorFactory}. *

* Instances of this class are designed to be thread safe. * @@ -34,9 +35,9 @@ import org.xml.sax.SAXParseException; public interface XmlValidator { /** - * Validates the given {@link Source}, and returns an array of {@link SAXParseException}s as result. The array will be - * empty if no validation errors are found. - * + * Validates the given {@link Source}, and returns an array of + * {@link SAXParseException}s as result. The array will be empty if no validation + * errors are found. * @param source the input document * @return an array of {@code SAXParseException}s * @throws IOException if the {@code source} cannot be read @@ -45,11 +46,12 @@ public interface XmlValidator { SAXParseException[] validate(Source source) throws IOException; /** - * Validates the given {@link Source} and {@link ValidationErrorHandler}, and returns an array of - * {@link SAXParseException}s as result. The array will be empty if no validation errors are found. - * + * Validates the given {@link Source} and {@link ValidationErrorHandler}, and returns + * an array of {@link SAXParseException}s as result. The array will be empty if no + * validation errors are found. * @param source the input document - * @param errorHandler the error handler to use. May be {@code null}, in which case a default will be used. + * @param errorHandler the error handler to use. May be {@code null}, in which case a + * default will be used. * @return an array of {@code SAXParseException}s * @throws IOException if the {@code source} cannot be read * @throws XmlValidationException if the {@code source} cannot be validated diff --git a/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidatorFactory.java b/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidatorFactory.java index 5cff38ef..e56e8270 100644 --- a/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidatorFactory.java +++ b/spring-xml/src/main/java/org/springframework/xml/validation/XmlValidatorFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,16 +22,18 @@ import javax.xml.validation.Validator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.core.io.Resource; import org.springframework.util.Assert; import org.springframework.xml.JaxpVersion; /** - * Factory for {@link XmlValidator} objects, being aware of JAXP 1.3 {@link Validator}s, and JAXP 1.0 parsing - * capabilities. Mainly for internal use within the framework. + * Factory for {@link XmlValidator} objects, being aware of JAXP 1.3 {@link Validator}s, + * and JAXP 1.0 parsing capabilities. Mainly for internal use within the framework. *

- * The goal of this class is to avoid runtime dependencies on JAXP 1.3 by using the best validation implementation that - * is available. Prefers JAXP 1.3 {@link XmlValidator} implementations to a custom, SAX-based implementation. + * The goal of this class is to avoid runtime dependencies on JAXP 1.3 by using the best + * validation implementation that is available. Prefers JAXP 1.3 {@link XmlValidator} + * implementations to a custom, SAX-based implementation. * * @author Arjen Poutsma * @see XmlValidator @@ -48,9 +50,8 @@ public abstract class XmlValidatorFactory { public static final String SCHEMA_RELAX_NG = "http://relaxng.org/ns/structure/1.0"; /** - * Create a {@link XmlValidator} with the given schema resource and schema language type. The schema language must be - * one of the {@code SCHEMA_XXX} constants. - * + * Create a {@link XmlValidator} with the given schema resource and schema language + * type. The schema language must be one of the {@code SCHEMA_XXX} constants. * @param schemaResource a resource that locates the schema to validate against * @param schemaLanguage the language of the schema * @return a validator @@ -66,10 +67,10 @@ public abstract class XmlValidatorFactory { } /** - * Create a {@link XmlValidator} with the given schema resources and schema language type. The schema language must be - * one of the {@code SCHEMA_XXX} constants. - * - * @param schemaResources an array of resource that locate the schemas to validate against + * Create a {@link XmlValidator} with the given schema resources and schema language + * type. The schema language must be one of the {@code SCHEMA_XXX} constants. + * @param schemaResources an array of resource that locate the schemas to validate + * against * @param schemaLanguage the language of the schemas * @return a validator * @throws IOException if the schema resource cannot be read @@ -91,10 +92,12 @@ public abstract class XmlValidatorFactory { if (JaxpVersion.getJaxpVersion() >= JaxpVersion.JAXP_15) { logger.trace("Creating JAXP 1.5 XmlValidator"); return Jaxp15ValidatorFactory.createValidator(schemaResources, schemaLanguage); - } else if (JaxpVersion.getJaxpVersion() >= JaxpVersion.JAXP_13) { + } + else if (JaxpVersion.getJaxpVersion() >= JaxpVersion.JAXP_13) { logger.trace("Creating JAXP 1.3 XmlValidator"); return Jaxp13ValidatorFactory.createValidator(schemaResources, schemaLanguage); - } else { + } + else { throw new IllegalStateException("Could not locate JAXP 1.3."); } } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/AbstractXPathTemplate.java b/spring-xml/src/main/java/org/springframework/xml/xpath/AbstractXPathTemplate.java index 79e157c1..4037aacb 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/AbstractXPathTemplate.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/AbstractXPathTemplate.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -22,14 +22,16 @@ import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; -import org.springframework.xml.transform.TransformerObjectSupport; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.springframework.xml.transform.TransformerObjectSupport; + /** - * Abstract base class for implementations of {@link XPathOperations}. Contains a namespaces property. + * Abstract base class for implementations of {@link XPathOperations}. Contains a + * namespaces property. * * @author Arjen Poutsma * @since 1.0.0 @@ -54,7 +56,10 @@ public abstract class AbstractXPathTemplate extends TransformerObjectSupport imp evaluate(expression, context, new NodeCallbackHandlerNodeMapper(callbackHandler)); } - /** Static inner class that adapts a {@link NodeCallbackHandler} to the interface of {@link NodeMapper}. */ + /** + * Static inner class that adapts a {@link NodeCallbackHandler} to the interface of + * {@link NodeMapper}. + */ private static class NodeCallbackHandlerNodeMapper implements NodeMapper { private final NodeCallbackHandler callbackHandler; @@ -68,11 +73,11 @@ public abstract class AbstractXPathTemplate extends TransformerObjectSupport imp callbackHandler.processNode(node); return null; } + } /** * Returns the root element of the given source. - * * @param source the source to get the root element from * @return the root element */ diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathExpressionFactory.java b/spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathExpressionFactory.java index acd1f820..bdb4ebd6 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathExpressionFactory.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathExpressionFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -39,7 +39,6 @@ abstract class JaxenXPathExpressionFactory { /** * Creates a Jaxen {@code XPathExpression} from the given string expression. - * * @param expression the XPath expression * @return the compiled {@code XPathExpression} * @throws XPathParseException when the given expression cannot be parsed @@ -48,15 +47,16 @@ abstract class JaxenXPathExpressionFactory { try { XPath xpath = new DOMXPath(expression); return new JaxenXpathExpression(xpath, expression); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new org.springframework.xml.xpath.XPathParseException( "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex); } } /** - * Creates a Jaxen {@code XPathExpression} from the given string expression and prefixes. - * + * Creates a Jaxen {@code XPathExpression} from the given string expression and + * prefixes. * @param expression the XPath expression * @param namespaces the namespaces * @return the compiled {@code XPathExpression} @@ -67,7 +67,8 @@ abstract class JaxenXPathExpressionFactory { XPath xpath = new DOMXPath(expression); xpath.setNamespaceContext(new SimpleNamespaceContext(namespaces)); return new JaxenXpathExpression(xpath, expression); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new org.springframework.xml.xpath.XPathParseException( "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex); } @@ -77,6 +78,7 @@ abstract class JaxenXPathExpressionFactory { private static class JaxenXpathExpression implements XPathExpression { private XPath xpath; + private final String expression; private JaxenXpathExpression(XPath xpath, String expression) { @@ -93,7 +95,8 @@ abstract class JaxenXPathExpressionFactory { public Node evaluateAsNode(Node node) { try { return (Node) xpath.selectSingleNode(node); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + xpath + "] :" + ex.getMessage(), ex); } } @@ -102,7 +105,8 @@ abstract class JaxenXPathExpressionFactory { public boolean evaluateAsBoolean(Node node) { try { return xpath.booleanValueOf(node); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + xpath + "] :" + ex.getMessage(), ex); } } @@ -111,7 +115,8 @@ abstract class JaxenXPathExpressionFactory { public double evaluateAsNumber(Node node) { try { return xpath.numberValueOf(node).doubleValue(); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + xpath + "] :" + ex.getMessage(), ex); } } @@ -120,7 +125,8 @@ abstract class JaxenXPathExpressionFactory { public String evaluateAsString(Node node) { try { return xpath.stringValueOf(node); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + xpath + "] :" + ex.getMessage(), ex); } } @@ -130,7 +136,8 @@ abstract class JaxenXPathExpressionFactory { public List evaluateAsNodeList(Node node) { try { return xpath.selectNodes(node); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + xpath + "] :" + ex.getMessage(), ex); } } @@ -142,13 +149,16 @@ abstract class JaxenXPathExpressionFactory { if (result != null) { try { return nodeMapper.mapNode(result, 0); - } catch (DOMException ex) { + } + catch (DOMException ex) { throw new XPathException("Mapping resulted in DOMException", ex); } - } else { + } + else { return null; } - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + xpath + "] :" + ex.getMessage(), ex); } } @@ -162,14 +172,18 @@ abstract class JaxenXPathExpressionFactory { Node node = (Node) nodes.get(i); try { results.add(nodeMapper.mapNode(node, i)); - } catch (DOMException ex) { + } + catch (DOMException ex) { throw new XPathException("Mapping resulted in DOMException", ex); } } return results; - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + xpath + "] :" + ex.getMessage(), ex); } } + } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathTemplate.java b/spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathTemplate.java index 8f4d45a8..3b648b01 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathTemplate.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathTemplate.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -47,9 +47,11 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate { XPath xpath = createXPath(expression); Element element = getRootElement(context); return xpath.booleanValueOf(element); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + expression + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XPathException("Could not transform context to DOM Node", ex); } } @@ -60,9 +62,11 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate { XPath xpath = createXPath(expression); Element element = getRootElement(context); return (Node) xpath.selectSingleNode(element); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + expression + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XPathException("Could not transform context to DOM Node", ex); } } @@ -74,9 +78,11 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate { XPath xpath = createXPath(expression); Element element = getRootElement(context); return xpath.selectNodes(element); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + expression + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XPathException("Could not transform context to DOM Node", ex); } } @@ -87,9 +93,11 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate { XPath xpath = createXPath(expression); Element element = getRootElement(context); return xpath.numberValueOf(element).doubleValue(); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + expression + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XPathException("Could not transform context to DOM Node", ex); } } @@ -100,9 +108,11 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate { XPath xpath = createXPath(expression); Element element = getRootElement(context); return xpath.stringValueOf(element); - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + expression + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XPathException("Could not transform context to DOM Node", ex); } } @@ -116,16 +126,20 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate { if (node != null) { try { return nodeMapper.mapNode(node, 0); - } catch (DOMException ex) { + } + catch (DOMException ex) { throw new XPathException("Mapping resulted in DOMException", ex); } - } else { + } + else { return null; } - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + expression + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XPathException("Could not transform context to DOM Node", ex); } } @@ -141,14 +155,17 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate { Node node = (Node) nodes.get(i); try { results.add(nodeMapper.mapNode(node, i)); - } catch (DOMException ex) { + } + catch (DOMException ex) { throw new XPathException("Mapping resulted in DOMException", ex); } } return results; - } catch (JaxenException ex) { + } + catch (JaxenException ex) { throw new XPathException("Could not evaluate XPath expression [" + expression + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XPathException("Could not transform context to DOM Node", ex); } } @@ -160,4 +177,5 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate { } return xpath; } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactory.java b/spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactory.java index e93f41bc..2c0e72a6 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactory.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,11 +26,12 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; -import org.springframework.xml.namespace.SimpleNamespaceContext; import org.w3c.dom.DOMException; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.springframework.xml.namespace.SimpleNamespaceContext; + /** * JAXP 1.3-specific factory creating {@link XPathExpression} objects. * @@ -45,7 +46,6 @@ abstract class Jaxp13XPathExpressionFactory { /** * Creates a JAXP 1.3 {@code XPathExpression} from the given string expression. - * * @param expression the XPath expression * @return the compiled {@code XPathExpression} * @throws XPathParseException when the given expression cannot be parsed @@ -55,15 +55,16 @@ abstract class Jaxp13XPathExpressionFactory { XPath xpath = createXPath(); javax.xml.xpath.XPathExpression xpathExpression = xpath.compile(expression); return new Jaxp13XPathExpression(xpathExpression, expression); - } catch (XPathExpressionException ex) { + } + catch (XPathExpressionException ex) { throw new org.springframework.xml.xpath.XPathParseException( "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex); } } /** - * Creates a JAXP 1.3 {@code XPathExpression} from the given string expression and namespaces. - * + * Creates a JAXP 1.3 {@code XPathExpression} from the given string expression and + * namespaces. * @param expression the XPath expression * @param namespaces the namespaces * @return the compiled {@code XPathExpression} @@ -77,7 +78,8 @@ abstract class Jaxp13XPathExpressionFactory { xpath.setNamespaceContext(namespaceContext); javax.xml.xpath.XPathExpression xpathExpression = xpath.compile(expression); return new Jaxp13XPathExpression(xpathExpression, expression); - } catch (XPathExpressionException ex) { + } + catch (XPathExpressionException ex) { throw new org.springframework.xml.xpath.XPathParseException( "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex); } @@ -91,6 +93,7 @@ abstract class Jaxp13XPathExpressionFactory { private static class Jaxp13XPathExpression implements XPathExpression { private final javax.xml.xpath.XPathExpression xpathExpression; + private final String expression; private Jaxp13XPathExpression(javax.xml.xpath.XPathExpression xpathExpression, String expression) { @@ -120,7 +123,8 @@ abstract class Jaxp13XPathExpressionFactory { synchronized (xpathExpression) { return xpathExpression.evaluate(node, returnType); } - } catch (XPathExpressionException ex) { + } + catch (XPathExpressionException ex) { throw new XPathException("Could not evaluate XPath expression:" + ex.getMessage(), ex); } } @@ -154,10 +158,12 @@ abstract class Jaxp13XPathExpressionFactory { if (result != null) { try { return nodeMapper.mapNode(result, 0); - } catch (DOMException ex) { + } + catch (DOMException ex) { throw new XPathException("Mapping resulted in DOMException", ex); } - } else { + } + else { return null; } } @@ -169,12 +175,14 @@ abstract class Jaxp13XPathExpressionFactory { for (int i = 0; i < nodes.getLength(); i++) { try { results.add(nodeMapper.mapNode(nodes.item(i), i)); - } catch (DOMException ex) { + } + catch (DOMException ex) { throw new XPathException("Mapping resulted in DOMException", ex); } } return results; } + } } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathTemplate.java b/spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathTemplate.java index e253369a..075b6815 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathTemplate.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathTemplate.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,10 +34,6 @@ import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactoryConfigurationException; -import org.springframework.util.xml.StaxUtils; -import org.springframework.xml.namespace.SimpleNamespaceContext; -import org.springframework.xml.transform.TransformerHelper; -import org.springframework.xml.transform.TraxUtils; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -46,8 +42,14 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; +import org.springframework.util.xml.StaxUtils; +import org.springframework.xml.namespace.SimpleNamespaceContext; +import org.springframework.xml.transform.TransformerHelper; +import org.springframework.xml.transform.TraxUtils; + /** - * Implementation of {@link XPathOperations} that uses JAXP 1.3. JAXP 1.3 is part of Java SE since 1.5. + * Implementation of {@link XPathOperations} that uses JAXP 1.3. JAXP 1.3 is part of Java + * SE since 1.5. *

* Namespaces can be set using the {@code namespaces} property. * @@ -66,7 +68,8 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate { public Jaxp13XPathTemplate(String xpathFactoryUri) { try { xpathFactory = XPathFactory.newInstance(xpathFactoryUri); - } catch (XPathFactoryConfigurationException ex) { + } + catch (XPathFactoryConfigurationException ex) { throw new XPathException("Could not create XPathFactory", ex); } } @@ -109,10 +112,12 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate { if (node != null) { try { return nodeMapper.mapNode(node, 0); - } catch (DOMException ex) { + } + catch (DOMException ex) { throw new XPathException("Mapping resulted in DOMException", ex); } - } else { + } + else { return null; } } @@ -124,7 +129,8 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate { for (int i = 0; i < nodes.getLength(); i++) { try { results.add(nodeMapper.mapNode(nodes.item(i), i)); - } catch (DOMException ex) { + } + catch (DOMException ex) { throw new XPathException("Mapping resulted in DOMException", ex); } } @@ -142,11 +148,14 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate { EvaluationCallback callback = new EvaluationCallback(xpath, expression, returnType); TraxUtils.doWithSource(context, callback); return callback.result; - } catch (javax.xml.xpath.XPathException ex) { + } + catch (javax.xml.xpath.XPathException ex) { throw new XPathException("Could not evaluate XPath expression [" + expression + "]", ex); - } catch (TransformerException ex) { + } + catch (TransformerException ex) { throw new XPathException("Could not transform context to DOM Node", ex); - } catch (Exception ex) { + } + catch (Exception ex) { throw new XPathException(ex.getMessage(), ex); } } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/NodeCallbackHandler.java b/spring-xml/src/main/java/org/springframework/xml/xpath/NodeCallbackHandler.java index 4644a645..33484cd3 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/NodeCallbackHandler.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/NodeCallbackHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,12 +20,12 @@ import org.w3c.dom.DOMException; import org.w3c.dom.Node; /** - * An interface used by {@link XPathOperations} implementations for processing {@link Node} objects on a per-node basis. - * Implementations of this interface perform the actual work of processing nodes, but don't need to worry about - * exception handling. + * An interface used by {@link XPathOperations} implementations for processing + * {@link Node} objects on a per-node basis. Implementations of this interface perform the + * actual work of processing nodes, but don't need to worry about exception handling. *

- * Consider using a {@link NodeMapper} instead if you need to map exactly result object per node, assembling them in a - * List. + * Consider using a {@link NodeMapper} instead if you need to map exactly result object + * per node, assembling them in a List. * * @author Arjen Poutsma * @see XPathOperations#evaluate(String,javax.xml.transform.Source,NodeCallbackHandler) @@ -35,7 +35,6 @@ public interface NodeCallbackHandler { /** * Processed a single node. - * * @param node the node to map * @throws DOMException in case of DOM errors */ diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/NodeMapper.java b/spring-xml/src/main/java/org/springframework/xml/xpath/NodeMapper.java index 9e029d62..1e11d19d 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/NodeMapper.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/NodeMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -20,9 +20,10 @@ import org.w3c.dom.DOMException; import org.w3c.dom.Node; /** - * An interface used by {@link XPathOperations} implementations for mapping {@link Node} objects on a per-node basis. - * Implementations of this interface perform the actual work of mapping each node to a result object, but don't need to - * worry about exception handling. + * An interface used by {@link XPathOperations} implementations for mapping {@link Node} + * objects on a per-node basis. Implementations of this interface perform the actual work + * of mapping each node to a result object, but don't need to worry about exception + * handling. * * @author Arjen Poutsma * @see XPathOperations#evaluate(String,javax.xml.transform.Source,NodeMapper) @@ -35,7 +36,6 @@ public interface NodeMapper { /** * Maps a single node to an arbitrary object. - * * @param node the node to map * @param nodeNum the number of the current node * @return object for the current node diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathException.java b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathException.java index 104bb342..c9e45a4c 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathException.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -28,8 +28,8 @@ import org.springframework.xml.XmlException; public class XPathException extends XmlException { /** - * Constructs a new instance of the {@code XPathException} with the specific detail message. - * + * Constructs a new instance of the {@code XPathException} with the specific detail + * message. * @param message the detail message */ public XPathException(String message) { @@ -37,12 +37,13 @@ public class XPathException extends XmlException { } /** - * Constructs a new instance of the {@code XPathException} with the specific detail message and exception. - * + * Constructs a new instance of the {@code XPathException} with the specific detail + * message and exception. * @param message the detail message * @param throwable the wrapped exception */ public XPathException(String message, Throwable throwable) { super(message, throwable); } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpression.java b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpression.java index 58459a73..cd4babfa 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpression.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpression.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,11 +21,11 @@ import java.util.List; import org.w3c.dom.Node; /** - * Defines the contract for a precompiled XPath expression. Concrete instances can be obtained through the - * {@link XPathExpressionFactory}. + * Defines the contract for a precompiled XPath expression. Concrete instances can be + * obtained through the {@link XPathExpressionFactory}. *

- * Implementations of this interface are precompiled, and thus faster, but less flexible, than the XPath expressions - * used by {@link XPathOperations} implementations. + * Implementations of this interface are precompiled, and thus faster, but less flexible, + * than the XPath expressions used by {@link XPathOperations} implementations. * * @author Arjen Poutsma * @since 1.0.0 @@ -33,26 +33,26 @@ import org.w3c.dom.Node; public interface XPathExpression { /** - * Evaluates the given expression as a {@code boolean}. Returns the boolean evaluation of the expression, or - * {@code false} if it is invalid. + * Evaluates the given expression as a {@code boolean}. Returns the boolean evaluation + * of the expression, or {@code false} if it is invalid. *

- * The return value is determined per the {@code boolean()} function defined in the XPath specification. This means - * that an expression that selects zero nodes will return {@code false}, while an expression that selects one or more - * nodes will return {@code true}. An expression that returns a string returns {@code false} for empty strings and - * {@code true} for all other strings. An expression that returns a number returns {@code false} for zero and - * {@code true} for non-zero numbers. - * + * The return value is determined per the {@code boolean()} function defined in the + * XPath specification. This means that an expression that selects zero nodes will + * return {@code false}, while an expression that selects one or more nodes will + * return {@code true}. An expression that returns a string returns {@code false} for + * empty strings and {@code true} for all other strings. An expression that returns a + * number returns {@code false} for zero and {@code true} for non-zero numbers. * @param node the starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors - * @see XPath specification - boolean() function + * @see XPath specification - + * boolean() function */ boolean evaluateAsBoolean(Node node) throws XPathException; /** - * Evaluates the given expression as a {@link Node}. Returns the evaluation of the expression, or {@code null} if it - * is invalid. - * + * Evaluates the given expression as a {@link Node}. Returns the evaluation of the + * expression, or {@code null} if it is invalid. * @param node the starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors @@ -61,9 +61,8 @@ public interface XPathExpression { Node evaluateAsNode(Node node) throws XPathException; /** - * Evaluates the given expression, and returns all {@link Node} objects that conform to it. Returns an empty list if - * no result could be found. - * + * Evaluates the given expression, and returns all {@link Node} objects that conform + * to it. Returns an empty list if no result could be found. * @param node the starting point * @return a list of {@code Node}s that are selected by the expression * @throws XPathException in case of XPath errors @@ -72,35 +71,38 @@ public interface XPathExpression { List evaluateAsNodeList(Node node) throws XPathException; /** - * Evaluates the given expression as a number ({@code double}). Returns the numeric evaluation of the expression, or - * {@link Double#NaN} if it is invalid. + * Evaluates the given expression as a number ({@code double}). Returns the numeric + * evaluation of the expression, or {@link Double#NaN} if it is invalid. *

- * The return value is determined per the {@code number()} function as defined in the XPath specification. This means - * that if the expression selects multiple nodes, it will return the number value of the first node. - * + * The return value is determined per the {@code number()} function as defined in the + * XPath specification. This means that if the expression selects multiple nodes, it + * will return the number value of the first node. * @param node the starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors - * @see XPath specification - number() function + * @see XPath specification - + * number() function */ double evaluateAsNumber(Node node) throws XPathException; /** - * Evaluates the given expression as a String. Returns {@code null} if no result could be found. + * Evaluates the given expression as a String. Returns {@code null} if no result could + * be found. *

- * The return value is determined per the {@code string()} function as defined in the XPath specification. This means - * that if the expression selects multiple nodes, it will return the string value of the first node. - * + * The return value is determined per the {@code string()} function as defined in the + * XPath specification. This means that if the expression selects multiple nodes, it + * will return the string value of the first node. * @param node the starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors - * @see XPath specification - string() function + * @see XPath specification - + * string() function */ String evaluateAsString(Node node) throws XPathException; /** - * Evaluates the given expression, mapping a single {@link Node} result to a Java object via a {@link NodeMapper}. - * + * Evaluates the given expression, mapping a single {@link Node} result to a Java + * object via a {@link NodeMapper}. * @param node the starting point * @param nodeMapper object that will map one object per node * @return the single mapped object @@ -110,8 +112,8 @@ public interface XPathExpression { T evaluateAsObject(Node node, NodeMapper nodeMapper) throws XPathException; /** - * Evaluates the given expression, mapping each result {@link Node} objects to a Java object via a {@link NodeMapper}. - * + * Evaluates the given expression, mapping each result {@link Node} objects to a Java + * object via a {@link NodeMapper}. * @param node the starting point * @param nodeMapper object that will map one object per node * @return the result list, containing mapped objects @@ -119,4 +121,5 @@ public interface XPathExpression { * @see XPath specification */ List evaluate(Node node, NodeMapper nodeMapper) throws XPathException; + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactory.java b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactory.java index ee074e4d..c5360ea7 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactory.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -21,14 +21,16 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.util.Assert; /** - * Factory for compiled {@code XPathExpression}s, being aware of JAXP 1.3+ XPath functionality, and Jaxen. Mainly for - * internal use of the framework. + * Factory for compiled {@code XPathExpression}s, being aware of JAXP 1.3+ XPath + * functionality, and Jaxen. Mainly for internal use of the framework. *

- * The goal of this class is to avoid runtime dependencies a specific XPath engine, simply using the best XPath - * implementation that is available. Prefers JAXP 1.3+ XPath implementations to Jaxen. + * The goal of this class is to avoid runtime dependencies a specific XPath engine, simply + * using the best XPath implementation that is available. Prefers JAXP 1.3+ XPath + * implementations to Jaxen. * * @author Arjen Poutsma * @see XPathExpression @@ -40,7 +42,6 @@ public abstract class XPathExpressionFactory { /** * Create a compiled XPath expression using the given string. - * * @param expression the XPath expression * @return the compiled XPath expression * @throws IllegalStateException if neither JAXP 1.3+, or Jaxen are available @@ -48,13 +49,12 @@ public abstract class XPathExpressionFactory { */ public static XPathExpression createXPathExpression(String expression) throws IllegalStateException, XPathParseException { - return createXPathExpression(expression, Collections. emptyMap()); + return createXPathExpression(expression, Collections.emptyMap()); } /** - * Create a compiled XPath expression using the given string and namespaces. The namespace map should consist of - * string prefixes mapped to string namespaces. - * + * Create a compiled XPath expression using the given string and namespaces. The + * namespace map should consist of string prefixes mapped to string namespaces. * @param expression the XPath expression * @param namespaces a map that binds string prefixes to string namespaces * @return the compiled XPath expression @@ -70,7 +70,8 @@ public abstract class XPathExpressionFactory { try { logger.trace("Creating [javax.xml.xpath.XPathExpression]"); return Jaxp13XPathExpressionFactory.createXPathExpression(expression, namespaces); - } catch (XPathException e) { + } + catch (XPathException e) { throw e; } } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactoryBean.java b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactoryBean.java index 291a3adf..52c1c9d1 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactoryBean.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactoryBean.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -24,10 +24,11 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; /** - * Spring {@link FactoryBean} for {@link XPathExpression} object. Facilitates injection of XPath expressions into - * endpoint beans. + * Spring {@link FactoryBean} for {@link XPathExpression} object. Facilitates injection of + * XPath expressions into endpoint beans. *

- * Uses {@link XPathExpressionFactory} underneath, so support is provided for JAXP 1.3, and Jaxen XPaths. + * Uses {@link XPathExpressionFactory} underneath, so support is provided for JAXP 1.3, + * and Jaxen XPaths. * * @author Arjen Poutsma * @see #setExpression(String) @@ -46,7 +47,10 @@ public class XPathExpressionFactoryBean implements FactoryBean, expressionString = expression; } - /** Sets the namespaces for the expressions. The given properties binds string prefixes to string namespaces. */ + /** + * Sets the namespaces for the expressions. The given properties binds string prefixes + * to string namespaces. + */ public void setNamespaces(Map namespaces) { this.namespaces = namespaces; } @@ -56,7 +60,8 @@ public class XPathExpressionFactoryBean implements FactoryBean, Assert.notNull(expressionString, "expression is required"); if (CollectionUtils.isEmpty(namespaces)) { expression = XPathExpressionFactory.createXPathExpression(expressionString); - } else { + } + else { expression = XPathExpressionFactory.createXPathExpression(expressionString, namespaces); } } @@ -75,4 +80,5 @@ public class XPathExpressionFactoryBean implements FactoryBean, public boolean isSingleton() { return true; } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathOperations.java b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathOperations.java index 2550dc86..78df83d7 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathOperations.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathOperations.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -23,12 +23,12 @@ import javax.xml.transform.Source; import org.w3c.dom.Node; /** - * Interface that specifies a basic set of XPath operations, implemented by various XPathTemplates. Contains numerous - * evaluation methods, + * Interface that specifies a basic set of XPath operations, implemented by various + * XPathTemplates. Contains numerous evaluation methods, *

- * The templates that implement this interface do not use precompiled XPath expressions. Consider using the - * {@link XPathExpressionFactory} or the {@link XPathExpressionFactoryBean} for optimal performance, but less - * flexibility. + * The templates that implement this interface do not use precompiled XPath expressions. + * Consider using the {@link XPathExpressionFactory} or the + * {@link XPathExpressionFactoryBean} for optimal performance, but less flexibility. * * @author Arjen Poutsma * @see Jaxp13XPathTemplate @@ -38,27 +38,27 @@ import org.w3c.dom.Node; public interface XPathOperations { /** - * Evaluates the given expression as a {@code boolean}. Returns the boolean evaluation of the expression, or - * {@code false} if it is invalid. + * Evaluates the given expression as a {@code boolean}. Returns the boolean evaluation + * of the expression, or {@code false} if it is invalid. *

- * The return value is determined per the {@code boolean()} function defined in the XPath specification. This means - * that an expression that selects zero nodes will return {@code false}, while an expression that selects one or more - * nodes will return {@code true}. An expression that returns a string returns {@code false} for empty strings and - * {@code true} for all other strings. An expression that returns a number returns {@code false} for zero and - * {@code true} for non-zero numbers. - * + * The return value is determined per the {@code boolean()} function defined in the + * XPath specification. This means that an expression that selects zero nodes will + * return {@code false}, while an expression that selects one or more nodes will + * return {@code true}. An expression that returns a string returns {@code false} for + * empty strings and {@code true} for all other strings. An expression that returns a + * number returns {@code false} for zero and {@code true} for non-zero numbers. * @param expression the XPath expression * @param context the context starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors - * @see XPath specification - boolean() function + * @see XPath specification - + * boolean() function */ boolean evaluateAsBoolean(String expression, Source context) throws XPathException; /** - * Evaluates the given expression as a {@link Node}. Returns the evaluation of the expression, or {@code null} if it - * is invalid. - * + * Evaluates the given expression as a {@link Node}. Returns the evaluation of the + * expression, or {@code null} if it is invalid. * @param expression the XPath expression * @param context the context starting point * @return the result of the evaluation @@ -68,9 +68,8 @@ public interface XPathOperations { Node evaluateAsNode(String expression, Source context) throws XPathException; /** - * Evaluates the given expression as a list of {@link Node} objects. Returns the evaluation of the expression, or an - * empty list if no results are found. - * + * Evaluates the given expression as a list of {@link Node} objects. Returns the + * evaluation of the expression, or an empty list if no results are found. * @param expression the XPath expression * @param context the context starting point * @return the result of the evaluation @@ -80,38 +79,40 @@ public interface XPathOperations { List evaluateAsNodeList(String expression, Source context) throws XPathException; /** - * Evaluates the given expression as a {@code double}. Returns the evaluation of the expression, or {@link Double#NaN} - * if it is invalid. + * Evaluates the given expression as a {@code double}. Returns the evaluation of the + * expression, or {@link Double#NaN} if it is invalid. *

- * The return value is determined per the {@code number()} function as defined in the XPath specification. This means - * that if the expression selects multiple nodes, it will return the number value of the first node. - * + * The return value is determined per the {@code number()} function as defined in the + * XPath specification. This means that if the expression selects multiple nodes, it + * will return the number value of the first node. * @param expression the XPath expression * @param context the context starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors - * @see XPath specification - number() function + * @see XPath specification - + * number() function */ double evaluateAsDouble(String expression, Source context) throws XPathException; /** - * Evaluates the given expression as a {@link String}. Returns the evaluation of the expression, or {@code null} if it - * is invalid. + * Evaluates the given expression as a {@link String}. Returns the evaluation of the + * expression, or {@code null} if it is invalid. *

- * The return value is determined per the {@code string()} function as defined in the XPath specification. This means - * that if the expression selects multiple nodes, it will return the string value of the first node. - * + * The return value is determined per the {@code string()} function as defined in the + * XPath specification. This means that if the expression selects multiple nodes, it + * will return the string value of the first node. * @param expression the XPath expression * @param context the context starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors - * @see XPath specification - string() function + * @see XPath specification - + * string() function */ String evaluateAsString(String expression, Source context) throws XPathException; /** - * Evaluates the given expression, mapping a single {@link Node} result to a Java object via a {@link NodeMapper}. - * + * Evaluates the given expression, mapping a single {@link Node} result to a Java + * object via a {@link NodeMapper}. * @param expression the XPath expression * @param context the context starting point * @param nodeMapper object that will map one object per node @@ -122,8 +123,8 @@ public interface XPathOperations { T evaluateAsObject(String expression, Source context, NodeMapper nodeMapper) throws XPathException; /** - * Evaluates the given expression, mapping each result {@link Node} objects to a Java object via a {@link NodeMapper}. - * + * Evaluates the given expression, mapping each result {@link Node} objects to a Java + * object via a {@link NodeMapper}. * @param expression the XPath expression * @param context the context starting point * @param nodeMapper object that will map one object per node @@ -134,9 +135,8 @@ public interface XPathOperations { List evaluate(String expression, Source context, NodeMapper nodeMapper) throws XPathException; /** - * Evaluates the given expression, handling the result {@link Node} objects on a per-node basis with a - * {@link NodeCallbackHandler}. - * + * Evaluates the given expression, handling the result {@link Node} objects on a + * per-node basis with a {@link NodeCallbackHandler}. * @param expression the XPath expression * @param context the context starting point * @param callbackHandler object that will extract results, one row at a time @@ -144,4 +144,5 @@ public interface XPathOperations { * @see XPath specification */ void evaluate(String expression, Source context, NodeCallbackHandler callbackHandler) throws XPathException; + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathParseException.java b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathParseException.java index 30bafb00..d3f63929 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xpath/XPathParseException.java +++ b/spring-xml/src/main/java/org/springframework/xml/xpath/XPathParseException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,8 +26,8 @@ package org.springframework.xml.xpath; public class XPathParseException extends XPathException { /** - * Constructs a new instance of the {@code XPathParseException} with the specific detail message. - * + * Constructs a new instance of the {@code XPathParseException} with the specific + * detail message. * @param message the detail message */ public XPathParseException(String message) { @@ -35,12 +35,13 @@ public class XPathParseException extends XPathException { } /** - * Constructs a new instance of the {@code XPathParseException} with the specific detail message and exception. - * + * Constructs a new instance of the {@code XPathParseException} with the specific + * detail message and exception. * @param message the detail message * @param throwable the wrapped exception */ public XPathParseException(String message, Throwable throwable) { super(message, throwable); } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xsd/SimpleXsdSchema.java b/spring-xml/src/main/java/org/springframework/xml/xsd/SimpleXsdSchema.java index 6f268d44..d749b770 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xsd/SimpleXsdSchema.java +++ b/spring-xml/src/main/java/org/springframework/xml/xsd/SimpleXsdSchema.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -25,6 +25,10 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -32,15 +36,12 @@ import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.sax.SaxUtils; import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.validation.XmlValidatorFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; /** * The default {@link XsdSchema} implementation. *

- * Allows a XSD to be set by the {@link #setXsd(Resource)}, or directly in the {@link #SimpleXsdSchema(Resource) - * constructor}. + * Allows a XSD to be set by the {@link #setXsd(Resource)}, or directly in the + * {@link #SimpleXsdSchema(Resource) constructor}. * * @author Mark LaFond * @author Arjen Poutsma @@ -68,13 +69,15 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean { *

* A subsequent call to the {@link #setXsd(Resource)} method is required. */ - public SimpleXsdSchema() {} + public SimpleXsdSchema() { + } /** - * Create a new instance of the {@link SimpleXsdSchema} class with the specified resource. - * + * Create a new instance of the {@link SimpleXsdSchema} class with the specified + * resource. * @param xsdResource the XSD resource; must not be {@code null} - * @throws IllegalArgumentException if the supplied {@code xsdResource} is {@code null} + * @throws IllegalArgumentException if the supplied {@code xsdResource} is + * {@code null} */ public SimpleXsdSchema(Resource xsdResource) { Assert.notNull(xsdResource, "xsdResource must not be null"); @@ -82,8 +85,8 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean { } /** - * Set the XSD resource to be exposed by calls to this instances' {@link #getSource()} method. - * + * Set the XSD resource to be exposed by calls to this instances' {@link #getSource()} + * method. * @param xsdResource the XSD resource */ public void setXsd(Resource xsdResource) { @@ -108,7 +111,8 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean { public XmlValidator createValidator() { try { return XmlValidatorFactory.createValidator(xsdResource, XmlValidatorFactory.SCHEMA_W3C_XML); - } catch (IOException ex) { + } + catch (IOException ex) { throw new XsdSchemaException(ex.getMessage(), ex); } } diff --git a/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchema.java b/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchema.java index 54ae9bdd..b80f7e82 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchema.java +++ b/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchema.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,22 +31,20 @@ public interface XsdSchema { /** * Returns the target namespace of this schema. - * * @return the target namespace */ String getTargetNamespace(); /** * Returns the {@link Source} of the schema. - * * @return the source of this XSD schema */ Source getSource(); /** * Creates a {@link XmlValidator} based on the schema. - * * @return a validator for this schema */ XmlValidator createValidator(); + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchemaCollection.java b/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchemaCollection.java index 761c40d3..9824f295 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchemaCollection.java +++ b/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchemaCollection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -28,14 +28,12 @@ public interface XsdSchemaCollection { /** * Returns all schemas contained in this collection. - * * @return the schemas contained in this collection */ XsdSchema[] getXsdSchemas(); /** * Creates a {@link XmlValidator} based on the schemas contained in this collection. - * * @return a validator for this collection */ XmlValidator createValidator(); diff --git a/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchemaException.java b/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchemaException.java index a172d633..082bee79 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchemaException.java +++ b/spring-xml/src/main/java/org/springframework/xml/xsd/XsdSchemaException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -35,4 +35,5 @@ public class XsdSchemaException extends XmlException { public XsdSchemaException(String message, Throwable throwable) { super(message, throwable); } + } diff --git a/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchema.java b/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchema.java index c268c38c..cc447548 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchema.java +++ b/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchema.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -31,6 +31,8 @@ import javax.xml.transform.stream.StreamSource; import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaCollection; import org.apache.ws.commons.schema.XmlSchemaSerializer; +import org.w3c.dom.Document; + import org.springframework.beans.BeanInstantiationException; import org.springframework.beans.BeanUtils; import org.springframework.core.io.Resource; @@ -39,10 +41,10 @@ import org.springframework.util.Assert; import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.validation.XmlValidatorFactory; import org.springframework.xml.xsd.XsdSchema; -import org.w3c.dom.Document; /** - * Implementation of the {@link XsdSchema} interface that uses Apache WS-Commons XML Schema. + * Implementation of the {@link XsdSchema} interface that uses Apache WS-Commons XML + * Schema. * * @author Arjen Poutsma * @see Commons XML Schema @@ -55,8 +57,8 @@ public class CommonsXsdSchema implements XsdSchema { private final XmlSchemaCollection collection; /** - * Create a new instance of the {@code CommonsXsdSchema} class with the specified {@link XmlSchema} reference. - * + * Create a new instance of the {@code CommonsXsdSchema} class with the specified + * {@link XmlSchema} reference. * @param schema the Commons {@code XmlSchema} object; must not be {@code null} * @throws IllegalArgumentException if the supplied {@code schema} is {@code null} */ @@ -65,11 +67,11 @@ public class CommonsXsdSchema implements XsdSchema { } /** - * Create a new instance of the {@code CommonsXsdSchema} class with the specified {@link XmlSchema} and - * {@link XmlSchemaCollection} reference. - * + * Create a new instance of the {@code CommonsXsdSchema} class with the specified + * {@link XmlSchema} and {@link XmlSchemaCollection} reference. * @param schema the Commons {@code XmlSchema} object; must not be {@code null} - * @param collection the Commons {@code XmlSchemaCollection} object; can be {@code null} + * @param collection the Commons {@code XmlSchemaCollection} object; can be + * {@code null} * @throws IllegalArgumentException if the supplied {@code schema} is {@code null} */ protected CommonsXsdSchema(XmlSchema schema, XmlSchemaCollection collection) { @@ -90,7 +92,8 @@ public class CommonsXsdSchema implements XsdSchema { @Override public Source getSource() { - // try to use the package-friendly XmlSchemaSerializer first, fall back to slower stream-based version + // try to use the package-friendly XmlSchemaSerializer first, fall back to slower + // stream-based version try { XmlSchemaSerializer serializer = BeanUtils.instantiateClass(XmlSchemaSerializer.class); if (collection != null) { @@ -98,13 +101,15 @@ public class CommonsXsdSchema implements XsdSchema { } Document[] serializedSchemas = serializer.serializeSchema(schema, false); return new DOMSource(serializedSchemas[0]); - } catch (BeanInstantiationException | XmlSchemaSerializer.XmlSchemaSerializerException ex) { + } + catch (BeanInstantiationException | XmlSchemaSerializer.XmlSchemaSerializerException ex) { // ignore } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { schema.write(bos); - } catch (UnsupportedEncodingException ex) { + } + catch (UnsupportedEncodingException ex) { throw new CommonsXsdSchemaException(ex.getMessage(), ex); } ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); @@ -116,7 +121,8 @@ public class CommonsXsdSchema implements XsdSchema { try { Resource resource = new UrlResource(schema.getSourceURI()); return XmlValidatorFactory.createValidator(resource, XmlValidatorFactory.SCHEMA_W3C_XML); - } catch (IOException ex) { + } + catch (IOException ex) { throw new CommonsXsdSchemaException(ex.getMessage(), ex); } } diff --git a/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java b/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java index 6f974917..dfbf1dcf 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java +++ b/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -32,6 +32,8 @@ import org.apache.ws.commons.schema.XmlSchemaInclude; import org.apache.ws.commons.schema.XmlSchemaObject; import org.apache.ws.commons.schema.resolver.DefaultURIResolver; import org.apache.ws.commons.schema.resolver.URIResolver; +import org.xml.sax.InputSource; + import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.io.Resource; @@ -44,14 +46,15 @@ import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.validation.XmlValidatorFactory; import org.springframework.xml.xsd.XsdSchema; import org.springframework.xml.xsd.XsdSchemaCollection; -import org.xml.sax.InputSource; /** - * Implementation of the {@link XsdSchemaCollection} that uses Apache WS-Commons XML Schema. + * Implementation of the {@link XsdSchemaCollection} that uses Apache WS-Commons XML + * Schema. *

- * Setting the {@link #setInline(boolean) inline} flag to {@code true} will result in all referenced schemas (included - * and imported) being merged into the referred schema. When including the schemas into a WSDL, this greatly simplifies - * the deployment of the schemas. + * Setting the {@link #setInline(boolean) inline} flag to {@code true} will result in all + * referenced schemas (included and imported) being merged into the referred schema. When + * including the schemas into a WSDL, this greatly simplifies the deployment of the + * schemas. * * @author Arjen Poutsma * @see Commons XML Schema @@ -78,11 +81,12 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali *

* A subsequent call to the {@link #setXsds(Resource[])} is required. */ - public CommonsXsdSchemaCollection() {} + public CommonsXsdSchemaCollection() { + } /** - * Constructs a new instance of the {@code CommonsXsdSchemaCollection} based on the given resources. - * + * Constructs a new instance of the {@code CommonsXsdSchemaCollection} based on the + * given resources. * @param resources the schema resources to load */ public CommonsXsdSchemaCollection(Resource... resources) { @@ -91,7 +95,6 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali /** * Sets the schema resources to be loaded. - * * @param xsdResources the schema resources to be loaded */ public void setXsds(Resource... xsdResources) { @@ -110,7 +113,8 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali /** * Sets the WS-Commons uri resolver to use when resolving (relative) schemas. *

- * Default is an internal subclass of {@link DefaultURIResolver} which correctly handles schemas on the classpath. + * Default is an internal subclass of {@link DefaultURIResolver} which correctly + * handles schemas on the classpath. */ public void setUriResolver(URIResolver uriResolver) { Assert.notNull(uriResolver, "'uriResolver' must not be null"); @@ -141,7 +145,8 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali inlineIncludes(xmlSchema, processedIncludes, processedImports); findImports(xmlSchema, processedImports, processedIncludes); } - } catch (Exception ex) { + } + catch (Exception ex) { throw new CommonsXsdSchemaException("Schema [" + xsdResource + "] could not be loaded", ex); } } @@ -173,7 +178,8 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali } } return XmlValidatorFactory.createValidator(resources, XmlValidatorFactory.SCHEMA_W3C_XML); - } catch (IOException ex) { + } + catch (IOException ex) { throw new CommonsXsdSchemaException(ex.getMessage(), ex); } } @@ -205,8 +211,8 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali if (external instanceof XmlSchemaImport) { XmlSchemaImport schemaImport = (XmlSchemaImport) external; XmlSchema importedSchema = schemaImport.getSchema(); - if (!"http://www.w3.org/XML/1998/namespace".equals(schemaImport.getNamespace()) && importedSchema != null - && !processedImports.contains(importedSchema)) { + if (!"http://www.w3.org/XML/1998/namespace".equals(schemaImport.getNamespace()) + && importedSchema != null && !processedImports.contains(importedSchema)) { inlineIncludes(importedSchema, processedIncludes, processedImports); findImports(importedSchema, processedImports, processedIncludes); xmlSchemas.add(importedSchema); @@ -239,7 +245,8 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali Resource resource = resourceLoader.getResource(schemaLocation); if (resource.exists()) { return createInputSource(resource); - } else if (StringUtils.hasLength(baseUri)) { + } + else if (StringUtils.hasLength(baseUri)) { // let's try and find it relative to the baseUri, see SWS-413 try { Resource baseUriResource = new UrlResource(baseUri); @@ -247,7 +254,8 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali if (resource.exists()) { return createInputSource(resource); } - } catch (IOException e) { + } + catch (IOException e) { // fall through } } @@ -264,10 +272,12 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali private InputSource createInputSource(Resource resource) { try { return SaxUtils.createInputSource(resource); - } catch (IOException ex) { + } + catch (IOException ex) { throw new CommonsXsdSchemaException("Could not resolve location", ex); } } + } } diff --git a/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaException.java b/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaException.java index 0519d234..6bcaf14d 100644 --- a/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaException.java +++ b/spring-xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaException.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -34,4 +34,5 @@ public class CommonsXsdSchemaException extends XsdSchemaException { public CommonsXsdSchemaException(String message, Throwable exception) { super(message, exception); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/dom/DomContentHandlerTest.java b/spring-xml/src/test/java/org/springframework/xml/dom/DomContentHandlerTest.java index 4a07f3e5..00c8fb2d 100644 --- a/spring-xml/src/test/java/org/springframework/xml/dom/DomContentHandlerTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/dom/DomContentHandlerTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.xml.dom; -import static org.xmlunit.assertj.XmlAssert.*; - import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; @@ -25,13 +23,16 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.xml.DocumentBuilderFactoryUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; +import org.springframework.xml.DocumentBuilderFactoryUtils; + +import static org.xmlunit.assertj.XmlAssert.assertThat; + public class DomContentHandlerTest { private static final String XML_1 = "" + "" @@ -42,7 +43,8 @@ public class DomContentHandlerTest { private static final String XML_2_EXPECTED = "" + "" + "" + ""; - private static final String XML_2_SNIPPET = "" + ""; + private static final String XML_2_SNIPPET = "" + + ""; private Document expected; @@ -99,4 +101,5 @@ public class DomContentHandlerTest { assertThat(result).and(expected).areSimilar(); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/namespace/QNameEditorTest.java b/spring-xml/src/test/java/org/springframework/xml/namespace/QNameEditorTest.java index 64a7d2a8..02d35b7c 100644 --- a/spring-xml/src/test/java/org/springframework/xml/namespace/QNameEditorTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/namespace/QNameEditorTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,13 +16,13 @@ package org.springframework.xml.namespace; -import static org.assertj.core.api.Assertions.*; - import javax.xml.namespace.QName; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class QNameEditorTest { private QNameEditor editor; @@ -70,4 +70,5 @@ public class QNameEditorTest { assertThat(result.getPrefix()).isEqualTo(qname.getPrefix()); assertThat(result.getNamespaceURI()).isEqualTo(qname.getNamespaceURI()); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/namespace/SimpleNamespaceContextTest.java b/spring-xml/src/test/java/org/springframework/xml/namespace/SimpleNamespaceContextTest.java index ccf91aea..6c413a12 100644 --- a/spring-xml/src/test/java/org/springframework/xml/namespace/SimpleNamespaceContextTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/namespace/SimpleNamespaceContextTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -51,7 +51,8 @@ class SimpleNamespaceContextTest { assertThat(context.getNamespaceURI("prefix")).isEqualTo("namespaceURI"); assertThat(context.getNamespaceURI("unbound")).isEmpty(); assertThat(context.getNamespaceURI(XMLConstants.XML_NS_PREFIX)).isEqualTo(XMLConstants.XML_NS_URI); - assertThat(context.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE)).isEqualTo(XMLConstants.XMLNS_ATTRIBUTE_NS_URI); + assertThat(context.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE)) + .isEqualTo(XMLConstants.XMLNS_ATTRIBUTE_NS_URI); } @Test @@ -103,13 +104,13 @@ class SimpleNamespaceContextTest { String result = iterator.next(); assertThat(result) - .has(new Condition<>(value -> value.equals("prefix1") || value.equals("prefix2"), "verify prefix")); + .has(new Condition<>(value -> value.equals("prefix1") || value.equals("prefix2"), "verify prefix")); assertThat(iterator.hasNext()).isTrue(); result = iterator.next(); assertThat(result) - .has(new Condition<>(value -> value.equals("prefix1") || value.equals("prefix2"), "verify prefix")); + .has(new Condition<>(value -> value.equals("prefix1") || value.equals("prefix2"), "verify prefix")); assertThat(iterator.hasNext()).isFalse(); } diff --git a/spring-xml/src/test/java/org/springframework/xml/sax/SaxUtilsTest.java b/spring-xml/src/test/java/org/springframework/xml/sax/SaxUtilsTest.java index dd88762b..f4165391 100644 --- a/spring-xml/src/test/java/org/springframework/xml/sax/SaxUtilsTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/sax/SaxUtilsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,12 +16,13 @@ package org.springframework.xml.sax; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.Test; + import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; +import static org.assertj.core.api.Assertions.assertThat; + public class SaxUtilsTest { @Test @@ -33,4 +34,5 @@ public class SaxUtilsTest { assertThat(systemId).isNotNull(); assertThat(systemId).endsWith("path%20with%20spaces/file%20with%20spaces.txt"); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/transform/StringResultTest.java b/spring-xml/src/test/java/org/springframework/xml/transform/StringResultTest.java index 4fec1e86..1245c05d 100644 --- a/spring-xml/src/test/java/org/springframework/xml/transform/StringResultTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/transform/StringResultTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,16 +16,17 @@ package org.springframework.xml.transform; -import static org.xmlunit.assertj.XmlAssert.*; - import javax.xml.transform.Transformer; import javax.xml.transform.dom.DOMSource; import org.junit.jupiter.api.Test; -import org.springframework.xml.DocumentBuilderFactoryUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.springframework.xml.DocumentBuilderFactoryUtils; + +import static org.xmlunit.assertj.XmlAssert.assertThat; + public class StringResultTest { @Test @@ -39,7 +40,9 @@ public class StringResultTest { StringResult result = new StringResult(); transformer.transform(new DOMSource(document), result); - assertThat(result.toString()).and("").ignoreWhitespace().areIdentical(); + assertThat(result.toString()).and("") + .ignoreWhitespace() + .areIdentical(); } } diff --git a/spring-xml/src/test/java/org/springframework/xml/transform/StringSourceTest.java b/spring-xml/src/test/java/org/springframework/xml/transform/StringSourceTest.java index 389052b0..1fab7c2e 100644 --- a/spring-xml/src/test/java/org/springframework/xml/transform/StringSourceTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/transform/StringSourceTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.xml.transform; -import static org.assertj.core.api.Assertions.*; - import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; @@ -25,6 +23,8 @@ import javax.xml.transform.dom.DOMResult; import org.junit.jupiter.api.Test; import org.w3c.dom.Element; +import static org.assertj.core.api.Assertions.assertThat; + public class StringSourceTest { @Test @@ -40,4 +40,5 @@ public class StringSourceTest { assertThat(rootElement.getPrefix()).isEqualTo("prefix"); assertThat(rootElement.getNamespaceURI()).isEqualTo("namespace"); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/transform/TransformerHelperTest.java b/spring-xml/src/test/java/org/springframework/xml/transform/TransformerHelperTest.java index ebd5fc7f..63f9f223 100644 --- a/spring-xml/src/test/java/org/springframework/xml/transform/TransformerHelperTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/transform/TransformerHelperTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.xml.transform; -import static org.mockito.Mockito.*; -import static org.xmlunit.assertj.XmlAssert.*; - import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -27,9 +24,13 @@ import javax.xml.transform.TransformerException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.mockito.Mockito.mock; +import static org.xmlunit.assertj.XmlAssert.assertThat; + public class TransformerHelperTest { private TransformerHelper helper; + private Transformer transformer; @BeforeEach diff --git a/spring-xml/src/test/java/org/springframework/xml/transform/TraxUtilsTest.java b/spring-xml/src/test/java/org/springframework/xml/transform/TraxUtilsTest.java index 2063b3fb..1307c5b4 100644 --- a/spring-xml/src/test/java/org/springframework/xml/transform/TraxUtilsTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/transform/TraxUtilsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,9 +16,6 @@ package org.springframework.xml.transform; -import static org.assertj.core.api.Assertions.*; -import static org.easymock.EasyMock.*; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -47,9 +44,6 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.Test; -import org.springframework.util.xml.StaxUtils; -import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.springframework.xml.XMLInputFactoryUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.ContentHandler; @@ -60,6 +54,16 @@ import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; +import org.springframework.util.xml.StaxUtils; +import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.XMLInputFactoryUtils; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + public class TraxUtilsTest { @Test @@ -307,7 +311,8 @@ public class TraxUtilsTest { Source source = new Source() { - public void setSystemId(String systemId) {} + public void setSystemId(String systemId) { + } public String getSystemId() { return null; @@ -321,7 +326,8 @@ public class TraxUtilsTest { public void testDoWithInvalidResult() throws Exception { Result result = new Result() { - public void setSystemId(String systemId) {} + public void setSystemId(String systemId) { + } public String getSystemId() { return null; @@ -330,4 +336,5 @@ public class TraxUtilsTest { assertThatIllegalArgumentException().isThrownBy(() -> TraxUtils.doWithResult(result, null)); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/validation/AbstractValidatorFactoryTestCase.java b/spring-xml/src/test/java/org/springframework/xml/validation/AbstractValidatorFactoryTestCase.java index a74c6d71..1ba892d4 100644 --- a/spring-xml/src/test/java/org/springframework/xml/validation/AbstractValidatorFactoryTestCase.java +++ b/spring-xml/src/test/java/org/springframework/xml/validation/AbstractValidatorFactoryTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.xml.validation; -import static org.assertj.core.api.Assertions.*; - import java.io.InputStream; import javax.xml.parsers.DocumentBuilderFactory; @@ -29,15 +27,18 @@ import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.springframework.xml.transform.ResourceSource; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.transform.ResourceSource; + +import static org.assertj.core.api.Assertions.assertThat; + public abstract class AbstractValidatorFactoryTestCase { private XmlValidator validator; @@ -159,11 +160,14 @@ public abstract class AbstractValidatorFactoryTestCase { return new SAXParseException[0]; } - public void warning(SAXParseException exception) throws SAXException {} + public void warning(SAXParseException exception) throws SAXException { + } - public void error(SAXParseException exception) throws SAXException {} + public void error(SAXParseException exception) throws SAXException { + } - public void fatalError(SAXParseException exception) throws SAXException {} + public void fatalError(SAXParseException exception) throws SAXException { + } }; SAXParseException[] errors = validator.validate(new StreamSource(invalidInputStream), myHandler); diff --git a/spring-xml/src/test/java/org/springframework/xml/validation/Jaxp13ValidatorFactoryTest.java b/spring-xml/src/test/java/org/springframework/xml/validation/Jaxp13ValidatorFactoryTest.java index 74f0ecca..f9201989 100644 --- a/spring-xml/src/test/java/org/springframework/xml/validation/Jaxp13ValidatorFactoryTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/validation/Jaxp13ValidatorFactoryTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,4 +26,5 @@ public class Jaxp13ValidatorFactoryTest extends AbstractValidatorFactoryTestCase protected XmlValidator createValidator(Resource[] schemaResources, String schemaLanguage) throws IOException { return Jaxp13ValidatorFactory.createValidator(schemaResources, schemaLanguage); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/validation/Jaxp15ValidatorFactoryTest.java b/spring-xml/src/test/java/org/springframework/xml/validation/Jaxp15ValidatorFactoryTest.java index 17deacc4..9296e21c 100644 --- a/spring-xml/src/test/java/org/springframework/xml/validation/Jaxp15ValidatorFactoryTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/validation/Jaxp15ValidatorFactoryTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -26,4 +26,5 @@ public class Jaxp15ValidatorFactoryTest extends AbstractValidatorFactoryTestCase protected XmlValidator createValidator(Resource[] schemaResources, String schemaLanguage) throws IOException { return Jaxp15ValidatorFactory.createValidator(schemaResources, schemaLanguage); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/validation/SchemaLoaderUtilsTest.java b/spring-xml/src/test/java/org/springframework/xml/validation/SchemaLoaderUtilsTest.java index fd80b15e..6a53b4ea 100644 --- a/spring-xml/src/test/java/org/springframework/xml/validation/SchemaLoaderUtilsTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/validation/SchemaLoaderUtilsTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,15 +16,17 @@ package org.springframework.xml.validation; -import static org.assertj.core.api.Assertions.*; - import javax.xml.XMLConstants; import javax.xml.validation.Schema; import org.junit.jupiter.api.Test; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class SchemaLoaderUtilsTest { @Test @@ -50,7 +52,7 @@ public class SchemaLoaderUtilsTest { public void testLoadNullSchema() throws Exception { assertThatIllegalArgumentException() - .isThrownBy(() -> SchemaLoaderUtils.loadSchema((Resource) null, XMLConstants.W3C_XML_SCHEMA_NS_URI)); + .isThrownBy(() -> SchemaLoaderUtils.loadSchema((Resource) null, XMLConstants.W3C_XML_SCHEMA_NS_URI)); } @Test @@ -65,4 +67,5 @@ public class SchemaLoaderUtilsTest { assertThat(envelope.isOpen()).isFalse(); assertThat(encoding.isOpen()).isFalse(); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/validation/XmlValidatorFactoryTest.java b/spring-xml/src/test/java/org/springframework/xml/validation/XmlValidatorFactoryTest.java index b237d6be..bb6fcc69 100644 --- a/spring-xml/src/test/java/org/springframework/xml/validation/XmlValidatorFactoryTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/validation/XmlValidatorFactoryTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.xml.validation; -import static org.assertj.core.api.Assertions.*; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -25,10 +23,14 @@ import java.net.URI; import java.net.URL; import org.junit.jupiter.api.Test; + import org.springframework.core.io.AbstractResource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class XmlValidatorFactoryTest { @Test @@ -43,15 +45,15 @@ public class XmlValidatorFactoryTest { @Test public void testNonExistentResource() { - assertThatIllegalArgumentException().isThrownBy( - () -> XmlValidatorFactory.createValidator(new NonExistentResource(), XmlValidatorFactory.SCHEMA_W3C_XML)); + assertThatIllegalArgumentException().isThrownBy(() -> XmlValidatorFactory + .createValidator(new NonExistentResource(), XmlValidatorFactory.SCHEMA_W3C_XML)); } @Test public void testInvalidSchemaLanguage() { assertThatIllegalArgumentException().isThrownBy(() -> XmlValidatorFactory - .createValidator(new ClassPathResource("schema.xsd", AbstractValidatorFactoryTestCase.class), "bla")); + .createValidator(new ClassPathResource("schema.xsd", AbstractValidatorFactoryTestCase.class), "bla")); } private static class NonExistentResource extends AbstractResource { @@ -105,5 +107,7 @@ public class XmlValidatorFactoryTest { public boolean isReadable() { return false; } + } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/xpath/AbstractXPathExpressionFactoryTestCase.java b/spring-xml/src/test/java/org/springframework/xml/xpath/AbstractXPathExpressionFactoryTestCase.java index b86b5774..8844bc84 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xpath/AbstractXPathExpressionFactoryTestCase.java +++ b/spring-xml/src/test/java/org/springframework/xml/xpath/AbstractXPathExpressionFactoryTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.xml.xpath; -import static org.assertj.core.api.Assertions.*; - import java.io.IOException; import java.io.InputStream; import java.util.HashMap; @@ -29,12 +27,16 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.xml.DocumentBuilderFactoryUtils; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.SAXException; +import org.springframework.xml.DocumentBuilderFactoryUtils; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public abstract class AbstractXPathExpressionFactoryTestCase { private Document noNamespacesDocument; @@ -57,14 +59,16 @@ public abstract class AbstractXPathExpressionFactoryTestCase { try { noNamespacesDocument = documentBuilder.parse(inputStream); - } finally { + } + finally { inputStream.close(); } inputStream = getClass().getResourceAsStream("namespaces.xml"); try { namespacesDocument = documentBuilder.parse(inputStream); - } finally { + } + finally { inputStream.close(); } } @@ -135,7 +139,8 @@ public abstract class AbstractXPathExpressionFactoryTestCase { @Test public void testEvaluateAsDoubleNamespaces() throws IOException, SAXException { - XPathExpression expression = createXPathExpression("/prefix1:root/prefix2:child/prefix2:number/text()", namespaces); + XPathExpression expression = createXPathExpression("/prefix1:root/prefix2:child/prefix2:number/text()", + namespaces); double result = expression.evaluateAsNumber(namespacesDocument); assertThat(result).isEqualTo(42.0D); @@ -229,7 +234,8 @@ public abstract class AbstractXPathExpressionFactoryTestCase { @Test public void testEvaluateAsStringNamespaces() { - XPathExpression expression = createXPathExpression("/prefix1:root/prefix2:child/prefix2:text/text()", namespaces); + XPathExpression expression = createXPathExpression("/prefix1:root/prefix2:child/prefix2:text/text()", + namespaces); String result = expression.evaluateAsString(namespacesDocument); assertThat(result).isEqualTo("text"); @@ -280,4 +286,5 @@ public abstract class AbstractXPathExpressionFactoryTestCase { protected abstract XPathExpression createXPathExpression(String expression); protected abstract XPathExpression createXPathExpression(String expression, Map namespaces); + } diff --git a/spring-xml/src/test/java/org/springframework/xml/xpath/AbstractXPathTemplateTestCase.java b/spring-xml/src/test/java/org/springframework/xml/xpath/AbstractXPathTemplateTestCase.java index 8ee4fe6d..ba57dd38 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xpath/AbstractXPathTemplateTestCase.java +++ b/spring-xml/src/test/java/org/springframework/xml/xpath/AbstractXPathTemplateTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.xml.xpath; -import static org.assertj.core.api.Assertions.*; - import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -36,16 +34,20 @@ import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; -import org.springframework.xml.DocumentBuilderFactoryUtils; -import org.springframework.xml.sax.SaxUtils; -import org.springframework.xml.transform.ResourceSource; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import org.springframework.core.io.ClassPathResource; +import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.sax.SaxUtils; +import org.springframework.xml.transform.ResourceSource; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public abstract class AbstractXPathTemplateTestCase { XPathOperations template; @@ -58,7 +60,8 @@ public abstract class AbstractXPathTemplateTestCase { public final void setUp() throws Exception { template = createTemplate(); namespaces = new ResourceSource(new ClassPathResource("namespaces.xml", AbstractXPathTemplateTestCase.class)); - nonamespaces = new ResourceSource(new ClassPathResource("nonamespaces.xml", AbstractXPathTemplateTestCase.class)); + nonamespaces = new ResourceSource( + new ClassPathResource("nonamespaces.xml", AbstractXPathTemplateTestCase.class)); } protected abstract XPathOperations createTemplate() throws Exception; @@ -153,8 +156,8 @@ public abstract class AbstractXPathTemplateTestCase { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - Document document = documentBuilder.parse( - SaxUtils.createInputSource(new ClassPathResource("nonamespaces.xml", AbstractXPathTemplateTestCase.class))); + Document document = documentBuilder.parse(SaxUtils + .createInputSource(new ClassPathResource("nonamespaces.xml", AbstractXPathTemplateTestCase.class))); String result = template.evaluateAsString("/root/child/text", new DOMSource(document)); @@ -231,4 +234,5 @@ public abstract class AbstractXPathTemplateTestCase { assertThat(results).isNotNull(); assertThat(results).containsExactly("text", "number", "boolean"); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactoryTest.java b/spring-xml/src/test/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactoryTest.java index e0caf5f4..4624f069 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactoryTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactoryTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -29,4 +29,5 @@ public class Jaxp13XPathExpressionFactoryTest extends AbstractXPathExpressionFac protected XPathExpression createXPathExpression(String expression, Map namespaces) { return Jaxp13XPathExpressionFactory.createXPathExpression(expression, namespaces); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/xpath/XPathExpressionFactoryBeanTest.java b/spring-xml/src/test/java/org/springframework/xml/xpath/XPathExpressionFactoryBeanTest.java index 51f414e2..9fa7a8a1 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xpath/XPathExpressionFactoryBeanTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/xpath/XPathExpressionFactoryBeanTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,11 +16,11 @@ package org.springframework.xml.xpath; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class XPathExpressionFactoryBeanTest { private XPathExpressionFactoryBean factoryBean; @@ -42,4 +42,5 @@ public class XPathExpressionFactoryBeanTest { assertThat(factoryBean.isSingleton()).isTrue(); assertThat(factoryBean.getObject()).isInstanceOf(XPathExpression.class); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/xpath/XPathExpressionFactoryTest.java b/spring-xml/src/test/java/org/springframework/xml/xpath/XPathExpressionFactoryTest.java index c0d6d23a..96b3e24e 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xpath/XPathExpressionFactoryTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/xpath/XPathExpressionFactoryTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,10 +16,11 @@ package org.springframework.xml.xpath; -import static org.assertj.core.api.Assertions.*; - import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class XPathExpressionFactoryTest { @Test @@ -34,4 +35,5 @@ public class XPathExpressionFactoryTest { public void testCreateEmptyXPathExpression() { assertThatIllegalArgumentException().isThrownBy(() -> XPathExpressionFactory.createXPathExpression("")); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/xsd/AbstractXsdSchemaTestCase.java b/spring-xml/src/test/java/org/springframework/xml/xsd/AbstractXsdSchemaTestCase.java index 0644120c..9102a180 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xsd/AbstractXsdSchemaTestCase.java +++ b/spring-xml/src/test/java/org/springframework/xml/xsd/AbstractXsdSchemaTestCase.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.xml.xsd; -import static org.assertj.core.api.Assertions.*; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -26,14 +24,17 @@ import javax.xml.transform.dom.DOMResult; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.sax.SaxUtils; import org.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.validation.XmlValidator; -import org.w3c.dom.Document; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractXsdSchemaTestCase { @@ -91,7 +92,8 @@ public abstract class AbstractXsdSchemaTestCase { Resource resource = new ClassPathResource("importing.xsd", AbstractXsdSchemaTestCase.class); XsdSchema importing = createSchema(resource); - assertThat(importing.getTargetNamespace()).isEqualTo("http://www.springframework.org/spring-ws/importing/schema"); + assertThat(importing.getTargetNamespace()) + .isEqualTo("http://www.springframework.org/spring-ws/importing/schema"); resource = new ClassPathResource("importing.xsd", AbstractXsdSchemaTestCase.class); Document expected = documentBuilder.parse(SaxUtils.createInputSource(resource)); @@ -130,4 +132,5 @@ public abstract class AbstractXsdSchemaTestCase { } protected abstract XsdSchema createSchema(Resource resource) throws Exception; + } diff --git a/spring-xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java b/spring-xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java index e3c96988..fb717f13 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,8 +16,6 @@ package org.springframework.xml.xsd.commons; -import static org.assertj.core.api.Assertions.*; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -26,6 +24,9 @@ import javax.xml.transform.dom.DOMResult; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xmlunit.assertj.XmlAssert; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.xml.DocumentBuilderFactoryUtils; @@ -34,8 +35,9 @@ import org.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.xsd.AbstractXsdSchemaTestCase; import org.springframework.xml.xsd.XsdSchema; -import org.w3c.dom.Document; -import org.xmlunit.assertj.XmlAssert; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; public class CommonsXsdSchemaCollectionTest { @@ -83,9 +85,10 @@ public class CommonsXsdSchemaCollectionTest { DOMResult domResult = new DOMResult(); transformer.transform(schemas[0].getSource(), domResult); - XmlAssert.assertThat(domResult.getNode()).and(expected) // - .ignoreWhitespace() // - .areIdentical(); + XmlAssert.assertThat(domResult.getNode()) + .and(expected) // + .ignoreWhitespace() // + .areIdentical(); assertThat(schemas[1].getTargetNamespace()).isEqualTo("urn:2"); Resource cd = new ClassPathResource("CD.xsd", AbstractXsdSchemaTestCase.class); @@ -93,9 +96,10 @@ public class CommonsXsdSchemaCollectionTest { domResult = new DOMResult(); transformer.transform(schemas[1].getSource(), domResult); - XmlAssert.assertThat(domResult.getNode()).and(expected) // - .ignoreWhitespace() // - .areIdentical(); + XmlAssert.assertThat(domResult.getNode()) + .and(expected) // + .ignoreWhitespace() // + .areIdentical(); } @Test @@ -172,4 +176,5 @@ public class CommonsXsdSchemaCollectionTest { XmlAssert.assertThat(domResult.getNode()).and(expected).ignoreWhitespace().areIdentical(); } + } diff --git a/spring-xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaTest.java b/spring-xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaTest.java index 1f273af0..c9d1f016 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2022 the original author or authors. + * Copyright 2005-2025 the original author or authors. * * Licensed 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 + * https://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, @@ -16,20 +16,21 @@ package org.springframework.xml.xsd.commons; -import static org.assertj.core.api.Assertions.*; - import javax.xml.transform.dom.DOMSource; import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaCollection; import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.xml.sax.SaxUtils; import org.springframework.xml.xsd.AbstractXsdSchemaTestCase; import org.springframework.xml.xsd.XsdSchema; -import org.w3c.dom.Document; -import org.w3c.dom.Element; + +import static org.assertj.core.api.Assertions.assertThat; public class CommonsXsdSchemaTest extends AbstractXsdSchemaTestCase { @@ -55,7 +56,8 @@ public class CommonsXsdSchemaTest extends AbstractXsdSchemaTestCase { Element schemaElement = result.getDocumentElement(); Element elementElement = (Element) schemaElement.getFirstChild(); - assertThat(elementElement.getAttributeNS("http://www.w3.org/2005/05/xmlmime", "expectedContentTypes")).isNotNull(); + assertThat(elementElement.getAttributeNS("http://www.w3.org/2005/05/xmlmime", "expectedContentTypes")) + .isNotNull(); } }

param-name