diff --git a/pom.xml b/pom.xml index 646ed8e9..1ce7c256 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.ws @@ -346,7 +346,7 @@ true - + true @@ -696,9 +696,13 @@ - - - + + + @@ -719,7 +723,9 @@ - ${project.build.directory}/${project.artifactId}-${project.version}.zip + + ${project.build.directory}/${project.artifactId}-${project.version}.zip + zip;zip.type=docs;zip.deployed=false diff --git a/spring-ws-core/pom.xml b/spring-ws-core/pom.xml index 109db594..bb17c2ee 100644 --- a/spring-ws-core/pom.xml +++ b/spring-ws-core/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 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 2a1dbecd..68fc223f 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 @@ -19,8 +19,8 @@ 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 @@ -41,7 +41,6 @@ public interface FaultAwareWebServiceMessage extends WebServiceMessage { */ QName getFaultCode(); - /** * Returns the fault reason message. * 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 9cea0c08..1b3b699f 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 @@ -40,7 +40,7 @@ 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} + * @param ex the root {@link Throwable exception} */ public WebServiceException(String msg, Throwable ex) { super(msg, ex); 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 e5207232..447b2720 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 @@ -18,13 +18,14 @@ package org.springframework.ws; import java.io.IOException; import java.io.OutputStream; + import javax.xml.transform.Result; import javax.xml.transform.Source; /** * Represents a protocol-agnostic XML message. - * - *

Contains methods that provide access to the payload of the message. + *

+ * Contains methods that provide access to the payload of the message. * * @author Arjen Poutsma * @see org.springframework.ws.soap.SoapMessage @@ -35,9 +36,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 */ @@ -45,10 +45,10 @@ public interface WebServiceMessage { /** * Returns the contents of the message as a {@link Result}. - * - *

Calling this method removes the current payload. - * - *

Implementations that are read-only will throw an {@link UnsupportedOperationException}. + *

+ * Calling this method removes the current payload. + *

+ * Implementations that are read-only will throw an {@link UnsupportedOperationException}. * * @return the message contents * @throws UnsupportedOperationException if the message is read-only @@ -56,8 +56,10 @@ public interface WebServiceMessage { Result getPayloadResult(); /** - * 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. + * 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. * * @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/WebServiceMessageFactory.java b/spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageFactory.java index 5fae1bf5..7e459cb5 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 @@ -22,8 +22,8 @@ import java.io.InputStream; /** * 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. + *

+ * Allows the creation of empty messages, or messages based on {@code InputStream}s. * * @author Arjen Poutsma * @see org.springframework.ws.WebServiceMessage @@ -40,8 +40,8 @@ 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 + *

+ * 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 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 5236482d..52a93168 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 @@ -40,7 +40,7 @@ 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} + * @param ex the root {@link Throwable exception} */ public WebServiceClientException(String msg, Throwable ex) { super(msg, ex); 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 167fb484..4a84106c 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 @@ -40,7 +40,7 @@ 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} + * @param ex the root {@link IOException} */ public WebServiceIOException(String msg, IOException ex) { super(msg, ex); 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 39e57702..ddf2f395 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 @@ -40,7 +40,7 @@ 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} + * @param ex the root {@link Throwable exception} */ public WebServiceTransformerException(String msg, TransformerException ex) { super(msg, ex); 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 b5103d18..50d58de3 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 @@ -40,7 +40,7 @@ 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} + * @param ex the root {@link TransportException} */ public WebServiceTransportException(String msg, TransportException ex) { super(msg, ex); 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 df35218d..8bcea27f 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 @@ -34,8 +34,7 @@ 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 8809d336..b97df928 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 @@ -17,18 +17,19 @@ package org.springframework.ws.client.core; import java.io.IOException; + 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. - * - *

Used for output object creation in {@link WebServiceTemplate}. Alternatively, output sources can also be returned to + *

+ * 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 + * {@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. * * @author Arjen Poutsma @@ -41,8 +42,8 @@ public interface SourceExtractor { * 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 338cc65d..c50bef6e 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 @@ -17,14 +17,15 @@ package org.springframework.ws.client.core; import java.io.IOException; + import javax.xml.transform.TransformerException; 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 + *

+ * 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 @@ -36,7 +37,7 @@ 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 IOException in case of I/O errors * @throws TransformerException in case of transformation errors */ void doWithMessage(WebServiceMessage message) throws IOException, TransformerException; 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 8d5a8c9a..13f15525 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 @@ -17,19 +17,20 @@ package org.springframework.ws.client.core; import java.io.IOException; + import javax.xml.transform.TransformerException; import org.springframework.ws.WebServiceMessage; /** * 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 + *

+ * 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 + * {@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. * * @author Arjen Poutsma @@ -41,9 +42,9 @@ public interface WebServiceMessageExtractor { * 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) - * @throws IOException in case of I/O errors + * @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 */ T extractData(WebServiceMessage message) throws IOException, TransformerException; 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 311f6ff1..c737a7d9 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 @@ -35,10 +35,10 @@ public interface WebServiceOperations { /** * 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! * - *

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 @@ -50,23 +50,22 @@ public interface WebServiceOperations { * 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 uri the URI to send the message to + * @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 */ - T sendAndReceive(String uri, - WebServiceMessageCallback requestCallback, - WebServiceMessageExtractor responseExtractor) throws WebServiceClientException; + 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. + *

+ * This will only work with a default uri specified! * - *

This will only work with a default uri specified! - * - * @param requestCallback the callback to be used for manipulating the request message + * @param requestCallback the callback to be used for manipulating the request 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 @@ -78,29 +77,28 @@ public interface WebServiceOperations { * 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 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 * @return {@code true} if a response was received; {@code false} otherwise * @throws WebServiceClientException if there is a problem sending or receiving the message */ - boolean sendAndReceive(String uri, - WebServiceMessageCallback requestCallback, - WebServiceMessageCallback responseCallback) throws WebServiceClientException; + boolean sendAndReceive(String uri, WebServiceMessageCallback requestCallback, + WebServiceMessageCallback responseCallback) throws WebServiceClientException; - //----------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- // Convenience methods for sending and receiving marshalled messages - //----------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- /** - * 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! + * 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 - * @throws XmlMappingException if there is a problem marshalling or unmarshalling + * @throws XmlMappingException if there is a problem marshalling or unmarshalling * @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) @@ -108,31 +106,30 @@ public interface WebServiceOperations { 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 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 - * @throws XmlMappingException if there is a problem marshalling or unmarshalling + * @throws XmlMappingException if there is a problem marshalling or unmarshalling * @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! * - *

This will only work with a default uri specified! - * - * @param requestPayload the object to marshal into the request message payload + * @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 - * @throws XmlMappingException if there is a problem marshalling or unmarshalling + * @throws XmlMappingException if there is a problem marshalling or unmarshalling * @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) @@ -141,15 +138,15 @@ 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 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 - * @throws XmlMappingException if there is a problem marshalling or unmarshalling + * @throws XmlMappingException if there is a problem marshalling or unmarshalling * @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) @@ -157,82 +154,75 @@ public interface WebServiceOperations { Object marshalSendAndReceive(String uri, Object requestPayload, WebServiceMessageCallback requestCallback) throws XmlMappingException, WebServiceClientException; - //----------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- // Convenience methods for sending Sources - //----------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- /** - * 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! * - *

This will only work with a default uri specified! - * - * @param requestPayload the payload of the request message + * @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 */ T sendSourceAndReceive(Source requestPayload, SourceExtractor responseExtractor) - throws WebServiceClientException; + 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 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 */ T sendSourceAndReceive(String uri, Source requestPayload, SourceExtractor responseExtractor) - throws WebServiceClientException; + 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. + *

+ * This will only work with a default uri specified! * - *

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 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 */ - T sendSourceAndReceive(Source requestPayload, - WebServiceMessageCallback requestCallback, - SourceExtractor responseExtractor) throws WebServiceClientException; + 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 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 */ - T sendSourceAndReceive(String uri, - Source requestPayload, - WebServiceMessageCallback requestCallback, - SourceExtractor responseExtractor) throws WebServiceClientException; + T sendSourceAndReceive(String uri, Source requestPayload, WebServiceMessageCallback requestCallback, + SourceExtractor responseExtractor) throws WebServiceClientException; - //----------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- // Convenience methods for sending Sources and receiving to Results - //----------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- /** * 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! + *

+ * 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 @@ -245,7 +235,7 @@ public interface WebServiceOperations { * 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 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 @@ -257,37 +247,34 @@ public interface WebServiceOperations { /** * 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. + *

+ * This will only work with a default uri specified! * - *

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 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 + * @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 */ - boolean sendSourceAndReceiveToResult(Source requestPayload, - WebServiceMessageCallback requestCallback, - Result responseResult) throws WebServiceClientException; + 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}. + *

+ * 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 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 + * @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 */ - boolean sendSourceAndReceiveToResult(String uri, - Source requestPayload, - WebServiceMessageCallback requestCallback, - Result responseResult) throws WebServiceClientException; + 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 028dbb8a..728fadce 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 @@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URI; import java.util.List; + import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -28,7 +29,6 @@ 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; @@ -62,38 +62,48 @@ 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. - * - *

Code using this class need only implement callback interfaces, provide {@link Source} objects to read data from, or + *

+ * 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) + *

+ * 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. Call {@link WebServiceMessageFactory#createWebServiceMessage() - * createWebServiceMessage()} on the registered message factory to create a request message.
  3. 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.
  4. 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.
  5. Call {@link - * WebServiceConnection#send(WebServiceMessage) send()} on the connection.
  6. 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.
    • 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.
    + *

    + * 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. + *
        + *
      • 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.
      • + *
      *
    13. Invoke {@link WebServiceConnection#receive(WebServiceMessageFactory) receive} on the connection to read the - * response message, if any.
      • 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 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.
      - *
    14. Call to {@link WebServiceConnection#close() close} on the connection.
    + * response message, if any. + *
      + *
    • 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 + * 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.
    • + *
    + *
  7. Call to {@link WebServiceConnection#close() close} on the connection.
  8. + *
* * @author Arjen Poutsma * @since 1.0.0 @@ -104,12 +114,12 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService public static final String MESSAGE_TRACING_LOG_CATEGORY = "org.springframework.ws.client.MessageTracing"; /** Additional logger to use for sent message tracing. */ - protected static final Log sentMessageTracingLogger = - LogFactory.getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".sent"); + protected static final Log sentMessageTracingLogger = LogFactory + .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"); + protected static final Log receivedMessageTracingLogger = LogFactory + .getLog(WebServiceTemplate.MESSAGE_TRACING_LOG_CATEGORY + ".received"); private Marshaller marshaller; @@ -141,26 +151,24 @@ 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. - * - *

Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, - * so that you can safely use this constructor. + * 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. * * @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) { Assert.notNull(marshaller, "marshaller must not be null"); if (!(marshaller instanceof Unmarshaller)) { - throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + - "interface. Please set an Unmarshaller explicitly by using the " + - "WebServiceTemplate(Marshaller, Unmarshaller) constructor."); - } - else { + throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + + "interface. Please set an Unmarshaller explicitly by using the " + + "WebServiceTemplate(Marshaller, Unmarshaller) constructor."); + } else { this.setMarshaller(marshaller); this.setUnmarshaller((Unmarshaller) marshaller); } @@ -170,7 +178,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller and unmarshaller. * - * @param marshaller the marshaller to use + * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use * @since 2.0.3 */ @@ -187,16 +195,15 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService if (destinationProvider != null) { URI uri = destinationProvider.getDestination(); return uri != null ? uri.toString() : null; - } - else { + } else { return null; } } /** * 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) @@ -222,8 +229,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * 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) @@ -264,8 +271,8 @@ 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; @@ -273,37 +280,35 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * 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 + * 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. + * "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 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}. - * - *

When using an HTTP transport, this property defines whether to check the HTTP response status code for fault + * 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. + * 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 + * Profile */ public void setCheckConnectionForFault(boolean checkConnectionForFault) { this.checkConnectionForFault = checkConnectionForFault; @@ -328,8 +333,8 @@ 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) @@ -384,17 +389,15 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } @Override - public Object marshalSendAndReceive(String uri, - final Object requestPayload, - final WebServiceMessageCallback requestCallback) { + public Object marshalSendAndReceive(String uri, final Object requestPayload, + final WebServiceMessageCallback requestCallback) { return sendAndReceive(uri, new WebServiceMessageCallback() { public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException { 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,8 +410,7 @@ 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); } @@ -430,17 +432,14 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } @Override - public boolean sendSourceAndReceiveToResult(Source requestPayload, - WebServiceMessageCallback requestCallback, - final Result responseResult) { + public boolean sendSourceAndReceiveToResult(Source requestPayload, WebServiceMessageCallback requestCallback, + final Result responseResult) { return sendSourceAndReceiveToResult(getDefaultUri(), requestPayload, requestCallback, responseResult); } @Override - public boolean sendSourceAndReceiveToResult(String uri, - Source requestPayload, - WebServiceMessageCallback requestCallback, - final Result responseResult) { + public boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, + WebServiceMessageCallback requestCallback, final Result responseResult) { try { final Transformer transformer = createTransformer(); Boolean retVal = doSendAndReceive(uri, transformer, requestPayload, requestCallback, @@ -454,8 +453,7 @@ 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); } } @@ -470,38 +468,30 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } @Override - public T sendSourceAndReceive(String uri, - final Source requestPayload, - final SourceExtractor responseExtractor) { + public T sendSourceAndReceive(String uri, final Source requestPayload, + final SourceExtractor responseExtractor) { return sendSourceAndReceive(uri, requestPayload, null, responseExtractor); } @Override - public T sendSourceAndReceive(final Source requestPayload, - final WebServiceMessageCallback requestCallback, - final SourceExtractor responseExtractor) { + public T sendSourceAndReceive(final Source requestPayload, final WebServiceMessageCallback requestCallback, + final SourceExtractor responseExtractor) { return sendSourceAndReceive(getDefaultUri(), requestPayload, requestCallback, responseExtractor); } @Override - public T sendSourceAndReceive(String uri, - final Source requestPayload, - final WebServiceMessageCallback requestCallback, - final SourceExtractor responseExtractor) { + public T sendSourceAndReceive(String uri, final Source requestPayload, + final WebServiceMessageCallback requestCallback, final SourceExtractor responseExtractor) { try { return doSendAndReceive(uri, createTransformer(), requestPayload, requestCallback, responseExtractor); - } - catch (TransformerConfigurationException ex) { + } catch (TransformerConfigurationException ex) { throw new WebServiceTransformerException("Could not create transformer", ex); } } - private T doSendAndReceive(String uri, - final Transformer transformer, - final Source requestPayload, - final WebServiceMessageCallback requestCallback, - final SourceExtractor responseExtractor) { + private T doSendAndReceive(String uri, final Transformer transformer, final Source requestPayload, + final WebServiceMessageCallback requestCallback, final SourceExtractor responseExtractor) { Assert.notNull(responseExtractor, "responseExtractor must not be null"); return sendAndReceive(uri, new WebServiceMessageCallback() { public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException { @@ -518,15 +508,13 @@ 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); } @Override - public boolean sendAndReceive(String uri, - WebServiceMessageCallback requestCallback, - WebServiceMessageCallback responseCallback) { + public boolean sendAndReceive(String uri, WebServiceMessageCallback requestCallback, + WebServiceMessageCallback responseCallback) { Assert.notNull(responseCallback, "responseCallback must not be null"); Boolean result = sendAndReceive(uri, requestCallback, new WebServiceMessageCallbackMessageExtractor(responseCallback)); @@ -535,14 +523,13 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService @Override public T sendAndReceive(WebServiceMessageCallback requestCallback, - WebServiceMessageExtractor responseExtractor) { + WebServiceMessageExtractor responseExtractor) { return sendAndReceive(getDefaultUri(), requestCallback, responseExtractor); } @Override - public T sendAndReceive(String uriString, - WebServiceMessageCallback requestCallback, - WebServiceMessageExtractor responseExtractor) { + public T sendAndReceive(String uriString, WebServiceMessageCallback requestCallback, + WebServiceMessageExtractor responseExtractor) { Assert.notNull(responseExtractor, "'responseExtractor' must not be null"); Assert.hasLength(uriString, "'uri' must not be empty"); TransportContext previousTransportContext = TransportContextHolder.getTransportContext(); @@ -553,14 +540,11 @@ 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); } @@ -568,22 +552,20 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService /** * 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. + * 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 messageContext the message context + * @param connection the connection to use + * @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 - * @throws IOException in case of I/O errors + * @throws IOException in case of I/O errors */ @SuppressWarnings("unchecked") - protected T doSendAndReceive(MessageContext messageContext, - WebServiceConnection connection, - WebServiceMessageCallback requestCallback, - WebServiceMessageExtractor responseExtractor) throws IOException { + protected T doSendAndReceive(MessageContext messageContext, WebServiceConnection connection, + WebServiceMessageCallback requestCallback, WebServiceMessageExtractor responseExtractor) throws IOException { int interceptorIndex = -1; try { if (requestCallback != null) { @@ -617,28 +599,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); + 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 ex) { + } catch (RuntimeException ex) { // Trigger after-completion for thrown exception. triggerAfterCompletion(interceptorIndex, messageContext, ex); throw ex; - } - catch (IOException ex) { + } catch (IOException ex) { // Trigger after-completion for thrown exception. triggerAfterCompletion(interceptorIndex, messageContext, ex); throw ex; @@ -651,8 +628,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService ByteArrayOutputStream os = new ByteArrayOutputStream(); request.writeTo(os); sentMessageTracingLogger.trace("Sent request [" + os.toString("UTF-8") + "]"); - } - else if (sentMessageTracingLogger.isDebugEnabled()) { + } else if (sentMessageTracingLogger.isDebugEnabled()) { sentMessageTracingLogger.debug("Sent request [" + request + "]"); } connection.send(request); @@ -660,12 +636,12 @@ 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} + * @param request the response message (possibly a {@link FaultAwareWebServiceMessage} * @return {@code true} if the connection has an error; {@code false} otherwise * @throws IOException in case of I/O errors */ @@ -675,8 +651,7 @@ 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; } } @@ -684,13 +659,12 @@ 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 + * @param request the corresponding request message + * @return the object to be returned from + * {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)}, if any */ protected Object handleError(WebServiceConnection connection, WebServiceMessage request) throws IOException { if (logger.isDebugEnabled()) { @@ -706,33 +680,28 @@ 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("UTF-8") + "] for request [" + - requestStream.toString("UTF-8") + "]"); + receivedMessageTracingLogger.trace("Received response [" + responseStream.toString("UTF-8") + "] for request [" + + requestStream.toString("UTF-8") + "]"); + } else if (receivedMessageTracingLogger.isDebugEnabled()) { + receivedMessageTracingLogger.debug("Received response [" + messageContext.getResponse() + "] for request [" + + messageContext.getRequest() + "]"); } - else if (receivedMessageTracingLogger.isDebugEnabled()) { - receivedMessageTracingLogger - .debug("Received response [" + messageContext.getResponse() + "] for request [" + - messageContext.getRequest() + "]"); - } - } - else { + } else { if (receivedMessageTracingLogger.isDebugEnabled()) { - receivedMessageTracingLogger - .debug("Received no response for request [" + messageContext.getRequest() + "]"); + receivedMessageTracingLogger.debug("Received no response for request [" + messageContext.getRequest() + "]"); } } } /** * 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 {@link - * FaultAwareWebServiceMessage#hasFault() message} otherwise. + *

+ * 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} + * @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 */ @@ -754,11 +723,10 @@ 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}. + * 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 + * @param messageContext the message context, whose request and response are filled * @see ClientInterceptor#handleResponse(MessageContext) * @see ClientInterceptor#handleFault(MessageContext) */ @@ -774,11 +742,10 @@ 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}. + * 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 + * @param messageContext the message context, whose request and response are filled * @see ClientInterceptor#handleResponse(MessageContext) * @see ClientInterceptor#handleFault(MessageContext) */ @@ -793,17 +760,16 @@ 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 * @see ClientInterceptor#afterCompletion */ - private void triggerAfterCompletion(int interceptorIndex, - MessageContext messageContext, Exception ex) + private void triggerAfterCompletion(int interceptorIndex, MessageContext messageContext, Exception ex) throws WebServiceClientException { if (interceptors != null) { for (int i = interceptorIndex; i >= 0; i--) { @@ -813,14 +779,13 @@ 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 connection the faulty connection * @param messageContext the message context - * @return the object to be returned from {@link #sendAndReceive(String,WebServiceMessageCallback, - * WebServiceMessageExtractor)}, if any + * @return the object to be returned from + * {@link #sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor)}, if any */ protected Object handleFault(WebServiceConnection connection, MessageContext messageContext) throws IOException { if (logger.isDebugEnabled()) { @@ -829,8 +794,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService if (getFaultMessageResolver() != null) { getFaultMessageResolver().resolveFault(messageContext.getResponse()); return null; - } - else { + } else { return handleError(connection, messageContext.getRequest()); } } 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 85d0ea55..1745fb78 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 @@ -18,7 +18,6 @@ package org.springframework.ws.client.core.support; 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; @@ -31,18 +30,18 @@ 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 + *

+ * 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} + *

+ * 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) @@ -58,8 +57,7 @@ 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(); @@ -126,11 +124,11 @@ 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"); @@ -189,7 +187,6 @@ public abstract class WebServiceGatewaySupport implements InitializingBean { * * @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 2917dba2..e5c8377b 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 @@ -30,8 +30,8 @@ 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}. - * - *

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 @@ -60,20 +60,20 @@ 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) { Assert.notNull(messageSender, "'messageSender' must not be null"); - messageSenders = new WebServiceMessageSender[]{messageSender}; + messageSenders = new WebServiceMessageSender[] { messageSender }; } /** * 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) */ @@ -90,15 +90,15 @@ public abstract class WebServiceAccessor extends TransformerObjectSupport implem /** * 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 - * @throws IOException when an I/O error occurs + * @throws IOException when an I/O error occurs */ protected WebServiceConnection createConnection(URI uri) throws IOException { Assert.notEmpty(getMessageSenders(), "Property 'messageSenders' is required"); @@ -109,8 +109,7 @@ 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 2a348861..56a6c59a 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 @@ -23,8 +23,8 @@ import org.apache.commons.logging.LogFactory; /** * 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 + *

+ * 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 @@ -40,9 +40,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,16 +55,15 @@ public abstract class AbstractCachingDestinationProvider implements DestinationP cachedUri = lookupDestination(); } return cachedUri; - } - else { + } else { return lookupDestination(); } } /** * 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 */ 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 9ac1c728..9d838c4c 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 @@ -21,8 +21,8 @@ import java.net.URI; /** * 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 + *

+ * Typically implemented by providers that use WSDL, a UDDI registry, or some other form to determine the destination * URI. * * @author Arjen Poutsma 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 86632be6..237fb881 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 @@ -20,13 +20,12 @@ import java.io.IOException; import java.net.URI; import java.util.HashMap; import java.util.Map; + import javax.xml.transform.Transformer; 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; @@ -35,13 +34,14 @@ 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. - * - *

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. + *

+ * 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. * * @author Tareq Abed Rabbo * @author Arjen Poutsma @@ -50,8 +50,7 @@ import org.springframework.xml.xpath.XPathExpressionFactory; public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvider { /** 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"; + public static final String DEFAULT_WSDL_LOCATION_EXPRESSION = "/wsdl:definitions/wsdl:service/wsdl:port/soap:address/@location"; private static TransformerFactory transformerFactory = TransformerFactoryUtils.newInstance(); @@ -66,8 +65,8 @@ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvide expressionNamespaces.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/"); expressionNamespaces.put("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/"); - locationXPathExpression = XPathExpressionFactory - .createXPathExpression(DEFAULT_WSDL_LOCATION_EXPRESSION, expressionNamespaces); + locationXPathExpression = XPathExpressionFactory.createXPathExpression(DEFAULT_WSDL_LOCATION_EXPRESSION, + expressionNamespaces); } /** Sets a WSDL location from which the service destination {@code URI} will be resolved. */ @@ -79,19 +78,33 @@ public class Wsdl11DestinationProvider extends AbstractCachingDestinationProvide /** * Sets the XPath expression to use when extracting the service location {@code URI} from a WSDL. - * - *

The expression can use the following bound prefixes:

- * - * - * - *
PrefixNamespace
{@code wsdl}{@code http://schemas.xmlsoap.org/wsdl/}
{@code soap}{@code http://schemas.xmlsoap.org/wsdl/soap/}
{@code soap12}{@code http://schemas.xmlsoap.org/wsdl/soap12/}
- * - *

Defaults to {@link #DEFAULT_WSDL_LOCATION_EXPRESSION}. + *

+ * The expression can use the following bound prefixes:

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
PrefixNamespace
{@code wsdl}{@code http://schemas.xmlsoap.org/wsdl/}
{@code soap}{@code http://schemas.xmlsoap.org/wsdl/soap/}
{@code soap12}{@code http://schemas.xmlsoap.org/wsdl/soap12/}
+ *
+ *

+ * Defaults to {@link #DEFAULT_WSDL_LOCATION_EXPRESSION}. */ public void setLocationExpression(String expression) { Assert.hasText(expression, "'expression' must not be empty"); - locationXPathExpression = XPathExpressionFactory - .createXPathExpression(expression, expressionNamespaces); + locationXPathExpression = XPathExpressionFactory.createXPathExpression(expression, expressionNamespaces); } @Override @@ -106,11 +119,9 @@ 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 162e85a0..04bfcb66 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 @@ -17,9 +17,8 @@ package org.springframework.ws.client.support.interceptor; import java.io.IOException; -import javax.xml.transform.Source; -import org.xml.sax.SAXParseException; +import javax.xml.transform.Source; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; @@ -35,13 +34,14 @@ 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 {@link - * #getValidationResponseSource(WebServiceMessage)} template methods. - * - *

By default, only the request message is validated, but this behaviour can be changed using the + * 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. * * @author Arjen Poutsma @@ -82,18 +82,18 @@ 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. + * 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. */ public void setSchema(Resource schema) { setSchemas(schema); } /** - * 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. + * 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. */ public void setSchemas(Resource... schemas) { Assert.notEmpty(schemas, "schemas must not be empty or null"); @@ -105,9 +105,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. + * 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. * * @param schema the xsd schema to use * @throws java.io.IOException in case of I/O errors @@ -117,9 +117,8 @@ 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 @@ -154,10 +153,10 @@ 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. - * - *

Returns {@code true} if the request is valid, or {@code false} if it isn't. + * 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 @@ -171,14 +170,12 @@ 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"); } } @@ -188,12 +185,12 @@ 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 + * @param errors the validation errors * @return {@code true} to continue processing the request, {@code false} otherwise */ protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors) { @@ -204,11 +201,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 + * 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. + *

+ * 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 @@ -222,14 +219,12 @@ 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"); } } @@ -239,12 +234,12 @@ 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 - * 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 + * @param errors the validation errors * @return {@code true} to continue the reponse interceptor chain, {@code false} (the default) otherwise */ protected boolean handleResponseValidationErrors(MessageContext messageContext, SAXParseException[] errors) @@ -261,11 +256,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup return true; } - /** Does nothing by default.*/ + /** 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. 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 a12a7e73..ca135dc8 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 @@ -25,16 +25,17 @@ 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. - * - *

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. - * - *

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. + *

+ * 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. + *

+ * 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 @@ -48,8 +49,8 @@ public interface ClientInterceptor { * 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() */ @@ -58,26 +59,26 @@ public interface ClientInterceptor { /** * 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 {@link - * org.springframework.ws.client.core.WebServiceTemplate}. - * - *

Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed. + * 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. * * @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() @@ -85,10 +86,10 @@ 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. - * - *

Note: Will only be called if this interceptor's {@link #handleRequest} method has successfully completed. + * 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 * @param ex exception thrown on handler execution, if any @@ -97,5 +98,4 @@ public interface ClientInterceptor { */ void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException; - } 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 273cae23..bd4525ea 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 @@ -17,7 +17,6 @@ package org.springframework.ws.client.support.interceptor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.ws.client.WebServiceClientException; import org.springframework.ws.context.MessageContext; 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 28760e1f..64c71427 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 @@ -21,15 +21,14 @@ 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. - * - *

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. + * 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. + *

+ * 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 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 c16fa352..c608e04f 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 @@ -16,9 +16,8 @@ package org.springframework.ws.client.support.interceptor; -import org.xml.sax.SAXParseException; - import org.springframework.ws.client.WebServiceClientException; +import org.xml.sax.SAXParseException; /** * Exception thrown whenever a validation error occurs on the client-side. 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 27fd62b6..9532181a 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 @@ -16,8 +16,6 @@ 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; @@ -48,6 +46,7 @@ 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. @@ -57,20 +56,20 @@ import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationM */ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { - private static final boolean dom4jPresent = - ClassUtils.isPresent("org.dom4j.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + private static final boolean dom4jPresent = ClassUtils.isPresent("org.dom4j.Element", + AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); - private static final boolean jaxb2Present = - ClassUtils.isPresent("javax.xml.bind.Binder", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + private static final boolean jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", + AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); - private static final boolean jdomPresent = - ClassUtils.isPresent("org.jdom2.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + private static final boolean jdomPresent = ClassUtils.isPresent("org.jdom2.Element", + AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); - private static final boolean staxPresent = ClassUtils - .isPresent("javax.xml.stream.XMLInputFactory", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + private static final boolean staxPresent = ClassUtils.isPresent("javax.xml.stream.XMLInputFactory", + AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); - private static final boolean xomPresent = - ClassUtils.isPresent("nu.xom.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + private static final boolean xomPresent = ClassUtils.isPresent("nu.xom.Element", + AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); @Override public BeanDefinition parse(Element element, ParserContext parserContext) { @@ -91,18 +90,17 @@ 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); - RootBeanDefinition soapActionMappingDef = - createBeanDefinition(SoapActionAnnotationMethodEndpointMapping.class, source); + RootBeanDefinition soapActionMappingDef = createBeanDefinition(SoapActionAnnotationMethodEndpointMapping.class, + source); soapActionMappingDef.getPropertyValues().add("order", 1); parserContext.getReaderContext().registerWithGeneratedName(soapActionMappingDef); - RootBeanDefinition annActionMappingDef = - createBeanDefinition(AnnotationActionEndpointMapping.class, source); + RootBeanDefinition annActionMappingDef = createBeanDefinition(AnnotationActionEndpointMapping.class, source); annActionMappingDef.getPropertyValues().add("order", 2); parserContext.getReaderContext().registerWithGeneratedName(annActionMappingDef); } @@ -125,31 +123,30 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { argumentResolvers.add(domProcessor); returnValueHandlers.add(domProcessor); - RuntimeBeanReference sourceProcessor = - createBeanReference(SourcePayloadMethodProcessor.class, source, parserContext); + RuntimeBeanReference sourceProcessor = createBeanReference(SourcePayloadMethodProcessor.class, source, + parserContext); argumentResolvers.add(sourceProcessor); returnValueHandlers.add(sourceProcessor); if (dom4jPresent) { - RuntimeBeanReference dom4jProcessor = - createBeanReference(Dom4jPayloadMethodProcessor.class, source, parserContext); + RuntimeBeanReference dom4jProcessor = createBeanReference(Dom4jPayloadMethodProcessor.class, source, + parserContext); argumentResolvers.add(dom4jProcessor); 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); } @@ -157,8 +154,7 @@ 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); } @@ -167,13 +163,12 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { RuntimeBeanReference unmarshallerReference; if (element.hasAttribute("unmarshaller")) { unmarshallerReference = new RuntimeBeanReference(element.getAttribute("unmarshaller")); - } - else { + } else { unmarshallerReference = marshallerReference; } - RootBeanDefinition marshallingProcessorDef = - createBeanDefinition(MarshallingPayloadMethodProcessor.class, source); + RootBeanDefinition marshallingProcessorDef = createBeanDefinition(MarshallingPayloadMethodProcessor.class, + source); marshallingProcessorDef.getPropertyValues().add("marshaller", marshallerReference); marshallingProcessorDef.getPropertyValues().add("unmarshaller", unmarshallerReference); argumentResolvers.add(marshallingProcessorDef); @@ -187,13 +182,11 @@ 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); - RootBeanDefinition simpleResolverDef = - createBeanDefinition(SimpleSoapExceptionResolver.class, source); + RootBeanDefinition simpleResolverDef = createBeanDefinition(SimpleSoapExceptionResolver.class, source); simpleResolverDef.getPropertyValues().add("order", Ordered.LOWEST_PRECEDENCE); parserContext.getReaderContext().registerWithGeneratedName(simpleResolverDef); } 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 0cdfc4be..46828bce 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 @@ -31,7 +31,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; /** @@ -76,12 +75,10 @@ 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."); + "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 63973329..f67ee571 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 @@ -18,8 +18,6 @@ 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; @@ -35,6 +33,7 @@ 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. @@ -46,26 +45,23 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { @Override public BeanDefinition parse(Element element, ParserContext parserContext) { - CompositeComponentDefinition compDefinition = - new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element)); + CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), + parserContext.extractSource(element)); parserContext.pushContainingComponent(compDefinition); List childElements = DomUtils.getChildElements(element); for (Element childElement : childElements) { if ("bean".equals(childElement.getLocalName())) { - RootBeanDefinition smartInterceptorDef = - createSmartInterceptorDefinition(DelegatingSmartSoapEndpointInterceptor.class, childElement, - parserContext); + RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( + DelegatingSmartSoapEndpointInterceptor.class, childElement, parserContext); BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, childElement); smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, interceptorDef); registerSmartInterceptor(parserContext, smartInterceptorDef); - } - else if ("ref".equals(childElement.getLocalName())) { - RootBeanDefinition smartInterceptorDef = - createSmartInterceptorDefinition(DelegatingSmartSoapEndpointInterceptor.class, childElement, - parserContext); + } else if ("ref".equals(childElement.getLocalName())) { + RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( + DelegatingSmartSoapEndpointInterceptor.class, childElement, parserContext); BeanReference interceptorRef = createInterceptorReference(parserContext, childElement); @@ -73,16 +69,13 @@ 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); + RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( + PayloadRootSmartSoapEndpointInterceptor.class, childElement, parserContext); + BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, payloadRootChild); String namespaceUri = childElement.getAttribute("namespaceUri"); String localPart = childElement.getAttribute("localPart"); @@ -92,11 +85,9 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, localPart); registerSmartInterceptor(parserContext, smartInterceptorDef); - } - else if ("ref".equals(payloadRootChild.getLocalName())) { - RootBeanDefinition smartInterceptorDef = - createSmartInterceptorDefinition(PayloadRootSmartSoapEndpointInterceptor.class, - childElement, parserContext); + } else if ("ref".equals(payloadRootChild.getLocalName())) { + RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( + PayloadRootSmartSoapEndpointInterceptor.class, childElement, parserContext); BeanReference interceptorRef = createInterceptorReference(parserContext, payloadRootChild); String namespaceUri = childElement.getAttribute("namespaceUri"); @@ -109,16 +100,13 @@ 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); + RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( + SoapActionSmartEndpointInterceptor.class, childElement, parserContext); + BeanDefinitionHolder interceptorDef = createInterceptorDefinition(parserContext, soapActionChild); String soapAction = childElement.getAttribute("value"); @@ -126,11 +114,9 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { smartInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, soapAction); registerSmartInterceptor(parserContext, smartInterceptorDef); - } - else if ("ref".equals(soapActionChild.getLocalName())) { - RootBeanDefinition smartInterceptorDef = - createSmartInterceptorDefinition(SoapActionSmartEndpointInterceptor.class, childElement, - parserContext); + } else if ("ref".equals(soapActionChild.getLocalName())) { + RootBeanDefinition smartInterceptorDef = createSmartInterceptorDefinition( + SoapActionSmartEndpointInterceptor.class, childElement, parserContext); BeanReference interceptorRef = createInterceptorReference(parserContext, soapActionChild); String soapAction = childElement.getAttribute("value"); @@ -179,9 +165,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { return ref; } - private RootBeanDefinition createSmartInterceptorDefinition(Class interceptorClass, - Element element, - ParserContext parserContext) { + private RootBeanDefinition createSmartInterceptorDefinition( + Class interceptorClass, Element element, ParserContext parserContext) { RootBeanDefinition smartInterceptorDef = new RootBeanDefinition(interceptorClass); smartInterceptorDef.setSource(parserContext.extractSource(element)); smartInterceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); 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 0693af46..141bcdc4 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 @@ -21,7 +21,6 @@ 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; /** @@ -34,15 +33,13 @@ import org.w3c.dom.Element; @Deprecated class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { - private static final String GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = - "org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter"; + private static final String GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = "org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter"; - private static final boolean genericAdapterPresent = - ClassUtils.isPresent(GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME, - MarshallingEndpointsBeanDefinitionParser.class.getClassLoader()); + private static final boolean genericAdapterPresent = ClassUtils.isPresent( + GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME, + MarshallingEndpointsBeanDefinitionParser.class.getClassLoader()); - private static final String MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = - "org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter"; + private static final String MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = "org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter"; @Override protected boolean shouldGenerateIdAsFallback() { @@ -52,7 +49,7 @@ class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinit @Override protected String getBeanClassName(Element element) { if (genericAdapterPresent) { - return GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME; + return GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME; } return MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME; } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/StaticWsdlBeanDefinitionParser.java b/spring-ws-core/src/main/java/org/springframework/ws/config/StaticWsdlBeanDefinitionParser.java index 66d21c50..36e65cb8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/StaticWsdlBeanDefinitionParser.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/StaticWsdlBeanDefinitionParser.java @@ -22,7 +22,6 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.util.StringUtils; - import org.w3c.dom.Element; /** 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 bbb4820c..baaaa40b 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 @@ -23,7 +23,6 @@ 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; /** @@ -36,8 +35,7 @@ import org.w3c.dom.Element; @Deprecated class XPathEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { - private static final String XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = - "org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter"; + private static final String XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = "org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter"; @Override protected boolean shouldGenerateIdAsFallback() { 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 a8c9d167..74f93b61 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 @@ -9,10 +9,9 @@ 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 @@ -40,8 +39,7 @@ public class DelegatingWsConfiguration extends WsConfigurationSupport { } @Override - protected void addReturnValueHandlers( - List returnValueHandlers) { + 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 ff3d6e4d..970966c4 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 @@ -26,9 +26,8 @@ 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,9 +37,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
@@ -48,48 +47,46 @@ import org.springframework.context.annotation.Import;
  * @ComponentScan(basePackageClasses = { MyConfiguration.class })
  * public class MyConfiguration extends WsConfigurerAdapter {
  *
- *	@Override
- *	public void addInterceptors(List<EndpointInterceptor> interceptors) {
- *		interceptors.add(new MyInterceptor());
- *	}
+ * 	@Override
+ * 	public void addInterceptors(List<EndpointInterceptor> interceptors) {
+ * 		interceptors.add(new MyInterceptor());
+ * 	}
  *
- *	@Override
- *	public void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
- *		argumentResolvers.add(new MyArgumentResolver());
- *	}
+ * 	@Override
+ * 	public void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
+ * 		argumentResolvers.add(new MyArgumentResolver());
+ * 	}
  *
- *	// More overridden methods ...
+ * 	// More overridden 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: + *

+ * 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
  * @ComponentScan(basePackageClasses = { MyConfiguration.class })
  * public class MyConfiguration extends WsConfigurationSupport {
  *
- *	@Override
- *	public void addInterceptors(List<EndpointInterceptor> interceptors) {
- *		interceptors.add(new MyInterceptor());
- *	}
+ * 	@Override
+ * 	public void addInterceptors(List<EndpointInterceptor> interceptors) {
+ * 		interceptors.add(new MyInterceptor());
+ * 	}
  *
- *	@Bean
- *	@Override
- *	public DefaultMethodEndpointAdapter defaultMethodEndpointAdapter() {
- *		// Create or delegate to "super" to create and
- *		// customize properties of DefaultMethodEndpointAdapter
- *	}
+ * 	@Bean
+ * 	@Override
+ * 	public DefaultMethodEndpointAdapter defaultMethodEndpointAdapter() {
+ * 		// Create or delegate to "super" to create and
+ * 		// customize properties of DefaultMethodEndpointAdapter
+ * 	}
  * }
  * 
* * @see WsConfigurer * @see WsConfigurerAdapter * @see WsConfigurationSupport - * * @author Arjen Poutsma * @since 2.2 */ 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 93befe39..8673bed0 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 @@ -40,44 +40,36 @@ 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 class registers the following {@link EndpointMapping}s: + * 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}: + *

+ * 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: + *

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

    - *
  • {@link SoapFaultAnnotationExceptionResolver} for handling exceptions - * annotated with {@link SoapFault @SoapFault}. - *
  • {@link SimpleSoapExceptionResolver} for creating default exceptions. + *
  • {@link SoapFaultAnnotationExceptionResolver} for handling exceptions annotated with {@link SoapFault @SoapFault}. + *
  • {@link SimpleSoapExceptionResolver} for creating default exceptions. *
* * @see EnableWs * @see WsConfigurer * @see WsConfigurerAdapter - * * @author Arjen Poutsma * @since 2.2 */ @@ -86,48 +78,43 @@ 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() { - PayloadRootAnnotationMethodEndpointMapping endpointMapping = - new PayloadRootAnnotationMethodEndpointMapping(); + PayloadRootAnnotationMethodEndpointMapping endpointMapping = new PayloadRootAnnotationMethodEndpointMapping(); endpointMapping.setOrder(0); endpointMapping.setInterceptors(getInterceptors()); return endpointMapping; } /** - * 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() { - SoapActionAnnotationMethodEndpointMapping endpointMapping = - new SoapActionAnnotationMethodEndpointMapping(); + SoapActionAnnotationMethodEndpointMapping endpointMapping = new SoapActionAnnotationMethodEndpointMapping(); endpointMapping.setOrder(1); endpointMapping.setInterceptors(getInterceptors()); return endpointMapping; } /** - * 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() { - AnnotationActionEndpointMapping endpointMapping = - new AnnotationActionEndpointMapping(); + AnnotationActionEndpointMapping endpointMapping = new AnnotationActionEndpointMapping(); endpointMapping.setOrder(2); endpointMapping.setPostInterceptors(getInterceptors()); return endpointMapping; } /** - * 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) { @@ -138,29 +125,25 @@ 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. + *
  • {@link #addArgumentResolvers(List)} for adding custom argument resolvers. + *
  • {@link #addReturnValueHandlers(List)} for adding custom return value handlers. *
*/ @Bean public DefaultMethodEndpointAdapter defaultMethodEndpointAdapter() { - List argumentResolvers = - new ArrayList(); + List argumentResolvers = new ArrayList(); addArgumentResolvers(argumentResolvers); - List returnValueHandlers = - new ArrayList(); + List returnValueHandlers = new ArrayList(); addReturnValueHandlers(returnValueHandlers); DefaultMethodEndpointAdapter adapter = new DefaultMethodEndpointAdapter(); @@ -171,27 +154,21 @@ public class WsConfigurationSupport { } /** - * 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. + * 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. - * @param returnValueHandlers the list of custom handlers; - * initially an empty list. + * 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() { @@ -202,9 +179,8 @@ 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 70372841..26e217e2 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 @@ -7,13 +7,12 @@ 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}. - * - *

{@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. + * 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. * * @author Arjen Poutsma * @since 2.2 @@ -21,22 +20,23 @@ 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); /** * 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 7a717cb5..9d1974d1 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 @@ -7,8 +7,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 @@ -17,27 +17,27 @@ public class WsConfigurerAdapter implements WsConfigurer { /** * {@inheritDoc} - *

This implementation is empty. + *

+ * This implementation is empty. */ @Override - public void addInterceptors(List interceptors) { - } + public void addInterceptors(List interceptors) {} /** * {@inheritDoc} - *

This implementation is empty. + *

+ * This implementation is empty. */ @Override - public void addArgumentResolvers(List argumentResolvers) { - } + public void addArgumentResolvers(List argumentResolvers) {} /** * {@inheritDoc} - *

This implementation is empty. + *

+ * This implementation is empty. */ @Override - public void addReturnValueHandlers( - List returnValueHandlers) { + 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 0a573f0e..04cca7c1 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 @@ -38,8 +38,7 @@ public class WsConfigurerComposite implements WsConfigurer { } @Override - public void addReturnValueHandlers( - List returnValueHandlers) { + public void addReturnValueHandlers(List returnValueHandlers) { for (WsConfigurer delegate : delegates) { delegate.addReturnValueHandlers(returnValueHandlers); } 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 a08ed51e..e4172914 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 @@ -30,8 +30,7 @@ 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; 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 6a41ca0a..e5229ba6 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 @@ -43,8 +43,7 @@ public class DefaultMessageContext extends AbstractMessageContext { } /** - * 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"); 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 3d94db04..5ef0e67e 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 @@ -24,11 +24,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 + *

+ * 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 + *

+ * Also contains properties, which can be used to by {@link EndpointInterceptor interceptors} to pass information on to * endpoints. * * @author Arjen Poutsma @@ -78,16 +78,16 @@ 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 IOException in case of I/O errors * @throws IllegalStateException if a response has already been created */ 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 name name of the property associated with the value * @param value value of the property */ void setProperty(String name, Object value); @@ -122,4 +122,4 @@ public interface MessageContext { */ String[] getPropertyNames(); -} \ No newline at end of file +} 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 a6fbac5c..f811c0ef 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 @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; + import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.FileDataSource; @@ -49,8 +50,8 @@ public abstract class AbstractMimeMessage implements MimeMessage { Assert.hasLength(contentId, "contentId must not be empty"); Assert.notNull(inputStreamSource, "InputStreamSource must not be null"); if (inputStreamSource instanceof Resource && ((Resource) inputStreamSource).isOpen()) { - throw new IllegalArgumentException("Passed-in Resource contains an open stream: invalid argument. " + - "MIME requires an InputStreamSource that creates a fresh stream for every call."); + throw new IllegalArgumentException("Passed-in Resource contains an open stream: invalid argument. " + + "MIME requires an InputStreamSource that creates a fresh stream for every call."); } DataHandler dataHandler = new DataHandler(new InputStreamSourceDataSource(inputStreamSource, contentType)); return addAttachment(contentId, dataHandler); @@ -93,8 +94,7 @@ 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 919ac931..daacaa85 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 @@ -18,6 +18,7 @@ package org.springframework.ws.mime; import java.io.IOException; import java.io.InputStream; + import javax.activation.DataHandler; /** @@ -45,8 +46,8 @@ public interface Attachment { 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 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 3310e9b8..55ad66fe 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 @@ -18,14 +18,15 @@ package org.springframework.ws.mime; import java.io.File; import java.util.Iterator; + import javax.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,8 +37,9 @@ 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. + * @return {@code true} when the constraints specified in + * Identifying XOP + * Documents are met. * @see XOP Packages */ boolean isXopPackage(); @@ -69,12 +71,12 @@ 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 + * @param file the file to take the content from * @return the added attachment * @throws AttachmentException in case of errors */ @@ -82,14 +84,14 @@ public interface MimeMessage extends WebServiceMessage { /** * 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 + *

+ * 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 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 contentType the content type to use for the element + * passed in here) + * @param contentType the content type to use for the element * @return the added attachment * @throws AttachmentException in case of errors * @see org.springframework.core.io.Resource 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 514123e5..0e51a500 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 @@ -18,6 +18,7 @@ package org.springframework.ws.pox.dom; import java.io.IOException; import java.io.OutputStream; + import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -26,15 +27,14 @@ 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. @@ -110,8 +110,7 @@ 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/DomPoxMessageFactory.java b/spring-ws-core/src/main/java/org/springframework/ws/pox/dom/DomPoxMessageFactory.java index 1d403fe1..e38fe2b4 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 @@ -18,18 +18,18 @@ package org.springframework.ws.pox.dom; import java.io.IOException; import java.io.InputStream; + import javax.xml.parsers.DocumentBuilder; 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.transform.TransformerObjectSupport; 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}. @@ -61,7 +61,7 @@ public class DomPoxMessageFactory extends TransformerObjectSupport implements We */ public DomPoxMessageFactory(DocumentBuilderFactory documentBuilderFactory) { this.documentBuilderFactory = documentBuilderFactory; - + documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating(false); documentBuilderFactory.setExpandEntityReferences(false); @@ -84,8 +84,7 @@ 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); @@ -97,11 +96,9 @@ 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); } } @@ -112,14 +109,11 @@ 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 9a6a6254..d51cddb5 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 @@ -20,10 +20,10 @@ 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. - * - *

This interface is not intended for application developers. It is available for those who want to develop their own + * 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. * * @author Arjen Poutsma @@ -34,8 +34,8 @@ public interface EndpointAdapter { /** * Does this {@code EndpointAdapter} support the given {@code endpoint}? - * - *

Typical {@code EndpointAdapters} will base the decision on the endpoint type. + *

+ * 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} @@ -46,8 +46,8 @@ public interface EndpointAdapter { * 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 66e58e32..ef8e08ff 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 @@ -30,8 +30,8 @@ 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 ex the exception that got thrown during endpoint execution + * @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 78379d3b..7013eb8e 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 @@ -22,17 +22,15 @@ 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. - * - *

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 + *

+ * 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>). + * {@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() @@ -45,15 +43,15 @@ public interface EndpointInterceptor { /** * 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, + *

+ * {@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 + * @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 * @throws Exception in case of errors * @see MessageContext#getRequest() */ @@ -62,17 +60,17 @@ public interface EndpointInterceptor { /** * 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, + *

+ * {@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. + * @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. * @throws Exception in case of errors * @see MessageContext#getRequest() * @see MessageContext#hasResponse() @@ -83,31 +81,31 @@ public interface EndpointInterceptor { /** * 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, + *

+ * {@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, 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. + * @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. */ 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. - * - *

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. + *

+ * 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 - * @param endpoint chosen endpoint to invoke + * @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 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 4aa5f48b..80763b7d 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 @@ -41,7 +41,7 @@ public class EndpointInvocationChain { /** * Create new {@code EndpointInvocationChain}. * - * @param endpoint the endpoint object to invoke + * @param endpoint the endpoint object to invoke * @param interceptors the array of interceptors to apply */ public EndpointInvocationChain(Object endpoint, EndpointInterceptor[] interceptors) { 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 ce345a8b..56216ded 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 @@ -20,15 +20,14 @@ 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 + *

+ * 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 @@ -41,17 +40,17 @@ 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. + *

+ * 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. * - *

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 + * @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 fad490a3..260ea7a9 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 @@ -25,7 +25,6 @@ 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; @@ -49,24 +48,24 @@ import org.springframework.ws.transport.WebServiceMessageReceiver; /** * 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 + *

+ * 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 {@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 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 * {@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 #setEndpointExceptionResolvers(List) endpointExceptionResolvers} + * 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.
  • *
* * @author Arjen Poutsma @@ -85,19 +84,19 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa public static final String ENDPOINT_NOT_FOUND_LOG_CATEGORY = "org.springframework.ws.server.EndpointNotFound"; /** 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); + protected static final Log endpointNotFoundLogger = LogFactory + .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"); + protected static final Log sentMessageTracingLogger = LogFactory + .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"); + protected static final Log receivedMessageTracingLogger = LogFactory + .getLog(MessageDispatcher.MESSAGE_TRACING_LOG_CATEGORY + ".received"); private final DefaultStrategiesHelper defaultStrategiesHelper; @@ -165,12 +164,11 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa // 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()); + 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); @@ -178,18 +176,14 @@ 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 + "]"); + sentMessageTracingLogger.trace("Sent response [" + responseContent + "] for request [" + requestContent + "]"); + } else if (sentMessageTracingLogger.isDebugEnabled()) { + sentMessageTracingLogger + .debug("Sent response [" + 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() + "]"); + } else if (sentMessageTracingLogger.isDebugEnabled()) { + sentMessageTracingLogger.debug("MessageDispatcher with name '" + beanName + "' sends no response for request [" + + messageContext.getRequest() + "]"); } } @@ -203,8 +197,8 @@ 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; @@ -237,25 +231,21 @@ 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; @@ -272,12 +262,11 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa 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"); } } @@ -299,15 +288,15 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa return endpointAdapter; } } - throw new IllegalStateException("No adapter for endpoint [" + endpoint + "]: Is your endpoint annotated with " + - "@Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?"); + throw new IllegalStateException("No adapter for endpoint [" + endpoint + "]: Is your endpoint annotated with " + + "@Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?"); } /** * 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}. + *

+ * Default implementation does nothing, and returns {@code true}. * * @param mappedEndpoint the mapped {@code EndpointInvocationChain} * @param messageContext the message context @@ -318,13 +307,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 ex the exception that got thrown during handler execution + * @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 */ protected void processEndpointException(MessageContext messageContext, Object endpoint, Exception ex) @@ -345,20 +333,19 @@ 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}. + * interceptors whose handleRequest invocation returned {@code true}, in addition to the last interceptor who returned + * {@code false}. * - * @param mappedEndpoint the mapped EndpointInvocationChain + * @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 + * @param messageContext the message context, whose request and response are filled * @see EndpointInterceptor#handleResponse(MessageContext,Object) * @see EndpointInterceptor#handleFault(MessageContext, Object) */ - private void triggerHandleResponse(EndpointInvocationChain mappedEndpoint, - int interceptorIndex, - MessageContext messageContext) throws Exception { - if (mappedEndpoint != null && messageContext.hasResponse() && - !ObjectUtils.isEmpty(mappedEndpoint.getInterceptors())) { + private void triggerHandleResponse(EndpointInvocationChain mappedEndpoint, int interceptorIndex, + MessageContext messageContext) throws Exception { + if (mappedEndpoint != null && messageContext.hasResponse() + && !ObjectUtils.isEmpty(mappedEndpoint.getInterceptors())) { boolean hasFault = false; WebServiceMessage response = messageContext.getResponse(); if (response instanceof FaultAwareWebServiceMessage) { @@ -369,8 +356,7 @@ 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()); } } @@ -378,20 +364,17 @@ 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 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 * @see EndpointInterceptor#afterCompletion */ - private void triggerAfterCompletion(EndpointInvocationChain mappedEndpoint, - int interceptorIndex, - MessageContext messageContext, - Exception ex) throws Exception { + private void triggerAfterCompletion(EndpointInvocationChain mappedEndpoint, int interceptorIndex, + MessageContext messageContext, Exception ex) throws Exception { // Apply afterCompletion methods of registered interceptors. if (mappedEndpoint != null) { @@ -401,8 +384,7 @@ 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); } } @@ -410,24 +392,21 @@ 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()); Collections.sort(endpointAdapters, 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"); } @@ -436,8 +415,8 @@ 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) */ @@ -448,10 +427,9 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa if (!matchingBeans.isEmpty()) { endpointExceptionResolvers = new ArrayList(matchingBeans.values()); Collections.sort(endpointExceptionResolvers, 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"); } @@ -460,22 +438,20 @@ 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()); Collections.sort(endpointMappings, 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 1f00aa21..71a5c5aa 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 @@ -19,8 +19,9 @@ 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 */ @@ -30,7 +31,7 @@ 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 + * @param endpoint chosen endpoint to invoke * @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 67d3d79a..3eea7452 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 @@ -26,15 +26,14 @@ import org.dom4j.Element; import org.dom4j.io.DOMReader; import org.dom4j.io.DocumentResult; import org.dom4j.io.DocumentSource; -import org.w3c.dom.Node; - import org.springframework.xml.transform.TransformerObjectSupport; +import org.w3c.dom.Node; /** * 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 + *

+ * An {@code AbstractDom4JPayloadEndpoint} only accept one payload element. Multiple payload elements are not in * accordance with WS-I. * * @author Arjen Poutsma @@ -49,8 +48,8 @@ public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupp /** * Set if the request {@link Source} should always be transformed into a new {@link DocumentResult}. - * - *

Default is {@code false}, which is faster. + *

+ * Default is {@code false}, which is faster. */ public void setAlwaysTransform(boolean alwaysTransform) { this.alwaysTransform = alwaysTransform; @@ -71,8 +70,8 @@ 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 + *

+ * 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 @@ -80,8 +79,7 @@ public abstract class AbstractDom4jPayloadEndpoint extends TransformerObjectSupp * * @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 + * @throws javax.xml.transform.TransformerException in case of errors */ protected Element getDocumentElement(Source source) throws TransformerException { if (source == null) { @@ -102,13 +100,12 @@ 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 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. */ 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 aa73f4d3..5efc766f 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 @@ -24,21 +24,20 @@ 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.transform.TransformerObjectSupport; -import org.springframework.xml.DocumentBuilderFactoryUtils; - /** * 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 + *

+ * 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 @@ -70,18 +69,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}. - * - *

Default is {@code false}, which is faster. + *

+ * Default is {@code false}, which is faster. */ public void setAlwaysTransform(boolean alwaysTransform) { this.alwaysTransform = alwaysTransform; @@ -107,8 +104,7 @@ public abstract class AbstractDomPayloadEndpoint extends TransformerObjectSuppor * @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(); } @@ -130,13 +126,13 @@ 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) + *

+ * 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 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 * @throws TransformerException in case of errors @@ -149,8 +145,7 @@ 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(); } } @@ -163,14 +158,13 @@ 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}. + *

+ * The given DOM {@code Document} is to be used for constructing {@code Node}s, by using the various {@code create} + * methods. * - *

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. - * - * @param requestElement the contents of the SOAP message as DOM elements + * @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 115b0fcc..86fefde8 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 @@ -20,15 +20,14 @@ 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; /** * Abstract base class for {@link EndpointExceptionResolver EndpointExceptionResolvers}. - * - *

Provides a set of mapped endpoints that the resolver should map. + *

+ * Provides a set of mapped endpoints that the resolver should map. * * @author Arjen Poutsma * @author Tareq Abed Rabbo @@ -39,17 +38,18 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep /** Shared {@link Log} for subclasses to use. */ protected final Log logger = LogFactory.getLog(getClass()); - private int order = Integer.MAX_VALUE; // default: same as non-Ordered + private int order = Integer.MAX_VALUE; // default: same as non-Ordered private Set mappedEndpoints; private Log warnLogger; /** - * 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. - * - *

If no endpoints are set, both the exception mappings and the default fault will apply to all handlers. This means + * 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. + *

+ * 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. */ @@ -60,9 +60,9 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep /** * 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) @@ -74,8 +74,8 @@ 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. + *

+ * Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered. * * @see org.springframework.core.Ordered#getOrder() */ @@ -89,8 +89,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) */ @@ -109,13 +109,13 @@ 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 ex the exception that got thrown during handler execution * @param messageContext current message context request * @see #setWarnLogCategory * @see #buildLogMessage @@ -130,7 +130,7 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep /** * 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 ex the exception that got thrown during handler execution * @param messageContext the message context * @return the log message to use */ @@ -142,8 +142,8 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep * 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 ex the exception that got thrown during endpoint execution + * @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 ac20425f..4bf2e6ce 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 @@ -25,18 +25,15 @@ import org.jdom2.Element; import org.jdom2.input.DOMBuilder; import org.jdom2.transform.JDOMResult; import org.jdom2.transform.JDOMSource; -import org.w3c.dom.Node; - import org.springframework.xml.transform.TransformerObjectSupport; +import org.w3c.dom.Node; /** * 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 @@ -49,8 +46,8 @@ public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSuppo /** * Set if the request {@link Source} should always be transformed into a new {@link JDOMResult}. - * - *

Default is {@code false}, which is faster. + *

+ * Default is {@code false}, which is faster. */ public void setAlwaysTransform(boolean alwaysTransform) { this.alwaysTransform = alwaysTransform; @@ -65,11 +62,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 @@ -84,8 +81,7 @@ 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(); } @@ -97,8 +93,8 @@ 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. 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 58262c74..d234f956 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 @@ -17,6 +17,7 @@ package org.springframework.ws.server.endpoint; import java.io.StringWriter; + import javax.xml.transform.OutputKeys; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -26,16 +27,15 @@ 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 @@ -63,10 +63,10 @@ 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. - * - *

This can be specified to not log into the category of a class but rather into a specific named category. + * 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. * * @see org.apache.commons.logging.LogFactory#getLog(String) * @see org.apache.log4j.Logger#getLogger(String) @@ -77,8 +77,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} @@ -93,8 +93,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} @@ -114,16 +114,15 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor return true; } - /** Does nothing by default*/ + /** 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(); @@ -138,12 +137,12 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor /** * 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 + * @param source the source to be logged * @throws TransformerException in case of errors */ protected void logMessageSource(String logMessage, Source source) throws TransformerException { @@ -158,9 +157,9 @@ 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 */ 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 e7b001f9..818107da 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 @@ -20,7 +20,6 @@ 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; @@ -31,8 +30,8 @@ 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. + * {@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) @@ -54,36 +53,33 @@ 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. - * - *

Note that all {@link Marshaller} implementations in Spring-WS also implement the {@link Unmarshaller} interface, - * so that you can safely use this constructor. + * 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. * * @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) { Assert.notNull(marshaller, "marshaller must not be null"); if (!(marshaller instanceof Unmarshaller)) { - throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + - "interface. Please set an Unmarshaller explicitly by using the " + - "AbstractMarshallingPayloadEndpoint(Marshaller, Unmarshaller) constructor."); - } - else { + throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + + "interface. Please set an Unmarshaller explicitly by using the " + + "AbstractMarshallingPayloadEndpoint(Marshaller, Unmarshaller) constructor."); + } else { setMarshaller(marshaller); setUnmarshaller((Unmarshaller) marshaller); } @@ -92,7 +88,7 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo /** * Creates a new {@code AbstractMarshallingPayloadEndpoint} with the given marshaller and unmarshaller. * - * @param marshaller the marshaller to use + * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use */ protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller, Unmarshaller unmarshaller) { @@ -154,11 +150,11 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo /** * Callback for post-processing in terms of unmarshalling. Called on each message request, after standard * unmarshalling. - * - *

Default implementation returns {@code true}. + *

+ * Default implementation returns {@code true}. * * @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} * @return {@code true} to continue and call {@link #invokeInternal(Object)}; {@code false} otherwise */ protected boolean onUnmarshalRequest(MessageContext messageContext, Object requestObject) throws Exception { @@ -175,34 +171,32 @@ 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. - * - *

Default implementation is empty. + * 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. + *

+ * The default implementation does nothing. * - *

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 + *

+ * 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 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 4270b245..39316246 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 @@ -19,16 +19,15 @@ package org.springframework.ws.server.endpoint; import javax.xml.transform.Source; import javax.xml.transform.sax.SAXResult; -import org.xml.sax.ContentHandler; - import org.springframework.xml.transform.TransformerObjectSupport; +import org.xml.sax.ContentHandler; /** * 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 + *

+ * 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 @@ -59,21 +58,21 @@ 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. - * - *

If an incoming message does not contain a payload, this method will not be invoked. + * 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. - * - *

If an incoming message does not contain a payload, this method will be invoked with {@code null} as content + * 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. * * @param contentHandler the content handler used to parse the request 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 c16fd7e1..60a2ede3 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 @@ -18,6 +18,7 @@ package org.springframework.ws.server.endpoint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; + import javax.xml.namespace.NamespaceContext; import javax.xml.stream.XMLEventFactory; import javax.xml.stream.XMLEventReader; @@ -42,7 +43,7 @@ import org.springframework.ws.context.MessageContext; * * @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 @@ -62,9 +63,9 @@ 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} */ @@ -92,8 +93,7 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo if (streamReader != null) { try { eventReader = getInputFactory().createXMLEventReader(streamReader); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { eventReader = null; } } @@ -102,11 +102,9 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo if (eventReader == null) { try { eventReader = getInputFactory().createXMLEventReader(source); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { eventReader = null; - } - catch (UnsupportedOperationException ex) { + } catch (UnsupportedOperationException ex) { eventReader = null; } } @@ -128,8 +126,7 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo if (eventWriter == null) { try { eventWriter = getOutputFactory().createXMLEventWriter(result); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { // ignore } } @@ -137,20 +134,19 @@ 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 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 */ - protected abstract void invokeInternal(XMLEventReader eventReader, - XMLEventConsumer eventWriter, - XMLEventFactory eventFactory) throws Exception; + protected abstract void invokeInternal(XMLEventReader eventReader, XMLEventConsumer eventWriter, + 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 { @@ -194,8 +190,7 @@ public abstract class AbstractStaxEventPayloadEndpoint extends AbstractStaxPaylo try { ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); transform(new StreamSource(is), messageContext.getResponse().getPayloadResult()); - } - catch (TransformerException ex) { + } catch (TransformerException ex) { throw new XMLStreamException(ex); } } 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 a7f88b39..40bad32c 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 @@ -23,8 +23,7 @@ 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 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 8b719717..a9b7fe97 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 @@ -18,6 +18,7 @@ package org.springframework.ws.server.endpoint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; + import javax.xml.namespace.NamespaceContext; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLStreamException; @@ -68,8 +69,7 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl if (eventReader != null) { try { streamReader = StaxUtils.createEventStreamReader(eventReader); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { streamReader = null; } } @@ -79,11 +79,9 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl if (streamReader == null) { try { streamReader = getInputFactory().createXMLStreamReader(source); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { streamReader = null; - } - catch (UnsupportedOperationException ex) { + } catch (UnsupportedOperationException ex) { streamReader = null; } } @@ -105,8 +103,7 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl if (streamWriter == null) { try { streamWriter = getOutputFactory().createXMLStreamWriter(result); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { // ignore } } @@ -114,8 +111,8 @@ 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 @@ -123,8 +120,8 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl 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 { @@ -160,8 +157,7 @@ public abstract class AbstractStaxStreamPayloadEndpoint extends AbstractStaxPayl 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); } } 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 762650fe..0c40a61a 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 @@ -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,12 +58,12 @@ 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}; + this.validators = new Validator[] { validator }; } /** Return the Validators for this controller. */ @@ -92,12 +92,11 @@ 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 errors validation errors holder + * @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 */ 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 c08ce77f..919273f2 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 @@ -16,20 +16,6 @@ package org.springframework.ws.server.endpoint; -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; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; - import nu.xom.Attribute; import nu.xom.Builder; import nu.xom.Document; @@ -40,21 +26,36 @@ import nu.xom.ParsingException; import nu.xom.Serializer; import nu.xom.ValidityException; 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 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; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +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 org.w3c.dom.Node; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; /** * 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 + *

+ * An {@code AbstractXomPayloadEndpoint} only accept one payload element. Multiple payload elements are not in * accordance with WS-I. * * @author Arjen Poutsma @@ -73,8 +74,7 @@ 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; @@ -97,9 +97,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 @@ -109,8 +108,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. @@ -125,12 +124,10 @@ 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"); } } @@ -142,20 +139,16 @@ 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 (ValidityException ex) { + } catch (ValidityException ex) { throw new XomParsingException(ex); - } - catch (ParsingException ex) { + } catch (ParsingException ex) { throw new XomParsingException(ex); } } @@ -177,8 +170,7 @@ 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); } } @@ -189,8 +181,7 @@ 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); } } @@ -201,8 +192,7 @@ 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); } } @@ -244,8 +234,7 @@ 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); } @@ -301,35 +290,25 @@ 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 3f242f78..59a13f33 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 @@ -20,8 +20,8 @@ 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 + *

+ * 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 @@ -32,8 +32,8 @@ public interface MessageEndpoint { /** * Invokes an operation. - * - *

The given {@code messageContext} can be used to create a response. + *

+ * The given {@code messageContext} can be used to create a response. * * @param messageContext the message context * @throws Exception if an exception occurs 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 b85313f1..c02f7149 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 @@ -26,8 +26,8 @@ import org.springframework.util.ReflectionUtils; /** * 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}. + *

+ * Consists of a {@link Method}, and a bean {@link Object}. * * @author Arjen Poutsma * @since 1.0.0 @@ -43,7 +43,7 @@ public final class MethodEndpoint { /** * Constructs a new method endpoint with the given bean and method. * - * @param bean the object bean + * @param bean the object bean * @param method the method */ public MethodEndpoint(Object bean, Method method) { @@ -57,8 +57,8 @@ 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 bean the object bean + * @param methodName the method name * @param parameterTypes the method parameter types * @throws NoSuchMethodException when the method cannot be found */ @@ -74,9 +74,9 @@ 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. * - * @param beanName the bean name + * @param beanName the bean name * @param beanFactory the bean factory to use for bean initialization - * @param method the method + * @param method the method */ public MethodEndpoint(String beanName, BeanFactory beanFactory, Method method) { Assert.hasText(beanName, "'beanName' must not be null"); @@ -94,8 +94,7 @@ public final class MethodEndpoint { if (beanFactory != null && bean instanceof String) { String beanName = (String) bean; return beanFactory.getBean(beanName); - } - else { + } else { return bean; } } @@ -132,12 +131,10 @@ 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()); + 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 b85a7732..62d51695 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 @@ -20,8 +20,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 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 1aa6bafd..6563a8c2 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 @@ -45,9 +45,8 @@ public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSup * 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 @@ -70,7 +69,6 @@ public abstract class AbstractMethodEndpointAdapter extends TransformerObjectSup * @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 2cbddc42..8c334f86 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 @@ -42,8 +42,9 @@ import org.springframework.ws.server.endpoint.adapter.method.jaxb.JaxbElementPay import org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElementPayloadMethodProcessor; /** - * Default extension of {@link AbstractMethodEndpointAdapter} with support for pluggable {@linkplain - * MethodArgumentResolver argument resolvers} and {@linkplain MethodReturnValueHandler return value handlers}. + * Default extension of {@link AbstractMethodEndpointAdapter} with support for pluggable + * {@linkplain MethodArgumentResolver argument resolvers} and {@linkplain MethodReturnValueHandler return value + * handlers}. * * @author Arjen Poutsma * @since 2.0 @@ -61,11 +62,9 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter private static final String XOM_CLASS_NAME = "nu.xom.Element"; - private static final String SOAP_METHOD_ARGUMENT_RESOLVER_CLASS_NAME = - "org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver"; + private static final String SOAP_METHOD_ARGUMENT_RESOLVER_CLASS_NAME = "org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver"; - private static final String SOAP_HEADER_ELEMENT_ARGUMENT_RESOLVER_CLASS_NAME = - "org.springframework.ws.soap.server.endpoint.adapter.method.SoapHeaderElementMethodArgumentResolver"; + private static final String SOAP_HEADER_ELEMENT_ARGUMENT_RESOLVER_CLASS_NAME = "org.springframework.ws.soap.server.endpoint.adapter.method.SoapHeaderElementMethodArgumentResolver"; private List methodArgumentResolvers; @@ -99,12 +98,10 @@ 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) { + public void setCustomMethodArgumentResolvers(List customMethodArgumentResolvers) { this.customMethodArgumentResolvers = customMethodArgumentResolvers; } @@ -130,12 +127,10 @@ 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) { + public void setCustomMethodReturnValueHandlers(List customMethodReturnValueHandlers) { this.customMethodReturnValueHandlers = customMethodReturnValueHandlers; } @@ -201,11 +196,10 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter @SuppressWarnings("unchecked") private void addMethodArgumentResolver(String className, List methodArgumentResolvers) { try { - Class methodArgumentResolverClass = - (Class) ClassUtils.forName(className, getClassLoader()); + Class methodArgumentResolverClass = (Class) ClassUtils + .forName(className, getClassLoader()); methodArgumentResolvers.add(BeanUtils.instantiateClass(methodArgumentResolverClass)); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { logger.warn("Could not find \"" + className + "\" on the classpath"); } } @@ -244,8 +238,8 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter @Override protected boolean supportsInternal(MethodEndpoint methodEndpoint) { - return supportsParameters(methodEndpoint.getMethodParameters()) && - supportsReturnType(methodEndpoint.getReturnType()); + return supportsParameters(methodEndpoint.getMethodParameters()) + && supportsReturnType(methodEndpoint.getReturnType()); } private boolean supportsParameters(MethodParameter[] methodParameters) { @@ -253,8 +247,8 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter boolean supported = false; for (MethodArgumentResolver methodArgumentResolver : methodArgumentResolvers) { if (logger.isTraceEnabled()) { - logger.trace("Testing if argument resolver [" + methodArgumentResolver + "] supports [" + - methodParameter.getGenericParameterType() + "]"); + logger.trace("Testing if argument resolver [" + methodArgumentResolver + "] supports [" + + methodParameter.getGenericParameterType() + "]"); } if (methodArgumentResolver.supportsParameter(methodParameter)) { supported = true; @@ -302,8 +296,8 @@ 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 + *

+ * This implementation iterates over the set {@linkplain #setMethodArgumentResolvers(List) argument resolvers} to * resolve each argument. * * @param messageContext the current message context @@ -311,8 +305,7 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter * @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++) { @@ -328,18 +321,17 @@ 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 + *

+ * 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 returnValue the return value * @param methodEndpoint the method endpoint to get arguments for * @throws Exception in case of errors */ - protected void handleMethodReturnValue(MessageContext messageContext, - Object returnValue, - MethodEndpoint methodEndpoint) throws Exception { + protected void handleMethodReturnValue(MessageContext messageContext, Object returnValue, + MethodEndpoint methodEndpoint) throws Exception { MethodParameter returnType = methodEndpoint.getReturnType(); for (MethodReturnValueHandler methodReturnValueHandler : methodReturnValueHandlers) { if (methodReturnValueHandler.supportsReturnType(returnType)) { @@ -347,7 +339,6 @@ 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 a7579a82..652f3f8b 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 @@ -26,43 +26,41 @@ 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()}. - * - *

Prefer to use this adapter rather than the plain {@link MarshallingMethodEndpointAdapter} in combination with Java 5 + * 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}. * * @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 + * 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); @@ -71,7 +69,7 @@ public class GenericMarshallingMethodEndpointAdapter extends MarshallingMethodEn /** * Creates a new {@code GenericMarshallingMethodEndpointAdapter} with the given marshaller and unmarshaller. * - * @param marshaller the marshaller to use + * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use */ public GenericMarshallingMethodEndpointAdapter(Marshaller marshaller, Unmarshaller unmarshaller) { @@ -87,12 +85,10 @@ 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()); } } @@ -101,12 +97,10 @@ 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 9c4f033e..2b673962 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 @@ -31,27 +31,30 @@ import org.springframework.ws.support.MarshallingUtils; /** * Adapter that supports endpoint methods that use marshalling. Supports methods with the following signature: + * *

  * void handleMyMessage(MyUnmarshalledType request);
  * 
+ * * or + * *
  * 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 + * + * 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 { @@ -61,35 +64,32 @@ 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. - * - *

Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, - * so that you can safely use this constructor. + * 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. * * @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"); if (!(marshaller instanceof Unmarshaller)) { - throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + - "interface. Please set an Unmarshaller explicitly by using the " + - "MarshallingMethodEndpointAdapter(Marshaller, Unmarshaller) constructor."); - } - else { + throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + + "interface. Please set an Unmarshaller explicitly by using the " + + "MarshallingMethodEndpointAdapter(Marshaller, Unmarshaller) constructor."); + } else { this.setMarshaller(marshaller); this.setUnmarshaller((Unmarshaller) marshaller); } @@ -98,7 +98,7 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap /** * Creates a new {@code MarshallingMethodEndpointAdapter} with the given marshaller and unmarshaller. * - * @param marshaller the marshaller to use + * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use */ public MarshallingMethodEndpointAdapter(Marshaller marshaller, Unmarshaller unmarshaller) { @@ -138,7 +138,7 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap protected void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception { WebServiceMessage request = messageContext.getRequest(); Object requestObject = unmarshalRequest(request); - Object responseObject = methodEndpoint.invoke(new Object[]{requestObject}); + Object responseObject = methodEndpoint.invoke(new Object[] { requestObject }); if (responseObject != null) { WebServiceMessage response = messageContext.getResponse(); marshalResponse(responseObject, response); @@ -161,8 +161,7 @@ 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) @@ -180,8 +179,7 @@ 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 02d850e2..94d2ee1e 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 @@ -24,8 +24,8 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher; /** * 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 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 41a82b8c..da9dbb73 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 @@ -25,19 +25,21 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher; /** * 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}. - * - *

This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}. + * + * 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}. * * @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 { @@ -45,8 +47,8 @@ public class MessageMethodEndpointAdapter extends AbstractMethodEndpointAdapter @Override protected boolean supportsInternal(MethodEndpoint methodEndpoint) { Method method = methodEndpoint.getMethod(); - return Void.TYPE.isAssignableFrom(method.getReturnType()) && method.getParameterTypes().length == 1 && - MessageContext.class.isAssignableFrom(method.getParameterTypes()[0]); + return Void.TYPE.isAssignableFrom(method.getReturnType()) && method.getParameterTypes().length == 1 + && MessageContext.class.isAssignableFrom(method.getParameterTypes()[0]); } @Override 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 f8dfdc02..83feb5b8 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 @@ -28,8 +28,8 @@ import org.springframework.xml.transform.TransformerObjectSupport; /** * 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 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 eb8a1d5e..9d67d62d 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 @@ -17,6 +17,7 @@ package org.springframework.ws.server.endpoint.adapter; import java.lang.reflect.Method; + import javax.xml.transform.Source; import org.springframework.ws.WebServiceMessage; @@ -27,23 +28,27 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher; /** * Adapter that supports endpoint methods that use marshalling. Supports methods with the following signature: + * *

  * void handleMyMessage(Source request);
  * 
+ * * or + * *
  * 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}. - * - *

This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}. + * + * 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}. * * @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 { @@ -51,9 +56,8 @@ 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]); } 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 89a182a6..5226c9db 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 @@ -19,6 +19,7 @@ package org.springframework.ws.server.endpoint.adapter; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Map; + import javax.xml.namespace.QName; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; @@ -28,38 +29,47 @@ 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: + * *

- * void handleMyMessage(@XPathParam("/root/child/text")String param);
+ * void handleMyMessage(@XPathParam("/root/child/text") String param);
  * 
+ * * or + * *
- * Source handleMyMessage(@XPathParam("/root/child/text")String param1, @XPathParam("/root/child/number")double
- * param2);
+ * Source handleMyMessage(@XPathParam("/root/child/text") String param1,
+ * 		@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:
  • {@code boolean}, or {@link Boolean}
  • {@code double}, or {@link - * Double}
  • {@link String}
  • {@link Node}
  • {@link NodeList}
+ * + * 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}
  • + *
  • {@link String}
  • + *
  • {@link Node}
  • + *
  • {@link 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 @@ -106,10 +116,10 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd } private boolean isSupportedType(Class clazz) { - return Boolean.class.isAssignableFrom(clazz) || Boolean.TYPE.isAssignableFrom(clazz) || - Double.class.isAssignableFrom(clazz) || Double.TYPE.isAssignableFrom(clazz) || - Node.class.isAssignableFrom(clazz) || NodeList.class.isAssignableFrom(clazz) || - String.class.isAssignableFrom(clazz); + return Boolean.class.isAssignableFrom(clazz) || Boolean.TYPE.isAssignableFrom(clazz) + || Double.class.isAssignableFrom(clazz) || Double.TYPE.isAssignableFrom(clazz) + || Node.class.isAssignableFrom(clazz) || NodeList.class.isAssignableFrom(clazz) + || String.class.isAssignableFrom(clazz); } @Override @@ -133,23 +143,17 @@ 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 { - throw new IllegalArgumentException("Invalid parameter type [" + parameterTypes[i] + "]. " + - "Supported are: Boolean, Double, Node, NodeList, and String."); + } else { + throw new IllegalArgumentException("Invalid parameter type [" + parameterTypes[i] + "]. " + + "Supported are: Boolean, Double, Node, NodeList, and String."); } args[i] = xpath.evaluate(expression, payloadElement, conversionType); } @@ -179,5 +183,4 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd return document.getDocumentElement(); } - } 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 939e44c4..0dfef4c4 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 @@ -18,6 +18,7 @@ package org.springframework.ws.server.endpoint.adapter.method; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; + import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.stream.StreamResult; @@ -42,8 +43,8 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu /** * {@inheritDoc} - * - *

This implementation gets checks if the given parameter is annotated with {@link RequestPayload}, and invokes + *

+ * This implementation gets checks if the given parameter is annotated with {@link RequestPayload}, and invokes * {@link #supportsRequestPayloadParameter(org.springframework.core.MethodParameter)} afterwards. */ @Override @@ -51,8 +52,7 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu Assert.isTrue(parameter.getParameterIndex() >= 0, "Parameter index smaller than 0"); if (parameter.getParameterAnnotation(RequestPayload.class) == null) { return false; - } - else { + } else { return supportsRequestPayloadParameter(parameter); } } @@ -67,11 +67,11 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu protected abstract boolean supportsRequestPayloadParameter(MethodParameter parameter); // MethodReturnValueHandler - + /** * {@inheritDoc} - * - *

This implementation gets checks if the method of the given return type is annotated with {@link ResponsePayload}, + *

+ * 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 @@ -79,15 +79,14 @@ public abstract class AbstractPayloadMethodProcessor extends TransformerObjectSu 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 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 ebbb38ce..32f221aa 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 @@ -49,7 +49,7 @@ public abstract class AbstractPayloadSourceMethodProcessor extends AbstractPaylo /** * Resolves the given parameter, annotated with {@link RequestPayload}, into a method argument. * - * @param parameter the parameter to resolve to an argument + * @param parameter the parameter to resolve to an argument * @param requestPayload the request payload * @return the resolved argument. May be {@code null}. * @throws Exception in case of errors @@ -74,7 +74,7 @@ public abstract class AbstractPayloadSourceMethodProcessor extends AbstractPaylo /** * Creates a response payload for the given return value. * - * @param returnType the return type to handle + * @param returnType the return type to handle * @param returnValue the return value to handle * @return the response payload * @throws Exception in case of errors 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 4e7ba29d..f396e62e 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 @@ -46,15 +46,14 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc * @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. - * - *

Note that all {@link Marshaller} implementations in Spring also implement the {@link Unmarshaller} interface, so + * 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. * * @param marshaller object used as marshaller and unmarshaller @@ -70,7 +69,7 @@ public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProc /** * Creates a new {@code MarshallingPayloadMethodProcessor} with the given marshaller and unmarshaller. * - * @param marshaller the marshaller to use + * @param marshaller the marshaller to use * @param unmarshaller the unmarshaller to use */ public MarshallingPayloadMethodProcessor(Marshaller marshaller, Unmarshaller unmarshaller) { @@ -113,11 +112,9 @@ 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()); } } @@ -140,12 +137,10 @@ 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/MethodArgumentResolver.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/MethodArgumentResolver.java index dd9b5b17..3e4a7ddc 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 @@ -20,9 +20,9 @@ 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 @@ -41,9 +41,9 @@ public interface MethodArgumentResolver { * 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 038e1855..7e0c1d67 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 @@ -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 @@ -41,14 +41,13 @@ public interface MethodReturnValueHandler { * 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 returnValue the return value to handle + * @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 */ void handleReturnValue(MessageContext messageContext, MethodParameter returnType, Object returnValue) throws Exception; - } 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 01d5ba04..366cb154 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 @@ -17,6 +17,7 @@ package org.springframework.ws.server.endpoint.adapter.method; import java.io.ByteArrayInputStream; + import javax.xml.stream.Location; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -29,13 +30,12 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamSource; -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; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.xml.sax.InputSource; /** * Implementation of {@link MethodArgumentResolver} and {@link MethodReturnValueHandler} that supports {@link Source} @@ -67,28 +67,23 @@ 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 ignored) { streamReader = null; - } - catch (XMLStreamException ignored) { + } catch (XMLStreamException ignored) { streamReader = null; } if (streamReader == null) { @@ -117,11 +112,11 @@ public class SourcePayloadMethodProcessor extends AbstractPayloadSourceMethodPro } /** - * 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. + * 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. * * @return the created factory */ 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 176c9c9d..5eed42a7 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 @@ -18,6 +18,7 @@ package org.springframework.ws.server.endpoint.adapter.method; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; + import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -34,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 @@ -48,8 +49,7 @@ 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,8 +65,7 @@ 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(); @@ -81,8 +80,7 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport if (eventReader != null) { try { streamReader = StaxUtils.createEventStreamReader(eventReader); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { streamReader = null; } } @@ -91,11 +89,9 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport if (streamReader == null) { try { streamReader = inputFactory.createXMLStreamReader(requestSource); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { streamReader = null; - } - catch (UnsupportedOperationException ex) { + } catch (UnsupportedOperationException ex) { streamReader = null; } } @@ -116,8 +112,7 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport if (streamReader != null) { try { eventReader = inputFactory.createXMLEventReader(streamReader); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { eventReader = null; } } @@ -127,11 +122,9 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport if (eventReader == null) { try { eventReader = inputFactory.createXMLEventReader(requestSource); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { eventReader = null; - } - catch (UnsupportedOperationException ex) { + } catch (UnsupportedOperationException ex) { eventReader = null; } } @@ -144,11 +137,11 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport } /** - * 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. + * 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. * * @return the created factory */ @@ -162,6 +155,4 @@ public class StaxPayloadMethodArgumentResolver extends TransformerObjectSupport return new ByteArrayInputStream(bos.toByteArray()); } - - } 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 4874fce0..52f9b7ad 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 @@ -25,11 +25,6 @@ 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; @@ -38,14 +33,18 @@ 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. - * - *

This resolver supports parameters annotated with {@link XPathParam @XPathParam} that specifies the XPath expression + *

+ * 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}. + * 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,9 +59,8 @@ 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; @@ -78,13 +76,11 @@ 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); } } @@ -112,20 +108,15 @@ 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; } } @@ -145,9 +136,9 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver /** * 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 */ @@ -155,5 +146,4 @@ public class XPathParamMethodArgumentResolver implements MethodArgumentResolver return XPathFactory.newInstance(); } - } 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 7396c6de..772a52b0 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 @@ -20,14 +20,13 @@ import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; -import org.springframework.core.MethodParameter; -import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; - import org.dom4j.Document; 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 @@ -76,4 +75,4 @@ public class Dom4jPayloadMethodProcessor extends AbstractPayloadSourceMethodProc return Element.class.equals(parameter.getParameterType()); } -} \ No newline at end of file +} 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 83f72661..95e1956b 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 @@ -22,7 +22,6 @@ 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; @@ -48,8 +47,7 @@ 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()); @@ -62,8 +60,7 @@ 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 e63fd872..8a45ada8 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 @@ -19,14 +19,13 @@ package org.springframework.ws.server.endpoint.adapter.method.dom; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; -import org.springframework.core.MethodParameter; -import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor; - import org.jdom2.Document; 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; /** @@ -51,8 +50,7 @@ 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(); } @@ -78,4 +76,4 @@ public class JDomPayloadMethodProcessor extends AbstractPayloadSourceMethodProce return Element.class.equals(parameter.getParameterType()); } -} \ No newline at end of file +} 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 cfe92f3e..f04234b6 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 @@ -16,8 +16,15 @@ 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; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -25,16 +32,10 @@ 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 @@ -60,8 +61,7 @@ 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(); } @@ -98,9 +98,9 @@ public class XomPayloadMethodProcessor extends AbstractPayloadSourceMethodProces /** * 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 */ 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 ab837732..08731918 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 @@ -24,6 +24,7 @@ import java.io.Writer; import java.net.URL; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; @@ -43,12 +44,6 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -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; @@ -57,6 +52,11 @@ 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 @@ -74,22 +74,22 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa private final ConcurrentMap, JAXBContext> jaxbContexts = new ConcurrentHashMap, JAXBContext>(); @Override - public final void handleReturnValue(MessageContext messageContext, - MethodParameter returnType, Object returnValue) throws Exception { + public final void handleReturnValue(MessageContext messageContext, MethodParameter returnType, Object returnValue) + throws Exception { if (returnValue != null) { handleReturnValueInternal(messageContext, returnType, returnValue); } } - protected abstract void handleReturnValueInternal(MessageContext messageContext, - MethodParameter returnType, Object returnValue) throws Exception; + protected abstract void handleReturnValueInternal(MessageContext messageContext, MethodParameter returnType, + Object returnValue) throws Exception; /** * 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 + * @param clazz the clazz to create a marshaller for + * @param jaxbElement the object to be marshalled * @throws JAXBException in case of JAXB2 errors */ protected final void marshalToResponsePayload(MessageContext messageContext, Class clazz, Object jaxbElement) @@ -106,14 +106,12 @@ 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); } } @@ -123,7 +121,7 @@ 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 + * @param clazz the class to unmarshal * @return the unmarshalled object, or {@code null} if the request has no payload * @throws JAXBException in case of JAXB2 errors */ @@ -140,8 +138,7 @@ 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); } } @@ -150,7 +147,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa * 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 + * @param clazz the class to unmarshal * @return the unmarshalled element, or {@code null} if the request has no payload * @throws JAXBException in case of JAXB2 errors */ @@ -167,8 +164,7 @@ 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); } } @@ -181,8 +177,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa private JAXBException convertToJaxbException(Exception ex) { if (ex instanceof JAXBException) { return (JAXBException) ex; - } - else { + } else { return new JAXBException(ex); } } @@ -221,7 +216,6 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa return createUnmarshaller(getJaxbContext(clazz)); } - private JAXBContext getJaxbContext(Class clazz) throws JAXBException { Assert.notNull(clazz, "'clazz' must not be null"); JAXBContext jaxbContext = jaxbContexts.get(clazz); @@ -419,12 +413,10 @@ 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); } } } - -} \ No newline at end of file +} 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 7d809832..d1a4ab64 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 @@ -18,6 +18,7 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; + import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; @@ -42,8 +43,7 @@ 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); @@ -56,8 +56,8 @@ public class JaxbElementPayloadMethodProcessor extends AbstractJaxb2PayloadMetho } @Override - protected void handleReturnValueInternal(MessageContext messageContext, MethodParameter returnType, Object returnValue) - throws JAXBException { + protected void handleReturnValueInternal(MessageContext messageContext, MethodParameter returnType, + Object returnValue) throws JAXBException { 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 f21de94a..409a7e3c 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 @@ -27,8 +27,8 @@ 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}. + * 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,8 +38,7 @@ 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 @@ -48,8 +47,7 @@ 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; } @@ -62,11 +60,10 @@ public class XmlRootElementPayloadMethodProcessor extends AbstractJaxb2PayloadMe } @Override - protected void handleReturnValueInternal(MessageContext messageContext, MethodParameter returnType, Object returnValue) - throws JAXBException { + protected void handleReturnValueInternal(MessageContext messageContext, MethodParameter returnType, + Object returnValue) throws JAXBException { Class parameterType = returnType.getParameterType(); marshalToResponsePayload(messageContext, parameterType, returnValue); } - } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/package.html b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/package.html index 2bdc3627..aae56b7b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/package.html +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/package.html @@ -1,6 +1,6 @@ -Provides the MethodArgumentResolver and MethodReturnValueHandler abstractions, and various +Provides the MethodArgumentResolver and MethodReturnValueHandler abstractions, and various implementations thereof. 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 4f75c92f..c5d8236a 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 @@ -28,10 +28,11 @@ 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 {@link - * AbstractAnnotationMethodEndpointMapping} implementation, such as {@link SoapActionAnnotationMethodEndpointMapping}. + *

+ * 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}. * * @author Arjen Poutsma * @see org.springframework.context.annotation.ClassPathBeanDefinitionScanner 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 44335ce3..d3e64869 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 @@ -21,12 +21,13 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; 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. - * - *

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 @@ -35,7 +36,7 @@ import javax.xml.XMLConstants; */ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD}) +@Target({ ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD }) public @interface Namespace { /** 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 52b4d416..7514d5d7 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 @@ -31,7 +31,7 @@ import java.lang.annotation.Target; */ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD}) +@Target({ ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD }) 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 69c71f75..2e623798 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 @@ -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 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 9dec3c1a..3a46432e 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 @@ -23,9 +23,9 @@ import java.lang.annotation.RetentionPolicy; 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. + * 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. * * @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 67ddf3a8..61ff2f80 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 @@ -23,9 +23,9 @@ import java.lang.annotation.RetentionPolicy; 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. + * 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. * * @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 55151359..330f24bd 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 @@ -24,9 +24,14 @@ 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:

  • {@code boolean}, or {@link - * Boolean}
  • {@code double}, or {@link Double}
  • {@link String}
  • {@link - * org.w3c.dom.Node}
  • {@link org.w3c.dom.NodeList}
+ * expression to use. The parameter can be of the following types: + *
    + *
  • {@code boolean}, or {@link Boolean}
  • + *
  • {@code double}, or {@link Double}
  • + *
  • {@link String}
  • + *
  • {@link org.w3c.dom.Node}
  • + *
  • {@link org.w3c.dom.NodeList}
  • + *
* * @author Arjen Poutsma * @see org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter 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 1aa2ae3c..251d535b 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 @@ -17,12 +17,10 @@ package org.springframework.ws.server.endpoint.interceptor; 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; @@ -39,13 +37,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 + * 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 + *

+ * 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 @@ -88,18 +88,18 @@ 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. + * 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. */ public void setSchema(Resource schema) { setSchemas(schema); } /** - * 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. + * 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. */ public void setSchemas(Resource... schemas) { Assert.notEmpty(schemas, "schemas must not be empty or null"); @@ -111,9 +111,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. + * 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. * * @param schema the xsd schema to use * @throws IOException in case of I/O errors @@ -123,9 +123,8 @@ 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 @@ -169,11 +168,11 @@ 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. - * - *

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. + * 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. * * @param messageContext the message context * @return {@code true} if the message is valid; {@code false} otherwise @@ -188,8 +187,7 @@ 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"); } } @@ -198,11 +196,11 @@ 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 + * @param errors the validation errors * @return {@code true} to continue processing the request, {@code false} (the default) otherwise */ protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors) @@ -214,10 +212,10 @@ 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. - * - *

Returns {@code true} if the request is valid, or {@code false} if it isn't. + * 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 @@ -231,8 +229,7 @@ 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"); } } @@ -245,7 +242,7 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup * 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 + * @param errors the validation errors * @return {@code true} to continue the response interceptor chain, {@code false} (the default) otherwise */ protected boolean handleResponseValidationErrors(MessageContext messageContext, SAXParseException[] errors) { @@ -261,10 +258,9 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup return true; } - /** Does nothing by default.*/ + /** 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. 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 26b23f7b..cddd39ca 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 @@ -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 @@ -45,6 +45,7 @@ public class DelegatingSmartEndpointInterceptor implements SmartEndpointIntercep /** * Returns the delegate. + * * @return the delegate */ public EndpointInterceptor getDelegate() { @@ -53,8 +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) { @@ -64,10 +65,10 @@ public class DelegatingSmartEndpointInterceptor implements SmartEndpointIntercep /** * Indicates whether this interceptor should intercept the given request message. + *

+ * This implementation always returns {@code true}. * - *

This implementation always returns {@code true}. - * - * @param request the request message + * @param request the request message * @param endpoint chosen endpoint to invoke * @return {@code true} to indicate that this interceptor applies; {@code false} otherwise */ 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 24d5beb2..de58fc84 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 @@ -18,10 +18,9 @@ package org.springframework.ws.server.endpoint.interceptor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Element; - import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; +import org.w3c.dom.Element; /** * Default implementation of the {@code EndpointInterceptor} interface, for simplified implementation of @@ -74,6 +73,5 @@ 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 d19f912e..82fc3376 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 @@ -24,9 +24,9 @@ import org.springframework.ws.server.endpoint.AbstractLoggingInterceptor; /** * 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 7a44979e..ee585617 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 @@ -18,6 +18,7 @@ package org.springframework.ws.server.endpoint.interceptor; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; + import javax.xml.transform.Source; import javax.xml.transform.Templates; import javax.xml.transform.Transformer; @@ -28,9 +29,6 @@ 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; @@ -39,15 +37,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. - * - *

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) @@ -78,8 +77,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} @@ -97,8 +96,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} @@ -128,10 +127,9 @@ public class PayloadTransformingInterceptor extends TransformerObjectSupport return true; } - /** Does nothing by default.*/ + /** 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 { 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 2ce19c16..da249ca8 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 @@ -26,8 +26,8 @@ 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. - * - *

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 @@ -38,13 +38,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). - * - *

Switch this flag on to detect endpoint beans in ancestor contexts (typically the Spring root - * WebApplicationContext) as well. + *

+ * 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. */ public void setDetectEndpointsInAncestorContexts(boolean detectEndpointsInAncestorContexts) { this.detectEndpointsInAncestorContexts = detectEndpointsInAncestorContexts; @@ -61,14 +60,13 @@ public abstract class AbstractAnnotationMethodEndpointMapping extends Abstrac if (logger.isDebugEnabled()) { logger.debug("Looking for endpoints in application context: " + getApplicationContext()); } - String[] beanNames = (this.detectEndpointsInAncestorContexts ? - BeanFactoryUtils.beanNamesForTypeIncludingAncestors(getApplicationContext(), Object.class) : - getApplicationContext().getBeanNamesForType(Object.class)); + String[] beanNames = (this.detectEndpointsInAncestorContexts + ? BeanFactoryUtils.beanNamesForTypeIncludingAncestors(getApplicationContext(), Object.class) + : getApplicationContext().getBeanNamesForType(Object.class)); 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 99090fd6..3b0e7847 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 @@ -41,7 +41,7 @@ import org.springframework.ws.server.SmartEndpointInterceptor; */ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport implements EndpointMapping, Ordered { - private int order = Integer.MAX_VALUE; // default: same as non-Ordered + private int order = Integer.MAX_VALUE; // default: same as non-Ordered private Object defaultEndpoint; @@ -74,8 +74,8 @@ 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. + *

+ * Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered. * * @see org.springframework.core.Ordered#getOrder() */ @@ -102,8 +102,8 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i Map smartInterceptors = BeanFactoryUtils .beansOfTypeIncludingAncestors(getApplicationContext(), SmartEndpointInterceptor.class, true, false); if (!smartInterceptors.isEmpty()) { - this.smartInterceptors = - smartInterceptors.values().toArray(new SmartEndpointInterceptor[smartInterceptors.size()]); + this.smartInterceptors = smartInterceptors.values() + .toArray(new SmartEndpointInterceptor[smartInterceptors.size()]); } } @@ -149,18 +149,16 @@ 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 endpoint the endpoint * @param interceptors the endpoint interceptors * @return the created invocation chain * @see #setInterceptors(org.springframework.ws.server.EndpointInterceptor[]) */ - protected EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext, - Object endpoint, - EndpointInterceptor[] interceptors) { + protected EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext, Object endpoint, + EndpointInterceptor[] interceptors) { return new EndpointInvocationChain(endpoint, interceptors); } @@ -176,8 +174,8 @@ 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. - * - *

Default is {@code null}, indicating no default endpoint. + *

+ * Default is {@code null}, indicating no default endpoint. * * @param defaultEndpoint the default endpoint, or null if none */ @@ -186,8 +184,7 @@ 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 @@ -195,18 +192,16 @@ public abstract class AbstractEndpointMapping extends ApplicationObjectSupport i 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. - * - *

The returned endpoint can be a string, in which case it is resolved as a bean name. Also, it can take the form + * 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. * * @return the looked up endpoint instance, or null 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 cad0e768..77731569 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 @@ -26,10 +26,10 @@ 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. - * - *

Subclasses determine the exact nature of the key in the enpoint map; this can be a qualified name, a SOAP Header, the + * 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. * * @author Arjen Poutsma @@ -47,21 +47,21 @@ 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. - * - *

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. + * 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. */ 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; @@ -78,8 +78,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()) { @@ -100,8 +100,7 @@ public abstract class AbstractMapBasedEndpointMapping extends AbstractEndpointMa 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} */ @@ -130,16 +129,15 @@ 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 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); if (mappedEndpoint != null) { - throw new ApplicationContextException("Cannot map endpoint [" + endpoint + "] on registration key [" + key + - "]: there's already endpoint [" + mappedEndpoint + "] mapped"); + throw new ApplicationContextException("Cannot map endpoint [" + endpoint + "] on registration key [" + key + + "]: there's already endpoint [" + mappedEndpoint + "] mapped"); } if (!lazyInitEndpoints && endpoint instanceof String) { String endpointName = (String) endpoint; @@ -156,11 +154,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}. + * {@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 + * {@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 38627329..93711098 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 @@ -38,10 +38,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 +51,7 @@ 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) @@ -89,15 +88,15 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM /** * Register the given endpoint instance under the key. * - * @param key the lookup key + * @param key the lookup key * @param endpoint the method endpoint instance * @throws BeansException if the endpoint could not be registered */ protected void registerEndpoint(T key, MethodEndpoint endpoint) throws BeansException { Object mappedEndpoint = endpointMap.get(key); if (mappedEndpoint != null) { - throw new ApplicationContextException("Cannot map endpoint [" + endpoint + "] on registration key [" + key + - "]: there's already endpoint [" + mappedEndpoint + "] mapped"); + throw new ApplicationContextException("Cannot map endpoint [" + endpoint + "] on registration key [" + key + + "]: there's already endpoint [" + mappedEndpoint + "] mapped"); } if (endpoint == null) { throw new ApplicationContextException("Could not find endpoint for key [" + key + "]"); @@ -109,9 +108,9 @@ 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 {@link #registerEndpoint(Object, MethodEndpoint)}. + * 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) */ @@ -131,8 +130,8 @@ 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 {@link #registerEndpoint(Object, MethodEndpoint)}. + * 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) @@ -141,7 +140,7 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM Assert.hasText(beanName, "'beanName' must not be empty"); Class endpointType = getApplicationContext().getType(beanName); endpointType = ClassUtils.getUserClass(endpointType); - + Set methods = findEndpointMethods(endpointType, new ReflectionUtils.MethodFilter() { public boolean matches(Method method) { return !getLookupKeysForMethod(method).isEmpty(); @@ -158,7 +157,7 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM } private Set findEndpointMethods(Class endpointType, - final ReflectionUtils.MethodFilter endpointMethodFilter) { + final ReflectionUtils.MethodFilter endpointMethodFilter) { final Set endpointMethods = new LinkedHashSet(); Set> endpointTypes = new LinkedHashSet>(); Class specificEndpointType = null; @@ -173,8 +172,8 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM public void doWith(Method method) { Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass); Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(specificMethod); - if (endpointMethodFilter.matches(specificMethod) && - (bridgedMethod == specificMethod || !endpointMethodFilter.matches(bridgedMethod))) { + if (endpointMethodFilter.matches(specificMethod) + && (bridgedMethod == specificMethod || !endpointMethodFilter.matches(bridgedMethod))) { endpointMethods.add(specificMethod); } } @@ -184,8 +183,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 @@ -196,8 +195,8 @@ 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 @@ -205,23 +204,23 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointM */ 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)}. + *

+ * 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/PayloadRootAnnotationMethodEndpointMapping.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMapping.java index 61505084..07d027dc 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 @@ -19,6 +19,7 @@ package org.springframework.ws.server.endpoint.mapping; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; + import javax.xml.namespace.QName; import javax.xml.transform.TransformerFactory; @@ -34,8 +35,9 @@ 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. - * - *

Endpoints typically have the following form: + *

+ * Endpoints typically have the following form: + * *

  * @Endpoint
  * public class MyEndpoint{
@@ -81,8 +83,7 @@ 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));
@@ -93,11 +94,9 @@ public class PayloadRootAnnotationMethodEndpointMapping extends AbstractAnnotati
 	}
 
 	private QName getQNameFromAnnotation(PayloadRoot payloadRoot) {
-		if (StringUtils.hasLength(payloadRoot.localPart()) && StringUtils.hasLength(
-				payloadRoot.namespace())) {
+		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 aa1c211b..96769066 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
@@ -25,21 +25,22 @@ 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
+ * 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. - * - *

Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the + *

+ * 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: + * *

  * {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 @@ -61,7 +62,7 @@ public class PayloadRootQNameEndpointMapping extends AbstractQNameEndpointMappin public static void setTransformerFactory(TransformerFactory transformerFactory) { PayloadRootQNameEndpointMapping.transformerFactory = transformerFactory; } - + @Override 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 72eb6c3d..2f6f5a96 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 @@ -17,6 +17,7 @@ package org.springframework.ws.server.endpoint.mapping; import java.lang.reflect.Method; + import javax.xml.namespace.QName; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; @@ -30,10 +31,11 @@ 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. - * - *

Endpoints typically have the following form: + * 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: + * *

  * public class MyEndpoint{
  *
@@ -42,6 +44,7 @@ import org.springframework.xml.transform.TransformerFactoryUtils;
  *	  }
  * }
  * 
+ * * This method will handle any message that has the {@code MyMessage} as a payload root local name. * * @author Arjen Poutsma @@ -69,8 +72,8 @@ public class SimpleMethodEndpointMapping extends AbstractMethodEndpointMappingWhen the {@link #setUsePath(boolean) usePath} property is enabled, the mapping will be based on the URI path rather + *

+ * 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 + *

+ * 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: + * *

  * http://example.com:8080/services/bookFlight=bookFlightEndpoint
  * jms://exampleQueue=getFlightsEndpoint
  * 
+ * * or, when the {@code usePath} property is enabled: + * *
  * /services/bookFlight=bookFlightEndpoint
  * 
+ * * 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 + *

+ * 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 AxiomSoapMessageFactory} with the {@code * payloadCaching} disabled). However, this endpoint mapping obviously is transport specific. * @@ -73,8 +77,7 @@ public class UriEndpointMapping extends AbstractMapBasedEndpointMapping { try { new URI(key); return true; - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { return false; } } @@ -88,8 +91,7 @@ public class UriEndpointMapping extends AbstractMapBasedEndpointMapping { URI connectionUri = connection.getUri(); if (usePath) { return connectionUri.getPath(); - } - else { + } else { return connectionUri.toString(); } } 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 058c23eb..852d708b 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 @@ -17,13 +17,12 @@ package org.springframework.ws.server.endpoint.mapping; import java.util.Map; + import javax.xml.transform.Transformer; 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; @@ -32,30 +31,33 @@ 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. - * - *

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 + * 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 {@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 + *

+ * 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: + * *

  * 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. * * @author Arjen Poutsma * @see #setExpression(String) - * @see #setNamespaces(java.util.Map) + * @see #setNamespaces(java.util.Map) * @since 1.0.0 */ public class XPathPayloadEndpointMapping extends AbstractMapBasedEndpointMapping implements InitializingBean { @@ -83,8 +85,7 @@ 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(); 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 bd079fe5..3334dff2 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 @@ -17,6 +17,7 @@ package org.springframework.ws.server.endpoint.mapping.jaxb; import java.lang.reflect.Method; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBIntrospector; @@ -32,8 +33,9 @@ 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. - * - *

Endpoints typically have the following form: + *

+ * Endpoints typically have the following form: + * *

  * @Endpoint
  * public class MyEndpoint{
@@ -42,7 +44,9 @@ import org.springframework.xml.transform.TransformerHelper;
  *	  }
  * }
  * 
+ * * where MyRootElement is annotated with {@code @XmlRootElement}: + * *
  * @XmlRootElement(name = "myRoot", namespace = "http://springframework.org/spring-ws")
  * public class MyRootElement {
@@ -85,11 +89,9 @@ public class XmlRootElementEndpointMapping extends AbstractAnnotationMethodEndpo
 			if (result != null) {
 				return result;
 			}
-		}
-		catch (InstantiationException e) {
+		} catch (InstantiationException e) {
 			// ignore
-		}
-		catch (IllegalAccessException ex) {
+		} catch (IllegalAccessException ex) {
 			// ignore
 		}
 		return null;
@@ -100,8 +102,7 @@ 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;
 		}
 	}
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 97786fa5..50bd923d 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
@@ -18,6 +18,7 @@ package org.springframework.ws.server.endpoint.support;
 
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Method;
+
 import javax.xml.namespace.NamespaceContext;
 
 import org.springframework.util.Assert;
@@ -33,15 +34,14 @@ 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.
-	 *
-	 * 

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 + * 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 * class-level annotations, which again are overridden by method-level annotations. * * @param method the method to create the namespace context for @@ -61,7 +61,7 @@ public abstract class NamespaceUtils { } private static void addNamespaceAnnotations(AnnotatedElement annotatedElement, - SimpleNamespaceContext namespaceContext) { + SimpleNamespaceContext namespaceContext) { if (annotatedElement.isAnnotationPresent(Namespaces.class)) { Namespaces namespacesAnn = annotatedElement.getAnnotation(Namespaces.class); for (Namespace namespaceAnn : namespacesAnn.value()) { 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 7666c1a5..c6b951c6 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 @@ -18,6 +18,7 @@ package org.springframework.ws.server.endpoint.support; import java.io.InputStream; import java.io.Reader; + import javax.xml.namespace.QName; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLStreamConstants; @@ -29,15 +30,14 @@ 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 +46,12 @@ import org.springframework.xml.transform.TraxUtils; */ 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 source the source to get the root element from * @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} */ @@ -71,19 +70,16 @@ 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; } } @@ -96,8 +92,7 @@ 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()); } @@ -112,8 +107,7 @@ 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(); } } @@ -124,13 +118,12 @@ 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); } } - if (streamReader.getEventType() == XMLStreamConstants.START_ELEMENT || - streamReader.getEventType() == XMLStreamConstants.END_ELEMENT) { + if (streamReader.getEventType() == XMLStreamConstants.START_ELEMENT + || streamReader.getEventType() == XMLStreamConstants.END_ELEMENT) { result = streamReader.getName(); } } @@ -156,5 +149,4 @@ public abstract class PayloadRootUtils { } } - } 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 6762e882..3c121a65 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 @@ -77,8 +77,7 @@ public abstract class AbstractSoapMessage extends AbstractMimeMessage implements public final String getFaultReason() { if (hasFault()) { return getSoapBody().getFault().getFaultStringOrReason(); - } - else { + } else { return null; } } @@ -89,11 +88,9 @@ 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."); } 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 491f7e8b..3c9a767f 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap; import java.util.Locale; + import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -25,9 +26,9 @@ 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). - * - *

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() @@ -48,8 +49,8 @@ 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. + *

+ * Calling this method removes the current content of the body. * * @return the message contents * @see WebServiceMessage#getPayloadResult() @@ -57,48 +58,48 @@ public interface SoapBody extends SoapElement { 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. - * - *

Adding a fault removes the current content of the body. + * 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 + * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @return the created {@code SoapFault} */ 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. - * - *

Adding a fault removes the current content of the body. + * 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 + * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @return the created {@code SoapFault} */ 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. - * - *

Adding a fault removes the current content of the body. + * 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 + * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @return the created {@code SoapFault} */ SoapFault addServerOrReceiverFault(String faultStringOrReason, Locale locale) throws SoapFaultException; /** * Adds a {@code VersionMismatch} fault to the body. - * - *

Adding a fault removes the current content of 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 + * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @return the created {@code SoapFault} */ SoapFault addVersionMismatchFault(String faultStringOrReason, Locale locale) throws SoapFaultException; 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 cd749ffd..0ffa8bf6 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.transform.Source; @@ -37,8 +38,8 @@ public interface SoapElement { 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 */ @@ -47,7 +48,7 @@ public interface SoapElement { /** * Adds an attribute with the specified qualified name and value to this element. * - * @param name the qualified name of the attribute + * @param name the qualified name of the attribute * @param value the value of the attribute */ void addAttribute(QName name, String value); @@ -77,7 +78,7 @@ public interface SoapElement { /** * 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 43efa055..456db889 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 @@ -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 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 6d411ab7..76679807 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 @@ -20,8 +20,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 + *

+ * A fault consists of a {@link #getFaultCode() fault code}, {@link #getFaultActorOrRole fault string/reason}, and * {@link #getFaultActorOrRole() role}. * * @author Arjen Poutsma 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 d8cabd76..88ca29e1 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 @@ -17,12 +17,13 @@ package org.springframework.ws.soap; import java.util.Iterator; + 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 @@ -40,8 +41,8 @@ public interface SoapFaultDetail extends SoapElement { /** * Returns a {@code Result} that represents the concents of the detail. - * - *

The result can be used for marshalling. + *

+ * The result can be used for marshalling. * * @return the {@code Result} of this element */ 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 149fee10..d2f956fa 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 @@ -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 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 96753b99..c6af0987 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 @@ -17,12 +17,13 @@ package org.springframework.ws.soap; import java.util.Iterator; + 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 @@ -33,8 +34,8 @@ public interface SoapHeader extends SoapElement { /** * Returns a {@code Result} that represents the contents of the header. - * - *

The result can be used for marshalling. + *

+ * The result can be used for marshalling. * * @return the {@code Result} of this element */ @@ -51,8 +52,8 @@ public interface SoapHeader extends SoapElement { /** * 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 + *

+ * 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 @@ -61,12 +62,12 @@ public interface SoapHeader extends SoapElement { 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} + * {@code MustUnderstand} * @throws SoapHeaderException if the headers cannot be returned * @see SoapHeaderElement */ @@ -80,7 +81,7 @@ public interface SoapHeader extends SoapElement { * @see SoapHeaderElement */ Iterator examineAllHeaderElements() throws SoapHeaderException; - + /** * Returns an {@code Iterator} over all the {@code SoapHeaderElement}s with the given qualified name in this header. * 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 e599bd81..6ac5399d 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 @@ -52,11 +52,10 @@ public interface SoapHeaderElement extends SoapElement { 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. + * 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 + * @param mustUnderstand {@code true} to set the {@code mustUnderstand} attribute on; {@code false} to turn it off */ void setMustUnderstand(boolean mustUnderstand) throws SoapHeaderException; 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 bbae2df5..f7e5b892 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 @@ -18,13 +18,12 @@ package org.springframework.ws.soap; import org.springframework.ws.FaultAwareWebServiceMessage; import org.springframework.ws.mime.MimeMessage; - import org.w3c.dom.Document; /** * 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. + * be retrieved by {@code getPayloadSource()} and {@code getPayloadResult()} on {@code WebServiceMessage}, the + * super-interface of this interface. * * @author Arjen Poutsma * @see #getPayloadSource() @@ -60,8 +59,8 @@ public interface SoapMessage extends MimeMessage, FaultAwareWebServiceMessage { 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() */ @@ -77,9 +76,9 @@ 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(); 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 49432e78..c6e4030f 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 @@ -23,9 +23,9 @@ import org.springframework.ws.WebServiceMessageFactory; /** * 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 @@ -51,8 +51,8 @@ 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 + *

+ * 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 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 27a935b1..9f7f806f 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 @@ -276,8 +276,8 @@ 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/client/ActionCallback.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/client/ActionCallback.java index 56666021..8d7a34cf 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 @@ -19,6 +19,7 @@ package org.springframework.ws.soap.addressing.client; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; + import javax.xml.transform.TransformerException; import org.springframework.util.Assert; @@ -35,17 +36,15 @@ 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. - * - *

A usage example with {@link org.springframework.ws.client.core.WebServiceTemplate}: + * {@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}: + * *

  * WebServiceTemplate template = new WebServiceTemplate(messageFactory);
  * Result result = new DOMResult();
- * template.sendSourceAndReceiveToResult(
- *	   new StringSource("<content xmlns=\"http://tempuri.org\"/>"),
- *	   new ActionCallback(new URI("http://tempuri.org/Action")),
- *	   result);
+ * template.sendSourceAndReceiveToResult(new StringSource("<content xmlns=\"http://tempuri.org\"/>"),
+ * 		new ActionCallback(new URI("http://tempuri.org/Action")), result);
  * 
* * @author Arjen Poutsma @@ -69,11 +68,11 @@ 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}. - * - *

The {@link AddressingVersion} is set to {@link Addressing10}. + *

+ * The {@code To} header of the outgoing message will reflect the + * {@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 */ @@ -83,11 +82,11 @@ 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}. - * - *

The {@link AddressingVersion} is set to {@link Addressing10}. + *

+ * The {@code To} header of the outgoing message will reflect the + * {@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 */ @@ -97,11 +96,11 @@ 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}. * - *

The {@code To} header of the outgoing message will reflect the {@link org.springframework.ws.transport.WebServiceConnection#getUri() - * connection URI}. - * - * @param action the value of the action property to set + * @param action the value of the action property to set * @param version the WS-Addressing version to use */ public ActionCallback(URI action, AddressingVersion version) { @@ -109,12 +108,11 @@ 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 action the value of the action property * @param version the WS-Addressing version to use - * @param to the value of the destination property + * @param to the value of the destination property */ public ActionCallback(URI action, AddressingVersion version, URI to) { Assert.notNull(action, "'action' must not be null"); @@ -134,8 +132,8 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the message id strategy used for creating WS-Addressing MessageIds. - * - *

By default, the {@link UuidMessageIdStrategy} is used. + *

+ * By default, the {@link UuidMessageIdStrategy} is used. */ public MessageIdStrategy getMessageIdStrategy() { return messageIdStrategy; @@ -143,8 +141,8 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Sets the message id strategy used for creating WS-Addressing MessageIds. - * - *

By default, the {@link UuidMessageIdStrategy} is used. + *

+ * By default, the {@link UuidMessageIdStrategy} is used. */ public void setMessageIdStrategy(MessageIdStrategy messageIdStrategy) { Assert.notNull(messageIdStrategy, "'messageIdStrategy' must not be null"); @@ -153,6 +151,7 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code Action}. + * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getAction() */ public URI getAction() { @@ -161,6 +160,7 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code From}. + * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getFrom() */ public EndpointReference getFrom() { @@ -169,6 +169,7 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Sets the {@code From}. + * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getFrom() */ public void setFrom(EndpointReference from) { @@ -177,6 +178,7 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code ReplyTo}. + * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getReplyTo() */ public EndpointReference getReplyTo() { @@ -185,6 +187,7 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Sets the {@code ReplyTo}. + * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getReplyTo() */ public void setReplyTo(EndpointReference replyTo) { @@ -193,6 +196,7 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Returns the {@code FaultTo}. + * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getFaultTo() */ public EndpointReference getFaultTo() { @@ -201,18 +205,17 @@ public class ActionCallback implements WebServiceMessageCallback { /** * Sets the {@code FaultTo}. + * * @see org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getFaultTo() */ public void setFaultTo(EndpointReference faultTo) { this.faultTo = faultTo; } - - /** * Returns the {@code Destination} for outgoing messages. - * - *

Defaults to the {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI} if no + *

+ * Defaults to the {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI} if no * destination was set. */ protected URI getTo() { @@ -221,14 +224,12 @@ 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; } } @@ -238,10 +239,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 a5bc5da0..5d93cd63 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 @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.List; import org.springframework.util.Assert; - import org.w3c.dom.Node; /** @@ -43,8 +42,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 */ @@ -59,7 +58,7 @@ public final class EndpointReference implements Serializable { * Creates a new instance of the {@link EndpointReference} class with the given address, reference properties, and * reference parameters. * - * @param address the endpoint address + * @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} */ 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 19906156..60244ff9 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 @@ -25,8 +25,8 @@ import org.w3c.dom.Node; /** * 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 @@ -57,19 +57,15 @@ 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 - * @param faultTo the value of the fault endpoint property - * @param action the value of the action property + * @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 + * @param faultTo the value of the fault endpoint property + * @param action the value of the action property * @param messageId the value of the message id property */ - public MessageAddressingProperties(URI to, - EndpointReference from, - EndpointReference replyTo, - EndpointReference faultTo, - URI action, - URI messageId) { + public MessageAddressingProperties(URI to, EndpointReference from, EndpointReference replyTo, + EndpointReference faultTo, URI action, URI messageId) { this.to = to; this.from = from; this.replyTo = replyTo; @@ -84,8 +80,8 @@ public final class MessageAddressingProperties implements Serializable { /** * 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 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 * @param relatesTo the value of the relates to property */ @@ -147,12 +143,13 @@ 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 epr the endpoint reference to create a reply to * @param action the action */ public MessageAddressingProperties getReplyProperties(EndpointReference epr, URI action, URI messageId) { 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 9ceb415b..2b6b4726 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 @@ -24,8 +24,8 @@ 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:}. - * - *

Note that the {@link UUID} class is only available on Java 5 and above. + *

+ * Note that the {@link UUID} class is only available on Java 5 and above. * * @author Arjen Poutsma * @since 1.5.0 @@ -44,4 +44,4 @@ public class UuidMessageIdStrategy implements MessageIdStrategy { public URI newMessageId(SoapMessage message) { return URI.create(PREFIX + UUID.randomUUID().toString()); } -} \ No newline at end of file +} 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 fe193bdf..e3d9c957 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 @@ -27,10 +27,10 @@ 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. - * - *

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 @@ -50,7 +50,6 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn private String faultActionSuffix = DEFAULT_OUTPUT_ACTION_SUFFIX; - /** Returns the suffix to add to request {@code Action}s for reply messages. */ public String getOutputActionSuffix() { return outputActionSuffix; @@ -98,9 +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 @@ -120,11 +119,10 @@ 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 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 * @throws IllegalStateException if there is a conflicting endpoint registered */ protected void registerEndpoint(URI action, Object endpoint) throws BeansException, IllegalStateException { @@ -141,11 +139,10 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn Object mappedEndpoint = this.endpointMap.get(action); if (mappedEndpoint != null) { if (mappedEndpoint != resolvedEndpoint) { - throw new IllegalStateException("Cannot map endpoint [" + endpoint + "] to action [" + action + - "]: There is already endpoint [" + resolvedEndpoint + "] mapped."); + 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 + "]"); @@ -158,8 +155,7 @@ public abstract class AbstractActionEndpointMapping extends AbstractAddressingEn URI requestAction = requestMap.getAction(); if (requestAction != null) { return URI.create(requestAction.toString() + getOutputActionSuffix()); - } - else { + } else { return null; } } @@ -169,8 +165,7 @@ 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 b9557938..6d2ed170 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 @@ -25,8 +25,7 @@ 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. + * implementations that map to {@link MethodEndpoint}s. Provides infrastructure for mapping endpoint methods to actions. * * @author Arjen Poutsma * @since 1.5.0 @@ -34,8 +33,8 @@ 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 + * 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) @@ -59,8 +58,8 @@ public abstract class AbstractActionMethodEndpointMapping extends AbstractAction /** * Return the class or interface to use for method reflection. - * - *

Default implementation delegates to {@link AopUtils#getTargetClass(Object)}. + *

+ * 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 86224849..7f017b49 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 @@ -16,6 +16,15 @@ package org.springframework.ws.soap.addressing.server; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.transform.TransformerException; + import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.InitializingBean; @@ -42,27 +51,25 @@ import org.springframework.ws.soap.server.SoapEndpointMapping; import org.springframework.ws.transport.WebServiceMessageSender; import org.springframework.xml.transform.TransformerObjectSupport; -import javax.xml.transform.TransformerException; -import java.net.URI; -import java.util.*; - /** - * 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 + * 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 #setMessageSenders(WebServiceMessageSender[]) messageSenders} are used to send out-of-band reply messages. + *

+ * 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 + *

+ * 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. + * 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 @@ -85,13 +92,11 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec private EndpointInterceptor[] postInterceptors = new EndpointInterceptor[0]; - private SmartEndpointInterceptor[] smartInterceptors = - new SmartEndpointInterceptor[0]; + private SmartEndpointInterceptor[] smartInterceptors = new SmartEndpointInterceptor[0]; private ApplicationContext applicationContext; - private int order = Integer.MAX_VALUE; // default: same as non-Ordered - + private int order = Integer.MAX_VALUE; // default: same as non-Ordered /** Protected constructor. Initializes the default settings. */ protected AbstractAddressingEndpointMapping() { @@ -99,19 +104,20 @@ 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}. + * 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}. */ protected void initDefaultStrategies() { - this.versions = new AddressingVersion[]{new Addressing200408(), new Addressing10()}; + this.versions = new AddressingVersion[] { new Addressing200408(), new Addressing10() }; messageIdStrategy = new UuidMessageIdStrategy(); } @Override public final void setActorOrRole(String actorOrRole) { Assert.notNull(actorOrRole, "actorOrRole must not be null"); - actorsOrRoles = new String[]{actorOrRole}; + actorsOrRoles = new String[] { actorOrRole }; } @Override @@ -130,8 +136,7 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } @Override - public void setApplicationContext(ApplicationContext applicationContext) - throws BeansException { + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } @@ -142,8 +147,8 @@ 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. + *

+ * Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered. * * @see org.springframework.core.Ordered#getOrder() */ @@ -171,8 +176,8 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec /** * Sets the message id strategy used for creating WS-Addressing MessageIds. - * - *

By default, the {@link UuidMessageIdStrategy} is used. + *

+ * By default, the {@link UuidMessageIdStrategy} is used. */ public final void setMessageIdStrategy(MessageIdStrategy messageIdStrategy) { Assert.notNull(messageIdStrategy, "'messageIdStrategy' must not be null"); @@ -187,21 +192,19 @@ 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) { Assert.notNull(messageSender, "'messageSender' must not be null"); - setMessageSenders(new WebServiceMessageSender[]{messageSender}); + setMessageSenders(new WebServiceMessageSender[] { messageSender }); } /** - * 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 */ @@ -221,10 +224,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; @@ -237,8 +240,7 @@ 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()]); @@ -270,13 +272,11 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec } /** - * Creates a {@link SoapEndpointInvocationChain} based on the given endpoint and {@link - * org.springframework.ws.soap.addressing.version.AddressingVersion}. + * Creates a {@link SoapEndpointInvocationChain} based on the given endpoint and + * {@link org.springframework.ws.soap.addressing.version.AddressingVersion}. */ - private EndpointInvocationChain getEndpointInvocationChain(Object endpoint, - AddressingVersion version, - MessageAddressingProperties requestMap, - MessageContext messageContext) { + private EndpointInvocationChain getEndpointInvocationChain(Object endpoint, AddressingVersion version, + MessageAddressingProperties requestMap, MessageContext messageContext) { URI responseAction = getResponseAction(endpoint, requestMap); URI faultAction = getFaultAction(endpoint, requestMap); @@ -287,7 +287,7 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec interceptors.addAll(Arrays.asList(preInterceptors)); AddressingEndpointInterceptor addressingInterceptor = new AddressingEndpointInterceptor(version, messageIdStrategy, - messageSenders, responseAction, faultAction); + messageSenders, responseAction, faultAction); interceptors.add(addressingInterceptor); interceptors.addAll(Arrays.asList(postInterceptors)); @@ -299,8 +299,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 +317,7 @@ 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 @@ -328,8 +327,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 @@ -339,8 +338,8 @@ 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} @@ -351,7 +350,7 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec * Provides the WS-Addressing Action for response messages, given the endpoint, and request Message Addressing * Properties. * - * @param endpoint the mapped endpoint + * @param endpoint the mapped endpoint * @param requestMap the MAP for the request * @return the response Action */ @@ -361,7 +360,7 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec * Provides the WS-Addressing Action for response fault messages, given the endpoint, and request Message Addressing * Properties. * - * @param endpoint the mapped endpoint + * @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 175b4c26..112dcecd 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 @@ -21,7 +21,6 @@ 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; @@ -55,11 +54,8 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { private URI faultAction; - AddressingEndpointInterceptor(AddressingVersion version, - MessageIdStrategy messageIdStrategy, - WebServiceMessageSender[] messageSenders, - URI replyAction, - URI faultAction) { + AddressingEndpointInterceptor(AddressingVersion version, MessageIdStrategy messageIdStrategy, + WebServiceMessageSender[] messageSenders, URI replyAction, URI faultAction) { Assert.notNull(version, "version must not be null"); Assert.notNull(messageIdStrategy, "messageIdStrategy must not be null"); Assert.notNull(messageSenders, "'messageSenders' must not be null"); @@ -99,8 +95,8 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { private boolean handleResponseOrFault(MessageContext messageContext, boolean isFault) throws Exception { Assert.isInstanceOf(SoapMessage.class, messageContext.getRequest()); Assert.isInstanceOf(SoapMessage.class, messageContext.getResponse()); - MessageAddressingProperties requestMap = - version.getMessageAddressingProperties((SoapMessage) messageContext.getRequest()); + MessageAddressingProperties requestMap = version + .getMessageAddressingProperties((SoapMessage) messageContext.getRequest()); EndpointReference replyEpr = !isFault ? requestMap.getReplyTo() : requestMap.getFaultTo(); if (handleNoneAddress(messageContext, replyEpr)) { return false; @@ -112,8 +108,7 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { version.addAddressingHeaders(reply, replyMap); if (handleAnonymousAddress(messageContext, replyEpr)) { return true; - } - else { + } else { sendOutOfBand(messageContext, replyEpr); return false; } @@ -122,9 +117,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; @@ -135,8 +129,8 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { private boolean handleAnonymousAddress(MessageContext messageContext, EndpointReference replyEpr) { if (version.hasAnonymousAddress(replyEpr)) { if (logger.isDebugEnabled()) { - logger.debug("Request [" + messageContext.getRequest() + "] has [" + replyEpr + - "] reply address; sending in-band reply [" + messageContext.getResponse() + "]"); + logger.debug("Request [" + messageContext.getRequest() + "] has [" + replyEpr + + "] reply address; sending in-band reply [" + messageContext.getResponse() + "]"); } return true; } @@ -145,8 +139,8 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { private void sendOutOfBand(MessageContext messageContext, EndpointReference replyEpr) throws IOException { if (logger.isDebugEnabled()) { - logger.debug("Request [" + messageContext.getRequest() + "] has [" + replyEpr + - "] reply address; sending out-of-band reply [" + messageContext.getResponse() + "]"); + logger.debug("Request [" + messageContext.getRequest() + "] has [" + replyEpr + + "] reply address; sending out-of-band reply [" + messageContext.getResponse() + "]"); } boolean supported = false; @@ -158,8 +152,7 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { connection = messageSender.createConnection(replyEpr.getAddress()); connection.send(messageContext.getResponse()); break; - } - finally { + } finally { messageContext.clearResponse(); if (connection != null) { connection.close(); @@ -168,8 +161,8 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor { } } if (!supported && logger.isWarnEnabled()) { - logger.warn("Could not send out-of-band response to [" + replyEpr.getAddress() + "]. " + - "Configure WebServiceMessageSenders which support this uri."); + logger.warn("Could not send out-of-band response to [" + replyEpr.getAddress() + "]. " + + "Configure WebServiceMessageSenders which support this uri."); } } @@ -182,8 +175,7 @@ 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) { 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 52cdac7c..b2f517dd 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 @@ -35,8 +35,9 @@ 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. - * - *

Endpoints typically have the following form: + *

+ * Endpoints typically have the following form: + * *

  * @Endpoint
  * @Address("mailto:joe@fabrikam123.example")
@@ -47,9 +48,9 @@ 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 + *

+ * 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 @@ -74,10 +75,8 @@ 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; @@ -85,9 +84,9 @@ public class AnnotationActionEndpointMapping extends AbstractActionMethodEndpoin /** * 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. + * 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 @@ -99,8 +98,7 @@ 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; } } @@ -111,8 +109,7 @@ 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); } } @@ -123,8 +120,7 @@ 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); } } @@ -132,10 +128,8 @@ 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 + "]"); } } 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 118e9c22..df23dda0 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 @@ -25,22 +25,24 @@ 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. - * - *

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 + * 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. + *

+ * 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
  * http://www.springframework.org/spring-ws/samples/airline/GetFlights=getFlightsEndpoint
  * 
+ * * 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 + *

+ * 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. * @@ -77,11 +79,9 @@ 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()); @@ -89,8 +89,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 + * 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. * * @param address the address URI @@ -109,14 +109,13 @@ 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 - * @throws BeansException if an endpoint couldn't be registered + * @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(); 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 1b1884d5..f112d13b 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 @@ -23,9 +23,8 @@ 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 @@ -36,20 +35,17 @@ 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 623f7d1a..ed882e17 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 @@ -23,9 +23,8 @@ 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 @@ -37,8 +36,7 @@ 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 a1a7dd3c..95c73347 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 @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; + import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -33,10 +34,6 @@ 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; @@ -48,11 +45,14 @@ import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; import org.springframework.ws.soap.soap11.Soap11Body; import org.springframework.ws.soap.soap12.Soap12Body; import org.springframework.ws.soap.soap12.Soap12Fault; +import org.springframework.xml.DocumentBuilderFactoryUtils; 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.springframework.xml.DocumentBuilderFactoryUtils; +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 @@ -95,14 +95,12 @@ 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; } } @@ -150,8 +148,7 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport } try { return new URI(messageId); - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { return null; } } @@ -169,8 +166,7 @@ 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); } } @@ -184,12 +180,12 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport if (address == null) { return null; } - List referenceProperties = - referencePropertiesExpression != null ? referencePropertiesExpression.evaluateAsNodeList(node) : - Collections.emptyList(); - List referenceParameters = - referenceParametersExpression != null ? referenceParametersExpression.evaluateAsNodeList(node) : - Collections.emptyList(); + List referenceProperties = referencePropertiesExpression != null + ? referencePropertiesExpression.evaluateAsNodeList(node) + : Collections. emptyList(); + List referenceParameters = referenceParametersExpression != null + ? referenceParametersExpression.evaluateAsNodeList(node) + : Collections. emptyList(); return new EndpointReference(address, referenceProperties, referenceParameters); } @@ -208,7 +204,7 @@ public abstract class AbstractAddressingVersion extends TransformerObjectSupport SoapHeaderElement from = header.addHeaderElement(getFromName()); addEndpointReference(from, map.getFrom()); } - //ReplyTo + // ReplyTo if (map.getReplyTo() != null) { SoapHeaderElement replyTo = header.addHeaderElement(getReplyToName()); addEndpointReference(replyTo, map.getReplyTo()); @@ -263,11 +259,9 @@ 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); } } @@ -278,8 +272,7 @@ 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); } } @@ -300,11 +293,9 @@ 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); + Soap12Fault soapFault = soapBody.addClientOrSenderFault(reason, Locale.ENGLISH); soapFault.addFaultSubcode(subcode); return soapFault; } @@ -380,16 +371,16 @@ 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()); 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 6f6f487f..08b1c54b 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.addressing.version; import java.net.URI; + import javax.xml.namespace.QName; import org.springframework.util.Assert; @@ -87,8 +88,7 @@ public class Addressing10 extends AbstractAddressingVersion { @Override protected final QName getMessageAddressingHeaderRequiredFaultSubcode() { - return new QName(NAMESPACE_URI, "MessageAddressingHeaderRequired", - getNamespacePrefix()); + return new QName(NAMESPACE_URI, "MessageAddressingHeaderRequired", getNamespacePrefix()); } @Override 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 2ebbe5a9..17370de5 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.addressing.version; import java.net.URI; + import javax.xml.namespace.QName; import org.springframework.util.Assert; @@ -30,7 +31,7 @@ import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; * * @author Arjen Poutsma * @see Web Services Addressing, August - * 2004 + * 2004 * @since 1.5.0 */ public class Addressing200408 extends AbstractAddressingVersion { @@ -70,8 +71,7 @@ public class Addressing200408 extends AbstractAddressingVersion { @Override protected final QName getInvalidAddressingHeaderFaultSubcode() { - return new QName(NAMESPACE_URI, "InvalidMessageInformationHeader", - getNamespacePrefix()); + return new QName(NAMESPACE_URI, "InvalidMessageInformationHeader", getNamespacePrefix()); } @Override @@ -81,8 +81,7 @@ public class Addressing200408 extends AbstractAddressingVersion { @Override protected final QName getMessageAddressingHeaderRequiredFaultSubcode() { - return new QName(NAMESPACE_URI, "MessageInformationHeaderRequired", - getNamespacePrefix()); + return new QName(NAMESPACE_URI, "MessageInformationHeaderRequired", getNamespacePrefix()); } @Override 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 e0ee7aa1..a959bfd9 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 @@ -31,8 +31,7 @@ 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 @@ -44,7 +43,7 @@ public interface AddressingVersion { * 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 + * @param map the message addressing properties */ void addAddressingHeaders(SoapMessage message, MessageAddressingProperties map); @@ -59,8 +58,8 @@ public interface AddressingVersion { /** * 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 + * @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); @@ -77,8 +76,8 @@ public interface AddressingVersion { 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. + * 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 */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AbstractPayload.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AbstractPayload.java index b3a082df..c40c6c89 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AbstractPayload.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AbstractPayload.java @@ -20,14 +20,13 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.transform.Result; import javax.xml.transform.Source; -import org.springframework.util.Assert; -import org.springframework.util.xml.StaxUtils; -import org.springframework.ws.soap.axiom.support.AxiomUtils; - import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; import org.apache.axiom.soap.SOAPBody; import org.apache.axiom.soap.SOAPFactory; +import org.springframework.util.Assert; +import org.springframework.util.xml.StaxUtils; +import org.springframework.ws.soap.axiom.support.AxiomUtils; /** * Abstract base class for {@link Payload} implementations. @@ -55,12 +54,10 @@ abstract class AbstractPayload extends Payload { if (payloadElement != null) { XMLStreamReader streamReader = getStreamReader(payloadElement); return StaxUtils.createCustomStaxSource(streamReader); - } - else { + } else { return null; } - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapBodyException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomAttachment.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomAttachment.java index c1ef1e18..b1e37626 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomAttachment.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomAttachment.java @@ -18,6 +18,7 @@ package org.springframework.ws.soap.axiom; import java.io.IOException; import java.io.InputStream; + import javax.activation.DataHandler; import org.springframework.util.Assert; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Body.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Body.java index f0cbab7d..da4b2206 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Body.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Body.java @@ -17,6 +17,7 @@ package org.springframework.ws.soap.axiom; import java.util.Locale; + import javax.xml.namespace.QName; import org.apache.axiom.om.OMAttribute; @@ -28,7 +29,6 @@ import org.apache.axiom.soap.SOAPFault; import org.apache.axiom.soap.SOAPFaultCode; import org.apache.axiom.soap.SOAPFaultReason; import org.apache.axiom.soap.SOAPProcessingException; - import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.ws.soap.axiom.support.AxiomUtils; @@ -45,10 +45,8 @@ class AxiomSoap11Body extends AxiomSoapBody implements Soap11Body { private final boolean langAttributeOnSoap11FaultString; - AxiomSoap11Body(SOAPBody axiomBody, - SOAPFactory axiomFactory, - boolean payloadCaching, - boolean langAttributeOnSoap11FaultString) { + AxiomSoap11Body(SOAPBody axiomBody, SOAPFactory axiomFactory, boolean payloadCaching, + boolean langAttributeOnSoap11FaultString) { super(axiomBody, axiomFactory, payloadCaching); this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString; } @@ -100,8 +98,7 @@ class AxiomSoap11Body extends AxiomSoapBody implements Soap11Body { faultReason.setText(faultString); return new AxiomSoap11Fault(fault, getAxiomFactory()); - } - catch (SOAPProcessingException ex) { + } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } } @@ -113,14 +110,12 @@ class AxiomSoap11Body extends AxiomSoapBody implements Soap11Body { if (namespace == null) { fault.declareNamespace(code.getNamespaceURI(), prefix); } - } - else if (StringUtils.hasLength(code.getNamespaceURI())) { + } else if (StringUtils.hasLength(code.getNamespaceURI())) { OMNamespace namespace = fault.findNamespace(code.getNamespaceURI(), null); if (namespace == null) { namespace = fault.declareNamespace(code.getNamespaceURI(), ""); } - code = new QName(code.getNamespaceURI(), code.getLocalPart(), - namespace.getPrefix()); + code = new QName(code.getNamespaceURI(), code.getLocalPart(), namespace.getPrefix()); } faultCode.setText(code); } @@ -131,24 +126,22 @@ class AxiomSoap11Body extends AxiomSoapBody implements Soap11Body { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault); - faultCode.setText(new QName(fault.getNamespace().getNamespaceURI(), localName, - fault.getNamespace().getPrefix())); + faultCode.setText(new QName(fault.getNamespace().getNamespaceURI(), localName, fault.getNamespace().getPrefix())); SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault); if (locale != null) { addLangAttribute(locale, faultReason); } faultReason.setText(faultString); return fault; - } - catch (SOAPProcessingException ex) { + } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } } private void addLangAttribute(Locale locale, SOAPFaultReason faultReason) { OMNamespace xmlNamespace = getAxiomFactory().createOMNamespace("http://www.w3.org/XML/1998/namespace", "xml"); - OMAttribute langAttribute = - getAxiomFactory().createOMAttribute("lang", xmlNamespace, AxiomUtils.toLanguage(locale)); + OMAttribute langAttribute = getAxiomFactory().createOMAttribute("lang", xmlNamespace, + AxiomUtils.toLanguage(locale)); faultReason.addAttribute(langAttribute); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Fault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Fault.java index 6be8c276..f9596095 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Fault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Fault.java @@ -17,12 +17,12 @@ package org.springframework.ws.soap.axiom; import java.util.Locale; + import javax.xml.namespace.QName; import org.apache.axiom.om.OMAttribute; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPFault; - import org.springframework.ws.soap.axiom.support.AxiomUtils; import org.springframework.ws.soap.soap11.Soap11Fault; @@ -54,8 +54,8 @@ class AxiomSoap11Fault extends AxiomSoapFault implements Soap11Fault { @Override public Locale getFaultStringLocale() { if (getAxiomFault().getReason() != null) { - OMAttribute langAttribute = - getAxiomFault().getReason().getAttribute(new QName("http://www.w3.org/XML/1998/namespace", "lang")); + OMAttribute langAttribute = getAxiomFault().getReason() + .getAttribute(new QName("http://www.w3.org/XML/1998/namespace", "lang")); if (langAttribute != null) { String xmlLangString = langAttribute.getAttributeValue(); if (xmlLangString != null) { diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Header.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Header.java index 9ec4a7bf..6aebf216 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Header.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap11Header.java @@ -24,7 +24,6 @@ import org.apache.axiom.soap.RolePlayer; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPHeader; import org.apache.axiom.soap.SOAPHeaderBlock; - import org.springframework.util.ObjectUtils; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.soap11.Soap11Header; @@ -57,7 +56,7 @@ class AxiomSoap11Header extends AxiomSoapHeader implements Soap11Header { } }; } - Iterator result = (Iterator)getAxiomHeader().getHeadersToProcess(rolePlayer); + Iterator result = (Iterator) getAxiomHeader().getHeadersToProcess(rolePlayer); return new AxiomSoapHeaderElementIterator(result); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Body.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Body.java index d045f4cf..94942a7b 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Body.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Body.java @@ -17,6 +17,7 @@ package org.springframework.ws.soap.axiom; import java.util.Locale; + import javax.xml.namespace.QName; import org.apache.axiom.soap.SOAP12Constants; @@ -28,7 +29,6 @@ import org.apache.axiom.soap.SOAPFaultReason; import org.apache.axiom.soap.SOAPFaultText; import org.apache.axiom.soap.SOAPFaultValue; import org.apache.axiom.soap.SOAPProcessingException; - import org.springframework.util.Assert; import org.springframework.ws.soap.axiom.support.AxiomUtils; import org.springframework.ws.soap.soap12.Soap12Body; @@ -96,8 +96,7 @@ class AxiomSoap12Body extends AxiomSoapBody implements Soap12Body { } text.setText(faultStringOrReason); return fault; - } - catch (SOAPProcessingException ex) { + } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Fault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Fault.java index af837c67..984ba78f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Fault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Fault.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Locale; + import javax.xml.namespace.QName; import org.apache.axiom.om.OMNamespace; @@ -32,7 +33,6 @@ import org.apache.axiom.soap.SOAPFaultSubCode; import org.apache.axiom.soap.SOAPFaultText; import org.apache.axiom.soap.SOAPFaultValue; import org.apache.axiom.soap.SOAPProcessingException; - import org.springframework.util.StringUtils; import org.springframework.ws.soap.axiom.support.AxiomUtils; import org.springframework.ws.soap.soap12.Soap12Fault; @@ -66,14 +66,12 @@ class AxiomSoap12Fault extends AxiomSoapFault implements Soap12Fault { SOAPFaultSubCode faultSubCode = null; if (faultCode.getSubCode() == null) { faultSubCode = getAxiomFactory().createSOAPFaultSubCode(faultCode); - } - else { + } else { faultSubCode = faultCode.getSubCode(); while (true) { if (faultSubCode.getSubCode() != null) { faultSubCode = faultSubCode.getSubCode(); - } - else { + } else { faultSubCode = getAxiomFactory().createSOAPFaultSubCode(faultSubCode); break; } @@ -90,14 +88,12 @@ class AxiomSoap12Fault extends AxiomSoapFault implements Soap12Fault { if (namespace == null) { getAxiomFault().declareNamespace(code.getNamespaceURI(), prefix); } - } - else if (StringUtils.hasLength(code.getNamespaceURI())) { + } else if (StringUtils.hasLength(code.getNamespaceURI())) { OMNamespace namespace = getAxiomFault().findNamespace(code.getNamespaceURI(), null); if (namespace == null) { throw new IllegalArgumentException("Could not resolve namespace of code [" + code + "]"); } - code = new QName(code.getNamespaceURI(), code.getLocalPart(), - namespace.getPrefix()); + code = new QName(code.getNamespaceURI(), code.getLocalPart(), namespace.getPrefix()); } faultValue.setText(prefix + ":" + code.getLocalPart()); } @@ -107,8 +103,7 @@ class AxiomSoap12Fault extends AxiomSoapFault implements Soap12Fault { SOAPFaultNode faultNode = getAxiomFault().getNode(); if (faultNode == null) { return null; - } - else { + } else { return faultNode.getFaultNodeValue(); } } @@ -119,8 +114,7 @@ class AxiomSoap12Fault extends AxiomSoapFault implements Soap12Fault { SOAPFaultNode faultNode = getAxiomFactory().createSOAPFaultNode(getAxiomFault()); faultNode.setFaultNodeValue(uri); getAxiomFault().setNode(faultNode); - } - catch (SOAPProcessingException ex) { + } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } } @@ -146,8 +140,7 @@ class AxiomSoap12Fault extends AxiomSoapFault implements Soap12Fault { SOAPFaultText faultText = getAxiomFactory().createSOAPFaultText(faultReason); faultText.setLang(language); faultText.setText(text); - } - catch (SOAPProcessingException ex) { + } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Header.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Header.java index b8e20497..5ae7eac7 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Header.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoap12Header.java @@ -19,6 +19,7 @@ package org.springframework.ws.soap.axiom; import java.util.Arrays; import java.util.Iterator; import java.util.List; + import javax.xml.namespace.QName; import org.apache.axiom.om.OMElement; @@ -29,7 +30,6 @@ import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPHeader; import org.apache.axiom.soap.SOAPHeaderBlock; import org.apache.axiom.soap.SOAPProcessingException; - import org.springframework.util.ObjectUtils; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapHeaderException; @@ -50,15 +50,12 @@ class AxiomSoap12Header extends AxiomSoapHeader implements Soap12Header { @Override public SoapHeaderElement addNotUnderstoodHeaderElement(QName headerName) { try { - SOAPHeaderBlock notUnderstood = - getAxiomHeader().addHeaderBlock("NotUnderstood", getAxiomHeader().getNamespace()); - OMNamespace headerNamespace = - notUnderstood.declareNamespace(headerName.getNamespaceURI(), - headerName.getPrefix()); + SOAPHeaderBlock notUnderstood = getAxiomHeader().addHeaderBlock("NotUnderstood", getAxiomHeader().getNamespace()); + OMNamespace headerNamespace = notUnderstood.declareNamespace(headerName.getNamespaceURI(), + headerName.getPrefix()); notUnderstood.addAttribute("qname", headerNamespace.getPrefix() + ":" + headerName.getLocalPart(), null); return new AxiomSoapHeaderElement(notUnderstood, getAxiomFactory()); - } - catch (SOAPProcessingException ex) { + } catch (SOAPProcessingException ex) { throw new AxiomSoapHeaderException(ex); } } @@ -68,22 +65,21 @@ class AxiomSoap12Header extends AxiomSoapHeader implements Soap12Header { try { SOAPHeaderBlock upgrade = getAxiomHeader().addHeaderBlock("Upgrade", getAxiomHeader().getNamespace()); for (String supportedSoapUri : supportedSoapUris) { - OMElement supportedEnvelope = getAxiomFactory() - .createOMElement("SupportedEnvelope", getAxiomHeader().getNamespace(), upgrade); + OMElement supportedEnvelope = getAxiomFactory().createOMElement("SupportedEnvelope", + getAxiomHeader().getNamespace(), upgrade); OMNamespace namespace = supportedEnvelope.declareNamespace(supportedSoapUri, ""); supportedEnvelope.addAttribute("qname", namespace.getPrefix() + ":Envelope", null); } return new AxiomSoapHeaderElement(upgrade, getAxiomFactory()); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } } @Override @SuppressWarnings("unchecked") - public Iterator examineHeaderElementsToProcess(final String[] roles, final boolean isUltimateDestination) - throws SoapHeaderException { + public Iterator examineHeaderElementsToProcess(final String[] roles, + final boolean isUltimateDestination) throws SoapHeaderException { RolePlayer rolePlayer = null; if (!ObjectUtils.isEmpty(roles)) { rolePlayer = new RolePlayer() { @@ -97,7 +93,7 @@ class AxiomSoap12Header extends AxiomSoapHeader implements Soap12Header { } }; } - Iterator result = (Iterator)getAxiomHeader().getHeadersToProcess(rolePlayer); + Iterator result = (Iterator) getAxiomHeader().getHeadersToProcess(rolePlayer); return new AxiomSoapHeaderElementIterator(result); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapBody.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapBody.java index 396cf2bf..23998fb8 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapBody.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapBody.java @@ -24,7 +24,6 @@ import org.apache.axiom.om.OMDataSource; import org.apache.axiom.om.OMElement; import org.apache.axiom.soap.SOAPBody; import org.apache.axiom.soap.SOAPFactory; - import org.springframework.util.Assert; import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.axiom.support.AxiomUtils; @@ -44,8 +43,7 @@ abstract class AxiomSoapBody extends AxiomSoapElement implements SoapBody { super(axiomBody, axiomFactory); if (payloadCaching) { payload = new CachingPayload(axiomBody, axiomFactory); - } - else { + } else { payload = new NonCachingPayload(axiomBody, axiomFactory); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapElement.java index 7d4303bd..5a4813b3 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapElement.java @@ -19,6 +19,7 @@ package org.springframework.ws.soap.axiom; import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import javax.xml.namespace.QName; import javax.xml.transform.Source; @@ -27,7 +28,6 @@ import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.soap.SOAPFactory; - import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.util.xml.StaxUtils; @@ -56,8 +56,7 @@ class AxiomSoapElement implements SoapElement { public final QName getName() { try { return axiomElement.getQName(); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapElementException(ex); } } @@ -66,8 +65,7 @@ class AxiomSoapElement implements SoapElement { public final Source getSource() { try { return StaxUtils.createCustomStaxSource(axiomElement.getXMLStreamReader()); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapElementException(ex); } } @@ -80,12 +78,10 @@ class AxiomSoapElement implements SoapElement { if (StringUtils.hasLength(namespaceUri) && !StringUtils.hasLength(prefix)) { prefix = null; } - OMNamespace namespace = - getAxiomFactory().createOMNamespace(namespaceUri, prefix); + OMNamespace namespace = getAxiomFactory().createOMNamespace(namespaceUri, prefix); OMAttribute attribute = getAxiomFactory().createOMAttribute(name.getLocalPart(), namespace, value); getAxiomElement().addAttribute(attribute); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapElementException(ex); } } @@ -97,8 +93,7 @@ class AxiomSoapElement implements SoapElement { if (attribute != null) { getAxiomElement().removeAttribute(attribute); } - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapElementException(ex); } } @@ -107,8 +102,7 @@ class AxiomSoapElement implements SoapElement { public final String getAttributeValue(QName name) { try { return getAxiomElement().getAttributeValue(name); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapElementException(ex); } } @@ -123,8 +117,7 @@ class AxiomSoapElement implements SoapElement { } return results.iterator(); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapElementException(ex); } } @@ -134,12 +127,10 @@ class AxiomSoapElement implements SoapElement { try { if (StringUtils.hasLength(prefix)) { getAxiomElement().declareNamespace(namespaceUri, prefix); - } - else { + } else { getAxiomElement().declareDefaultNamespace(namespaceUri); } - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapElementException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapEnvelope.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapEnvelope.java index 2d36133b..643a3991 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapEnvelope.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapEnvelope.java @@ -23,7 +23,6 @@ import org.apache.axiom.soap.SOAPBody; import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPHeader; - import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapEnvelope; import org.springframework.ws.soap.SoapHeader; @@ -42,10 +41,8 @@ class AxiomSoapEnvelope extends AxiomSoapElement implements SoapEnvelope { private final boolean langAttributeOnSoap11FaultString; - AxiomSoapEnvelope(SOAPEnvelope axiomEnvelope, - SOAPFactory axiomFactory, - boolean payloadCaching, - boolean langAttributeOnSoap11FaultString) { + AxiomSoapEnvelope(SOAPEnvelope axiomEnvelope, SOAPFactory axiomFactory, boolean payloadCaching, + boolean langAttributeOnSoap11FaultString) { super(axiomEnvelope, axiomFactory); this.payloadCaching = payloadCaching; this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString; @@ -56,22 +53,18 @@ class AxiomSoapEnvelope extends AxiomSoapElement implements SoapEnvelope { try { if (getAxiomEnvelope().getHeader() == null) { return null; - } - else { + } else { SOAPHeader axiomHeader = getAxiomEnvelope().getHeader(); String namespaceURI = getAxiomEnvelope().getNamespace().getNamespaceURI(); if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) { return new AxiomSoap11Header(axiomHeader, getAxiomFactory()); - } - else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) { + } else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) { return new AxiomSoap12Header(axiomHeader, getAxiomFactory()); - } - else { + } else { throw new AxiomSoapEnvelopeException("Unknown SOAP namespace \"" + namespaceURI + "\""); } } - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } } @@ -83,17 +76,13 @@ class AxiomSoapEnvelope extends AxiomSoapElement implements SoapEnvelope { SOAPBody axiomBody = getAxiomEnvelope().getBody(); String namespaceURI = getAxiomEnvelope().getNamespace().getNamespaceURI(); if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) { - body = new AxiomSoap11Body(axiomBody, getAxiomFactory(), payloadCaching, - langAttributeOnSoap11FaultString); - } - else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) { + body = new AxiomSoap11Body(axiomBody, getAxiomFactory(), payloadCaching, langAttributeOnSoap11FaultString); + } else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) { body = new AxiomSoap12Body(axiomBody, getAxiomFactory(), payloadCaching); - } - else { + } else { throw new AxiomSoapEnvelopeException("Unknown SOAP namespace \"" + namespaceURI + "\""); } - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapBodyException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFault.java index 102b0087..369f3f57 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFault.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFault.java @@ -22,7 +22,6 @@ import org.apache.axiom.soap.SOAPFault; import org.apache.axiom.soap.SOAPFaultDetail; import org.apache.axiom.soap.SOAPFaultRole; import org.apache.axiom.soap.SOAPProcessingException; - import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapFaultDetail; @@ -44,8 +43,7 @@ abstract class AxiomSoapFault extends AxiomSoapElement implements SoapFault { try { SOAPFaultRole axiomFaultRole = getAxiomFactory().createSOAPFaultRole(getAxiomFault()); axiomFaultRole.setRoleValue(actor); - } - catch (SOAPProcessingException ex) { + } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } @@ -56,8 +54,7 @@ abstract class AxiomSoapFault extends AxiomSoapElement implements SoapFault { try { SOAPFaultDetail axiomFaultDetail = getAxiomFault().getDetail(); return axiomFaultDetail != null ? new AxiomSoapFaultDetail(axiomFaultDetail, getAxiomFactory()) : null; - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapFaultException(ex); } @@ -68,8 +65,7 @@ abstract class AxiomSoapFault extends AxiomSoapElement implements SoapFault { try { SOAPFaultDetail axiomFaultDetail = getAxiomFactory().createSOAPFaultDetail(getAxiomFault()); return new AxiomSoapFaultDetail(axiomFaultDetail, getAxiomFactory()); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapFaultException(ex); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetail.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetail.java index 699d8a61..4b631bd3 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetail.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetail.java @@ -17,6 +17,7 @@ package org.springframework.ws.soap.axiom; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.transform.Result; @@ -24,7 +25,6 @@ import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPFaultDetail; - import org.springframework.ws.soap.SoapFaultDetail; import org.springframework.ws.soap.SoapFaultDetailElement; @@ -45,8 +45,7 @@ class AxiomSoapFaultDetail extends AxiomSoapElement implements SoapFaultDetail { try { OMElement element = getAxiomFactory().createOMElement(name, getAxiomFaultDetail()); return new AxiomSoapFaultDetailElement(element, getAxiomFactory()); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapFaultException(ex); } @@ -85,8 +84,7 @@ class AxiomSoapFaultDetail extends AxiomSoapElement implements SoapFaultDetail { try { OMElement axiomElement = axiomIterator.next(); return new AxiomSoapFaultDetailElement(axiomElement, getAxiomFactory()); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapFaultException(ex); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailElement.java index 5978f813..f80203f6 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailElement.java @@ -21,7 +21,6 @@ import javax.xml.transform.Result; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; import org.apache.axiom.soap.SOAPFactory; - import org.springframework.ws.soap.SoapFaultDetailElement; /** @@ -40,8 +39,7 @@ class AxiomSoapFaultDetailElement extends AxiomSoapElement implements SoapFaultD public Result getResult() { try { return getAxiomElement().getSAXResult(); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapFaultException(ex); } @@ -51,8 +49,7 @@ class AxiomSoapFaultDetailElement extends AxiomSoapElement implements SoapFaultD public void addText(String text) { try { getAxiomElement().setText(text); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapFaultException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeader.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeader.java index 2f62f3b0..8dc01b3e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeader.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeader.java @@ -17,6 +17,7 @@ package org.springframework.ws.soap.axiom; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.transform.Result; @@ -26,7 +27,6 @@ import org.apache.axiom.om.OMNamespace; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPHeader; import org.apache.axiom.soap.SOAPHeaderBlock; - import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapHeaderException; @@ -51,13 +51,10 @@ abstract class AxiomSoapHeader extends AxiomSoapElement implements SoapHeader { @Override public SoapHeaderElement addHeaderElement(QName name) { try { - OMNamespace namespace = - getAxiomFactory().createOMNamespace(name.getNamespaceURI(), - name.getPrefix()); + OMNamespace namespace = getAxiomFactory().createOMNamespace(name.getNamespaceURI(), name.getPrefix()); SOAPHeaderBlock axiomHeaderBlock = getAxiomHeader().addHeaderBlock(name.getLocalPart(), namespace); return new AxiomSoapHeaderElement(axiomHeaderBlock, getAxiomFactory()); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } } @@ -69,8 +66,7 @@ abstract class AxiomSoapHeader extends AxiomSoapElement implements SoapHeader { if (element != null) { element.detach(); } - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } } @@ -80,8 +76,7 @@ abstract class AxiomSoapHeader extends AxiomSoapElement implements SoapHeader { public Iterator examineMustUnderstandHeaderElements(String role) { try { return new AxiomSoapHeaderElementIterator(getAxiomHeader().examineMustUnderstandHeaderBlocks(role)); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } } @@ -91,8 +86,7 @@ abstract class AxiomSoapHeader extends AxiomSoapElement implements SoapHeader { public Iterator examineAllHeaderElements() { try { return new AxiomSoapHeaderElementIterator(getAxiomHeader().examineAllHeaderBlocks()); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } } @@ -102,8 +96,7 @@ abstract class AxiomSoapHeader extends AxiomSoapElement implements SoapHeader { public Iterator examineHeaderElements(QName name) throws SoapHeaderException { try { return new AxiomSoapHeaderElementIterator(getAxiomHeader().getChildrenWithName(name)); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } } @@ -130,8 +123,7 @@ abstract class AxiomSoapHeader extends AxiomSoapElement implements SoapHeader { try { OMElement axiomHeaderBlock = axiomIterator.next(); return new AxiomSoapHeaderElement(axiomHeaderBlock, getAxiomFactory()); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeaderElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeaderElement.java index 6bb983e8..a7677574 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeaderElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapHeaderElement.java @@ -22,7 +22,6 @@ import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPHeaderBlock; - import org.springframework.ws.soap.SoapHeaderElement; /** Axiom-specific version of {@code org.springframework.ws.soap.SoapHeaderHeaderElement}. */ @@ -56,8 +55,7 @@ class AxiomSoapHeaderElement extends AxiomSoapElement implements SoapHeaderEleme public Result getResult() { try { return getAxiomHeaderBlock().getSAXResult(); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapHeaderException(ex); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java index 10b21ab8..2904d6c9 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java @@ -23,6 +23,7 @@ import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.util.Iterator; + import javax.activation.DataHandler; import javax.xml.stream.XMLStreamException; import javax.xml.transform.dom.DOMSource; @@ -39,8 +40,6 @@ import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPMessage; import org.apache.axiom.soap.SOAPProcessingException; -import org.w3c.dom.Document; - import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.ws.mime.Attachment; @@ -54,6 +53,7 @@ import org.springframework.ws.stream.StreamingPayload; import org.springframework.ws.stream.StreamingWebServiceMessage; import org.springframework.ws.transport.TransportConstants; import org.springframework.ws.transport.TransportOutputStream; +import org.w3c.dom.Document; /** * AXIOM-specific implementation of the {@link SoapMessage} interface. Created via the {@link AxiomSoapMessageFactory}, @@ -111,30 +111,25 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe /** * Create a new {@code AxiomSoapMessage} based on the given AXIOM {@code SOAPMessage}. * - * @param soapMessage the AXIOM SOAPMessage - * @param soapAction the value of the SOAP Action header + * @param soapMessage the AXIOM SOAPMessage + * @param soapAction the value of the SOAP Action header * @param payloadCaching whether the contents of the SOAP body should be cached or not */ - public AxiomSoapMessage(SOAPMessage soapMessage, - String soapAction, - boolean payloadCaching, - boolean langAttributeOnSoap11FaultString) { + public AxiomSoapMessage(SOAPMessage soapMessage, String soapAction, boolean payloadCaching, + boolean langAttributeOnSoap11FaultString) { this(soapMessage, new Attachments(), soapAction, payloadCaching, langAttributeOnSoap11FaultString); } /** * Create a new {@code AxiomSoapMessage} based on the given AXIOM {@code SOAPMessage} and attachments. * - * @param soapMessage the AXIOM SOAPMessage - * @param attachments the attachments - * @param soapAction the value of the SOAP Action header + * @param soapMessage the AXIOM SOAPMessage + * @param attachments the attachments + * @param soapAction the value of the SOAP Action header * @param payloadCaching whether the contents of the SOAP body should be cached or not */ - public AxiomSoapMessage(SOAPMessage soapMessage, - Attachments attachments, - String soapAction, - boolean payloadCaching, - boolean langAttributeOnSoap11FaultString) { + public AxiomSoapMessage(SOAPMessage soapMessage, Attachments attachments, String soapAction, boolean payloadCaching, + boolean langAttributeOnSoap11FaultString) { Assert.notNull(soapMessage, "'soapMessage' must not be null"); Assert.notNull(attachments, "'attachments' must not be null"); axiomMessage = soapMessage; @@ -155,8 +150,8 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe /** * Sets the AXIOM {@code SOAPMessage} that this {@code AxiomSoapMessage} is based on. - * - *

Calling this method also clears the SOAP Action property. + *

+ * Calling this method also clears the SOAP Action property. */ public final void setAxiomMessage(SOAPMessage axiomMessage) { Assert.notNull(axiomMessage, "'axiomMessage' must not be null"); @@ -186,8 +181,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe try { envelope = new AxiomSoapEnvelope(axiomMessage.getSOAPEnvelope(), axiomFactory, payloadCaching, langAttributeOnSoap11FaultString); - } - catch (SOAPProcessingException ex) { + } catch (SOAPProcessingException ex) { throw new AxiomSoapEnvelopeException(ex); } } @@ -215,8 +209,8 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe // save the Soap Action String soapAction = getSoapAction(); // replace the Axiom message - setAxiomMessage(OMXMLBuilderFactory.createSOAPModelBuilder(axiomFactory.getMetaFactory(), - new DOMSource(document)).getSOAPMessage()); + setAxiomMessage(OMXMLBuilderFactory.createSOAPModelBuilder(axiomFactory.getMetaFactory(), new DOMSource(document)) + .getSOAPMessage()); // restore the Soap Action setSoapAction(soapAction); } @@ -225,11 +219,9 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe public boolean isXopPackage() { try { return MTOMConstants.MTOM_TYPE.equals(attachments.getAttachmentSpecType()); - } - catch (OMException ex) { + } catch (OMException ex) { return false; - } - catch (NullPointerException ex) { + } catch (NullPointerException ex) { // gotta love Axis2 return false; } @@ -279,8 +271,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe if (SoapVersion.SOAP_11 == version) { transportOutputStream.addHeader(TransportConstants.HEADER_SOAP_ACTION, soapAction); transportOutputStream.addHeader(TransportConstants.HEADER_ACCEPT, version.getContentType()); - } - else if (SoapVersion.SOAP_12 == version) { + } else if (SoapVersion.SOAP_12 == version) { contentType += "; action=" + soapAction; transportOutputStream.addHeader(TransportConstants.HEADER_ACCEPT, version.getContentType()); } @@ -289,21 +280,17 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe } if (!(outputFormat.isOptimized()) & outputFormat.isDoingSWA()) { writeSwAMessage(outputStream, outputFormat); - } - else { + } else { if (payloadCaching) { axiomMessage.serialize(outputStream, outputFormat); - } - else { + } else { axiomMessage.serializeAndConsume(outputStream, outputFormat); } } outputStream.flush(); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { throw new AxiomSoapMessageException("Could not write message to OutputStream: " + ex.getMessage(), ex); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapMessageException("Could not write message to OutputStream: " + ex.getMessage(), ex); } } @@ -311,8 +298,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe private OMOutputFormat getOutputFormat() { if (outputFormat != null) { return outputFormat; - } - else { + } else { String charsetEncoding = axiomMessage.getCharsetEncoding(); OMOutputFormat outputFormat = new OMOutputFormat(); @@ -320,8 +306,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe outputFormat.setSOAP11(getVersion() == SoapVersion.SOAP_11); if (isXopPackage()) { outputFormat.setDoOptimize(true); - } - else if (!attachments.getContentIDSet().isEmpty()) { + } else if (!attachments.getContentIDSet().isEmpty()) { outputFormat.setDoingSWA(true); } return outputFormat; @@ -334,27 +319,24 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe SOAPEnvelope envelope = axiomMessage.getSOAPEnvelope(); if (payloadCaching) { envelope.serialize(writer, format); - } - else { + } else { envelope.serializeAndConsume(writer, format); } try { OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format); - Writer rootPartWriter = new OutputStreamWriter(mpw.writeRootPart(), - format.getCharSetEncoding()); + Writer rootPartWriter = new OutputStreamWriter(mpw.writeRootPart(), format.getCharSetEncoding()); rootPartWriter.write(writer.toString()); rootPartWriter.close(); // Get the collection of ids associated with the attachments - for (String id: attachments.getAllContentIDs()) { + for (String id : attachments.getAllContentIDs()) { mpw.writePart(attachments.getDataHandler(id), id); } mpw.complete(); - } - catch (IOException ex) { + } catch (IOException ex) { throw new OMException("Error writing SwA message", ex); } } @@ -374,8 +356,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWe } } } - } - catch (OMException ex) { + } catch (OMException ex) { // ignore } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessageFactory.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessageFactory.java index bc0131fc..1e2ec0d1 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessageFactory.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessageFactory.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import java.util.Locale; + import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -40,7 +41,6 @@ import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder; import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; 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.util.StringUtils; @@ -58,21 +58,21 @@ import org.springframework.xml.XMLInputFactoryUtils; /** * Axiom-specific implementation of the {@link org.springframework.ws.WebServiceMessageFactory WebServiceMessageFactory} * interface. Creates {@link org.springframework.ws.soap.axiom.AxiomSoapMessage AxiomSoapMessages}. - * - *

To increase reading performance on the SOAP request created by this message factory, you can set the {@link - * #setPayloadCaching(boolean) payloadCaching} property to {@code false} (default is {@code true}). This this + *

+ * To increase reading performance on the SOAP request created by this message factory, you can set the + * {@link #setPayloadCaching(boolean) payloadCaching} property to {@code false} (default is {@code true}). This this * will read the contents of the body directly from the stream. However, when this setting is enabled, the * payload can only be read once. This means that any endpoint mappings or interceptors which are based on the - * message payload (such as the {@link PayloadRootAnnotationMethodEndpointMapping}, the {@link PayloadValidatingInterceptor}, or - * the {@link PayloadLoggingInterceptor}) cannot be used. Instead, use an endpoint mapping that does not consume the - * payload (i.e. the {@link SoapActionAnnotationMethodEndpointMapping}). - * - *

Additionally, this message factory can cache large attachments to disk by setting the {@link - * #setAttachmentCaching(boolean) attachmentCaching} property to {@code true} (default is {@code false}). + * message payload (such as the {@link PayloadRootAnnotationMethodEndpointMapping}, the + * {@link PayloadValidatingInterceptor}, or the {@link PayloadLoggingInterceptor}) cannot be used. Instead, use an + * endpoint mapping that does not consume the payload (i.e. the {@link SoapActionAnnotationMethodEndpointMapping}). + *

+ * Additionally, this message factory can cache large attachments to disk by setting the + * {@link #setAttachmentCaching(boolean) attachmentCaching} property to {@code true} (default is {@code false}). * Optionally, the location where attachments are stored can be defined via the {@link #setAttachmentCacheDir(File) * attachmentCacheDir} property (defaults to the system temp file path). - * - *

Mostly derived from {@code org.apache.axis2.transport.http.HTTPTransportUtils} and + *

+ * Mostly derived from {@code org.apache.axis2.transport.http.HTTPTransportUtils} and * {@code org.apache.axis2.transport.TransportUtils}, which we cannot use since they are not part of the Axiom * distribution. * @@ -111,12 +111,11 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing private boolean supportingExternalEntities = false; - /** * Indicates whether the SOAP Body payload should be cached or not. Default is {@code true}. - * - *

Setting this to {@code false} will increase performance, but also result in the fact that the message - * payload can only be read once. + *

+ * Setting this to {@code false} will increase performance, but also result in the fact that the message payload can + * only be read once. */ public void setPayloadCaching(boolean payloadCaching) { this.payloadCaching = payloadCaching; @@ -124,9 +123,9 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing /** * Indicates whether SOAP attachments should be cached or not. Default is {@code false}. - * - *

Setting this to {@code true} will cause Axiom to store larger attachments on disk, rather than in memory. - * This decreases memory consumption, but decreases performance. + *

+ * Setting this to {@code true} will cause Axiom to store larger attachments on disk, rather than in memory. This + * decreases memory consumption, but decreases performance. */ public void setAttachmentCaching(boolean attachmentCaching) { this.attachmentCaching = attachmentCaching; @@ -135,8 +134,8 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing /** * Sets the directory where SOAP attachments will be stored. Only used when {@link #setAttachmentCaching(boolean) * attachmentCaching} is set to {@code true}. - * - *

The parameter should be an existing, writable directory. This property defaults to the temporary directory of the + *

+ * The parameter should be an existing, writable directory. This property defaults to the temporary directory of the * operating system (i.e. the value of the {@code java.io.tmpdir} system property). */ public void setAttachmentCacheDir(File attachmentCacheDir) { @@ -147,11 +146,11 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing } /** - * Sets the threshold for attachments caching, in bytes. Attachments larger than this threshold will be cached in - * the {@link #setAttachmentCacheDir(File) attachment cache directory}. Only used when {@link - * #setAttachmentCaching(boolean) attachmentCaching} is set to {@code true}. - * - *

Defaults to 4096 bytes (i.e. 4 kilobytes). + * Sets the threshold for attachments caching, in bytes. Attachments larger than this threshold will be cached in the + * {@link #setAttachmentCacheDir(File) attachment cache directory}. Only used when + * {@link #setAttachmentCaching(boolean) attachmentCaching} is set to {@code true}. + *

+ * Defaults to 4096 bytes (i.e. 4 kilobytes). */ public void setAttachmentCacheThreshold(int attachmentCacheThreshold) { Assert.isTrue(attachmentCacheThreshold > 0, "'attachmentCacheThreshold' must be larger than 0"); @@ -162,11 +161,9 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing public void setSoapVersion(SoapVersion version) { if (SoapVersion.SOAP_11 == version) { soapFactory = OMAbstractFactory.getSOAP11Factory(); - } - else if (SoapVersion.SOAP_12 == version) { + } else if (SoapVersion.SOAP_12 == version) { soapFactory = OMAbstractFactory.getSOAP12Factory(); - } - else { + } else { throw new IllegalArgumentException( "Invalid version [" + version + "]. " + "Expected the SOAP_11 or SOAP_12 constant"); } @@ -174,8 +171,8 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing /** * 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 + *

+ * 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 @@ -185,8 +182,9 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing } /** - * Sets whether internal entity references should be replaced with their replacement - * text and report them as characters. + * Sets whether internal entity references should be replaced with their replacement text and report them as + * characters. + * * @see XMLInputFactory#IS_REPLACING_ENTITY_REFERENCES */ public void setReplacingEntityReferences(boolean replacingEntityReferences) { @@ -195,6 +193,7 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing /** * Sets whether external parsed entities should be resolved. + * * @see XMLInputFactory#IS_SUPPORTING_EXTERNAL_ENTITIES */ public void setSupportingExternalEntities(boolean supportingExternalEntities) { @@ -229,8 +228,8 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing String contentType = getHeaderValue(transportInputStream, TransportConstants.HEADER_CONTENT_TYPE); if (!StringUtils.hasLength(contentType)) { if (logger.isDebugEnabled()) { - logger.debug("TransportInputStream has no Content-Type header; defaulting to \"" + - soapFactory.getSOAPVersion().getMediaType() + "\""); + logger.debug("TransportInputStream has no Content-Type header; defaulting to \"" + + soapFactory.getSOAPVersion().getMediaType() + "\""); } contentType = soapFactory.getSOAPVersion().getMediaType().toString(); } @@ -241,15 +240,12 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing try { if (isMultiPartRelated(contentType)) { return createMultiPartAxiomSoapMessage(inputStream, contentType, soapAction); - } - else { + } else { return createAxiomSoapMessage(inputStream, contentType, soapAction); } - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { throw new AxiomSoapMessageCreationException("Could not parse request: " + ex.getMessage(), ex); - } - catch (OMException ex) { + } catch (OMException ex) { throw new AxiomSoapMessageCreationException("Could not create message: " + ex.getMessage(), ex); } } @@ -281,24 +277,20 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing @SuppressWarnings("deprecation") /** Creates an AxiomSoapMessage with attachments. */ - private AxiomSoapMessage createMultiPartAxiomSoapMessage(InputStream inputStream, - String contentType, - String soapAction) throws XMLStreamException { - Attachments attachments = - new Attachments(inputStream, contentType, attachmentCaching, attachmentCacheDir.getAbsolutePath(), - Integer.toString(attachmentCacheThreshold)); + private AxiomSoapMessage createMultiPartAxiomSoapMessage(InputStream inputStream, String contentType, + String soapAction) throws XMLStreamException { + Attachments attachments = new Attachments(inputStream, contentType, attachmentCaching, + attachmentCacheDir.getAbsolutePath(), Integer.toString(attachmentCacheThreshold)); XMLStreamReader reader = inputFactory.createXMLStreamReader(attachments.getRootPartInputStream(), getCharSetEncoding(attachments.getRootPartContentType())); SOAPModelBuilder builder; String envelopeNamespace = getSoapEnvelopeNamespace(contentType); - if (MTOMConstants.SWA_TYPE.equals(attachments.getAttachmentSpecType()) || - MTOMConstants.SWA_TYPE_12.equals(attachments.getAttachmentSpecType())) { + if (MTOMConstants.SWA_TYPE.equals(attachments.getAttachmentSpecType()) + || MTOMConstants.SWA_TYPE_12.equals(attachments.getAttachmentSpecType())) { builder = new StAXSOAPModelBuilder(reader, soapFactory, envelopeNamespace); - } - else if (MTOMConstants.MTOM_TYPE.equals(attachments.getAttachmentSpecType())) { + } else if (MTOMConstants.MTOM_TYPE.equals(attachments.getAttachmentSpecType())) { builder = new MTOMStAXSOAPModelBuilder(reader, attachments, envelopeNamespace); - } - else { + } else { throw new AxiomSoapMessageCreationException( "Unknown attachment type: [" + attachments.getAttachmentSpecType() + "]"); } @@ -309,11 +301,9 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing private String getSoapEnvelopeNamespace(String contentType) { if (contentType.contains(SOAP11Constants.SOAP_11_CONTENT_TYPE)) { return SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI; - } - else if (contentType.contains(SOAP12Constants.SOAP_12_CONTENT_TYPE)) { + } else if (contentType.contains(SOAP12Constants.SOAP_12_CONTENT_TYPE)) { return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI; - } - else { + } else { throw new AxiomSoapMessageCreationException("Unknown content type '" + contentType + "'"); } @@ -336,8 +326,7 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing if (indexOfSemiColon > 0) { value = contentType.substring(eqIdx + 1, indexOfSemiColon); - } - else { + } else { value = contentType.substring(eqIdx + 1, contentType.length()).trim(); } if (value.startsWith("\"")) { @@ -348,21 +337,20 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing } if ("null".equalsIgnoreCase(value)) { return DEFAULT_CHARSET_ENCODING; - } - else { + } else { return value.trim(); } } /** * Create a {@code XMLInputFactory} that this resolver will use to create {@link XMLStreamReader} 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. - * - *

By default this method creates a standard {@link XMLInputFactory} and configures it - * based on the {@link #setReplacingEntityReferences(boolean) replacingEntityReferences} - * and {@link #setSupportingExternalEntities(boolean) supportingExternalEntities} properties. + *

+ * Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so + * this method will only be called once. + *

+ * By default this method creates a standard {@link XMLInputFactory} and configures it based on the + * {@link #setReplacingEntityReferences(boolean) replacingEntityReferences} and + * {@link #setSupportingExternalEntities(boolean) supportingExternalEntities} properties. * * @return the created factory */ @@ -373,20 +361,17 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing return inputFactory; } - public String toString() { StringBuilder builder = new StringBuilder("AxiomSoapMessageFactory["); if (soapFactory.getSOAPVersion() == SOAP11Version.getSingleton()) { builder.append("SOAP 1.1"); - } - else if (soapFactory.getSOAPVersion() == SOAP12Version.getSingleton()) { + } else if (soapFactory.getSOAPVersion() == SOAP12Version.getSingleton()) { builder.append("SOAP 1.2"); } builder.append(','); if (payloadCaching) { builder.append("PayloadCaching enabled"); - } - else { + } else { builder.append("PayloadCaching disabled"); } builder.append(']'); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/NonCachingPayload.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/NonCachingPayload.java index a16272ea..8159d104 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/NonCachingPayload.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/NonCachingPayload.java @@ -17,6 +17,7 @@ package org.springframework.ws.soap.axiom; import java.io.ByteArrayOutputStream; + import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; @@ -31,7 +32,6 @@ import org.apache.axiom.om.ds.ByteArrayDataSource; import org.apache.axiom.om.util.StAXUtils; import org.apache.axiom.soap.SOAPBody; import org.apache.axiom.soap.SOAPFactory; - import org.springframework.util.xml.StaxUtils; /** @@ -76,8 +76,7 @@ class NonCachingPayload extends AbstractPayload { private DelegatingStreamWriter() { try { this.delegate = StAXUtils.createXMLStreamWriter(baos); - } - catch (XMLStreamException ex) { + } catch (XMLStreamException ex) { throw new AxiomSoapBodyException("Could not determine payload root element", ex); } } @@ -137,10 +136,8 @@ class NonCachingPayload extends AbstractPayload { if (baos.size() > 0) { byte[] buf = baos.toByteArray(); OMDataSource dataSource = new ByteArrayDataSource(buf, encoding); - OMNamespace namespace = - getAxiomFactory().createOMNamespace(name.getNamespaceURI(), name.getPrefix()); - OMElement payloadElement = - getAxiomFactory().createOMElement(dataSource, name.getLocalPart(), namespace); + OMNamespace namespace = getAxiomFactory().createOMNamespace(name.getNamespaceURI(), name.getPrefix()); + OMElement payloadElement = getAxiomFactory().createOMElement(dataSource, name.getLocalPart(), namespace); getAxiomBody().addChild(payloadElement); payloadAdded = true; } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/StreamingOMDataSource.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/StreamingOMDataSource.java index 10c30b50..cda70ffa 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/StreamingOMDataSource.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/StreamingOMDataSource.java @@ -21,7 +21,6 @@ import javax.xml.stream.XMLStreamWriter; import org.apache.axiom.om.OMDataSource; import org.apache.axiom.om.ds.AbstractPushOMDataSource; - import org.springframework.util.Assert; import org.springframework.ws.stream.StreamingPayload; diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/support/AxiomUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/support/AxiomUtils.java index 528c1da4..33a99e2f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/support/AxiomUtils.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/axiom/support/AxiomUtils.java @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Iterator; import java.util.Locale; + import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMSource; @@ -30,11 +31,10 @@ import org.apache.axiom.om.OMException; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axiom.soap.SOAPEnvelope; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - import org.springframework.util.StringUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Element; /** * Collection of generic utility methods to work with Axiom. Includes conversion from {@code OMNamespace}s to @@ -50,25 +50,23 @@ import org.springframework.xml.DocumentBuilderFactoryUtils; public abstract class AxiomUtils { /** - * Converts a {@code javax.xml.namespace.QName} to a {@code org.apache.axiom.om.OMNamespace}. A - * {@code OMElement} is used to resolve the namespace, or to declare a new one. + * Converts a {@code javax.xml.namespace.QName} to a {@code org.apache.axiom.om.OMNamespace}. A {@code OMElement} is + * used to resolve the namespace, or to declare a new one. * - * @param qName the {@code QName} to convert + * @param qName the {@code QName} to convert * @param resolveElement the element used to resolve the Q * @return the converted SAAJ Name - * @throws OMException if conversion is unsuccessful + * @throws OMException if conversion is unsuccessful * @throws IllegalArgumentException if {@code qName} is not fully qualified */ public static OMNamespace toNamespace(QName qName, OMElement resolveElement) throws OMException { String prefix = qName.getPrefix(); if (StringUtils.hasLength(qName.getNamespaceURI()) && StringUtils.hasLength(prefix)) { return resolveElement.declareNamespace(qName.getNamespaceURI(), prefix); - } - else if (StringUtils.hasLength(qName.getNamespaceURI())) { + } else if (StringUtils.hasLength(qName.getNamespaceURI())) { // check for existing namespace, and declare if necessary return resolveElement.declareNamespace(qName.getNamespaceURI(), ""); - } - else { + } else { throw new IllegalArgumentException("qName [" + qName + "] does not contain a namespace"); } } @@ -113,8 +111,7 @@ public abstract class AxiomUtils { try { if (envelope instanceof Element) { return ((Element) envelope).getOwnerDocument(); - } - else { + } else { ByteArrayOutputStream bos = new ByteArrayOutputStream(); envelope.build(); envelope.serialize(bos); @@ -124,8 +121,7 @@ public abstract class AxiomUtils { documentBuilderFactory.setNamespaceAware(true); return documentBuilderFactory.newDocumentBuilder().parse(bis); } - } - catch (Exception ex) { + } catch (Exception ex) { throw new IllegalArgumentException("Error in converting SOAP Envelope to Document", ex); } } 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 9cec009f..8112cd51 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 @@ -58,12 +58,11 @@ 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. - * - *

Note that this message returns the same as {@link #getMessage()}. + *

+ * Note that this message returns the same as {@link #getMessage()}. */ public String getFaultStringOrReason() { return soapFault != null ? soapFault.getFaultStringOrReason() : null; } - } 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 089709d7..87644ec7 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 @@ -26,15 +26,14 @@ import org.springframework.ws.soap.SoapMessage; /** * {@link WebServiceMessageCallback} implementation that sets the SOAP Action header on the message. - * - *

A usage example with {@link org.springframework.ws.client.core.WebServiceTemplate}: + *

+ * A usage example with {@link org.springframework.ws.client.core.WebServiceTemplate}: + * *

  * WebServiceTemplate template = new WebServiceTemplate(messageFactory);
  * Result result = new DOMResult();
- * template.sendSourceAndReceiveToResult(
- *	   new StringSource("<content xmlns=\"http://tempuri.org\"/>"),
- *	   new SoapActionCallback("http://tempuri.org/SOAPAction"),
- *	   result);
+ * template.sendSourceAndReceiveToResult(new StringSource("<content xmlns=\"http://tempuri.org\"/>"),
+ * 		new SoapActionCallback("http://tempuri.org/SOAPAction"), result);
  * 
* * @author Arjen Poutsma 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 63125120..095a302d 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 @@ -18,6 +18,7 @@ package org.springframework.ws.soap.saaj; import java.io.IOException; import java.io.InputStream; + import javax.activation.DataHandler; import javax.xml.soap.AttachmentPart; import javax.xml.soap.SOAPException; @@ -26,8 +27,7 @@ import org.springframework.util.Assert; import org.springframework.ws.mime.Attachment; /** - * SAAJ-specific implementation of the {@code Attachment} interface. Wraps a {@link - * javax.xml.soap.AttachmentPart}. + * SAAJ-specific implementation of the {@code Attachment} interface. Wraps a {@link javax.xml.soap.AttachmentPart}. * * @author Arjen Poutsma * @since 1.0.0 @@ -55,8 +55,7 @@ class SaajAttachment implements Attachment { public InputStream getInputStream() throws IOException { try { return saajAttachment.getDataHandler().getInputStream(); - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } @@ -65,8 +64,7 @@ class SaajAttachment implements Attachment { public long getSize() { try { return saajAttachment.getSize(); - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } @@ -75,8 +73,7 @@ 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/SaajSoap11Body.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoap11Body.java index d369d1e9..e193601c 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.saaj; import java.util.Locale; + import javax.xml.namespace.QName; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPException; @@ -63,14 +64,12 @@ 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 e8c3cb5e..f44aaf9b 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.saaj; import java.util.Locale; + import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPFault; @@ -43,8 +44,7 @@ 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); } } 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 5fee1ff7..833aef33 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 @@ -19,6 +19,7 @@ package org.springframework.ws.soap.saaj; import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPHeader; import javax.xml.soap.SOAPHeaderElement; 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 c5168cb0..07cca037 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.saaj; import java.util.Locale; + import javax.xml.namespace.QName; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPException; @@ -86,14 +87,12 @@ 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 dfdf861f..9f70401f 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 @@ -18,6 +18,7 @@ package org.springframework.ws.soap.saaj; import java.util.Iterator; import java.util.Locale; + import javax.xml.namespace.QName; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPFault; @@ -43,8 +44,7 @@ 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); } } @@ -59,8 +59,7 @@ 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,8 +73,7 @@ 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); } @@ -85,8 +83,7 @@ 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); } @@ -96,8 +93,7 @@ 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); } } 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 118dad25..9a445fd6 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 @@ -19,6 +19,7 @@ package org.springframework.ws.soap.saaj; import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import javax.xml.namespace.QName; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPException; @@ -46,11 +47,9 @@ class SaajSoap12Header extends SaajSoapHeader implements Soap12Header { @Override public SoapHeaderElement addNotUnderstoodHeaderElement(QName headerName) { try { - SOAPHeaderElement headerElement = - getSaajHeader().addNotUnderstoodHeaderElement(headerName); + SOAPHeaderElement headerElement = getSaajHeader().addNotUnderstoodHeaderElement(headerName); return new SaajSoapHeaderElement(headerElement); - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new SaajSoapHeaderException(ex); } } @@ -58,11 +57,9 @@ class SaajSoap12Header extends SaajSoapHeader implements Soap12Header { @Override public SoapHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris) { try { - SOAPHeaderElement headerElement = - getSaajHeader().addUpgradeHeaderElement(supportedSoapUris); + SOAPHeaderElement headerElement = getSaajHeader().addUpgradeHeaderElement(supportedSoapUris); return new SaajSoapHeaderElement(headerElement); - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new SaajSoapHeaderException(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 b1160b3e..81454cce 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.saaj; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPException; @@ -55,8 +56,7 @@ 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); } } @@ -81,8 +81,7 @@ 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/SaajSoapEnvelope.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapEnvelope.java index 25b8c36e..a37f4933 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 @@ -27,8 +27,7 @@ import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapVersion; /** - * SAAJ-specific implementation of the {@code SoapEnvelope} interface. Wraps a {@link - * javax.xml.soap.SOAPEnvelope}. + * SAAJ-specific implementation of the {@code SoapEnvelope} interface. Wraps a {@link javax.xml.soap.SOAPEnvelope}. * * @author Arjen Poutsma * @since 1.0.0 @@ -54,15 +53,12 @@ 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); } } @@ -75,19 +71,15 @@ 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/SaajSoapFault.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapFault.java index dcc90b3b..1343ea80 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 @@ -56,8 +56,7 @@ 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 6dc35077..282b7014 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.saaj; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.soap.Detail; import javax.xml.soap.DetailEntry; @@ -30,8 +31,8 @@ import org.springframework.ws.soap.SoapFaultDetail; import org.springframework.ws.soap.SoapFaultDetailElement; /** - * SAAJ-specific implementation of the {@code SoapFaultDetail} interface. Wraps a {@link - * javax.xml.soap.SOAPFaultElement}. + * SAAJ-specific implementation of the {@code SoapFaultDetail} interface. Wraps a + * {@link javax.xml.soap.SOAPFaultElement}. * * @author Arjen Poutsma * @since 1.0.0 @@ -52,8 +53,7 @@ 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); } } @@ -95,5 +95,4 @@ class SaajSoapFaultDetail extends SaajSoapElement implements S } } - } 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 fc4e66e3..e118863e 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 @@ -24,8 +24,8 @@ import javax.xml.transform.dom.DOMResult; import org.springframework.ws.soap.SoapFaultDetailElement; /** - * SAAJ-specific implementation of the {@code SoapFaultDetailElement} interface. Wraps a {@link - * javax.xml.soap.DetailEntry}. + * SAAJ-specific implementation of the {@code SoapFaultDetailElement} interface. Wraps a + * {@link javax.xml.soap.DetailEntry}. * * @author Arjen Poutsma * @since 1.0.0 @@ -45,8 +45,7 @@ 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/SaajSoapHeader.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeader.java index 03bf32b9..23573fc7 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.saaj; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.soap.Node; import javax.xml.soap.SOAPException; @@ -58,9 +59,9 @@ abstract class SaajSoapHeader extends SaajSoapElement implements Soa @Override @SuppressWarnings("unchecked") - public Iterator examineMustUnderstandHeaderElements(String actorOrRole) throws SoapHeaderException { - Iterator iterator = - getSaajHeader().examineMustUnderstandHeaderElements(actorOrRole); + public Iterator examineMustUnderstandHeaderElements(String actorOrRole) + throws SoapHeaderException { + Iterator iterator = getSaajHeader().examineMustUnderstandHeaderElements(actorOrRole); return new SaajSoapHeaderElementIterator(iterator); } @@ -69,8 +70,7 @@ 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); } } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderElement.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderElement.java index c41dec6c..bc6013cc 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderElement.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapHeaderElement.java @@ -24,8 +24,8 @@ import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapHeaderException; /** - * SAAJ-specific implementation of the {@code SoapHeaderElement} interface. Wraps a {@link - * javax.xml.soap.SOAPHeaderElement}. + * SAAJ-specific implementation of the {@code SoapHeaderElement} interface. Wraps a + * {@link javax.xml.soap.SOAPHeaderElement}. * * @author Arjen Poutsma * @since 1.0.0 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 cefc2b70..be9086d5 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 @@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; + import javax.activation.DataHandler; import javax.xml.soap.AttachmentPart; import javax.xml.soap.MessageFactory; @@ -33,12 +34,6 @@ import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; import javax.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; @@ -51,6 +46,11 @@ 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}, @@ -96,8 +96,8 @@ 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); @@ -107,11 +107,12 @@ 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, MessageFactory messageFactory) { + public SaajSoapMessage(SOAPMessage soapMessage, boolean langAttributeOnSoap11FaultString, + MessageFactory messageFactory) { Assert.notNull(soapMessage, "soapMessage must not be null"); saajMessage = soapMessage; this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString; @@ -136,8 +137,7 @@ 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); } } @@ -150,13 +150,11 @@ 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 { + return !ObjectUtils.isEmpty(contentTypes) ? SoapUtils.extractActionFromContentType(contentTypes[0]) + : TransportConstants.EMPTY_SOAP_ACTION; + } else { throw new IllegalStateException("Unsupported SOAP version: " + getVersion()); } } @@ -167,13 +165,11 @@ 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); @@ -181,8 +177,7 @@ 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()); } @@ -199,11 +194,9 @@ public class SaajSoapMessage extends AbstractSoapMessage { SOAPMessage saajMessage = messageFactory.createMessage(getSaajMessage().getMimeHeaders(), bis); setSaajMessage(saajMessage); return saajMessage.getSOAPPart(); - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new SaajSoapMessageException("Could not save changes", ex); - } - catch (IOException ex) { + } catch (IOException ex) { throw new SaajSoapMessageException("Could not save changes", ex); } } @@ -228,11 +221,9 @@ public class SaajSoapMessage extends AbstractSoapMessage { this.saajMessage = messageFactory.createMessage(saajMessage.getMimeHeaders(), bis); - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new SaajSoapMessageException("Could not read input stream", ex); - } - catch (IOException ex) { + } catch (IOException ex) { throw new SaajSoapMessageException("Could not read input stream", ex); } } @@ -251,15 +242,11 @@ public class SaajSoapMessage extends AbstractSoapMessage { TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream; // 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))) { + 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(); @@ -272,8 +259,7 @@ 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); } } @@ -300,8 +286,7 @@ 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 + '"'); } @@ -309,8 +294,7 @@ 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 + '"'); } @@ -344,8 +328,7 @@ public class SaajSoapMessage extends AbstractSoapMessage { AttachmentPart attachmentPart = message.createAttachmentPart(dataHandler); message.addAttachmentPart(attachmentPart); attachmentPart.setContentId(contentId); - attachmentPart.setMimeHeader(TransportConstants.HEADER_CONTENT_TRANSFER_ENCODING, - "binary"); + attachmentPart.setMimeHeader(TransportConstants.HEADER_CONTENT_TRANSFER_ENCODING, "binary"); return new SaajAttachment(attachmentPart); } @@ -363,8 +346,7 @@ public class SaajSoapMessage extends AbstractSoapMessage { } } } - } - catch (SOAPException ex) { + } catch (SOAPException ex) { // ignore } return builder.toString(); 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 05daec56..bfa4368b 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 @@ -23,6 +23,7 @@ import java.io.PushbackInputStream; import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; + import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPConstants; @@ -31,8 +32,6 @@ import javax.xml.soap.SOAPMessage; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.xml.sax.SAXParseException; - import org.springframework.beans.factory.InitializingBean; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; @@ -44,13 +43,13 @@ import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.saaj.support.SaajUtils; import org.springframework.ws.transport.TransportConstants; import org.springframework.ws.transport.TransportInputStream; +import org.xml.sax.SAXParseException; /** * 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(javax.xml.soap.MessageFactory) + * 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(javax.xml.soap.MessageFactory) * constructor}, or by the {@link #setMessageFactory(javax.xml.soap.MessageFactory)} property. When a SAAJ message * factory is injected, the {@link #setSoapVersion(org.springframework.ws.soap.SoapVersion)} property is ignored. * @@ -72,8 +71,7 @@ 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) { @@ -92,6 +90,7 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB /** * Sets the SAAJ message properties. These properties will be set on created messages. + * * @see javax.xml.soap.SOAPMessage#setProperty(String, Object) */ public void setMessageProperties(Map messageProperties) { @@ -100,8 +99,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB /** * 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 + *

+ * 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 @@ -115,16 +114,13 @@ 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"); } } @@ -141,27 +137,22 @@ 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?", ex); - } - catch (SOAPException ex) { + "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?", + ex); + } catch (SOAPException ex) { throw new SoapMessageCreationException("Could not create SAAJ MessageFactory: " + ex.getMessage(), ex); } } @@ -176,8 +167,7 @@ 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); } } @@ -191,8 +181,7 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB saajMessage.getSOAPPart().getEnvelope(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); - } - catch (SOAPException ex) { + } 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 @@ -203,10 +192,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB try { SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); - return new SaajSoapMessage(saajMessage, - langAttributeOnSoap11FaultString); - } - catch (SOAPException e) { + return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString); + } catch (SOAPException e) { // fall-through } } @@ -214,9 +201,7 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB if (parseException != null) { throw new InvalidXmlException("Could not parse XML", parseException); } else { - throw new SoapMessageCreationException( - "Could not create message from InputStream: " + ex.getMessage(), - ex); + throw new SoapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(), ex); } } } @@ -282,7 +267,9 @@ 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) */ 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 e8dc57e1..66febf5b 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 @@ -18,19 +18,19 @@ package org.springframework.ws.soap.saaj.support; import java.util.LinkedHashMap; import java.util.Map; + import javax.xml.soap.Name; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPException; +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. @@ -49,8 +49,7 @@ 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 */ @@ -58,8 +57,7 @@ public class SaajContentHandler implements ContentHandler { Assert.notNull(element, "element must not be null"); if (element instanceof SOAPEnvelope) { envelope = (SOAPEnvelope) element; - } - else { + } else { envelope = SaajUtils.getEnvelope(element); } this.element = element; @@ -70,8 +68,7 @@ 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); } } @@ -97,8 +94,7 @@ public class SaajContentHandler implements ContentHandler { } } element = child; - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new SAXException(ex); } } @@ -107,15 +103,13 @@ 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; @@ -140,35 +134,28 @@ 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 e51b3133..e8f06b1e 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 @@ -19,6 +19,7 @@ package org.springframework.ws.soap.saaj.support; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; @@ -35,8 +36,8 @@ 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 @@ -54,8 +55,7 @@ public abstract class SaajUtils { private static int saajVersion = SAAJ_13; /** - * Gets the SAAJ version. - * Returns {@link #SAAJ_13} as of Spring-WS 2.2. + * 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 */ @@ -64,8 +64,7 @@ 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 @@ -79,8 +78,8 @@ public abstract class SaajUtils { } /** - * Gets the SAAJ version for the specified {@link javax.xml.soap.SOAPElement}. - * Returns {@link #SAAJ_13} as of Spring-WS 2.2. + * Gets the SAAJ version for the specified {@link javax.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 @@ -105,14 +104,11 @@ 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 ""; } } @@ -120,10 +116,10 @@ public abstract class SaajUtils { /** * Converts a {@link QName} to a {@link Name}. A {@link SOAPElement} is required to resolve namespaces. * - * @param qName the {@code QName} to convert + * @param qName the {@code QName} to convert * @param resolveElement a {@code SOAPElement} used to resolve namespaces to prefixes * @return the converted SAAJ Name - * @throws SOAPException if conversion is unsuccessful + * @throws SOAPException if conversion is unsuccessful * @throws IllegalArgumentException if {@code qName} is not fully qualified */ public static Name toName(QName qName, SOAPElement resolveElement) throws SOAPException { @@ -131,13 +127,11 @@ 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()) { @@ -147,8 +141,7 @@ public abstract class SaajUtils { } } return envelope.createName(qName.getLocalPart(), "", qName.getNamespaceURI()); - } - else { + } else { return envelope.createName(qName.getLocalPart()); } } @@ -162,11 +155,9 @@ public abstract class SaajUtils { 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()); } } @@ -174,11 +165,11 @@ public abstract class SaajUtils { /** * Loads a SAAJ {@code SOAPMessage} from the given resource with a given message factory. * - * @param resource the resource to read from + * @param resource the resource to read from * @param messageFactory SAAJ message factory used to construct the message * @return the loaded SAAJ message * @throws SOAPException if the message cannot be constructed - * @throws IOException if the input stream resource cannot be loaded + * @throws IOException if the input stream resource cannot be loaded */ public static SOAPMessage loadMessage(Resource resource, MessageFactory messageFactory) throws SOAPException, IOException { @@ -188,8 +179,7 @@ public abstract class SaajUtils { mimeHeaders.addHeader(TransportConstants.HEADER_CONTENT_TYPE, "text/xml"); mimeHeaders.addHeader(TransportConstants.HEADER_CONTENT_LENGTH, Long.toString(resource.getFile().length())); return messageFactory.createMessage(mimeHeaders, is); - } - finally { + } finally { is.close(); } } @@ -207,8 +197,7 @@ public abstract class SaajUtils { return (SOAPEnvelope) element; } element = element.getParentElement(); - } - while (element != null); + } while (element != null); return null; } @@ -216,7 +205,7 @@ public abstract class SaajUtils { * Returns the first child element of the given body. */ public static SOAPElement getFirstBodyElement(SOAPBody body) { - for (Iterator iterator = body.getChildElements(); iterator.hasNext(); ) { + for (Iterator iterator = body.getChildElements(); iterator.hasNext();) { Object child = iterator.next(); if (child instanceof SOAPElement) { return (SOAPElement) child; 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 693d305a..3d3ca2ff 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 @@ -17,11 +17,14 @@ package org.springframework.ws.soap.saaj.support; import java.util.Iterator; + import javax.xml.soap.Name; import javax.xml.soap.Node; import javax.xml.soap.SOAPElement; import javax.xml.soap.Text; +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; @@ -29,12 +32,9 @@ 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 javax.xml.soap.Node @@ -66,11 +66,9 @@ 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); } } @@ -79,19 +77,17 @@ 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); } } /** * Parses the StAX XML reader passed at construction-time. - * - *

Note that the given {@code InputSource} is not read, but ignored. + *

+ * 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} @@ -103,8 +99,8 @@ 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. + *

+ * 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} @@ -127,8 +123,7 @@ 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); } @@ -143,11 +138,9 @@ public class SaajXmlReader extends AbstractXmlReader { String namespaceUri = element.getNamespaceURI(prefix); getContentHandler().startPrefixMapping(prefix, namespaceUri); } - getContentHandler() - .startElement(elementName.getURI(), elementName.getLocalName(), elementName.getQualifiedName(), - getAttributes(element)); - } - else { + getContentHandler().startElement(elementName.getURI(), elementName.getLocalName(), + elementName.getQualifiedName(), getAttributes(element)); + } else { getContentHandler().startElement("", "", elementName.getQualifiedName(), getAttributes(element)); } } @@ -157,14 +150,13 @@ public class SaajXmlReader extends AbstractXmlReader { } if (getContentHandler() != null) { if (namespacesFeature) { - getContentHandler() - .endElement(elementName.getURI(), elementName.getLocalName(), elementName.getQualifiedName()); + getContentHandler().endElement(elementName.getURI(), elementName.getLocalName(), + elementName.getQualifiedName()); for (Iterator iterator = element.getNamespacePrefixes(); iterator.hasNext();) { String prefix = (String) iterator.next(); getContentHandler().endPrefixMapping(prefix); } - } - else { + } else { getContentHandler().endElement("", "", elementName.getQualifiedName()); } } @@ -197,8 +189,7 @@ 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/SoapEndpointInvocationChain.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/server/SoapEndpointInvocationChain.java index 53694ad1..958fa1ff 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 @@ -20,9 +20,8 @@ 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() @@ -47,7 +46,7 @@ public class SoapEndpointInvocationChain extends EndpointInvocationChain { /** * Create new {@code SoapEndpointInvocationChain}. * - * @param endpoint the endpoint object to invoke + * @param endpoint the endpoint object to invoke * @param interceptors the array of interceptors to apply */ public SoapEndpointInvocationChain(Object endpoint, EndpointInterceptor[] interceptors) { @@ -57,15 +56,13 @@ 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 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 */ - public SoapEndpointInvocationChain(Object endpoint, - EndpointInterceptor[] interceptors, - String[] actorsOrRoles, - boolean isUltimateReceiver) { + public SoapEndpointInvocationChain(Object endpoint, EndpointInterceptor[] interceptors, String[] actorsOrRoles, + boolean isUltimateReceiver) { super(endpoint, interceptors); this.actorsOrRoles = actorsOrRoles; this.isUltimateReceiver = 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 e45cf565..c3ce7fb4 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 @@ -19,11 +19,10 @@ 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. - * - *

The main purpose for this interface is to add consitency between all SOAP-specific {@code EndpointMappings}. The + * 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. * * @author Arjen Poutsma 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 9075d9e4..7791c7a5 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 @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Locale; + import javax.xml.namespace.QName; import org.springframework.util.ObjectUtils; @@ -48,16 +49,14 @@ import org.springframework.ws.soap.soap12.Soap12Header; public class SoapMessageDispatcher extends MessageDispatcher { /** Default message used when creating a SOAP MustUnderstand fault. */ - public static final String DEFAULT_MUST_UNDERSTAND_FAULT_STRING = - "One or more mandatory SOAP header blocks not understood"; + public static final String DEFAULT_MUST_UNDERSTAND_FAULT_STRING = "One or more mandatory SOAP header blocks not understood"; private String mustUnderstandFaultString = DEFAULT_MUST_UNDERSTAND_FAULT_STRING; 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; @@ -70,9 +69,9 @@ public class SoapMessageDispatcher extends MessageDispatcher { /** * 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. + * {@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 @@ -95,10 +94,8 @@ public class SoapMessageDispatcher extends MessageDispatcher { return true; } - private boolean handleHeaders(EndpointInvocationChain mappedEndpoint, - MessageContext messageContext, - String[] actorsOrRoles, - boolean isUltimateReceiver) { + private boolean handleHeaders(EndpointInvocationChain mappedEndpoint, MessageContext messageContext, + String[] actorsOrRoles, boolean isUltimateReceiver) { SoapMessage soapRequest = (SoapMessage) messageContext.getRequest(); SoapHeader soapHeader = soapRequest.getSoapHeader(); if (soapHeader == null) { @@ -107,10 +104,8 @@ 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()) { @@ -125,8 +120,7 @@ public class SoapMessageDispatcher extends MessageDispatcher { } if (notUnderstoodHeaderNames.isEmpty()) { return true; - } - else { + } else { SoapMessage response = (SoapMessage) messageContext.getResponse(); createMustUnderstandFault(response, notUnderstoodHeaderNames, actorsOrRoles); return false; @@ -134,10 +128,10 @@ 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) */ @@ -147,24 +141,22 @@ public class SoapMessageDispatcher extends MessageDispatcher { return false; } for (EndpointInterceptor interceptor : interceptors) { - if (interceptor instanceof SoapEndpointInterceptor && - ((SoapEndpointInterceptor) interceptor).understands(headerElement)) { + if (interceptor instanceof SoapEndpointInterceptor + && ((SoapEndpointInterceptor) interceptor).understands(headerElement)) { return true; } } return false; } - private void createMustUnderstandFault(SoapMessage soapResponse, - List notUnderstoodHeaderNames, - String[] actorsOrRoles) { + private void createMustUnderstandFault(SoapMessage soapResponse, List notUnderstoodHeaderNames, + String[] actorsOrRoles) { if (logger.isWarnEnabled()) { - logger.warn("Could not handle mustUnderstand headers: " + - StringUtils.collectionToCommaDelimitedString(notUnderstoodHeaderNames) + ". Returning fault"); + logger.warn("Could not handle mustUnderstand headers: " + + 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 53bcb994..bd083ef6 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.server.endpoint; import java.util.Locale; + import javax.xml.namespace.QName; import org.springframework.context.MessageSource; @@ -32,30 +33,30 @@ 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. - * - *

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. + * 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 + * {@link #setDetailElementName(QName) detailElementName} properties. * * @author Arjen Poutsma * @since 1.0.2 * @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. * * @see #setDetailElementName(javax.xml.namespace.QName) */ - public static final QName DEFAULT_DETAIL_ELEMENT_NAME = - new QName("http://springframework.org/spring-ws", "ValidationError", - "spring-ws"); + public static final QName DEFAULT_DETAIL_ELEMENT_NAME = new QName("http://springframework.org/spring-ws", + "ValidationError", "spring-ws"); /** * Default SOAP Fault string used when a validation errors occur on the request. @@ -76,8 +77,8 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint /** * 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}. + * 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() */ @@ -86,9 +87,9 @@ 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() */ @@ -117,9 +118,8 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint } /** - * 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 */ @@ -133,7 +133,7 @@ public abstract class AbstractFaultCreatingValidatingMarshallingPayloadEndpoint } /** - * Sets the locale for SOAP fault reason and validation messages. It is only added when the underlying message is a + * 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 @@ -148,12 +148,12 @@ 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}. + * 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 + * @param errors the validation errors * @return {@code true} to continue processing the request, {@code false} (the default) otherwise * @see Errors#getAllErrors() */ 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 b85e1186..8956d5cd 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 @@ -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) @@ -50,8 +50,8 @@ public abstract class AbstractSoapFaultDefinitionExceptionResolver extends Abstr /** * 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 + * @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. */ protected abstract SoapFaultDefinition getFaultDefinition(Object endpoint, Exception ex); @@ -76,27 +76,22 @@ public abstract class AbstractSoapFaultDefinitionExceptionResolver extends Abstr SoapBody soapBody = ((SoapMessage) messageContext.getResponse()).getSoapBody(); SoapFault fault; - if (SoapFaultDefinition.SERVER.equals(definition.getFaultCode()) || - SoapFaultDefinition.RECEIVER.equals(definition.getFaultCode())) { + if (SoapFaultDefinition.SERVER.equals(definition.getFaultCode()) + || SoapFaultDefinition.RECEIVER.equals(definition.getFaultCode())) { fault = soapBody.addServerOrReceiverFault(faultStringOrReason, definition.getLocale()); - } - else if (SoapFaultDefinition.CLIENT.equals(definition.getFaultCode()) || - SoapFaultDefinition.SENDER.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."); } } @@ -108,15 +103,14 @@ public abstract class AbstractSoapFaultDefinitionExceptionResolver extends Abstr /** * 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. * - *

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 + * @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 12b4a719..b1bda421 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 @@ -29,8 +29,8 @@ 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. - * - *

The fault code is always set to a Server (in SOAP 1.1) or Receiver (SOAP 1.2). + *

+ * The fault code is always set to a Server (in SOAP 1.1) or Receiver (SOAP 1.2). * * @author Arjen Poutsma * @since 1.0.0 @@ -41,8 +41,8 @@ public class SimpleSoapExceptionResolver extends AbstractEndpointExceptionResolv /** * Returns the locale for the faultstring or reason of the SOAP Fault. - * - *

Defaults to {@link Locale#ENGLISH}. + *

+ * Defaults to {@link Locale#ENGLISH}. */ public Locale getLocale() { return locale; @@ -50,8 +50,8 @@ public class SimpleSoapExceptionResolver extends AbstractEndpointExceptionResolv /** * Sets the locale for the faultstring or reason of the SOAP Fault. - * - *

Defaults to {@link Locale#ENGLISH}. + *

+ * Defaults to {@link Locale#ENGLISH}. */ public void setLocale(Locale locale) { Assert.notNull(locale, "locale must not be null"); @@ -75,10 +75,9 @@ public class SimpleSoapExceptionResolver extends AbstractEndpointExceptionResolv * {@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 ex the exception that got thrown during endpoint execution - * @param fault the SOAP fault to be customized. + * @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 d1aa5290..546c0ab8 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 @@ -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,15 +38,13 @@ 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 802afe24..2c0f48b4 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.server.endpoint; import java.util.Locale; + import javax.xml.namespace.QName; /** @@ -52,7 +53,7 @@ public class SoapFaultDefinition { 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) */ 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 61cbfca7..d7f8b082 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 @@ -18,6 +18,7 @@ package org.springframework.ws.soap.server.endpoint; import java.beans.PropertyEditorSupport; import java.util.Locale; + import javax.xml.namespace.QName; import org.springframework.beans.propertyeditors.LocaleEditor; @@ -26,27 +27,33 @@ import org.springframework.xml.namespace.QNameEditor; /** * PropertyEditor for {@code SoapFaultDefinition} objects. Takes strings of form + * *

  * 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. - * - *

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: + * + * 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. + *

+ * For example: + * *

  * RECEIVER,Server error
  * 
+ * * or + * *
  * CLIENT,Client error
  * 
+ * * or + * *
  * {http://springframework.org/spring-ws}spring-ws:FatalError},A fatal error has occurred
  * 
@@ -73,12 +80,11 @@ 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 + - "]: SoapFaultDefinitionEditor requires at least 1"); + throw new IllegalArgumentException("Invalid amount of comma delimited values in [" + text + + "]: SoapFaultDefinitionEditor requires at least 1"); } SoapFaultDefinition definition = new SoapFaultDefinition(); QNameEditor qNameEditor = new QNameEditor(); 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 27d49cb3..4da833d3 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 @@ -36,20 +36,19 @@ public class SoapFaultMappingExceptionResolver extends AbstractSoapFaultDefiniti /** * 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}. - * - *

Follows the same matching algorithm as {@code SimpleMappingExceptionResolver}. + *

+ * 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 + * values * @see SoapFaultDefinitionEditor */ public void setExceptionMappings(Properties mappings) { for (Map.Entry entry : mappings.entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String) { - exceptionMappings.put((String)entry.getKey(), (String)entry.getValue()); + exceptionMappings.put((String) entry.getKey(), (String) entry.getValue()); } } } @@ -76,10 +75,10 @@ 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. - * - *

Follows the same algorithm as RollbackRuleAttribute, and SimpleMappingExceptionResolver + * 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 */ 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 67d9c187..60699918 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 @@ -21,6 +21,7 @@ import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import javax.xml.namespace.QName; import org.springframework.core.MethodParameter; @@ -36,12 +37,17 @@ 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.

The following snippet shows an example of supported declarations. - *

+ * times in the same SOAP header.
+ * 

+ * The following snippet shows an example of supported declarations. + * + *
+ * 
  * 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 @@ -86,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); @@ -95,8 +101,7 @@ 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 @@ -115,7 +120,7 @@ public class SoapHeaderElementMethodArgumentResolver implements MethodArgumentRe } private List extractSoapHeaderList(QName qname, - org.springframework.ws.soap.SoapHeader soapHeader) { + org.springframework.ws.soap.SoapHeader soapHeader) { List result = new ArrayList(); Iterator elements = soapHeader.examineAllHeaderElements(); while (elements.hasNext()) { 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 1d5ffa13..8f39c306 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 @@ -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 @@ -37,8 +37,8 @@ public class SoapMethodArgumentResolver implements MethodArgumentResolver { @Override public boolean supportsParameter(MethodParameter parameter) { Class parameterType = parameter.getParameterType(); - return SoapMessage.class.equals(parameterType) || SoapBody.class.equals(parameterType) || - SoapEnvelope.class.equals(parameterType) || SoapHeader.class.equals(parameterType); + return SoapMessage.class.equals(parameterType) || SoapBody.class.equals(parameterType) + || SoapEnvelope.class.equals(parameterType) || SoapHeader.class.equals(parameterType); } @Override @@ -50,14 +50,11 @@ 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 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 ca684d8e..ec7ac420 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 @@ -32,8 +32,8 @@ 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}. - * - *

Note that custom Fault Codes are only supported on SOAP 1.1. + *

+ * 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) @@ -62,7 +62,7 @@ public enum FaultCode { 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) */ @@ -78,5 +78,4 @@ public enum FaultCode { return 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 79b006a0..a9cf8072 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 @@ -22,6 +22,7 @@ import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import javax.xml.namespace.QName; /** @@ -42,11 +43,11 @@ public @interface SoapFault { /** * 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 + *

+ * 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. + *

+ * Note that custom Fault Codes are only supported on SOAP 1.1. */ String customFaultCode() default ""; @@ -56,5 +57,4 @@ public @interface SoapFault { /** The fault string locale. By default, it is English. */ String locale() default "en"; - } 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 f544aa86..f3eebb14 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 @@ -23,7 +23,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marks an endpoint method parameter to be resolved as a single or a list of {@link org.springframework.ws.soap.SoapHeaderElement}. + * Marks an endpoint method parameter to be resolved as a single or a list of + * {@link org.springframework.ws.soap.SoapHeaderElement}. * * @author Tareq Abedrabbo * @since 2.0 @@ -33,8 +34,8 @@ import java.lang.annotation.Target; @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 20927ff1..28e330ab 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 @@ -17,11 +17,10 @@ package org.springframework.ws.soap.server.endpoint.interceptor; 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; @@ -29,12 +28,13 @@ 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 overriding {@code handleRequestValidationErrors}. + * 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 * @see #setAddValidationErrorDetail(boolean) @@ -52,9 +52,8 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac * * @see #setDetailElementName(javax.xml.namespace.QName) */ - public static final QName DEFAULT_DETAIL_ELEMENT_NAME = - new QName("http://springframework.org/spring-ws", "ValidationError", - "spring-ws"); + public static final QName DEFAULT_DETAIL_ELEMENT_NAME = new QName("http://springframework.org/spring-ws", + "ValidationError", "spring-ws"); /** * Default SOAP Fault string used when a validation errors occur on the request. @@ -73,8 +72,8 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac /** * 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}. + * 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() */ @@ -83,9 +82,9 @@ 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() */ @@ -114,9 +113,8 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac } /** - * 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 */ @@ -130,7 +128,7 @@ public abstract class AbstractFaultCreatingValidatingInterceptor extends Abstrac } /** - * Sets the SOAP fault reason locale used when validation errors occur on the request. It is only added when the + * 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 @@ -142,11 +140,11 @@ 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}. + * 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 + * @param errors the validation errors * @return {@code true} to continue processing the request, {@code false} (the default) otherwise */ @Override 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 424124cf..3abbe3f3 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 @@ -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 @@ -46,8 +46,7 @@ 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 cdde3fb8..9ceb5d57 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 @@ -42,9 +42,7 @@ 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; @@ -64,8 +62,7 @@ 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 4deecf52..ff4ef3bc 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 @@ -21,16 +21,15 @@ 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. - * - *

When the payload is invalid, this interceptor stops processing of the interceptor chain. Additionally, if the message + * 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. - * - *

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) 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 3d9bb23f..c3a3267b 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 @@ -43,13 +43,12 @@ public class SoapActionSmartEndpointInterceptor extends DelegatingSmartSoapEndpo protected boolean shouldIntercept(WebServiceMessage request, Object endpoint) { if (request instanceof SoapMessage) { String soapAction = ((SoapMessage) request).getSoapAction(); - if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' && - soapAction.charAt(soapAction.length() - 1) == '"') { + if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' + && soapAction.charAt(soapAction.length() - 1) == '"') { 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 c64b021e..22ff2fb7 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 @@ -26,9 +26,9 @@ 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 +63,7 @@ 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 c40d9808..481bd37e 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 @@ -26,14 +26,13 @@ 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}. - * - *

This endpoint mapping makes it possible to set actors/roles on a specific endpoint, without making the all endpoint + * {@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. - * - *

It is only in a scenario when a certain endpoint act as a SOAP intermediary for another endpoint, as described in the + *

+ * 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 @@ -57,7 +56,7 @@ public class DelegatingSoapEndpointMapping implements InitializingBean, SoapEndp @Override public final void setActorOrRole(String actorOrRole) { Assert.notNull(actorOrRole, "actorOrRole must not be null"); - actorsOrRoles = new String[]{actorOrRole}; + actorsOrRoles = new String[] { actorOrRole }; } @Override @@ -72,8 +71,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[]) */ @@ -83,8 +82,7 @@ public class DelegatingSoapEndpointMapping implements InitializingBean, SoapEndp if (delegateChain != null) { return new SoapEndpointInvocationChain(delegateChain.getEndpoint(), delegateChain.getInterceptors(), actorsOrRoles, isUltimateReceiver); - } - else { + } else { return null; } } 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 fae1ea88..1da28423 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 @@ -34,10 +34,11 @@ 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. - * - *

Endpoints typically have the following form: + * 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: + * *

  * @Endpoint
  * public class MyEndpoint{
@@ -61,7 +62,7 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio
 	@Override
 	public final void setActorOrRole(String actorOrRole) {
 		Assert.notNull(actorOrRole, "actorOrRole must not be null");
-		actorsOrRoles = new String[]{actorOrRole};
+		actorsOrRoles = new String[] { actorOrRole };
 	}
 
 	@Override
@@ -79,16 +80,15 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio
 	 * Creates a new {@code SoapEndpointInvocationChain} based on the given endpoint, and the set interceptors, and
 	 * actors/roles.
 	 *
-	 * @param endpoint	   the endpoint
+	 * @param endpoint the endpoint
 	 * @param interceptors the endpoint interceptors
 	 * @return the created invocation chain
 	 * @see #setInterceptors(org.springframework.ws.server.EndpointInterceptor[])
 	 * @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,15 +97,13 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio
 		if (messageContext.getRequest() instanceof SoapMessage) {
 			SoapMessage request = (SoapMessage) messageContext.getRequest();
 			String soapAction = request.getSoapAction();
-			if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' &&
-					soapAction.charAt(soapAction.length() - 1) == '"') {
+			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;
 		}
 	}
@@ -120,14 +118,12 @@ public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotatio
 	protected List getLookupKeysForMethod(Method method) {
 		List result = new ArrayList();
 
-		SoapActions soapActions = AnnotationUtils.findAnnotation(method,
-				SoapActions.class);
+		SoapActions soapActions = AnnotationUtils.findAnnotation(method, SoapActions.class);
 		if (soapActions != null) {
 			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());
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 6a7c1d0c..1eb5833b 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
@@ -28,22 +28,23 @@ 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.
- *
- * 

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 + * 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. + *

+ * 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
  * http://www.springframework.org/spring-ws/samples/airline/GetFlights=getFlightsEndpoint
  * 
+ * * 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 + *

+ * 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 AxiomSoapMessageFactory} with the * {@code payloadCaching} disabled). * @@ -59,7 +60,7 @@ public class SoapActionEndpointMapping extends AbstractMapBasedEndpointMapping i @Override public final void setActorOrRole(String actorOrRole) { Assert.notNull(actorOrRole, "actorOrRole must not be null"); - actorsOrRoles = new String[]{actorOrRole}; + actorsOrRoles = new String[] { actorOrRole }; } @Override @@ -77,16 +78,15 @@ public class SoapActionEndpointMapping extends AbstractMapBasedEndpointMapping i * Creates a new {@code SoapEndpointInvocationChain} based on the given endpoint, and the set interceptors, and * actors/roles. * - * @param endpoint the endpoint + * @param endpoint the endpoint * @param interceptors the endpoint interceptors * @return the created invocation chain * @see #setInterceptors(org.springframework.ws.server.EndpointInterceptor[]) * @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); } @@ -95,15 +95,13 @@ public class SoapActionEndpointMapping extends AbstractMapBasedEndpointMapping i if (messageContext.getRequest() instanceof SoapMessage) { SoapMessage request = (SoapMessage) messageContext.getRequest(); String soapAction = request.getSoapAction(); - if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' && - soapAction.charAt(soapAction.length() - 1) == '"') { + 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; } } 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 43f7bf3c..4b56d0bf 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 @@ -17,14 +17,15 @@ package org.springframework.ws.soap.soap11; import java.util.Locale; + import javax.xml.namespace.QName; 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 @@ -36,8 +37,8 @@ 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. * - * @param faultCode the fully qualified fault faultCode - * @param faultString the faultString + * @param faultCode the fully qualified fault faultCode + * @param faultString the faultString * @param faultStringLocale the faultString locale. May be {@code null} * @return the added Soap11Fault * @throws IllegalArgumentException if the fault faultCode is not fully qualified 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 901ec0f3..62584532 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 @@ -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 92636006..b1fa834f 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 @@ -31,8 +31,8 @@ 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 @@ -41,5 +41,4 @@ public interface Soap11Header extends SoapHeader { */ Iterator examineHeaderElementsToProcess(String[] actors) throws SoapHeaderException; - } 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 f7879408..28c44d42 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 @@ -17,14 +17,15 @@ package org.springframework.ws.soap.soap12; import java.util.Locale; + import javax.xml.namespace.QName; 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 @@ -33,16 +34,16 @@ public interface Soap12Body extends SoapBody { /** * Adds a {@code DataEncodingUnknown} fault to the body. - * - *

Adding a fault removes the current content of 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 + * @param reason the fault reason + * @param locale the language of the fault reason * @return the created {@code SoapFault} */ Soap12Fault addDataEncodingUnknownFault(QName[] subcodes, String reason, Locale locale) throws SoapFaultException; - + @Override Soap12Fault getFault(); @@ -57,5 +58,5 @@ public interface Soap12Body extends SoapBody { @Override Soap12Fault addVersionMismatchFault(String faultStringOrReason, Locale locale) throws SoapFaultException; - + } 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 5bdadff0..89f2aa6f 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 @@ -18,13 +18,14 @@ package org.springframework.ws.soap.soap12; import java.util.Iterator; import java.util.Locale; + 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 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 66b5020f..736d3167 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.soap12; import java.util.Iterator; + import javax.xml.namespace.QName; import org.springframework.ws.soap.SoapHeader; @@ -36,8 +37,7 @@ public interface Soap12Header extends SoapHeader { * * @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); @@ -46,23 +46,22 @@ public interface Soap12Header extends SoapHeader { * * @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 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 * @throws SoapHeaderException if the headers cannot be returned * @see SoapHeaderElement */ - Iterator examineHeaderElementsToProcess(String[] roles, boolean isUltimateReceiver) throws SoapHeaderException; - + Iterator examineHeaderElementsToProcess(String[] roles, boolean isUltimateReceiver) + throws SoapHeaderException; } 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 7dca6991..97b26c8c 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 @@ -33,8 +33,7 @@ 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) { @@ -70,7 +69,7 @@ public abstract class SoapUtils { * 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 + * @param action the action * @return the new content type */ public static String setActionInContentType(String contentType, String action) { @@ -82,15 +81,12 @@ public abstract class SoapUtils { matcher.appendReplacement(buffer, "action=" + action); matcher.appendTail(buffer); return buffer.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 5e625eac..0f161fe4 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 @@ -30,9 +30,8 @@ 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 */ 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 677d3fda..10961aad 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 @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Properties; + import javax.servlet.ServletContext; import org.springframework.beans.BeanUtils; @@ -50,10 +51,10 @@ 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. - * - *

Simulates the {@link BeanFactory normal lifecycle} for beans, by calling {@link - * BeanFactoryAware#setBeanFactory(BeanFactory)}, {@link ApplicationContextAware#setApplicationContext(ApplicationContext)}, - * etc. + *

+ * Simulates the {@link BeanFactory normal lifecycle} for beans, by calling + * {@link BeanFactoryAware#setBeanFactory(BeanFactory)}, + * {@link ApplicationContextAware#setApplicationContext(ApplicationContext)}, etc. * * @author Arjen Poutsma * @since 1.0.0 @@ -73,16 +74,15 @@ public class DefaultStrategiesHelper { 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. - * - *

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)); @@ -105,9 +105,8 @@ public class DefaultStrategiesHelper { * {@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 strategyInterface the strategy interface + * @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 */ @@ -130,20 +129,18 @@ public class DefaultStrategiesHelper { } for (String className : classNames) { Class clazz = (Class) ClassUtils.forName(className, classLoader); - Assert.isTrue(strategyInterface.isAssignableFrom(clazz), clazz.getName() + " is not a " + strategyInterface.getName()); + Assert.isTrue(strategyInterface.isAssignableFrom(clazz), + clazz.getName() + " is not a " + strategyInterface.getName()); T strategy = instantiateBean(clazz, applicationContext); result.add(strategy); } - } - else { + } else { result = Collections.emptyList(); } Collections.sort(result, 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); } } @@ -183,8 +180,7 @@ 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); } } @@ -205,12 +201,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 strategyInterface the strategy interface + * @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 bce31c8b..57247f56 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 @@ -17,6 +17,7 @@ package org.springframework.ws.support; import java.io.IOException; + import javax.activation.DataHandler; import javax.xml.transform.Source; @@ -37,17 +38,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}. - * - *

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 + * @param message the message of which the payload is to be unmarshalled * @return the unmarshalled object * @throws IOException in case of I/O errors */ @@ -55,13 +55,11 @@ 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); } } @@ -70,8 +68,8 @@ public abstract class MarshallingUtils { * 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 + * @param graph the root of the object graph to marshal + * @param message the message of which the payload is to be unmarshalled * @throws IOException in case of I/O errors */ public static void marshal(Marshaller marshaller, Object graph, WebServiceMessage message) throws IOException { @@ -79,8 +77,7 @@ 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()); } } 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 26cf3f54..5d2094e2 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 @@ -16,9 +16,8 @@ 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 @@ -29,8 +28,9 @@ 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") */ @@ -64,5 +64,4 @@ public abstract class WebUtils { return urlPath.substring(begin, end); } - } 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 067ea964..88322841 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 @@ -28,8 +28,8 @@ import java.util.Iterator; * @author Greg Turnquist * @since 1.0.0 */ -public abstract class AbstractReceiverConnection extends AbstractWebServiceConnection implements - HeadersAwareReceiverWebServiceConnection { +public abstract class AbstractReceiverConnection extends AbstractWebServiceConnection + implements HeadersAwareReceiverWebServiceConnection { private TransportInputStream requestInputStream; @@ -57,8 +57,7 @@ public abstract class AbstractReceiverConnection extends AbstractWebServiceConne * @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; @@ -101,5 +100,4 @@ public abstract class AbstractReceiverConnection extends AbstractWebServiceConne } - } 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 64254ec3..a1f508ea 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 @@ -28,8 +28,8 @@ import java.util.Iterator; * @author Greg Turnquist * @since 1.0.0 */ -public abstract class AbstractSenderConnection extends AbstractWebServiceConnection implements - HeadersAwareSenderWebServiceConnection { +public abstract class AbstractSenderConnection extends AbstractWebServiceConnection + implements HeadersAwareSenderWebServiceConnection { private TransportOutputStream requestOutputStream; @@ -50,8 +50,7 @@ public abstract class AbstractSenderConnection extends AbstractWebServiceConnect responseInputStream = new ResponseTransportInputStream(); } return responseInputStream; - } - else { + } else { return null; } } @@ -62,8 +61,7 @@ public abstract class AbstractSenderConnection extends AbstractWebServiceConnect * @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; 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 9685999a..f5787a5c 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 @@ -49,20 +49,18 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti } /** - * Called before the given message has been written to the {@code TransportOutputStream}. Called from {@link - * #send(WebServiceMessage)}. - * - *

Default implementation does nothing. + * 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 @@ -70,16 +68,15 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti protected abstract TransportOutputStream createTransportOutputStream() throws IOException; /** - * Called after the given message has been written to the {@code TransportOutputStream}. Called from {@link - * #send(WebServiceMessage)}. - * - *

Default implementation does nothing. + * 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 { @@ -95,15 +92,14 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti } /** - * Called before a message has been read from the {@code TransportInputStream}. Called from {@link - * #receive(WebServiceMessageFactory)}. - * - *

Default implementation does nothing. + * 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)}. @@ -114,16 +110,15 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti protected abstract TransportInputStream createTransportInputStream() throws IOException; /** - * Called when the given message has been read from the {@code TransportInputStream}. Called from {@link - * #receive(WebServiceMessageFactory)}. - * - *

Default implementation does nothing. + * 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 { @@ -131,16 +126,14 @@ 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; } } @@ -162,7 +155,6 @@ public abstract class AbstractWebServiceConnection implements WebServiceConnecti * * @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/FaultAwareWebServiceConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/FaultAwareWebServiceConnection.java index 138033a7..2f41501d 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 @@ -17,6 +17,7 @@ package org.springframework.ws.transport; import java.io.IOException; + import javax.xml.namespace.QName; import org.springframework.ws.soap.SoapFault; @@ -33,8 +34,8 @@ public interface FaultAwareWebServiceConnection extends WebServiceConnection { /** * Indicates whether this connection received a fault. - * - *

Typically implemented by looking at an HTTP status code. + *

+ * 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 @@ -43,8 +44,8 @@ public interface FaultAwareWebServiceConnection extends WebServiceConnection { /** * Sets whether this connection will send a fault. - * - *

Typically implemented by setting an HTTP status code. + *

+ * 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 @@ -55,8 +56,8 @@ public interface FaultAwareWebServiceConnection extends WebServiceConnection { /** * Sets a specific fault code. - * - *

Typically implemented by setting an HTTP status 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. * @throws IOException in case of I/O errors 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 afe4a88a..e92a21fd 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 @@ -27,14 +27,14 @@ 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; @@ -42,7 +42,7 @@ public interface HeadersAwareReceiverWebServiceConnection { * 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 name the name of the header * @param value the value of the header */ void addResponseHeader(String name, String value) throws IOException; 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 59eab209..4a91a7cb 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 @@ -25,22 +25,22 @@ 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 name the name of the header * @param value the value of the header */ void addRequestHeader(String name, String value) throws IOException; 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 bd49f100..9f0c8b19 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 @@ -23,8 +23,8 @@ 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,8 +35,7 @@ public abstract class TransportInputStream extends InputStream { private InputStream inputStream; - protected TransportInputStream() { - } + protected TransportInputStream() {} private InputStream getInputStream() throws IOException { if (inputStream == null) { @@ -60,8 +59,7 @@ public abstract class TransportInputStream extends InputStream { public synchronized void mark(int readlimit) { try { getInputStream().mark(readlimit); - } - catch (IOException e) { + } catch (IOException e) { // ignored } } @@ -70,8 +68,7 @@ public abstract class TransportInputStream extends InputStream { public boolean markSupported() { try { return getInputStream().markSupported(); - } - catch (IOException e) { + } catch (IOException e) { return false; } } @@ -105,14 +102,14 @@ 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 c00d55e7..5c6dd7dd 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 @@ -22,8 +22,8 @@ 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,8 +33,7 @@ public abstract class TransportOutputStream extends OutputStream { private OutputStream outputStream; - protected TransportOutputStream() { - } + protected TransportOutputStream() {} private OutputStream getOutputStream() throws IOException { if (outputStream == null) { @@ -73,7 +72,7 @@ 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. * - * @param name the name of the header + * @param name the name of the header * @param value the value of the header */ public abstract void addHeader(String name, String value) 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 d9e2701f..d58c0d59 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 @@ -26,8 +26,8 @@ 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. - * - *

A {@code WebServiceConnection} can be obtained using a {@link WebServiceMessageSender}. + *

+ * A {@code WebServiceConnection} can be obtained using a {@link WebServiceMessageSender}. * * @author Arjen Poutsma * @see WebServiceMessageSender#createConnection(URI) @@ -74,8 +74,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 */ 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 8114610b..60215da4 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 @@ -24,8 +24,8 @@ import org.springframework.ws.WebServiceMessage; /** * 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 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 c7fe1b6f..2f62990f 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 @@ -4,8 +4,8 @@ import 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 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 5ff80b80..d2f31e68 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 @@ -21,6 +21,7 @@ import java.io.InputStream; import java.io.PushbackInputStream; import java.util.Iterator; import java.util.zip.GZIPInputStream; + import javax.xml.namespace.QName; import org.springframework.util.StringUtils; @@ -72,8 +73,8 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect @Override protected final boolean hasResponse() throws IOException { int responseCode = getResponseCode(); - if (HttpTransportConstants.STATUS_ACCEPTED == responseCode || - HttpTransportConstants.STATUS_NO_CONTENT == responseCode) { + if (HttpTransportConstants.STATUS_ACCEPTED == responseCode + || HttpTransportConstants.STATUS_NO_CONTENT == responseCode) { return false; } if (hasResponse != null) { @@ -109,8 +110,7 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect Iterator iterator = getResponseHeaders(HttpTransportConstants.HEADER_CONTENT_ENCODING); if (iterator.hasNext()) { String encodingHeader = iterator.next(); - return encodingHeader.toLowerCase() - .contains(HttpTransportConstants.CONTENT_ENCODING_GZIP); + return encodingHeader.toLowerCase().contains(HttpTransportConstants.CONTENT_ENCODING_GZIP); } return false; } @@ -167,10 +167,8 @@ 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 ce068908..ddc5b516 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 @@ -20,7 +20,6 @@ import java.net.URI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.ws.transport.WebServiceMessageSender; /** @@ -40,8 +39,8 @@ 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; @@ -50,9 +49,9 @@ public abstract class AbstractHttpWebServiceMessageSender implements WebServiceM /** * 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; @@ -60,7 +59,7 @@ public abstract class AbstractHttpWebServiceMessageSender implements WebServiceM @Override public boolean supports(URI uri) { - return uri.getScheme().equals(HttpTransportConstants.HTTP_URI_SCHEME) || - uri.getScheme().equals(HttpTransportConstants.HTTPS_URI_SCHEME); + 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 3bd4fd89..b2df8301 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 @@ -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 @@ -98,8 +98,7 @@ public class ClientHttpRequestConnection extends AbstractHttpSenderConnection { @Override public Iterator getResponseHeaders(String name) throws IOException { List headers = response.getHeaders().get(name); - return headers != null ? headers.iterator() : - Collections.emptyList().iterator(); + return headers != null ? headers.iterator() : Collections. emptyList().iterator(); } @Override 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 2d450953..87551f7c 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 @@ -27,8 +27,7 @@ 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 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 1d3c7e5e..e9e4e919 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 @@ -31,14 +31,13 @@ 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 @@ -83,8 +82,7 @@ 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()); } } 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 0920ead1..777919e7 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 @@ -32,19 +32,18 @@ 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; import org.springframework.ws.transport.WebServiceConnection; /** - * {@code WebServiceMessageSender} implementation that uses 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}). + * {@code WebServiceMessageSender} implementation that uses + * 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}). * * @author Arjen Poutsma * @see HttpUrlConnectionMessageSender @@ -68,8 +67,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()); @@ -78,7 +77,7 @@ 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 */ @@ -154,46 +153,45 @@ 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: + * *

 	 * https://www.example.com=1
 	 * http://www.example.com:8080=7
 	 * www.springframework.org=10
 	 * *=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 * @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. - * - *

By default, the {@link AuthScope#ANY} is returned. + *

+ * By default, the {@link AuthScope#ANY} is returned. */ public AuthScope getAuthScope() { return authScope != null ? authScope : AuthScope.ANY; @@ -201,8 +199,8 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende /** * 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. + *

+ * By default, the {@link AuthScope#ANY} is used. * * @see #setCredentials(Credentials) */ @@ -237,4 +235,3 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende } } - 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 e214d69b..8ce547be 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 @@ -33,7 +33,6 @@ 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; @@ -116,8 +115,7 @@ public class HttpComponentsConnection extends AbstractHttpSenderConnection { requestBuffer = null; if (httpContext != null) { httpResponse = httpClient.execute(httpPost, httpContext); - } - else { + } else { httpResponse = httpClient.execute(httpPost); } } @@ -173,4 +171,4 @@ public class HttpComponentsConnection extends AbstractHttpSenderConnection { } return Arrays.asList(values).iterator(); } -} \ No newline at end of file +} 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 01436ea4..84bf3941 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 @@ -34,7 +34,6 @@ 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; @@ -43,10 +42,10 @@ import org.springframework.ws.transport.WebServiceConnection; /** * {@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 @@ -70,12 +69,12 @@ 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 {@link org.apache.http.impl.conn.PoolingClientConnectionManager}. + * 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() { - org.apache.http.impl.client.DefaultHttpClient defaultClient = - new org.apache.http.impl.client.DefaultHttpClient(new org.apache.http.impl.conn.PoolingClientConnectionManager()); + org.apache.http.impl.client.DefaultHttpClient defaultClient = new org.apache.http.impl.client.DefaultHttpClient( + new org.apache.http.impl.conn.PoolingClientConnectionManager()); defaultClient.addRequestInterceptor(new RemoveSoapHeadersInterceptor(), 0); this.httpClient = defaultClient; @@ -84,13 +83,12 @@ 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 - * {@linkplain org.apache.http.impl.client.DefaultHttpClient#addRequestInterceptor(org.apache.http.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 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 */ @@ -161,9 +159,9 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } org.apache.http.conn.ClientConnectionManager connectionManager = getHttpClient().getConnectionManager(); if (!(connectionManager instanceof org.apache.http.impl.conn.PoolingClientConnectionManager)) { - throw new IllegalArgumentException("maxTotalConnections is not supported on " + - connectionManager.getClass().getName() + ". Use " + org.apache.http.impl.conn.PoolingClientConnectionManager.class.getName() + - " instead"); + throw new IllegalArgumentException( + "maxTotalConnections is not supported on " + connectionManager.getClass().getName() + ". Use " + + org.apache.http.impl.conn.PoolingClientConnectionManager.class.getName() + " instead"); } ((org.apache.http.impl.conn.PoolingClientConnectionManager) connectionManager).setMaxTotal(maxTotalConnections); } @@ -177,8 +175,8 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe * http://www.example.com:8080=7 * http://www.springframework.org=10 *

- * - *

The host can be specified as a URI (with scheme and port). + *

+ * 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) @@ -186,12 +184,11 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe public void setMaxConnectionsPerHost(Map maxConnectionsPerHost) throws URISyntaxException { org.apache.http.conn.ClientConnectionManager connectionManager = getHttpClient().getConnectionManager(); if (!(connectionManager instanceof org.apache.http.impl.conn.PoolingClientConnectionManager)) { - throw new IllegalArgumentException("maxConnectionsPerHost is not supported on " + - connectionManager.getClass().getName() + ". Use " + org.apache.http.impl.conn.PoolingClientConnectionManager.class.getName() + - " instead"); + throw new IllegalArgumentException( + "maxConnectionsPerHost is not supported on " + connectionManager.getClass().getName() + ". Use " + + org.apache.http.impl.conn.PoolingClientConnectionManager.class.getName() + " instead"); } - org.apache.http.impl.conn.PoolingClientConnectionManager poolingConnectionManager = - (org.apache.http.impl.conn.PoolingClientConnectionManager) connectionManager; + org.apache.http.impl.conn.PoolingClientConnectionManager poolingConnectionManager = (org.apache.http.impl.conn.PoolingClientConnectionManager) connectionManager; for (Map.Entry entry : maxConnectionsPerHost.entrySet()) { URI uri = new URI(entry.getKey()); @@ -212,8 +209,8 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe /** * 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. + *

+ * By default, the {@link AuthScope#ANY} is used. * * @see #setCredentials(Credentials) */ @@ -223,10 +220,9 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe @Override 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); + if (credentials != null && getHttpClient() instanceof org.apache.http.impl.client.DefaultHttpClient) { + ((org.apache.http.impl.client.DefaultHttpClient) getHttpClient()).getCredentialsProvider() + .setCredentials(authScope, credentials); } } @@ -234,16 +230,15 @@ 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} @@ -259,8 +254,8 @@ 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. + * {@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 { @@ -276,4 +271,4 @@ public class HttpComponentsMessageSender extends AbstractHttpWebServiceMessageSe } } } -} \ No newline at end of file +} 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 0093bed4..af8ba650 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 @@ -22,6 +22,7 @@ import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; import java.util.Iterator; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.namespace.QName; @@ -51,8 +52,7 @@ 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; @@ -96,8 +96,8 @@ 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); } /* @@ -159,8 +159,7 @@ 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; @@ -170,15 +169,11 @@ public class HttpServletConnection extends AbstractReceiverConnection public void setFaultCode(QName faultCode) throws IOException { if (faultCode != null) { if (SOAPConstants.SOAP_SENDER_FAULT.equals(faultCode)) { - getHttpServletResponse() - .setStatus(HttpTransportConstants.STATUS_BAD_REQUEST); + getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_BAD_REQUEST); + } else { + getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR); } - 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/HttpUrlConnection.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java index 3c70524c..97262852 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 @@ -132,9 +132,9 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection { List headerValues = headersListMappedByLowerCaseName.get(name.toLowerCase()); if (headerValues == null) { - return Collections.emptyList().iterator(); + return Collections. emptyList().iterator(); } else { - return headerValues.iterator(); + return headerValues.iterator(); } } @@ -152,8 +152,7 @@ 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 6ae53e68..9c9626f4 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 @@ -26,12 +26,11 @@ 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. - * - *

Consider {@link HttpComponentsMessageSender} for more sophisticated needs: this class - * is rather limited in its capabilities. + * {@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. * * @author Arjen Poutsma * @author Kazuki Shimizu @@ -71,8 +70,7 @@ 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); @@ -81,8 +79,8 @@ 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 + *

+ * 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}. * 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 2ddf962e..71e9ce68 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 @@ -19,13 +19,13 @@ package org.springframework.ws.transport.http; import java.io.File; import java.net.URI; 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,8 +35,7 @@ import org.springframework.xml.transform.TraxUtils; */ class LastModifiedHelper { - private LastModifiedHelper() { - } + private LastModifiedHelper() {} /** * Returns the last modified date of the given {@link Source}. @@ -48,8 +47,7 @@ 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()); } } @@ -64,8 +62,7 @@ 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 f62e2f42..161969a8 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 @@ -17,22 +17,22 @@ package org.springframework.ws.transport.http; import java.util.List; + import javax.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.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Node; /** - * 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 @@ -44,13 +44,13 @@ public abstract class LocationTransformerObjectSupport extends TransformerObject /** * 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 */ - protected void transformLocations(XPathExpression xPathExpression, - Document definitionDocument, - HttpServletRequest request) { + protected void transformLocations(XPathExpression xPathExpression, Document definitionDocument, + HttpServletRequest request) { Assert.notNull(xPathExpression, "'xPathExpression' must not be null"); Assert.notNull(definitionDocument, "'definitionDocument' must not be null"); Assert.notNull(request, "'request' must not be null"); @@ -71,19 +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. - * - *

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}. - * - *

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 + * 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}. + *

+ * 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. + *

+ * This method is only called when the {@code transformLocations} property is true. */ protected String transformLocation(String location, HttpServletRequest request) { StringBuilder url = new StringBuilder(request.getScheme()); @@ -92,8 +93,7 @@ public abstract class LocationTransformerObjectSupport extends TransformerObject // 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 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 dbf08791..0b2138a6 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 @@ -17,6 +17,7 @@ package org.springframework.ws.transport.http; import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -34,27 +35,26 @@ import org.springframework.ws.server.EndpointExceptionResolver; import org.springframework.ws.server.EndpointMapping; import org.springframework.ws.server.MessageDispatcher; import org.springframework.ws.support.DefaultStrategiesHelper; -import org.springframework.ws.transport.WebServiceMessageReceiver; import org.springframework.ws.support.WebUtils; +import org.springframework.ws.transport.WebServiceMessageReceiver; import org.springframework.ws.wsdl.WsdlDefinition; 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} + *

+ * 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 + *

+ * 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 @@ -130,43 +130,39 @@ 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. - *

Using this constructor indicates that the following properties / init-params - * will be ignored: + * 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: *

    *
  • {@link #setContextClass(Class)} / 'contextClass'
  • *
  • {@link #setContextConfigLocation(String)} / 'contextConfigLocation'
  • *
  • {@link #setContextAttribute(String)} / 'contextAttribute'
  • *
  • {@link #setNamespace(String)} / 'namespace'
  • *
- *

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: + *

+ * 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: *

    - *
  • 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.
  • - *
  • 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
  • + *
  • 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.
  • + *
  • 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
  • *
  • {@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. - *

See {@link org.springframework.web.WebApplicationInitializer} for usage examples. + * 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) @@ -185,8 +181,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * Sets the bean name used to lookup a {@link WebServiceMessageFactory}. Defaults to {@link - * #DEFAULT_MESSAGE_FACTORY_BEAN_NAME}. + * Sets the bean name used to lookup a {@link WebServiceMessageFactory}. Defaults to + * {@link #DEFAULT_MESSAGE_FACTORY_BEAN_NAME}. */ public void setMessageFactoryBeanName(String messageFactoryBeanName) { this.messageFactoryBeanName = messageFactoryBeanName; @@ -198,8 +194,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * Sets the bean name used to lookup a {@link WebServiceMessageReceiver}. Defaults to {@link - * #DEFAULT_MESSAGE_RECEIVER_BEAN_NAME}. + * Sets the bean name used to lookup a {@link WebServiceMessageReceiver}. Defaults to + * {@link #DEFAULT_MESSAGE_RECEIVER_BEAN_NAME}. */ public void setMessageReceiverBeanName(String messageReceiverBeanName) { this.messageReceiverBeanName = messageReceiverBeanName; @@ -222,8 +218,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * 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; @@ -243,8 +239,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * Sets the bean name used to lookup a {@link WebServiceMessageReceiverHandlerAdapter}. Defaults to {@link - * #DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME}. + * 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) { this.messageReceiverHandlerAdapterBeanName = messageReceiverHandlerAdapterBeanName; @@ -256,8 +252,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; @@ -269,14 +265,13 @@ public class MessageDispatcherServlet extends FrameworkServlet { } /** - * Sets the bean name used to lookup a {@link XsdSchemaHandlerAdapter}. Defaults to {@link - * #DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME}. + * Sets the bean name used to lookup a {@link XsdSchemaHandlerAdapter}. Defaults to + * {@link #DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME}. */ public void setXsdSchemaHandlerAdapterBeanName(String xsdSchemaHandlerAdapterBeanName) { this.xsdSchemaHandlerAdapterBeanName = xsdSchemaHandlerAdapterBeanName; } - @Override protected void doService(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { @@ -321,49 +316,46 @@ public class MessageDispatcherServlet extends FrameworkServlet { /** * 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} */ protected WsdlDefinition getWsdlDefinition(HttpServletRequest request) { - if (HttpTransportConstants.METHOD_GET.equals(request.getMethod()) && - request.getRequestURI().endsWith(WSDL_SUFFIX_NAME)) { + if (HttpTransportConstants.METHOD_GET.equals(request.getMethod()) + && 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. - * - *

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} */ protected XsdSchema getXsdSchema(HttpServletRequest request) { - if (HttpTransportConstants.METHOD_GET.equals(request.getMethod()) && - request.getRequestURI().endsWith(XSD_SUFFIX_NAME)) { + if (HttpTransportConstants.METHOD_GET.equals(request.getMethod()) + && request.getRequestURI().endsWith(XSD_SUFFIX_NAME)) { String fileName = WebUtils.extractFilenameFromUrlPath(request.getRequestURI()); return xsdSchemas.get(fileName); - } - else { + } else { return null; } } /** * Initialize the strategy objects that this servlet uses. - *

May be overridden in subclasses in order to initialize further strategy objects. + *

+ * May be overridden in subclasses in order to initialize further strategy objects. */ protected void initStrategies(ApplicationContext context) { initMessageReceiverHandlerAdapter(context); @@ -374,20 +366,17 @@ public class MessageDispatcherServlet extends FrameworkServlet { initXsdSchemas(context); } - private void initMessageReceiverHandlerAdapter(ApplicationContext context) { try { 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); } } @@ -396,10 +385,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { WebServiceMessageFactory messageFactory; try { messageFactory = context.getBean(getMessageFactoryBeanName(), WebServiceMessageFactory.class); - } - catch (NoSuchBeanDefinitionException ignored) { - messageFactory = defaultStrategiesHelper - .getDefaultStrategy(WebServiceMessageFactory.class, context); + } catch (NoSuchBeanDefinitionException ignored) { + messageFactory = defaultStrategiesHelper.getDefaultStrategy(WebServiceMessageFactory.class, context); if (logger.isDebugEnabled()) { logger.debug("No WebServiceMessageFactory found in servlet '" + getServletName() + "': using default"); } @@ -410,18 +397,16 @@ public class MessageDispatcherServlet extends FrameworkServlet { private void initWsdlDefinitionHandlerAdapter(ApplicationContext context) { try { try { - wsdlDefinitionHandlerAdapter = - context.getBean(getWsdlDefinitionHandlerAdapterBeanName(), WsdlDefinitionHandlerAdapter.class); + 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); } } @@ -429,17 +414,14 @@ 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); } } @@ -447,10 +429,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { private void initMessageReceiver(ApplicationContext context) { try { messageReceiver = context.getBean(getMessageReceiverBeanName(), WebServiceMessageReceiver.class); - } - catch (NoSuchBeanDefinitionException ex) { - messageReceiver = defaultStrategiesHelper - .getDefaultStrategy(WebServiceMessageReceiver.class, context); + } catch (NoSuchBeanDefinitionException ex) { + messageReceiver = defaultStrategiesHelper.getDefaultStrategy(WebServiceMessageReceiver.class, context); if (messageReceiver instanceof BeanNameAware) { ((BeanNameAware) messageReceiver).setBeanName(getServletName()); } @@ -461,8 +441,7 @@ public class MessageDispatcherServlet extends FrameworkServlet { } private void initWsdlDefinitions(ApplicationContext context) { - wsdlDefinitions = BeanFactoryUtils - .beansOfTypeIncludingAncestors(context, WsdlDefinition.class, true, false); + wsdlDefinitions = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, WsdlDefinition.class, true, false); if (logger.isDebugEnabled()) { for (Map.Entry entry : wsdlDefinitions.entrySet()) { String beanName = entry.getKey(); @@ -473,8 +452,7 @@ public class MessageDispatcherServlet extends FrameworkServlet { } private void initXsdSchemas(ApplicationContext context) { - xsdSchemas = BeanFactoryUtils - .beansOfTypeIncludingAncestors(context, XsdSchema.class, true, false); + xsdSchemas = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, XsdSchema.class, true, false); if (logger.isDebugEnabled()) { for (Map.Entry entry : xsdSchemas.entrySet()) { String beanName = entry.getKey(); 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 8ac53a3d..5f155fb7 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 @@ -27,14 +27,14 @@ import org.springframework.ws.transport.WebServiceMessageReceiver; import org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport; /** - * 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}. - * - *

Note that the {@code MessageDispatcher} implements the {@code WebServiceMessageReceiver} interface, - * enabling this adapter to function as a gateway to further message handling logic. + * 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}. + *

+ * 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) @@ -52,19 +52,16 @@ public class WebServiceMessageReceiverHandlerAdapter extends WebServiceMessageRe } @Override - public ModelAndView handle(HttpServletRequest httpServletRequest, - HttpServletResponse httpServletResponse, - Object handler) throws Exception { + public ModelAndView handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, + Object handler) throws Exception { if (HttpTransportConstants.METHOD_POST.equals(httpServletRequest.getMethod())) { 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; @@ -76,36 +73,33 @@ 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 httpServletRequest current HTTP request * @param httpServletResponse current HTTP response - * @param handler current handler + * @param handler current handler */ - protected void handleNonPostMethod(HttpServletRequest httpServletRequest, - HttpServletResponse httpServletResponse, - Object handler) throws Exception { + protected void handleNonPostMethod(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, + Object handler) throws Exception { httpServletResponse.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } /** * 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 httpServletRequest current HTTP request * @param httpServletResponse current HTTP response - * @param handler current handler - * @param ex the invalid XML exception that resulted in this method being called + * @param handler current handler + * @param ex the invalid XML exception that resulted in this method being called */ protected void handleInvalidXmlException(HttpServletRequest httpServletRequest, - HttpServletResponse httpServletResponse, - Object handler, - InvalidXmlException ex) throws Exception { + HttpServletResponse httpServletResponse, Object handler, InvalidXmlException ex) throws Exception { httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST); } 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 be6ee092..a3e9afff 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 @@ -18,6 +18,7 @@ package org.springframework.ws.transport.http; import java.util.HashMap; import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.transform.Source; @@ -26,38 +27,38 @@ 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.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}. - * - *

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

+ * 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. - * - *

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}. - * - *

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 + *

+ * 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}. + *

+ * 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 @@ -66,7 +67,8 @@ import org.springframework.xml.xpath.XPathExpressionFactory; * @see #transformLocation(String,javax.servlet.http.HttpServletRequest) * @since 1.0.0 */ -public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSupport implements HandlerAdapter, InitializingBean { +public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSupport + implements HandlerAdapter, InitializingBean { /** Default XPath expression used for extracting all {@code location} attributes from the WSDL definition. */ public static final String DEFAULT_LOCATION_EXPRESSION = "//@location"; @@ -92,8 +94,8 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo /** * Sets the XPath expression used for extracting the {@code location} attributes from the WSDL 1.1 definition. - * - *

Defaults to {@code DEFAULT_LOCATION_EXPRESSION}. + *

+ * Defaults to {@code DEFAULT_LOCATION_EXPRESSION}. */ public void setLocationExpression(String locationExpression) { this.locationExpression = locationExpression; @@ -101,8 +103,8 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo /** * Sets the XPath expression used for extracting the {@code schemaLocation} attributes from the WSDL 1.1 definition. - * - *

Defaults to {@code DEFAULT_SCHEMA_LOCATION_EXPRESSION}. + *

+ * Defaults to {@code DEFAULT_SCHEMA_LOCATION_EXPRESSION}. */ public void setSchemaLocationExpression(String schemaLocationExpression) { this.schemaLocationExpression = schemaLocationExpression; @@ -155,8 +157,7 @@ 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; @@ -169,18 +170,17 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo @Override public void afterPropertiesSet() throws Exception { - locationXPathExpression = - XPathExpressionFactory.createXPathExpression(locationExpression, expressionNamespaces); - schemaLocationXPathExpression = - XPathExpressionFactory.createXPathExpression(schemaLocationExpression, 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. - * - *

This method is only called when the {@code transformLocations} property is true. + * 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) @@ -194,8 +194,8 @@ 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. - * - *

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) 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 490b3c94..83ae699e 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 @@ -18,6 +18,7 @@ package org.springframework.ws.transport.http; import java.util.HashMap; import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.transform.Source; @@ -26,19 +27,18 @@ 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.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}. - * - *

Reads the source from the mapped {@link XsdSchema} implementation, and writes that as the result to the + *

+ * 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 @@ -66,8 +66,8 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport /** * Sets the XPath expression used for extracting the {@code schemaLocation} attributes from the WSDL 1.1 definition. - * - *

Defaults to {@code DEFAULT_SCHEMA_LOCATION_EXPRESSION}. + *

+ * Defaults to {@code DEFAULT_SCHEMA_LOCATION_EXPRESSION}. */ public void setSchemaLocationExpression(String schemaLocationExpression) { this.schemaLocationExpression = schemaLocationExpression; @@ -105,8 +105,7 @@ 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; @@ -119,15 +118,15 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport @Override public void afterPropertiesSet() throws Exception { - schemaLocationXPathExpression = - XPathExpressionFactory.createXPathExpression(schemaLocationExpression, expressionNamespaces); + schemaLocationXPathExpression = XPathExpressionFactory.createXPathExpression(schemaLocationExpression, + expressionNamespaces); } /** * 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()}. + *

+ * Default implementation simply returns {@link XsdSchema#getSource()}. * * @param schema the schema * @return the source of the given schema @@ -141,8 +140,8 @@ 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 * 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, javax.servlet.http.HttpServletRequest) @@ -151,5 +150,4 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport transformLocations(schemaLocationXPathExpression, definitionDocument, request); } - -} \ No newline at end of file +} 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 dfb2702d..24d6181c 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 @@ -25,14 +25,12 @@ 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. - * - *

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}. + * 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}. * * @author Arjen Poutsma * @since 2.2 @@ -42,9 +40,10 @@ 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() { @@ -53,16 +52,16 @@ public abstract class AbstractAnnotationConfigMessageDispatcherServletInitialize AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext(); rootAppContext.register(configClasses); return rootAppContext; - } - else { + } else { return null; } } /** * {@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() { @@ -75,21 +74,21 @@ 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 8e3929f4..19141c0c 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 @@ -26,26 +26,22 @@ 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. - * - *

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 + * 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)}. + *

+ * 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 * @since 2.2 */ -public abstract class AbstractMessageDispatcherServletInitializer extends - AbstractContextLoaderInitializer { +public abstract class AbstractMessageDispatcherServletInitializer extends AbstractContextLoaderInitializer { /** * The default servlet name. Can be customized by overriding {@link #getServletName}. @@ -55,7 +51,7 @@ public abstract class AbstractMessageDispatcherServletInitializer extends /** * The default servlet mappings. Can be customized by overriding {@link #getServletMappings()}. */ - public static final String[] DEFAULT_SERVLET_MAPPINGS = new String[] { "/services", "*.wsdl"}; + public static final String[] DEFAULT_SERVLET_MAPPINGS = new String[] { "/services", "*.wsdl" }; @Override public void onStartup(ServletContext servletContext) throws ServletException { @@ -66,12 +62,13 @@ public abstract class AbstractMessageDispatcherServletInitializer extends /** * 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()}. - *

Further customization can be achieved by overriding {@link - * #customizeRegistration(ServletRegistration.Dynamic)}. + *

+ * 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)}. + * * @param servletContext the context to register the servlet against */ protected void registerMessageDispatcherServlet(ServletContext servletContext) { @@ -79,21 +76,17 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Assert.hasLength(servletName, "getServletName() may not return empty or null"); WebApplicationContext servletAppContext = this.createServletApplicationContext(); - Assert.notNull(servletAppContext, - "createServletApplicationContext() did not return an application " + - "context for servlet [" + servletName + "]"); + Assert.notNull(servletAppContext, "createServletApplicationContext() did not return an application " + + "context for servlet [" + servletName + "]"); - MessageDispatcherServlet dispatcherServlet = - new MessageDispatcherServlet(servletAppContext); + MessageDispatcherServlet dispatcherServlet = new MessageDispatcherServlet(servletAppContext); dispatcherServlet.setTransformWsdlLocations(isTransformWsdlLocations()); dispatcherServlet.setTransformSchemaLocations(isTransformSchemaLocations()); - ServletRegistration.Dynamic registration = - servletContext.addServlet(servletName, dispatcherServlet); + ServletRegistration.Dynamic registration = servletContext.addServlet(servletName, dispatcherServlet); - Assert.notNull(registration, - "Failed to register servlet with name '" + servletName + "'." + - "Check if there is another servlet registered under the same name."); + Assert.notNull(registration, "Failed to register servlet with name '" + servletName + "'." + + "Check if there is another servlet registered under the same name."); registration.setLoadOnStartup(1); registration.addMapping(getServletMappings()); @@ -102,8 +95,9 @@ public abstract class AbstractMessageDispatcherServletInitializer extends } /** - * 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() { @@ -112,17 +106,19 @@ public abstract class AbstractMessageDispatcherServletInitializer extends /** * 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. + *

+ * 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. + * * @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() { @@ -130,30 +126,28 @@ public abstract class AbstractMessageDispatcherServletInitializer extends } /** - * 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; } - /** * Optionally perform further registration customization once * {@link #registerMessageDispatcherServlet(ServletContext)} has completed. + * * @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/TransportUtils.java b/spring-ws-core/src/main/java/org/springframework/ws/transport/support/TransportUtils.java index 5083c306..f11ad056 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 @@ -20,7 +20,6 @@ import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.ws.transport.WebServiceConnection; /** @@ -43,11 +42,9 @@ public abstract class TransportUtils { 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 d3227503..e6585927 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 @@ -20,7 +20,6 @@ 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; @@ -68,14 +67,14 @@ 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). - * - *

Stores the given connection in the {@link TransportContext}. + * 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 { @@ -89,19 +88,16 @@ 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); } @@ -109,18 +105,16 @@ 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} * @throws Exception in case of errors */ - protected void handleNoEndpointFoundException(NoEndpointFoundException ex, - WebServiceConnection connection, + protected void handleNoEndpointFoundException(NoEndpointFoundException ex, WebServiceConnection connection, WebServiceMessageReceiver receiver) throws Exception { if (connection instanceof EndpointAwareWebServiceConnection) { ((EndpointAwareWebServiceConnection) connection).endpointNotFound(); @@ -131,8 +125,7 @@ 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/wsdl11/DefaultWsdl11Definition.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java index a73cca61..918a20a1 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 @@ -17,6 +17,7 @@ package org.springframework.ws.wsdl.wsdl11; import java.util.Properties; + import javax.xml.transform.Source; import org.springframework.beans.factory.InitializingBean; @@ -31,11 +32,12 @@ 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 + * 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: + *

+ * Example configuration: + * *

  * <bean id="airline" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
  *	 <property name="schema">
@@ -76,8 +78,8 @@ public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBe
 
 	/**
 	 * Sets the target namespace used for this definition.
-	 *
-	 * 

Defaults to the target namespace of the defined schema. + *

+ * Defaults to the target namespace of the defined schema. */ public void setTargetNamespace(String targetNamespace) { delegate.setTargetNamespace(targetNamespace); @@ -124,8 +126,8 @@ public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBe /** * Indicates whether a SOAP 1.1 binding should be created. - * - *

Defaults to {@code true}. + *

+ * Defaults to {@code true}. */ public void setCreateSoap11Binding(boolean createSoap11Binding) { soapProvider.setCreateSoap11Binding(createSoap11Binding); @@ -133,8 +135,8 @@ public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBe /** * Indicates whether a SOAP 1.2 binding should be created. - * - *

Defaults to {@code false}. + *

+ * Defaults to {@code false}. */ public void setCreateSoap12Binding(boolean createSoap12Binding) { soapProvider.setCreateSoap12Binding(createSoap12Binding); @@ -162,8 +164,8 @@ public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBe /** * Sets the service name. - * - *

Defaults to the port type name, with the suffix {@code Service} appended to it. + *

+ * Defaults to the port type name, with the suffix {@code Service} appended to it. */ public void setServiceName(String serviceName) { soapProvider.setServiceName(serviceName); @@ -172,8 +174,8 @@ public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBe @Override public void afterPropertiesSet() throws Exception { - if (!StringUtils.hasText(delegate.getTargetNamespace()) && typesProvider.getSchemaCollection() != null && - typesProvider.getSchemaCollection().getXsdSchemas().length > 0) { + if (!StringUtils.hasText(delegate.getTargetNamespace()) && typesProvider.getSchemaCollection() != null + && typesProvider.getSchemaCollection().getXsdSchemas().length > 0) { XsdSchema schema = typesProvider.getSchemaCollection().getXsdSchemas()[0]; setTargetNamespace(schema.getTargetNamespace()); } 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 510bf1be..9bc6a46e 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 @@ -30,15 +30,21 @@ 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}. - * - *

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. {@link TypesProvider}
  3. {@link MessagesProvider}
  4. {@link - * PortTypesProvider}
  5. {@link BindingsProvider}
  6. {@link ServicesProvider}
- * - *

This definition requires the target namespace to be set via {@link #setTargetNamespace(String)} + * 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: + *

    + *
  1. {@link ImportsProvider}
  2. + *
  3. {@link TypesProvider}
  4. + *
  5. {@link MessagesProvider}
  6. + *
  7. {@link PortTypesProvider}
  8. + *
  9. {@link BindingsProvider}
  10. + *
  11. {@link ServicesProvider}
  12. + *
+ *

+ * This definition requires the target namespace to be set via {@link #setTargetNamespace(String)} * * @author Arjen Poutsma * @see #setImportsProvider(ImportsProvider) @@ -70,8 +76,8 @@ 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 + *

+ * Default is {@code null}, indicating that no {@code <import>} will be created * * @return the import provider; or {@code null} */ @@ -81,8 +87,8 @@ 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 + *

+ * Default is {@code null}, indicating that no {@code <import>} will be created * * @param importsProvider the import provider */ @@ -92,8 +98,8 @@ 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 + *

+ * Defaults to {@code null}, indicating that no {@code <types>} will be created * * @return the types provider; or {@code null} */ @@ -103,8 +109,8 @@ 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 + *

+ * Defaults to {@code null}, indicating that no {@code <types>} will be created * * @param typesProvider the types provider; or {@code null} */ @@ -114,8 +120,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} */ @@ -125,8 +131,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} */ @@ -136,8 +142,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} */ @@ -147,8 +153,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} */ @@ -158,8 +164,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} */ @@ -169,8 +175,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} */ @@ -180,8 +186,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} */ @@ -191,8 +197,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} */ 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 b742efe9..8be3f0a2 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 @@ -17,23 +17,23 @@ package org.springframework.ws.wsdl.wsdl11; 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 javax.xml.transform.Source; 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. - * - *

Allows a WSDL to be set by the {@link #setWsdl wsdl} property, or directly in the {@link - * #SimpleWsdl11Definition(Resource) constructor}. + *

+ * Allows a WSDL to be set by the {@link #setWsdl wsdl} property, or directly in the + * {@link #SimpleWsdl11Definition(Resource) constructor}. * * @author Arjen Poutsma * @since 1.0.0 @@ -44,14 +44,13 @@ public class SimpleWsdl11Definition implements Wsdl11Definition, InitializingBea /** * Create a new instance of the {@link SimpleWsdl11Definition} class. - * - *

A subsequent call to the {@link #setWsdl(Resource)} method is required. + *

+ * 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} @@ -73,11 +72,9 @@ 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); } } @@ -95,5 +92,4 @@ public class SimpleWsdl11Definition implements Wsdl11Definition, InitializingBea return "SimpleWsdl11Definition " + wsdlResource; } - -} \ No newline at end of file +} diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/Wsdl11Definition.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/Wsdl11Definition.java index 6f52e8ce..b69ba94d 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/Wsdl11Definition.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/Wsdl11Definition.java @@ -20,8 +20,8 @@ import org.springframework.ws.wsdl.WsdlDefinition; /** * Models a WSDL 1.1-specific {@link WsdlDefinition}. - * - *

Just a marker interface at the moment. + *

+ * Just a marker interface at the moment. * * @author Arjen Poutsma * @see DefaultWsdl11Definition 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 fae63703..21d3e99f 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 @@ -23,15 +23,14 @@ 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 @@ -51,8 +50,7 @@ public class Wsdl4jDefinition implements Wsdl11Definition { * * @see #setDefinition(javax.wsdl.Definition) */ - public Wsdl4jDefinition() { - } + public Wsdl4jDefinition() {} /** * Constructs a new {@code Wsdl4jDefinition} based on the given {@code Definition}. @@ -86,8 +84,7 @@ 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); } } 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 0c8cd779..3d58d870 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 @@ -18,6 +18,7 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Iterator; import java.util.List; + import javax.wsdl.Definition; import javax.wsdl.Fault; import javax.wsdl.Input; @@ -31,7 +32,6 @@ 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; @@ -78,8 +78,8 @@ 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. + *

+ * 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 @@ -99,7 +99,7 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { Message message = (Message) iterator.next(); String operationName = getOperationName(message); if (StringUtils.hasText(operationName)) { - operations.add(operationName,message); + operations.add(operationName, message); } } if (operations.isEmpty() && logger.isWarnEnabled()) { @@ -115,14 +115,12 @@ 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); @@ -132,16 +130,15 @@ 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} @@ -159,11 +156,11 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { /** * 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. + *

+ * Default implementation sets the input name to the message name. * * @param definition the WSDL4J {@code Definition} - * @param input the WSDL4J {@code Input} + * @param input the WSDL4J {@code Input} */ protected void populateInput(Definition definition, Input input) { input.setName(input.getMessage().getQName().getLocalPart()); @@ -180,11 +177,11 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { /** * 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. + *

+ * Default implementation sets the output name to the message name. * * @param definition the WSDL4J {@code Definition} - * @param output the WSDL4J {@code Output} + * @param output the WSDL4J {@code Output} */ protected void populateOutput(Definition definition, Output output) { output.setName(output.getMessage().getQName().getLocalPart()); @@ -201,11 +198,11 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { /** * 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. + *

+ * Default implementation sets the fault name to the message name. * * @param definition the WSDL4J {@code Definition} - * @param fault the WSDL4J {@code Fault} + * @param fault the WSDL4J {@code Fault} */ protected void populateFault(Definition definition, Fault fault) { fault.setName(fault.getMessage().getQName().getLocalPart()); @@ -213,9 +210,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 @@ -223,20 +220,13 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider { protected OperationType getOperationType(Operation operation) { 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/BindingsProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/BindingsProvider.java index 754ff43d..27ed0b3e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/BindingsProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/BindingsProvider.java @@ -21,8 +21,8 @@ import javax.wsdl.WSDLException; /** * Strategy for adding {@link javax.wsdl.Binding}s to a {@link javax.wsdl.Definition}. - * - *

Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. * * @author Arjen Poutsma * @since 1.5.0 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 399dd718..5c2c6fa9 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 @@ -17,6 +17,7 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Iterator; + import javax.wsdl.Binding; import javax.wsdl.BindingFault; import javax.wsdl.BindingInput; @@ -36,15 +37,14 @@ 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. - * - *

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 @@ -81,11 +81,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. - * - *

Calls the various {@code populate} methods with the created WSDL4J objects. + * 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. + *

+ * Calls the various {@code populate} methods with the created WSDL4J objects. * * @param definition the WSDL4J {@code Definition} * @throws WSDLException in case of errors @@ -116,18 +116,17 @@ 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. - * - *

Default implementation sets the binding name to the port type name with the {@link #getBindingSuffix() suffix} + *

+ * 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} + * @param binding the WSDL4J {@code Binding} */ protected void populateBinding(Definition definition, Binding binding) throws WSDLException { QName portTypeName = binding.getPortType().getQName(); 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 + "]"); } @@ -145,14 +144,11 @@ 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); } @@ -171,10 +167,10 @@ 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. + *

+ * 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 definition the WSDL4J {@code Definition} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws WSDLException in case of errors */ @@ -198,14 +194,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. * - *

Default implementation set the name of the binding input to the name of the input. - * - * @param definition the WSDL4J {@code Definition} + * @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 { @@ -213,14 +209,14 @@ 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 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 { @@ -228,13 +224,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. - * - *

Default implementation set the name of the binding fault to the name of the fault. + * 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 { @@ -243,8 +239,8 @@ 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 {@link - * #populatePort(javax.wsdl.Definition,javax.wsdl.Port)}. + * 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 @@ -255,8 +251,7 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr Service service; if (definition.getServices().isEmpty()) { service = definition.createService(); - } - else { + } else { service = (Service) definition.getServices().values().iterator().next(); } populateService(definition, service); @@ -267,10 +262,10 @@ 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. - * - *

Default implementation sets the name to the {@link #setServiceName(String) serviceName} property. + * 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. * * @param service the WSDL4J {@code Service} * @throws WSDLException in case of errors @@ -315,11 +310,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. - * - *

Default implementation sets the port name to the binding name. + *

+ * Default implementation sets the port name to the binding name. * * @param definition the WSDL4J {@code Definition} - * @param port the WSDL4J {@code Port} + * @param port the WSDL4J {@code Port} * @throws WSDLException in case of errors */ protected void populatePort(Definition definition, Port port) throws WSDLException { 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 da68fa29..498de344 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 @@ -17,6 +17,7 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Iterator; + import javax.wsdl.Definition; import javax.wsdl.Message; import javax.wsdl.Part; @@ -28,16 +29,15 @@ 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}. - * - *

Simply adds all elements contained in the schema(s) as messages. + *

+ * Simply adds all elements contained in the schema(s) as messages. * * @author Arjen Poutsma * @since 1.5.0 @@ -101,25 +101,25 @@ public class DefaultMessagesProvider implements MessagesProvider { /** * 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 + *

+ * 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 */ protected boolean isMessageElement(Element element) { - return "element".equals(element.getLocalName()) && - "http://www.w3.org/2001/XMLSchema".equals(element.getNamespaceURI()); + return "element".equals(element.getLocalName()) + && "http://www.w3.org/2001/XMLSchema".equals(element.getNamespaceURI()); } /** * Called after the {@link Message} has been created. + *

+ * Default implementation sets the name of the message to the element name. * - *

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 definition the WSDL4J {@code Definition} + * @param message the WSDL4J {@code Message} * @param elementName the element name * @throws WSDLException in case of errors */ @@ -133,11 +133,11 @@ public class DefaultMessagesProvider implements MessagesProvider { /** * Called after the {@link Part} has been created. + *

+ * Default implementation sets the element name of the part. * - *

Default implementation sets the element name of the part. - * - * @param definition the WSDL4J {@code Definition} - * @param part the WSDL4J {@code Part} + * @param definition the WSDL4J {@code Definition} + * @param part the WSDL4J {@code Part} * @param elementName the elementName @throws WSDLException in case of errors * @see Part#setElementName(javax.xml.namespace.QName) */ diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ImportsProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ImportsProvider.java index dd0e4437..6452c55f 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ImportsProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ImportsProvider.java @@ -21,8 +21,8 @@ import javax.wsdl.WSDLException; /** * Strategy for adding {@link javax.wsdl.Import}s to a {@link javax.wsdl.Definition}. - * - *

Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. * * @author Arjen Poutsma * @since 1.5.0 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 0889eedd..9a20bf48 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 @@ -26,15 +26,14 @@ 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 @@ -60,7 +59,7 @@ public class InliningXsdSchemaTypesProvider extends TransformerObjectSupport imp this.schemaCollection = new XsdSchemaCollection() { public XsdSchema[] getXsdSchemas() { - return new XsdSchema[]{schema}; + return new XsdSchema[] { schema }; } public XmlValidator createValidator() { @@ -93,14 +92,13 @@ 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); } @@ -113,8 +111,7 @@ 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/MessagesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/MessagesProvider.java index af05e52a..45c281a1 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/MessagesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/MessagesProvider.java @@ -21,8 +21,8 @@ import javax.wsdl.WSDLException; /** * Strategy for adding {@link javax.wsdl.Message}s to a {@link javax.wsdl.Definition}. - * - *

Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. * * @author Arjen Poutsma * @since 1.5.0 diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/PortTypesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/PortTypesProvider.java index 794682e3..2a2a6e91 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/PortTypesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/PortTypesProvider.java @@ -21,8 +21,8 @@ import javax.wsdl.WSDLException; /** * Strategy for adding {@link javax.wsdl.PortType}s to a {@link javax.wsdl.Definition}. - * - *

Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. * * @author Arjen Poutsma * @since 1.5.0 diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ServicesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ServicesProvider.java index da3c139e..eb8c6c69 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ServicesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ServicesProvider.java @@ -21,8 +21,8 @@ import javax.wsdl.WSDLException; /** * Strategy for adding {@link javax.wsdl.Service}s to a {@link javax.wsdl.Definition}. - * - *

Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. * * @author Arjen Poutsma * @since 1.5.0 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 54e69073..f8677ca8 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 @@ -18,6 +18,7 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Iterator; import java.util.Properties; + import javax.wsdl.Binding; import javax.wsdl.BindingFault; import javax.wsdl.BindingInput; @@ -42,8 +43,8 @@ import org.springframework.util.Assert; /** * 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 + *

+ * 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. * @@ -69,8 +70,8 @@ public class Soap11Provider extends DefaultConcretePartProvider { /** * Constructs a new version of the {@link Soap11Provider}. - * - *

Sets the {@link #setBindingSuffix(String) binding suffix} to {@code Soap11}. + *

+ * Sets the {@link #setBindingSuffix(String) binding suffix} to {@code Soap11}. */ public Soap11Provider() { setBindingSuffix("Soap11"); @@ -87,8 +88,8 @@ 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 */ @@ -129,13 +130,13 @@ 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. - * - *

Default implementation calls {@link DefaultConcretePartProvider#populateBinding(Definition, Binding)}, adds the + *

+ * 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} + * @param binding the WSDL4J {@code Binding} */ @Override protected void populateBinding(Definition definition, Binding binding) throws WSDLException { @@ -148,9 +149,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 @@ -165,15 +166,16 @@ 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)}. * - *

Default implementation calls {@link DefaultConcretePartProvider#populateBindingFault(Definition, BindingFault, - * Fault)}, creates a {@link SOAPFault}, and calls {@link #populateSoapFault(BindingFault, SOAPFault)}. - * - * @param definition the WSDL4J {@code Definition} + * @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) @@ -186,12 +188,12 @@ 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} + * @param soapFault the WSDL4J {@code SOAPFault} * @throws WSDLException in case of errors * @see SOAPFault#setUse(String) */ @@ -201,16 +203,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)}. * - *

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 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) @@ -223,8 +225,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 @@ -237,12 +239,13 @@ 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. + *

+ * 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. * - *

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. - * - * @param definition the WSDL4J {@code Definition} + * @param definition the WSDL4J {@code Definition} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws WSDLException in case of errors */ @@ -250,19 +253,18 @@ public class Soap11Provider extends DefaultConcretePartProvider { protected void populateBindingOperation(Definition definition, BindingOperation bindingOperation) 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); } /** * 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 soapOperation the WSDL4J {@code SOAPOperation} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws WSDLException in case of errors * @see SOAPOperation#setSoapActionURI(String) @@ -276,15 +278,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)}. * - *

Default implementation calls {@link DefaultConcretePartProvider#populateBindingOutput(Definition, BindingOutput, - * Output)}, creates a {@link SOAPBody}, and calls {@link #populateSoapBody(SOAPBody)}. - * - * @param definition the WSDL4J {@code Definition} + * @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,9 +301,10 @@ 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. - * - *

Default implementation calls {@link DefaultConcretePartProvider#populatePort(javax.wsdl.Definition,javax.wsdl.Port)}, - * creates a {@link SOAPAddress}, and calls {@link #populateSoapAddress(SOAPAddress)}. + *

+ * Default implementation calls + * {@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 @@ -309,7 +313,7 @@ public class Soap11Provider extends DefaultConcretePartProvider { protected void populatePort(Definition definition, Port port) throws WSDLException { for (Iterator iterator = port.getBinding().getExtensibilityElements().iterator(); iterator.hasNext();) { if (iterator.next() instanceof SOAPBinding) { - // this is a SOAP 1.1 binding, create a SOAP Address for it + // this is a SOAP 1.1 binding, create a SOAP Address for it super.populatePort(definition, port); SOAPAddress soapAddress = (SOAPAddress) createSoapExtension(definition, Port.class, "address"); populateSoapAddress(soapAddress); @@ -337,15 +341,14 @@ public class Soap11Provider extends DefaultConcretePartProvider { * * @param definition the WSDL4J {@code Definition} * @param parentType a class object indicating where in the WSDL definition this extension will exist - * @param localName the local name of the extensibility element + * @param localName the local name of the extensibility element * @return the extensibility element * @throws WSDLException in case of errors * @see ExtensionRegistry#createExtension(Class, QName) */ 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 250d72ea..efbe3387 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 @@ -18,6 +18,7 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Iterator; import java.util.Properties; + import javax.wsdl.Binding; import javax.wsdl.BindingFault; import javax.wsdl.BindingInput; @@ -41,8 +42,8 @@ import org.springframework.util.Assert; /** * 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 + *

+ * 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. * @@ -68,17 +69,16 @@ public class Soap12Provider extends DefaultConcretePartProvider { /** * Constructs a new version of the {@link Soap12Provider}. - * - *

Sets the {@link #setBindingSuffix(String) binding suffix} to {@code Soap12}. + *

+ * Sets the {@link #setBindingSuffix(String) binding suffix} to {@code Soap12}. */ public Soap12Provider() { setBindingSuffix("Soap12"); } /** - * 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 */ @@ -127,16 +127,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. - * - *

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. + * 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. * * @param definition the WSDL4J {@code Definition} - * @param binding the WSDL4J {@code Binding} + * @param binding the WSDL4J {@code Binding} */ @Override protected void populateBinding(Definition definition, Binding binding) throws WSDLException { @@ -149,9 +150,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 @@ -168,14 +169,15 @@ 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. - * - *

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 + *

+ * 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 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) @@ -188,12 +190,12 @@ 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} + * @param soapFault the WSDL4J {@code SOAPFault} * @throws javax.wsdl.WSDLException in case of errors * @see javax.wsdl.extensions.soap.SOAPFault#setUse(String) */ @@ -205,14 +207,15 @@ 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. - * - *

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 + *

+ * 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 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 +228,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 @@ -239,12 +242,13 @@ 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. + *

+ * 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. * - *

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. - * - * @param definition the WSDL4J {@code Definition} + * @param definition the WSDL4J {@code Definition} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws javax.wsdl.WSDLException in case of errors */ @@ -252,19 +256,19 @@ public class Soap12Provider extends DefaultConcretePartProvider { protected void populateBindingOperation(Definition definition, BindingOperation bindingOperation) throws WSDLException { super.populateBindingOperation(definition, bindingOperation); - SOAP12Operation soapOperation = - (SOAP12Operation) createSoapExtension(definition, BindingOperation.class, "operation"); + SOAP12Operation soapOperation = (SOAP12Operation) createSoapExtension(definition, BindingOperation.class, + "operation"); populateSoapOperation(soapOperation, bindingOperation); bindingOperation.addExtensibilityElement(soapOperation); } /** * 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 soapOperation the WSDL4J {@code SOAPOperation} * @param bindingOperation the WSDL4J {@code BindingOperation} * @throws javax.wsdl.WSDLException in case of errors * @see javax.wsdl.extensions.soap.SOAPOperation#setSoapActionURI(String) @@ -280,14 +284,15 @@ 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. - * - *

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 + *

+ * 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 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) @@ -301,9 +306,10 @@ 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. - * - *

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)}. + *

+ * 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)}. * * @param port the WSDL4J {@code Port} * @throws WSDLException in case of errors @@ -312,7 +318,7 @@ public class Soap12Provider extends DefaultConcretePartProvider { protected void populatePort(Definition definition, Port port) throws WSDLException { for (Iterator iterator = port.getBinding().getExtensibilityElements().iterator(); iterator.hasNext();) { if (iterator.next() instanceof SOAP12Binding) { - // this is a SOAP 1.2 binding, create a SOAP Address for it + // this is a SOAP 1.2 binding, create a SOAP Address for it super.populatePort(definition, port); SOAP12Address soapAddress = (SOAP12Address) createSoapExtension(definition, Port.class, "address"); populateSoapAddress(soapAddress); @@ -323,8 +329,8 @@ 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 @@ -340,15 +346,14 @@ public class Soap12Provider extends DefaultConcretePartProvider { * * @param definition the WSDL4J {@code Definition} * @param parentType a class object indicating where in the WSDL definition this extension will exist - * @param localName the local name of the extensibility element + * @param localName the local name of the extensibility element * @return the extensibility element * @throws WSDLException in case of errors * @see javax.wsdl.extensions.ExtensionRegistry#createExtension(Class, QName) */ 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)); } -} \ No newline at end of file +} 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 ee7eaf34..f0431784 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 @@ -17,18 +17,19 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Properties; + 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}. - * - *

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} + *

+ * 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 * {@code true} and {@code false} respectively. * @@ -47,8 +48,8 @@ public class SoapProvider implements BindingsProvider, ServicesProvider { /** * Indicates whether a SOAP 1.1 binding should be created. - * - *

Defaults to {@code true}. + *

+ * Defaults to {@code true}. */ public void setCreateSoap11Binding(boolean createSoap11Binding) { this.createSoap11Binding = createSoap11Binding; @@ -56,8 +57,8 @@ public class SoapProvider implements BindingsProvider, ServicesProvider { /** * Indicates whether a SOAP 1.2 binding should be created. - * - *

Defaults to {@code false}. + *

+ * Defaults to {@code false}. */ public void setCreateSoap12Binding(boolean createSoap12Binding) { this.createSoap12Binding = createSoap12Binding; 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 0e8c5d33..15867530 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 @@ -16,9 +16,8 @@ package org.springframework.ws.wsdl.wsdl11.provider; -import org.w3c.dom.Element; - import org.springframework.util.Assert; +import org.w3c.dom.Element; /** * Implementation of the {@link MessagesProvider} interface that is based on suffixes. @@ -105,10 +104,9 @@ public class SuffixBasedMessagesProvider extends DefaultMessagesProvider { if (super.isMessageElement(element)) { String elementName = getElementName(element); Assert.hasText(elementName, "Element has no name"); - return elementName.endsWith(getRequestSuffix()) || elementName.endsWith(getResponseSuffix()) || - elementName.endsWith(getFaultSuffix()); - } - else { + return elementName.endsWith(getRequestSuffix()) || elementName.endsWith(getResponseSuffix()) + || elementName.endsWith(getFaultSuffix()); + } 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 947ff1f7..44a7b37c 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 @@ -21,7 +21,7 @@ import javax.wsdl.Message; import org.springframework.util.Assert; /** - * Implementation of the {@link PortTypesProvider} interface that is based on suffixes. + * Implementation of the {@link PortTypesProvider} interface that is based on suffixes. * * @author Arjen Poutsma * @since 1.5.0 @@ -106,11 +106,9 @@ 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()); } } @@ -119,9 +117,8 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * 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 @@ -134,8 +131,8 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * 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) + *

+ * This implementation checks whether the message name ends with the {@link #setResponseSuffix(String) * responseSuffix}. * * @param message the message @@ -149,8 +146,8 @@ public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { /** * 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 diff --git a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/TypesProvider.java b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/TypesProvider.java index d865d55a..d60f9cdb 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/TypesProvider.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/TypesProvider.java @@ -21,8 +21,8 @@ import javax.wsdl.WSDLException; /** * Strategy for adding {@link javax.wsdl.Types} to a {@link javax.wsdl.Definition}. - * - *

Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. * * @author Arjen Poutsma * @since 1.5.0 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 304a7547..47c19801 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 @@ -36,4 +36,4 @@ public abstract class AbstractWebServiceMessageFactoryTestCase { } protected abstract WebServiceMessageFactory createMessageFactory() throws Exception; -} \ No newline at end of file +} 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 e46e7592..b2764b20 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 @@ -16,12 +16,15 @@ package org.springframework.ws; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringWriter; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.stream.XMLEventReader; @@ -43,24 +46,21 @@ import javax.xml.transform.stream.StreamSource; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Before; import org.junit.Test; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.util.FileCopyUtils; +import org.springframework.util.xml.StaxUtils; +import org.springframework.xml.DocumentBuilderFactoryUtils; +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 org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.util.FileCopyUtils; -import org.springframework.util.xml.StaxUtils; -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.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; - public abstract class AbstractWebServiceMessageTestCase { protected Transformer transformer; 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 00179634..0599f38a 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 @@ -23,6 +23,7 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; + import javax.xml.namespace.QName; import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -55,8 +56,7 @@ public class MockWebServiceMessage implements FaultAwareWebServiceMessage { private String faultReason; - public MockWebServiceMessage() { - } + public MockWebServiceMessage() {} public MockWebServiceMessage(Source source) throws TransformerException { TransformerFactory transformerFactory = TransformerFactoryUtils.newInstance(); @@ -90,8 +90,7 @@ public class MockWebServiceMessage implements FaultAwareWebServiceMessage { is = inputStreamSource.getInputStream(); Reader reader = new InputStreamReader(is, "UTF-8"); content.replace(0, content.length(), FileCopyUtils.copyToString(reader)); - } - finally { + } finally { if (is != null) { is.close(); } @@ -187,19 +186,16 @@ public class MockWebServiceMessage implements FaultAwareWebServiceMessage { } @Override - public void close() throws IOException { - } + public void close() throws IOException {} @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 a9711ef8..df220ca2 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 @@ -18,6 +18,7 @@ package org.springframework.ws; import java.io.IOException; import java.io.InputStream; + import javax.xml.transform.TransformerException; import javax.xml.transform.stream.StreamSource; @@ -32,8 +33,7 @@ public class MockWebServiceMessageFactory implements WebServiceMessageFactory { public MockWebServiceMessage createWebServiceMessage(InputStream inputStream) throws IOException { 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 f6860384..c9672d8b 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 @@ -16,10 +16,14 @@ package org.springframework.ws.client.core; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; + import java.io.IOException; import java.util.Enumeration; import java.util.Iterator; import java.util.StringTokenizer; + import javax.activation.DataHandler; import javax.mail.util.ByteArrayDataSource; import javax.servlet.ServletConfig; @@ -48,8 +52,6 @@ import org.junit.Test; import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.ServletHolder; -import org.xml.sax.SAXException; - import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.XmlMappingException; @@ -64,9 +66,7 @@ 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 static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; +import org.xml.sax.SAXException; public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { @@ -74,7 +74,6 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { private static String baseUrl; - private WebServiceTemplate template; private String messagePayload = ""; @@ -110,22 +109,20 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { template.setMessageSender(new HttpComponentsMessageSender()); } - public abstract SoapMessageFactory createMessageFactory() throws Exception; @Test public void sendSourceAndReceiveToResult() throws SAXException, IOException { 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); Assert.assertTrue("Invalid result", b); assertXMLEqual(messagePayload, result.toString()); } @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()); Assert.assertFalse("Invalid result", b); } @@ -140,8 +137,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { Assert.assertEquals("Invalid object", graph, requestObject); try { transformer.transform(new StringSource(messagePayload), result); - } - catch (TransformerException e) { + } catch (TransformerException e) { Assert.fail(e.getMessage()); } } @@ -183,8 +179,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { Assert.assertEquals("Invalid object", graph, requestObject); try { transformer.transform(new StringSource(messagePayload), result); - } - catch (TransformerException e) { + } catch (TransformerException e) { Assert.fail(e.getMessage()); } } @@ -203,12 +198,11 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { @Test public void notFound() { try { - template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", - new StringSource(messagePayload), new StringResult()); + template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", new StringSource(messagePayload), + new StringResult()); Assert.fail("WebServiceTransportException expected"); - } - catch (WebServiceTransportException ex) { - //expected + } catch (WebServiceTransportException ex) { + // expected } } @@ -216,12 +210,10 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { public void fault() { Result result = new StringResult(); try { - template.sendSourceAndReceiveToResult(baseUrl + "/soap/fault", new StringSource(messagePayload), - result); + template.sendSourceAndReceiveToResult(baseUrl + "/soap/fault", new StringSource(messagePayload), result); Assert.fail("SoapFaultClientException expected"); - } - catch (SoapFaultClientException ex) { - //expected + } catch (SoapFaultClientException ex) { + // expected } } @@ -231,12 +223,11 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { template.setCheckConnectionForFault(false); template.setCheckConnectionForError(false); try { - template.sendSourceAndReceiveToResult(baseUrl + "/soap/badRequestFault", - new StringSource(messagePayload), result); + template.sendSourceAndReceiveToResult(baseUrl + "/soap/badRequestFault", new StringSource(messagePayload), + result); Assert.fail("SoapFaultClientException expected"); - } - catch (SoapFaultClientException ex) { - //expected + } catch (SoapFaultClientException ex) { + // expected } } @@ -288,8 +279,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { super.init(servletConfig); try { messageFactory = MessageFactory.newInstance(); - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new ServletException("Unable to create message factory" + ex.getMessage()); } } @@ -306,17 +296,15 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase { if (reply != null) { reply.saveChanges(); if (sc == -1) { - 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 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); } } 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 20065dbe..971f5109 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 @@ -16,10 +16,14 @@ package org.springframework.ws.client.core; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; + import java.io.IOException; import java.util.Enumeration; import java.util.Iterator; import java.util.StringTokenizer; + import javax.activation.CommandMap; import javax.activation.DataHandler; import javax.activation.MailcapCommandMap; @@ -50,8 +54,6 @@ import org.junit.Test; import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.ServletHolder; -import org.xml.sax.SAXException; - import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.XmlMappingException; @@ -65,9 +67,7 @@ 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 static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; +import org.xml.sax.SAXException; public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { @@ -75,7 +75,6 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { private static String baseUrl; - private WebServiceTemplate template; private String messagePayload = ""; @@ -104,8 +103,8 @@ 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 */ @Before public void removeXmlDataContentHandler() throws SOAPException { @@ -121,22 +120,20 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { template.setMessageSender(new HttpComponentsMessageSender()); } - public abstract SoapMessageFactory createMessageFactory() throws Exception; @Test public void sendSourceAndReceiveToResult() throws SAXException, IOException { 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); Assert.assertTrue("Invalid result", b); assertXMLEqual(messagePayload, result.toString()); } @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()); Assert.assertFalse("Invalid result", b); } @@ -151,8 +148,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { Assert.assertEquals("Invalid object", graph, requestObject); try { transformer.transform(new StringSource(messagePayload), result); - } - catch (TransformerException e) { + } catch (TransformerException e) { Assert.fail(e.getMessage()); } } @@ -194,8 +190,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { Assert.assertEquals("Invalid object", graph, requestObject); try { transformer.transform(new StringSource(messagePayload), result); - } - catch (TransformerException e) { + } catch (TransformerException e) { Assert.fail(e.getMessage()); } } @@ -214,12 +209,11 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { @Test public void notFound() { try { - template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", - new StringSource(messagePayload), new StringResult()); + template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", new StringSource(messagePayload), + new StringResult()); Assert.fail("WebServiceTransportException expected"); - } - catch (WebServiceTransportException ex) { - //expected + } catch (WebServiceTransportException ex) { + // expected } } @@ -227,12 +221,10 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { public void receiverFault() { Result result = new StringResult(); try { - template.sendSourceAndReceiveToResult(baseUrl + "/soap/receiverFault", new StringSource(messagePayload), - result); + template.sendSourceAndReceiveToResult(baseUrl + "/soap/receiverFault", new StringSource(messagePayload), result); Assert.fail("SoapFaultClientException expected"); - } - catch (SoapFaultClientException ex) { - //expected + } catch (SoapFaultClientException ex) { + // expected } } @@ -240,12 +232,10 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { public void senderFault() { Result result = new StringResult(); try { - template.sendSourceAndReceiveToResult(baseUrl + "/soap/senderFault", new StringSource(messagePayload), - result); + template.sendSourceAndReceiveToResult(baseUrl + "/soap/senderFault", new StringSource(messagePayload), result); Assert.fail("SoapFaultClientException expected"); - } - catch (SoapFaultClientException ex) { - //expected + } catch (SoapFaultClientException ex) { + // expected } } @@ -291,8 +281,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { super.init(servletConfig); 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()); } } @@ -308,25 +297,20 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase { SOAPBody replyBody = reply.getSOAPBody(); if (!replyBody.hasFault()) { resp.setStatus(HttpServletResponse.SC_OK); - } - else { - if (replyBody.getFault().getFaultCodeAsQName() - .equals(SOAPConstants.SOAP_SENDER_FAULT)) { + } 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); } } 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 0e15a96e..b5b53d41 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 @@ -16,7 +16,10 @@ package org.springframework.ws.client.core; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.IOException; + import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -36,18 +39,15 @@ import org.junit.Test; import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.ServletHolder; -import org.w3c.dom.Document; - import org.springframework.ws.client.WebServiceTransportException; import org.springframework.ws.pox.dom.DomPoxMessageFactory; import org.springframework.ws.transport.http.HttpComponentsMessageSender; import org.springframework.ws.transport.support.FreePortScanner; +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.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; +import org.w3c.dom.Document; public class DomPoxWebServiceTemplateIntegrationTest { @@ -80,24 +80,20 @@ public class DomPoxWebServiceTemplateIntegrationTest { template.setMessageSender(new HttpComponentsMessageSender()); String content = ""; StringResult result = new StringResult(); - template.sendSourceAndReceiveToResult(baseUrl + "/pox", new StringSource(content), - result); + template.sendSourceAndReceiveToResult(baseUrl + "/pox", new StringSource(content), result); assertXMLEqual(content, result.toString()); try { - template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", - new StringSource(content), new StringResult()); + template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound", new StringSource(content), + new StringResult()); Assert.fail("WebServiceTransportException expected"); - } - catch (WebServiceTransportException ex) { - //expected + } catch (WebServiceTransportException ex) { + // expected } try { - template.sendSourceAndReceiveToResult(baseUrl + "/errors/server", - new StringSource(content), result); + template.sendSourceAndReceiveToResult(baseUrl + "/errors/server", new StringSource(content), result); Assert.fail("WebServiceTransportException expected"); - } - catch (WebServiceTransportException ex) { - //expected + } catch (WebServiceTransportException ex) { + // expected } } @@ -140,8 +136,7 @@ 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 5fa55161..7fc1b1ff 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 @@ -25,8 +25,7 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; /** * @author Arjen Poutsma */ -public class SaajSoap11WebServiceTemplateIntegrationTest - extends AbstractSoap11WebServiceTemplateIntegrationTestCase { +public class SaajSoap11WebServiceTemplateIntegrationTest extends AbstractSoap11WebServiceTemplateIntegrationTestCase { @Override public SoapMessageFactory createMessageFactory() throws Exception { 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 496adf3a..a7492a0c 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 @@ -25,8 +25,7 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; /** * @author Arjen Poutsma */ -public class SaajSoap12WebServiceTemplateIntegrationTest - extends AbstractSoap12WebServiceTemplateIntegrationTestCase { +public class SaajSoap12WebServiceTemplateIntegrationTest extends AbstractSoap12WebServiceTemplateIntegrationTestCase { @Override public SoapMessageFactory createMessageFactory() throws Exception { 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 a40a4cc3..aabf50c1 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 @@ -16,14 +16,13 @@ package org.springframework.ws.client.core; -import org.springframework.ws.FaultAwareWebServiceMessage; -import org.springframework.ws.client.WebServiceFaultException; +import static org.easymock.EasyMock.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - -import static org.easymock.EasyMock.*; +import org.springframework.ws.FaultAwareWebServiceMessage; +import org.springframework.ws.client.WebServiceFaultException; public class SimpleFaultMessageResolverTest { @@ -45,11 +44,10 @@ public class SimpleFaultMessageResolverTest { try { resolver.resolveFault(messageMock); Assert.fail("WebServiceFaultExcpetion expected"); - } - catch (WebServiceFaultException ex) { + } catch (WebServiceFaultException ex) { // expected Assert.assertEquals("Invalid exception message", message, ex.getMessage()); } verify(messageMock); } -} \ No newline at end of file +} 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 f350dbaa..1061fdd7 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 @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.Enumeration; import java.util.Iterator; import java.util.StringTokenizer; + import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -49,8 +50,7 @@ public class SimpleSaajServlet extends HttpServlet { super.init(servletConfig); try { msgFactory = MessageFactory.newInstance(); - } - catch (SOAPException ex) { + } catch (SOAPException ex) { throw new ServletException("Unable to create message factory" + ex.getMessage()); } } @@ -89,16 +89,14 @@ 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()); } } @@ -107,5 +105,4 @@ public class SimpleSaajServlet extends HttpServlet { 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 25a5713e..0285e49d 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 @@ -16,14 +16,17 @@ package org.springframework.ws.client.core; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + import java.io.IOException; import java.net.URI; + import javax.xml.transform.Result; import javax.xml.transform.Source; import org.junit.Before; import org.junit.Test; - import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.ws.MockWebServiceMessage; @@ -40,9 +43,6 @@ import org.springframework.ws.transport.WebServiceMessageSender; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import static org.easymock.EasyMock.*; -import static org.junit.Assert.*; - @SuppressWarnings("unchecked") public class WebServiceTemplateTest { @@ -85,8 +85,7 @@ public class WebServiceTemplateTest { try { template.marshalSendAndReceive(new Object()); fail("IllegalStateException expected"); - } - catch (IllegalStateException ex) { + } catch (IllegalStateException ex) { // expected behavior } @@ -103,8 +102,7 @@ public class WebServiceTemplateTest { try { template.marshalSendAndReceive(new Object()); fail("IllegalStateException expected"); - } - catch (IllegalStateException ex) { + } catch (IllegalStateException ex) { // expected behavior } @@ -194,9 +192,8 @@ public class WebServiceTemplateTest { try { template.sendAndReceive(null, extractorMock); fail("Expected WebServiceTransportException"); - } - catch (WebServiceTransportException ex) { - //expected + } catch (WebServiceTransportException ex) { + // expected assertEquals("Invalid exception message", errorMessage, ex.getMessage()); } @@ -292,7 +289,6 @@ public class WebServiceTemplateTest { verify(connectionMock, response); } - @Test public void testSendAndReceiveMarshalResponse() throws Exception { Marshaller marshallerMock = createMock(Marshaller.class); @@ -378,13 +374,13 @@ public class WebServiceTemplateTest { public void testInterceptors() throws Exception { ClientInterceptor interceptorMock1 = createStrictMock("interceptor1", ClientInterceptor.class); ClientInterceptor interceptorMock2 = createStrictMock("interceptor2", ClientInterceptor.class); - template.setInterceptors(new ClientInterceptor[]{interceptorMock1, interceptorMock2}); + template.setInterceptors(new ClientInterceptor[] { interceptorMock1, interceptorMock2 }); expect(interceptorMock1.handleRequest(isA(MessageContext.class))).andReturn(true); expect(interceptorMock2.handleRequest(isA(MessageContext.class))).andReturn(true); expect(interceptorMock2.handleResponse(isA(MessageContext.class))).andReturn(true); expect(interceptorMock1.handleResponse(isA(MessageContext.class))).andReturn(true); - interceptorMock2.afterCompletion(isA(MessageContext.class), (Exception)isNull()); - interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception)isNull()); + interceptorMock2.afterCompletion(isA(MessageContext.class), (Exception) isNull()); + interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception) isNull()); WebServiceMessageCallback requestCallback = createMock(WebServiceMessageCallback.class); requestCallback.doWithMessage(isA(WebServiceMessage.class)); @@ -413,9 +409,9 @@ public class WebServiceTemplateTest { ClientInterceptor interceptorMock1 = createStrictMock("interceptor1", ClientInterceptor.class); ClientInterceptor interceptorMock2 = createStrictMock("interceptor2", ClientInterceptor.class); - template.setInterceptors(new ClientInterceptor[]{interceptorMock1, interceptorMock2}); + template.setInterceptors(new ClientInterceptor[] { interceptorMock1, interceptorMock2 }); expect(interceptorMock1.handleRequest(isA(MessageContext.class))).andReturn(false); - interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception)isNull()); + interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception) isNull()); WebServiceMessageCallback requestCallback = createMock(WebServiceMessageCallback.class); requestCallback.doWithMessage(messageContext.getRequest()); @@ -438,10 +434,10 @@ public class WebServiceTemplateTest { ClientInterceptor interceptorMock1 = createStrictMock("interceptor1", ClientInterceptor.class); ClientInterceptor interceptorMock2 = createStrictMock("interceptor2", ClientInterceptor.class); - template.setInterceptors(new ClientInterceptor[]{interceptorMock1, interceptorMock2}); + template.setInterceptors(new ClientInterceptor[] { interceptorMock1, interceptorMock2 }); expect(interceptorMock1.handleRequest(isA(MessageContext.class))).andReturn(false); expect(interceptorMock1.handleResponse(isA(MessageContext.class))).andReturn(true); - interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception)isNull()); + interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception) isNull()); WebServiceMessageCallback requestCallback = createMock(WebServiceMessageCallback.class); requestCallback.doWithMessage(messageContext.getRequest()); @@ -459,7 +455,7 @@ public class WebServiceTemplateTest { verify(connectionMock, interceptorMock1, interceptorMock2, requestCallback, extractorMock); } - + @Test public void testDestinationResolver() throws Exception { DestinationProvider providerMock = createMock(DestinationProvider.class); @@ -488,7 +484,7 @@ public class WebServiceTemplateTest { connectionMock.send(isA(WebServiceMessage.class)); expect(connectionMock.hasError()).andReturn(false); expect(connectionMock.receive(messageFactory)).andReturn(null); -// expect(connectionMock.getUri()).andReturn(new URI("http://example.com")); + // expect(connectionMock.getUri()).andReturn(new URI("http://example.com")); connectionMock.close(); replay(connectionMock, extractorMock, providerMock); @@ -499,5 +495,4 @@ public class WebServiceTemplateTest { verify(connectionMock, extractorMock, providerMock); } - } 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 e8b2e1cb..592833f2 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 @@ -19,12 +19,11 @@ package org.springframework.ws.client.support.destination; import java.net.URI; import java.net.URISyntaxException; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; public class Wsdl11DestinationProviderTest { @@ -65,4 +64,4 @@ public class Wsdl11DestinationProviderTest { Assert.assertEquals("Invalid URI returned", new URI("http://example.com/soap12"), result); } -} \ No newline at end of file +} 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 fa602dd7..738f6a9d 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 @@ -20,7 +20,6 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; - import org.springframework.ws.client.WebServiceClientException; import org.springframework.ws.context.MessageContext; @@ -94,4 +93,4 @@ public class ClientInterceptorAdapterTest { } } -} \ No newline at end of file +} 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 6dadacac..ea2494df 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 @@ -17,6 +17,7 @@ package org.springframework.ws.client.support.interceptor; import java.io.InputStream; + import javax.xml.XMLConstants; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; @@ -27,7 +28,6 @@ import javax.xml.transform.stream.StreamSource; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.core.io.ClassPathResource; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -88,8 +88,7 @@ public class PayloadValidatingInterceptorTest { boolean validated; try { validated = interceptor.handleRequest(context); - } - catch (WebServiceClientException e) { + } catch (WebServiceClientException e) { validated = false; Assert.assertNotNull("No exception details provided in WebServiceClientException", e.getMessage()); } @@ -105,8 +104,7 @@ public class PayloadValidatingInterceptorTest { boolean validated; try { validated = interceptor.handleRequest(context); - } - catch (WebServiceClientException e) { + } catch (WebServiceClientException e) { validated = false; Assert.assertNotNull("No exception details provided in WebServiceClientException", e.getMessage()); } @@ -148,8 +146,8 @@ public class PayloadValidatingInterceptorTest { 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 // See http://opensource.atlassian.com/projects/spring/browse/SWS-35 - String previousSchemaFactory = - System.getProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, ""); + String previousSchemaFactory = System + .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 { @@ -157,16 +155,14 @@ public class PayloadValidatingInterceptorTest { interceptor.setSchema(new ClassPathResource(SCHEMA2, PayloadValidatingInterceptorTest.class)); interceptor.afterPropertiesSet(); MessageFactory messageFactory = MessageFactory.newInstance(); - SOAPMessage saajMessage = - SaajUtils.loadMessage(new ClassPathResource(VALID_SOAP_MESSAGE, getClass()), messageFactory); - context = new DefaultMessageContext(new SaajSoapMessage(saajMessage), - new SaajSoapMessageFactory(messageFactory)); + SOAPMessage saajMessage = SaajUtils.loadMessage(new ClassPathResource(VALID_SOAP_MESSAGE, getClass()), + messageFactory); + context = new DefaultMessageContext(new SaajSoapMessage(saajMessage), new SaajSoapMessageFactory(messageFactory)); boolean result = interceptor.handleRequest(context); Assert.assertTrue("Invalid response from interceptor", result); Assert.assertFalse("Response set", context.hasResponse()); - } - finally { + } finally { // Reset the property System.setProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, previousSchemaFactory); @@ -179,8 +175,7 @@ public class PayloadValidatingInterceptorTest { interceptor.setSchema(new ClassPathResource("invalid")); interceptor.afterPropertiesSet(); Assert.fail("IllegalArgumentException expected"); - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { // expected } } @@ -196,8 +191,7 @@ public class PayloadValidatingInterceptorTest { boolean validated; try { validated = interceptor.handleRequest(context); - } - catch (WebServiceClientException e) { + } catch (WebServiceClientException e) { validated = false; Assert.assertNotNull("No exception details provided in WebServiceClientException", e.getMessage()); } 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 49105582..bae152f5 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 @@ -16,10 +16,14 @@ package org.springframework.ws.config; +import static org.junit.Assert.*; + import java.util.Collection; import java.util.List; import java.util.Map; +import org.junit.Before; +import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.ws.server.EndpointAdapter; @@ -46,12 +50,6 @@ 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 org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** * @author Arjen Poutsma */ @@ -61,8 +59,7 @@ public class AnnotationDrivenBeanDefinitionParserTest { @Before public void setUp() throws Exception { - applicationContext = - new ClassPathXmlApplicationContext("annotationDrivenBeanDefinitionParserTest.xml", getClass()); + applicationContext = new ClassPathXmlApplicationContext("annotationDrivenBeanDefinitionParserTest.xml", getClass()); } @Test @@ -76,8 +73,7 @@ public class AnnotationDrivenBeanDefinitionParserTest { @Test public void endpointAdapters() { - Map result = - applicationContext.getBeansOfType(EndpointAdapter.class); + Map result = applicationContext.getBeansOfType(EndpointAdapter.class); assertEquals("invalid amount of endpoint mappings found", 1, result.size()); DefaultMethodEndpointAdapter endpointAdapter = (DefaultMethodEndpointAdapter) result.values().iterator().next(); @@ -115,7 +111,6 @@ public class AnnotationDrivenBeanDefinitionParserTest { assertContainsInstanceOf(result.values(), SimpleSoapExceptionResolver.class); } - private void assertContainsInstanceOf(Collection collection, Class clazz) { boolean found = false; for (T item : collection) { 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 75cad738..1c601037 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 @@ -22,8 +22,7 @@ import org.springframework.ws.server.EndpointInterceptor; public class DummyInterceptor implements EndpointInterceptor { - @Autowired - private DummyInterceptorDependency autowiredDependency; + @Autowired private DummyInterceptorDependency autowiredDependency; private DummyInterceptorDependency propertyDependency; @@ -40,25 +39,20 @@ public class DummyInterceptor implements EndpointInterceptor { } @Override - public boolean handleRequest(MessageContext messageContext, Object endpoint) - throws Exception { + public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception { return true; } @Override - public boolean handleResponse(MessageContext messageContext, Object endpoint) - throws Exception { + public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception { return true; } @Override - public boolean handleFault(MessageContext messageContext, Object endpoint) - throws Exception { + public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception { return true; } @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 3b8a1a14..c7e0e4d2 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 @@ -17,6 +17,7 @@ package org.springframework.ws.config; import java.io.IOException; + import javax.xml.transform.Result; import javax.xml.transform.Source; diff --git a/spring-ws-core/src/test/java/org/springframework/ws/config/InterceptorsBeanDefinitionParserTest.java b/spring-ws-core/src/test/java/org/springframework/ws/config/InterceptorsBeanDefinitionParserTest.java index ff5f3930..316445f5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/config/InterceptorsBeanDefinitionParserTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/config/InterceptorsBeanDefinitionParserTest.java @@ -16,14 +16,13 @@ package org.springframework.ws.config; +import static org.junit.Assert.*; + import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.ws.server.endpoint.interceptor.DelegatingSmartEndpointInterceptor; @@ -34,8 +33,8 @@ public class InterceptorsBeanDefinitionParserTest { @Test public void namespace() throws Exception { - ApplicationContext applicationContext = - new ClassPathXmlApplicationContext("interceptorsBeanDefinitionParserTest.xml", getClass()); + ApplicationContext applicationContext = new ClassPathXmlApplicationContext( + "interceptorsBeanDefinitionParserTest.xml", getClass()); Map result = applicationContext.getBeansOfType(DelegatingSmartEndpointInterceptor.class); assertEquals("no smart interceptors found", 8, result.size()); @@ -48,8 +47,8 @@ public class InterceptorsBeanDefinitionParserTest { @Test public void ordering() throws Exception { - ApplicationContext applicationContext = - new ClassPathXmlApplicationContext("interceptorsBeanDefinitionParserOrderTest.xml", getClass()); + ApplicationContext applicationContext = new ClassPathXmlApplicationContext( + "interceptorsBeanDefinitionParserOrderTest.xml", getClass()); List interceptors = new ArrayList( applicationContext.getBeansOfType(DelegatingSmartEndpointInterceptor.class).values()); @@ -64,15 +63,14 @@ public class InterceptorsBeanDefinitionParserTest { @Test public void injection() throws Exception { - ApplicationContext applicationContext = - new ClassPathXmlApplicationContext("interceptorsBeanDefinitionParserInjectionTest.xml", getClass()); + ApplicationContext applicationContext = new ClassPathXmlApplicationContext( + "interceptorsBeanDefinitionParserInjectionTest.xml", getClass()); List interceptors = new ArrayList( applicationContext.getBeansOfType(DelegatingSmartEndpointInterceptor.class).values()); assertEquals("not enough smart interceptors found", 1, interceptors.size()); - DummyInterceptor interceptor = - (DummyInterceptor) interceptors.get(0).getDelegate(); + DummyInterceptor interceptor = (DummyInterceptor) interceptors.get(0).getDelegate(); assertNotNull(interceptor.getPropertyDependency()); assertNotNull(interceptor.getAutowiredDependency()); } 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 4cd6b8af..29baa1f6 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 @@ -50,6 +50,5 @@ 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 bedb97bf..ac0d7711 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 @@ -18,13 +18,12 @@ package org.springframework.ws.config; import java.util.Map; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter; public class WebServiceNamespaceHandlerTest { @@ -37,7 +36,8 @@ public class WebServiceNamespaceHandlerTest { @Test public void testMarshallingMethods() throws Exception { - Map result = applicationContext.getBeansOfType(MarshallingMethodEndpointAdapter.class); + Map result = applicationContext + .getBeansOfType(MarshallingMethodEndpointAdapter.class); Assert.assertFalse("no MarshallingMethodEndpointAdapter found", result.isEmpty()); } -} \ No newline at end of file +} 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 2a7c9e42..5b5a2dc4 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 @@ -18,36 +18,34 @@ package org.springframework.ws.config; import java.util.Map; +import org.junit.Assert; +import org.junit.Before; +import org.junit.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 org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class WebServicesNamespaceHandlerTigerTest { private ApplicationContext applicationContext; @Before public void setUp() throws Exception { - applicationContext = - new ClassPathXmlApplicationContext("webServicesNamespaceHandlerTest-tiger.xml", getClass()); + applicationContext = new ClassPathXmlApplicationContext("webServicesNamespaceHandlerTest-tiger.xml", getClass()); } @Test public void testMarshallingEndpoints() throws Exception { - Map result = - applicationContext.getBeansOfType(GenericMarshallingMethodEndpointAdapter.class); + Map result = applicationContext + .getBeansOfType(GenericMarshallingMethodEndpointAdapter.class); Assert.assertFalse("no MarshallingMethodEndpointAdapter found", result.isEmpty()); } @Test public void testXpathEndpoints() throws Exception { - Map result = - applicationContext.getBeansOfType(XPathParamAnnotationMethodEndpointAdapter.class); + Map result = applicationContext + .getBeansOfType(XPathParamAnnotationMethodEndpointAdapter.class); Assert.assertFalse("no XPathParamAnnotationMethodEndpointAdapter found", result.isEmpty()); } -} \ No newline at end of file +} 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 9773c6cd..b5356c17 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 @@ -18,16 +18,15 @@ package org.springframework.ws.config; import java.util.Map; +import org.junit.Assert; +import org.junit.Before; +import org.junit.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 org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - /** * @author Arjen Poutsma */ 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 62826204..b6c81953 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,10 +1,9 @@ package org.springframework.ws.config.annotation; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.*; + import org.junit.Before; import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -34,41 +33,39 @@ public class DefaultWsConfigurationTest { @Test public void payloadRootAnnotationMethodEndpointMapping() throws Exception { - PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext.getBean( - PayloadRootAnnotationMethodEndpointMapping.class); + PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext + .getBean(PayloadRootAnnotationMethodEndpointMapping.class); assertEquals(0, endpointMapping.getOrder()); } @Test public void soapActionAnnotationMethodEndpointMapping() throws Exception { - SoapActionAnnotationMethodEndpointMapping endpointMapping = this.applicationContext.getBean( - SoapActionAnnotationMethodEndpointMapping.class); + SoapActionAnnotationMethodEndpointMapping endpointMapping = this.applicationContext + .getBean(SoapActionAnnotationMethodEndpointMapping.class); assertEquals(1, endpointMapping.getOrder()); } @Test public void annotationActionEndpointMapping() throws Exception { - AnnotationActionEndpointMapping endpointMapping = this.applicationContext.getBean( - AnnotationActionEndpointMapping.class); + AnnotationActionEndpointMapping endpointMapping = this.applicationContext + .getBean(AnnotationActionEndpointMapping.class); assertEquals(2, endpointMapping.getOrder()); } @Test public void defaultMethodEndpointAdapter() throws Exception { - DefaultMethodEndpointAdapter adapter = - this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); + DefaultMethodEndpointAdapter adapter = this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); assertFalse(adapter.getMethodArgumentResolvers().isEmpty()); assertFalse(adapter.getMethodReturnValueHandlers().isEmpty()); } - @EnableWs @Configuration public static class TestConfig { - @Bean(name="testEndpoint") + @Bean(name = "testEndpoint") public TestEndpoint testEndpoint() { return new TestEndpoint(); } @@ -78,8 +75,7 @@ public class DefaultWsConfigurationTest { 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 f004c2f0..40d59a11 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,11 @@ package org.springframework.ws.config.annotation; +import static org.junit.Assert.*; + import java.util.List; -import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -24,8 +24,7 @@ public class WsConfigurationSupportTest { @Before public void setUp() throws Exception { - AnnotationConfigApplicationContext applicationContext = - new AnnotationConfigApplicationContext(); + AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); applicationContext.register(TestConfig.class); applicationContext.refresh(); @@ -34,8 +33,8 @@ public class WsConfigurationSupportTest { @Test public void interceptors() { - PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext.getBean( - PayloadRootAnnotationMethodEndpointMapping.class); + PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext + .getBean(PayloadRootAnnotationMethodEndpointMapping.class); assertEquals(0, endpointMapping.getOrder()); EndpointInterceptor[] interceptors = endpointMapping.getInterceptors(); @@ -45,14 +44,12 @@ public class WsConfigurationSupportTest { @Test public void defaultMethodEndpointAdapter() { - DefaultMethodEndpointAdapter endpointAdapter = - this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); + DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); assertNotNull(endpointAdapter); assertTrue(endpointAdapter instanceof MyDefaultMethodEndpointAdapter); } - @Configuration public static class TestConfig extends WsConfigurationSupport { @@ -72,8 +69,7 @@ public class WsConfigurationSupportTest { } - public static class MyDefaultMethodEndpointAdapter - extends DefaultMethodEndpointAdapter { + public static class MyDefaultMethodEndpointAdapter extends DefaultMethodEndpointAdapter { } 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 0240144e..b0780466 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,11 @@ package org.springframework.ws.config.annotation; +import static org.junit.Assert.*; + import java.util.List; -import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; @@ -36,8 +36,8 @@ public class WsConfigurerAdapterTest { @Test public void interceptors() { - PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext.getBean( - PayloadRootAnnotationMethodEndpointMapping.class); + PayloadRootAnnotationMethodEndpointMapping endpointMapping = this.applicationContext + .getBean(PayloadRootAnnotationMethodEndpointMapping.class); assertEquals(0, endpointMapping.getOrder()); EndpointInterceptor[] interceptors = endpointMapping.getInterceptors(); @@ -49,8 +49,7 @@ public class WsConfigurerAdapterTest { public void argumentResolvers() { DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); - List argumentResolvers = - endpointAdapter.getCustomMethodArgumentResolvers(); + List argumentResolvers = endpointAdapter.getCustomMethodArgumentResolvers(); assertEquals(1, argumentResolvers.size()); assertTrue(argumentResolvers.get(0) instanceof MyMethodArgumentResolver); @@ -62,8 +61,7 @@ public class WsConfigurerAdapterTest { public void returnValueHandlers() { DefaultMethodEndpointAdapter endpointAdapter = this.applicationContext.getBean(DefaultMethodEndpointAdapter.class); - List returnValueHandlers = - endpointAdapter.getCustomMethodReturnValueHandlers(); + List returnValueHandlers = endpointAdapter.getCustomMethodReturnValueHandlers(); assertEquals(1, returnValueHandlers.size()); assertTrue(returnValueHandlers.get(0) instanceof MyReturnValueHandler); @@ -71,7 +69,6 @@ public class WsConfigurerAdapterTest { assertFalse(returnValueHandlers.isEmpty()); } - @Configuration @EnableWs public static class TestConfig extends WsConfigurerAdapter { @@ -87,14 +84,12 @@ public class WsConfigurerAdapterTest { } @Override - public void addReturnValueHandlers( - List returnValueHandlers) { + 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 { @@ -104,8 +99,7 @@ public class WsConfigurerAdapterTest { } @Override - public Object resolveArgument(MessageContext messageContext, - MethodParameter parameter) throws Exception { + public Object resolveArgument(MessageContext messageContext, MethodParameter parameter) throws Exception { return null; } } @@ -118,11 +112,8 @@ public class WsConfigurerAdapterTest { } @Override - public void handleReturnValue(MessageContext messageContext, - MethodParameter returnType, Object returnValue) throws Exception { - } + public void handleReturnValue(MessageContext messageContext, MethodParameter returnType, Object returnValue) + 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 4e9bda2a..7913071f 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 @@ -16,17 +16,16 @@ package org.springframework.ws.context; -import java.util.Arrays; +import static org.easymock.EasyMock.*; -import org.springframework.ws.MockWebServiceMessage; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.WebServiceMessageFactory; +import java.util.Arrays; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - -import static org.easymock.EasyMock.*; +import org.springframework.ws.MockWebServiceMessage; +import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.WebServiceMessageFactory; public class DefaultMessageContextTest { @@ -75,4 +74,4 @@ public class DefaultMessageContextTest { Assert.assertEquals("Invalid property names returned", 0, context.getPropertyNames().length); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/mime/AbstractMimeMessageTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/mime/AbstractMimeMessageTestCase.java index 8fba10ed..cdd2ca50 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/mime/AbstractMimeMessageTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/mime/AbstractMimeMessageTestCase.java @@ -16,12 +16,12 @@ package org.springframework.ws.mime; +import static org.junit.Assert.*; + import java.io.IOException; import java.util.Iterator; -import static org.junit.Assert.*; import org.junit.Test; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.util.FileCopyUtils; @@ -88,4 +88,4 @@ public abstract class AbstractMimeMessageTestCase extends AbstractWebServiceMess assertTrue("No contents", contents.length > 0); } -} \ No newline at end of file +} 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 8ef9716a..5fd98009 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 @@ -25,4 +25,4 @@ public class DomPoxMessageFactoryTest extends AbstractWebServiceMessageFactoryTe protected WebServiceMessageFactory createMessageFactory() throws Exception { return new DomPoxMessageFactory(); } -} \ No newline at end of file +} 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 9c851455..35f33cf5 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 @@ -16,7 +16,10 @@ package org.springframework.ws.pox.dom; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.ByteArrayOutputStream; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -24,14 +27,11 @@ import javax.xml.transform.TransformerFactory; import org.junit.Before; import org.junit.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.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; +import org.w3c.dom.Document; public class DomPoxMessageTest { @@ -78,4 +78,4 @@ public class DomPoxMessageTest { message.writeTo(os); assertXMLEqual(content, os.toString("UTF-8")); } -} \ No newline at end of file +} 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 264fbe6c..ef947893 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 @@ -16,8 +16,13 @@ package org.springframework.ws.server; +import static org.easymock.EasyMock.*; + import java.util.Collections; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.NoEndpointFoundException; @@ -28,12 +33,6 @@ 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 org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class MessageDispatcherTest { private MessageDispatcher dispatcher; @@ -97,8 +96,7 @@ public class MessageDispatcherTest { try { dispatcher.getEndpointAdapter(endpoint); Assert.fail("getEndpointAdapter does not throw IllegalStateException for unsupported endpoint"); - } - catch (IllegalStateException ex) { + } catch (IllegalStateException ex) { // Expected } @@ -117,9 +115,8 @@ public class MessageDispatcherTest { dispatcher.setEndpointMappings(Collections.singletonList(endpointMapping)); EndpointExceptionResolver resolver = new EndpointExceptionResolver() { - public boolean resolveException(MessageContext givenMessageContext, - Object givenEndpoint, - Exception givenException) { + public boolean resolveException(MessageContext givenMessageContext, Object givenEndpoint, + Exception givenException) { Assert.assertEquals("Invalid message context", messageContext, givenMessageContext); Assert.assertNull("Invalid endpoint", givenEndpoint); Assert.assertEquals("Invalid exception", ex, givenException); @@ -153,8 +150,7 @@ public class MessageDispatcherTest { try { dispatcher.processEndpointException(messageContext, endpoint, ex); - } - catch (Exception result) { + } catch (Exception result) { Assert.assertEquals("processEndpointException throws invalid exception", ex, result); } verify(factoryMock, resolverMock); @@ -185,15 +181,15 @@ public class MessageDispatcherTest { interceptorMock2.afterCompletion(messageContext, endpoint, null); interceptorMock1.afterCompletion(messageContext, endpoint, null); - EndpointInvocationChain chain = - new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock1, interceptorMock2}); + EndpointInvocationChain chain = new EndpointInvocationChain(endpoint, + new EndpointInterceptor[] { interceptorMock1, interceptorMock2 }); expect(mappingMock.getEndpoint(messageContext)).andReturn(chain); expect(factoryMock.createWebServiceMessage()).andReturn(new MockWebServiceMessage()); replay(mappingMock, interceptorMock1, interceptorMock2, adapterMock, factoryMock); - // response required for interceptor invocation + // response required for interceptor invocation messageContext.getResponse(); dispatcher.dispatch(messageContext); @@ -214,8 +210,8 @@ public class MessageDispatcherTest { EndpointInterceptor interceptorMock1 = createStrictMock("interceptor1", EndpointInterceptor.class); EndpointInterceptor interceptorMock2 = createStrictMock("interceptor2", EndpointInterceptor.class); - EndpointInvocationChain chain = - new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock1, interceptorMock2}); + EndpointInvocationChain chain = new EndpointInvocationChain(endpoint, + new EndpointInterceptor[] { interceptorMock1, interceptorMock2 }); expect(mappingMock.getEndpoint(messageContext)).andReturn(chain); expect(interceptorMock1.handleRequest(messageContext, endpoint)).andReturn(true); @@ -249,15 +245,15 @@ public class MessageDispatcherTest { expect(interceptorMock1.handleResponse(messageContext, endpoint)).andReturn(true); interceptorMock1.afterCompletion(messageContext, endpoint, null); - EndpointInvocationChain chain = - new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock1, interceptorMock2}); + EndpointInvocationChain chain = new EndpointInvocationChain(endpoint, + new EndpointInterceptor[] { interceptorMock1, interceptorMock2 }); expect(mappingMock.getEndpoint(messageContext)).andReturn(chain); expect(factoryMock.createWebServiceMessage()).andReturn(new MockWebServiceMessage()); replay(mappingMock, interceptorMock1, interceptorMock2, adapterMock, factoryMock); - // response required for interceptor invocation + // response required for interceptor invocation messageContext.getResponse(); dispatcher.dispatch(messageContext); @@ -283,15 +279,15 @@ public class MessageDispatcherTest { interceptorMock1.afterCompletion(messageContext, endpoint, null); interceptorMock2.afterCompletion(messageContext, endpoint, null); - EndpointInvocationChain chain = - new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock1, interceptorMock2}); + EndpointInvocationChain chain = new EndpointInvocationChain(endpoint, + new EndpointInterceptor[] { interceptorMock1, interceptorMock2 }); expect(mappingMock.getEndpoint(messageContext)).andReturn(chain); expect(factoryMock.createWebServiceMessage()).andReturn(new MockWebServiceMessage()); replay(mappingMock, interceptorMock1, interceptorMock2, adapterMock, factoryMock); - // response required for interceptor invocation + // response required for interceptor invocation messageContext.getResponse(); dispatcher.dispatch(messageContext); @@ -327,18 +323,18 @@ public class MessageDispatcherTest { interceptorMock.afterCompletion(messageContext, endpoint, null); - EndpointInvocationChain chain = - new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock}); + EndpointInvocationChain chain = new EndpointInvocationChain(endpoint, + new EndpointInterceptor[] { interceptorMock }); expect(mappingMock.getEndpoint(messageContext)).andReturn(chain); expect(factoryMock.createWebServiceMessage()).andReturn(new MockWebServiceMessage()); replay(mappingMock, interceptorMock, adapterMock, factoryMock, resolverMock); - // response required for interceptor invocation + // response required for interceptor invocation messageContext.getResponse(); try { - dispatcher.dispatch(messageContext); + dispatcher.dispatch(messageContext); } catch (RuntimeException ex) { } @@ -364,8 +360,8 @@ public class MessageDispatcherTest { expect(interceptorMock.handleFault(messageContext, endpoint)).andReturn(true); interceptorMock.afterCompletion(messageContext, endpoint, null); - EndpointInvocationChain chain = - new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock}); + EndpointInvocationChain chain = new EndpointInvocationChain(endpoint, + new EndpointInterceptor[] { interceptorMock }); expect(mappingMock.getEndpoint(messageContext)).andReturn(chain); MockWebServiceMessage response = new MockWebServiceMessage(); @@ -374,7 +370,7 @@ public class MessageDispatcherTest { replay(mappingMock, interceptorMock, adapterMock, factoryMock); - // response required for interceptor invocation + // response required for interceptor invocation messageContext.getResponse(); dispatcher.dispatch(messageContext); @@ -383,12 +379,11 @@ public class MessageDispatcherTest { @Test public void testNoEndpointFound() throws Exception { - dispatcher.setEndpointMappings(Collections.emptyList()); + dispatcher.setEndpointMappings(Collections. emptyList()); try { dispatcher.receive(messageContext); Assert.fail("NoEndpointFoundException expected"); - } - catch (NoEndpointFoundException ex) { + } catch (NoEndpointFoundException ex) { // expected } } @@ -406,8 +401,7 @@ public class MessageDispatcherTest { Assert.assertEquals("Invalid amount of adapters detected", 1, dispatcher.getEndpointAdapters().size()); Assert.assertTrue("Invalid mappings detected", dispatcher.getEndpointAdapters().get(0) instanceof PayloadEndpointAdapter); - Assert.assertEquals("Invalid amount of resolvers detected", 1, - dispatcher.getEndpointExceptionResolvers().size()); + Assert.assertEquals("Invalid amount of resolvers detected", 1, dispatcher.getEndpointExceptionResolvers().size()); Assert.assertTrue("Invalid mappings detected", dispatcher.getEndpointExceptionResolvers().get(0) instanceof SimpleSoapExceptionResolver); } @@ -418,4 +412,4 @@ public class MessageDispatcherTest { dispatcher.setApplicationContext(applicationContext); } -} \ No newline at end of file +} 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 d7ea728e..05c550dd 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 @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.stream.XMLEventReader; @@ -31,15 +32,14 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; import org.junit.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.XMLInputFactoryUtils; -import org.springframework.xml.DocumentBuilderFactoryUtils; - @SuppressWarnings("Since15") public abstract class AbstractEndpointTestCase { 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 928e4757..a9c73772 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 @@ -16,21 +16,20 @@ package org.springframework.ws.server.endpoint; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import javax.xml.transform.Source; +import org.junit.Before; +import org.junit.Test; 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.junit.Before; -import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public abstract class AbstractMessageEndpointTestCase extends AbstractEndpointTestCase { private MessageEndpoint endpoint; @@ -45,8 +44,8 @@ public abstract class AbstractMessageEndpointTestCase extends AbstractEndpointTe endpoint = createNoResponseEndpoint(); StringSource requestSource = new StringSource(REQUEST); - MessageContext context = - new DefaultMessageContext(new MockWebServiceMessage(requestSource), new MockWebServiceMessageFactory()); + MessageContext context = new DefaultMessageContext(new MockWebServiceMessage(requestSource), + new MockWebServiceMessageFactory()); endpoint.invoke(context); assertFalse("Response message created", context.hasResponse()); } @@ -63,8 +62,8 @@ public abstract class AbstractMessageEndpointTestCase extends AbstractEndpointTe @Override protected final void testSource(Source requestSource) throws Exception { - MessageContext context = - new DefaultMessageContext(new MockWebServiceMessage(requestSource), new MockWebServiceMessageFactory()); + MessageContext context = new DefaultMessageContext(new MockWebServiceMessage(requestSource), + new MockWebServiceMessageFactory()); endpoint.invoke(context); assertTrue("No response message created", context.hasResponse()); assertXMLEqual(RESPONSE, ((MockWebServiceMessage) context.getResponse()).getPayloadAsString()); 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 4402a2a1..02c01b98 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 @@ -16,20 +16,19 @@ package org.springframework.ws.server.endpoint; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import javax.xml.transform.Source; import javax.xml.transform.Transformer; import org.junit.Before; import org.junit.Test; - import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - public abstract class AbstractPayloadEndpointTestCase extends AbstractEndpointTestCase { private PayloadEndpoint endpoint; diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/Dom4jPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/Dom4jPayloadEndpointTest.java index 2c0d8d18..c9eb0939 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/Dom4jPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/Dom4jPayloadEndpointTest.java @@ -16,11 +16,11 @@ package org.springframework.ws.server.endpoint; +import static org.junit.Assert.*; + import org.dom4j.Document; import org.dom4j.Element; -import static org.junit.Assert.*; - public class Dom4jPayloadEndpointTest extends AbstractPayloadEndpointTestCase { @Override @@ -61,5 +61,4 @@ public class Dom4jPayloadEndpointTest extends AbstractPayloadEndpointTestCase { }; } - } 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 1185e732..0ba6afc5 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 @@ -16,11 +16,11 @@ package org.springframework.ws.server.endpoint; +import static org.junit.Assert.*; + import org.w3c.dom.Document; import org.w3c.dom.Element; -import static org.junit.Assert.*; - public class DomPayloadEndpointTest extends AbstractPayloadEndpointTestCase { @Override 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 e428423a..c992f268 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 @@ -18,11 +18,10 @@ package org.springframework.ws.server.endpoint; import java.util.Collections; -import org.springframework.ws.context.MessageContext; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.ws.context.MessageContext; /** * Test for AbstractEndpointExceptionResolver @@ -56,6 +55,5 @@ public class EndpointExceptionResolverTest { Assert.assertTrue("AbstractEndpointExceptionResolver did not match mapped MethodEndpoint", matched); } - 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 4d2c05f1..28cb077d 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 @@ -16,11 +16,11 @@ package org.springframework.ws.server.endpoint; +import static org.junit.Assert.*; + import org.jdom2.Element; import org.jdom2.Namespace; -import static org.junit.Assert.*; - public class JDomPayloadEndpointTest extends AbstractPayloadEndpointTestCase { @Override 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 0dabdeb9..589ced57 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 @@ -16,9 +16,14 @@ package org.springframework.ws.server.endpoint; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.fail; + import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; + import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -29,7 +34,6 @@ import javax.xml.transform.stream.StreamSource; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.XmlMappingException; @@ -45,10 +49,6 @@ import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.easymock.EasyMock.*; -import static org.junit.Assert.fail; - public class MarshallingPayloadEndpointTest { private Transformer transformer; @@ -76,8 +76,7 @@ public class MarshallingPayloadEndpointTest { transformer.transform(source, new StreamResult(writer)); assertXMLEqual("Invalid source", "", writer.toString()); return 42L; - } - catch (Exception e) { + } catch (Exception e) { Assert.fail(e.getMessage()); return null; } @@ -89,8 +88,7 @@ public class MarshallingPayloadEndpointTest { Assert.assertEquals("Invalid graph", "result", graph); try { transformer.transform(new StreamSource(new StringReader("")), result); - } - catch (TransformerException e) { + } catch (TransformerException e) { Assert.fail(e.getMessage()); } } @@ -128,8 +126,7 @@ public class MarshallingPayloadEndpointTest { transformer.transform(source, new StreamResult(writer)); assertXMLEqual("Invalid source", "", writer.toString()); return (long) 42; - } - catch (Exception e) { + } catch (Exception e) { Assert.fail(e.getMessage()); return null; } 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 40ea9245..82493083 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 @@ -16,18 +16,16 @@ package org.springframework.ws.server.endpoint; +import static org.junit.Assert.*; + 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.SAXException; import org.xml.sax.helpers.DefaultHandler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - public class SaxPayloadEndpointTest extends AbstractPayloadEndpointTestCase { @Override @@ -89,8 +87,7 @@ public class SaxPayloadEndpointTest extends AbstractPayloadEndpointTestCase { } @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) - throws SAXException { + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { assertEquals("Invalid local name", REQUEST_ELEMENT, localName); assertEquals("Invalid qName", REQUEST_ELEMENT, localName); assertEquals("Invalid namespace", NAMESPACE_URI, 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 df2667e7..f3760c21 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 @@ -16,7 +16,10 @@ package org.springframework.ws.server.endpoint; +import static org.junit.Assert.*; + import java.util.Collections; + import javax.xml.namespace.QName; import javax.xml.stream.XMLEventFactory; import javax.xml.stream.XMLEventReader; @@ -25,8 +28,6 @@ import javax.xml.stream.events.Namespace; import javax.xml.stream.events.XMLEvent; import javax.xml.stream.util.XMLEventConsumer; -import static org.junit.Assert.*; - /** * Test case for AbstractStaxEventPayloadEndpoint. * @@ -39,9 +40,8 @@ public class StaxEventPayloadEndpointTest extends AbstractMessageEndpointTestCas protected MessageEndpoint createNoResponseEndpoint() { return new AbstractStaxEventPayloadEndpoint() { @Override - protected void invokeInternal(XMLEventReader eventReader, - XMLEventConsumer eventWriter, - XMLEventFactory eventFactory) throws Exception { + protected void invokeInternal(XMLEventReader eventReader, XMLEventConsumer eventWriter, + XMLEventFactory eventFactory) throws Exception { assertNotNull("No EventReader passed", eventReader); } }; @@ -52,9 +52,8 @@ public class StaxEventPayloadEndpointTest extends AbstractMessageEndpointTestCas return new AbstractStaxEventPayloadEndpoint() { @Override - protected void invokeInternal(XMLEventReader eventReader, - XMLEventConsumer eventWriter, - XMLEventFactory eventFactory) throws Exception { + protected void invokeInternal(XMLEventReader eventReader, XMLEventConsumer eventWriter, + XMLEventFactory eventFactory) throws Exception { assertNull("EventReader passed", eventReader); } }; @@ -65,9 +64,8 @@ public class StaxEventPayloadEndpointTest extends AbstractMessageEndpointTestCas return new AbstractStaxEventPayloadEndpoint() { @Override - protected void invokeInternal(XMLEventReader eventReader, - XMLEventConsumer eventWriter, - XMLEventFactory eventFactory) throws XMLStreamException { + protected void invokeInternal(XMLEventReader eventReader, XMLEventConsumer eventWriter, + XMLEventFactory eventFactory) throws XMLStreamException { assertNotNull("eventReader not given", eventReader); assertNotNull("eventWriter not given", eventWriter); assertNotNull("eventFactory not given", eventFactory); @@ -83,19 +81,15 @@ public class StaxEventPayloadEndpointTest extends AbstractMessageEndpointTestCas assertTrue("eventReader has not next element", eventReader.hasNext()); event = eventReader.nextEvent(); assertTrue("Not a end element", event.isEndElement()); - assertEquals("Invalid end event local name", REQUEST_ELEMENT, - event.asEndElement().getName().getLocalPart()); - assertEquals("Invalid end event namespace", NAMESPACE_URI, - event.asEndElement().getName().getNamespaceURI()); + assertEquals("Invalid end event local name", REQUEST_ELEMENT, event.asEndElement().getName().getLocalPart()); + assertEquals("Invalid end event namespace", NAMESPACE_URI, event.asEndElement().getName().getNamespaceURI()); 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/StaxStreamPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/StaxStreamPayloadEndpointTest.java index 557580d1..6551b0f0 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/StaxStreamPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/StaxStreamPayloadEndpointTest.java @@ -16,6 +16,13 @@ package org.springframework.ws.server.endpoint; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import javax.xml.soap.MessageFactory; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamConstants; @@ -26,7 +33,6 @@ import javax.xml.transform.Transformer; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.soap.SOAPFactory; import org.junit.Test; - import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.axiom.AxiomSoapMessage; @@ -37,13 +43,6 @@ import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - /** * Test case for AbstractStaxStreamPayloadEndpoint. * @@ -190,5 +189,4 @@ public class StaxStreamPayloadEndpointTest extends AbstractMessageEndpointTestCa assertFalse("context has response", context.hasResponse()); } - -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/XomPayloadEndpointTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/XomPayloadEndpointTest.java index 74bbe61c..e1ff3e04 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/XomPayloadEndpointTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/XomPayloadEndpointTest.java @@ -16,10 +16,10 @@ package org.springframework.ws.server.endpoint; -import nu.xom.Element; - import static org.junit.Assert.*; +import nu.xom.Element; + public class XomPayloadEndpointTest extends AbstractPayloadEndpointTestCase { @Override 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 488aac4e..1297f442 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 @@ -16,15 +16,15 @@ package org.springframework.ws.server.endpoint.adapter; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + import java.io.IOException; import java.util.Arrays; import java.util.Collections; -import static org.easymock.EasyMock.*; -import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; - import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -62,8 +62,7 @@ public class DefaultMethodEndpointAdapterTest { argumentResolver2 = createMock("intResolver", MethodArgumentResolver.class); returnValueHandler = createMock(MethodReturnValueHandler.class); adapter.setMethodArgumentResolvers(Arrays.asList(argumentResolver1, argumentResolver2)); - adapter.setMethodReturnValueHandlers( - Collections.singletonList(returnValueHandler)); + adapter.setMethodReturnValueHandlers(Collections.singletonList(returnValueHandler)); supportedEndpoint = new MethodEndpoint(this, "supported", String.class, Integer.class); nullReturnValue = new MethodEndpoint(this, "nullReturnValue", String.class); unsupportedEndpoint = new MethodEndpoint(this, "unsupported", String.class); @@ -102,7 +101,6 @@ public class DefaultMethodEndpointAdapterTest { replay(argumentResolver1, argumentResolver2, returnValueHandler); - boolean result = adapter.supports(unsupportedEndpoint); assertFalse("adapter does not support method", result); @@ -136,7 +134,8 @@ 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(new Integer(42)); + expect(argumentResolver2.resolveArgument(eq(messageContext), isA(MethodParameter.class))) + .andReturn(new Integer(42)); expect(returnValueHandler.supportsReturnType(isA(MethodParameter.class))).andReturn(true); returnValueHandler.handleReturnValue(eq(messageContext), isA(MethodParameter.class), eq(value)); @@ -180,14 +179,12 @@ public class DefaultMethodEndpointAdapterTest { expect(argumentResolver1.supportsParameter(isA(MethodParameter.class))).andReturn(true); expect(argumentResolver1.resolveArgument(eq(messageContext), isA(MethodParameter.class))).andReturn(value); - replay(argumentResolver1, argumentResolver2, returnValueHandler); try { adapter.invoke(messageContext, exceptionEndpoint); fail("IOException expected"); - } - catch (IOException expected) { + } catch (IOException expected) { // expected } assertEquals("Invalid argument passed", value, supportedArgument); 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 55407888..c138e8c2 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 @@ -16,10 +16,16 @@ package org.springframework.ws.server.endpoint.adapter; +import static org.easymock.EasyMock.*; + import java.lang.reflect.Method; + import javax.xml.transform.Result; import javax.xml.transform.Source; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.oxm.GenericMarshaller; import org.springframework.oxm.GenericUnmarshaller; import org.springframework.ws.WebServiceMessage; @@ -30,12 +36,6 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class GenericMarshallingMethodEndpointAdapterTest { private GenericMarshallingMethodEndpointAdapter adapter; @@ -195,8 +195,7 @@ 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; @@ -210,5 +209,4 @@ public class GenericMarshallingMethodEndpointAdapterTest { } - -} \ No newline at end of file +} 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 844cea77..da18c29e 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 @@ -16,10 +16,16 @@ package org.springframework.ws.server.endpoint.adapter; +import static org.easymock.EasyMock.*; + import java.lang.reflect.Method; + import javax.xml.transform.Result; import javax.xml.transform.Source; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.ws.MockWebServiceMessage; @@ -28,12 +34,6 @@ import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MethodEndpoint; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class MarshallingMethodEndpointAdapterTest { private MarshallingMethodEndpointAdapter adapter; @@ -62,7 +62,7 @@ public class MarshallingMethodEndpointAdapterTest { @Test public void testNoResponse() throws Exception { - Method noResponse = getClass().getMethod("noResponse", new Class[]{MyType.class}); + Method noResponse = getClass().getMethod("noResponse", new Class[] { MyType.class }); MethodEndpoint methodEndpoint = new MethodEndpoint(this, noResponse); expect(unmarshallerMock.unmarshal(isA(Source.class))).andReturn(new MyType()); @@ -79,7 +79,7 @@ public class MarshallingMethodEndpointAdapterTest { public void testNoRequestPayload() throws Exception { MockWebServiceMessage request = new MockWebServiceMessage(); messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); - Method noResponse = getClass().getMethod("noResponse", new Class[]{MyType.class}); + Method noResponse = getClass().getMethod("noResponse", new Class[] { MyType.class }); MethodEndpoint methodEndpoint = new MethodEndpoint(this, noResponse); replay(marshallerMock, unmarshallerMock); @@ -93,7 +93,7 @@ public class MarshallingMethodEndpointAdapterTest { @Test public void testResponse() throws Exception { - Method response = getClass().getMethod("response", new Class[]{MyType.class}); + Method response = getClass().getMethod("response", new Class[] { MyType.class }); MethodEndpoint methodEndpoint = new MethodEndpoint(this, response); expect(unmarshallerMock.unmarshal(isA(Source.class))).andReturn(new MyType()); marshallerMock.marshal(isA(MyType.class), isA(Result.class)); @@ -109,7 +109,7 @@ public class MarshallingMethodEndpointAdapterTest { @Test public void testSupportedNoResponse() throws NoSuchMethodException { - Method noResponse = getClass().getMethod("noResponse", new Class[]{MyType.class}); + Method noResponse = getClass().getMethod("noResponse", new Class[] { MyType.class }); MethodEndpoint methodEndpoint = new MethodEndpoint(this, noResponse); expect(unmarshallerMock.supports(MyType.class)).andReturn(true); @@ -122,7 +122,7 @@ public class MarshallingMethodEndpointAdapterTest { @Test public void testSupportedResponse() throws NoSuchMethodException { - Method response = getClass().getMethod("response", new Class[]{MyType.class}); + Method response = getClass().getMethod("response", new Class[] { MyType.class }); MethodEndpoint methodEndpoint = new MethodEndpoint(this, response); expect(unmarshallerMock.supports(MyType.class)).andReturn(true); expect(marshallerMock.supports(MyType.class)).andReturn(true); @@ -136,7 +136,7 @@ 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); @@ -147,7 +147,7 @@ public class MarshallingMethodEndpointAdapterTest { @Test public void testUnsupportedMethodWrongParam() throws NoSuchMethodException { - Method unsupported = getClass().getMethod("unsupportedWrongParam", new Class[]{String.class}); + Method unsupported = getClass().getMethod("unsupportedWrongParam", new Class[] { String.class }); expect(unmarshallerMock.supports(String.class)).andReturn(false); expect(marshallerMock.supports(String.class)).andReturn(true); @@ -160,7 +160,7 @@ public class MarshallingMethodEndpointAdapterTest { @Test public void testUnsupportedMethodWrongReturnType() throws NoSuchMethodException { - Method unsupported = getClass().getMethod("unsupportedWrongParam", new Class[]{String.class}); + Method unsupported = getClass().getMethod("unsupportedWrongParam", new Class[] { String.class }); expect(marshallerMock.supports(String.class)).andReturn(false); replay(marshallerMock, unmarshallerMock); @@ -180,8 +180,7 @@ 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; @@ -191,4 +190,4 @@ public class MarshallingMethodEndpointAdapterTest { } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MessageEndpointAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MessageEndpointAdapterTest.java index b7ae3932..f0f90b81 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MessageEndpointAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/MessageEndpointAdapterTest.java @@ -16,16 +16,15 @@ package org.springframework.ws.server.endpoint.adapter; -import org.springframework.ws.MockWebServiceMessageFactory; -import org.springframework.ws.context.DefaultMessageContext; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.endpoint.MessageEndpoint; +import static org.easymock.EasyMock.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - -import static org.easymock.EasyMock.*; +import org.springframework.ws.MockWebServiceMessageFactory; +import org.springframework.ws.context.DefaultMessageContext; +import org.springframework.ws.context.MessageContext; +import org.springframework.ws.server.endpoint.MessageEndpoint; public class MessageEndpointAdapterTest { @@ -57,6 +56,4 @@ public class MessageEndpointAdapterTest { verify(endpointMock); } - - -} \ No newline at end of file +} 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 6d27de12..9ddd7e6d 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 @@ -16,15 +16,14 @@ package org.springframework.ws.server.endpoint.adapter; +import org.junit.Assert; +import org.junit.Before; +import org.junit.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 org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class MessageMethodEndpointAdapterTest { private MessageMethodEndpointAdapter adapter; @@ -41,26 +40,25 @@ public class MessageMethodEndpointAdapterTest { @Test public void testSupported() throws NoSuchMethodException { - MethodEndpoint methodEndpoint = new MethodEndpoint(this, "supported", new Class[]{MessageContext.class}); + MethodEndpoint methodEndpoint = new MethodEndpoint(this, "supported", new Class[] { MessageContext.class }); Assert.assertTrue("Method unsupported", adapter.supportsInternal(methodEndpoint)); } @Test public void testUnsupportedMethodMultipleParams() throws NoSuchMethodException { - Assert.assertFalse("Method supported", adapter.supportsInternal( - new MethodEndpoint(this, "unsupportedMultipleParams", - new Class[]{MessageContext.class, MessageContext.class}))); + Assert.assertFalse("Method supported", adapter.supportsInternal(new MethodEndpoint(this, + "unsupportedMultipleParams", new Class[] { MessageContext.class, MessageContext.class }))); } @Test public void testUnsupportedMethodWrongParam() throws NoSuchMethodException { Assert.assertFalse("Method supported", - adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[]{String.class}))); + adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[] { String.class }))); } @Test public void testInvokeSupported() throws Exception { - MethodEndpoint methodEndpoint = new MethodEndpoint(this, "supported", new Class[]{MessageContext.class}); + MethodEndpoint methodEndpoint = new MethodEndpoint(this, "supported", new Class[] { MessageContext.class }); Assert.assertFalse("Method invoked", supportedInvoked); adapter.invoke(messageContext, methodEndpoint); Assert.assertTrue("Method not invoked", supportedInvoked); @@ -70,9 +68,7 @@ public class MessageMethodEndpointAdapterTest { supportedInvoked = true; } - public void unsupportedMultipleParams(MessageContext s1, MessageContext s2) { - } + public void unsupportedMultipleParams(MessageContext s1, MessageContext s2) {} - public void unsupportedWrongParam(String request) { - } -} \ No newline at end of file + public void unsupportedWrongParam(String request) {} +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/PayloadEndpointAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/PayloadEndpointAdapterTest.java index a0e13630..42cfb0f6 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/PayloadEndpointAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/PayloadEndpointAdapterTest.java @@ -16,8 +16,12 @@ package org.springframework.ws.server.endpoint.adapter; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.easymock.EasyMock.*; + import java.io.StringReader; import java.io.StringWriter; + import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.stream.StreamResult; @@ -26,7 +30,6 @@ import javax.xml.transform.stream.StreamSource; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -34,9 +37,6 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.PayloadEndpoint; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.easymock.EasyMock.*; - public class PayloadEndpointAdapterTest { private PayloadEndpointAdapter adapter; 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 2646fbb8..e42f5921 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 @@ -20,6 +20,9 @@ import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamSource; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.WebServiceMessage; @@ -27,10 +30,6 @@ import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MethodEndpoint; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class PayloadMethodEndpointAdapterTest { private PayloadMethodEndpointAdapter adapter; @@ -49,37 +48,37 @@ public class PayloadMethodEndpointAdapterTest { @Test public void testSupportedNoResponse() throws NoSuchMethodException { - MethodEndpoint methodEndpoint = new MethodEndpoint(this, "noResponse", new Class[]{DOMSource.class}); + MethodEndpoint methodEndpoint = new MethodEndpoint(this, "noResponse", new Class[] { DOMSource.class }); Assert.assertTrue("Method unsupported", adapter.supportsInternal(methodEndpoint)); } @Test public void testSupportedResponse() throws NoSuchMethodException { - MethodEndpoint methodEndpoint = new MethodEndpoint(this, "response", new Class[]{StreamSource.class}); + MethodEndpoint methodEndpoint = new MethodEndpoint(this, "response", new Class[] { StreamSource.class }); Assert.assertTrue("Method unsupported", adapter.supportsInternal(methodEndpoint)); } @Test public void testUnsupportedMethodMultipleParams() throws NoSuchMethodException { Assert.assertFalse("Method supported", adapter.supportsInternal( - new MethodEndpoint(this, "unsupportedMultipleParams", new Class[]{Source.class, Source.class}))); + new MethodEndpoint(this, "unsupportedMultipleParams", new Class[] { Source.class, Source.class }))); } @Test public void testUnsupportedMethodWrongReturnType() throws NoSuchMethodException { - Assert.assertFalse("Method supported", adapter.supportsInternal( - new MethodEndpoint(this, "unsupportedWrongReturnType", new Class[]{Source.class}))); + Assert.assertFalse("Method supported", + adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongReturnType", new Class[] { Source.class }))); } @Test public void testUnsupportedMethodWrongParam() throws NoSuchMethodException { Assert.assertFalse("Method supported", - adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[]{String.class}))); + adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[] { String.class }))); } @Test public void testNoResponse() throws Exception { - MethodEndpoint methodEndpoint = new MethodEndpoint(this, "noResponse", new Class[]{DOMSource.class}); + MethodEndpoint methodEndpoint = new MethodEndpoint(this, "noResponse", new Class[] { DOMSource.class }); Assert.assertFalse("Method invoked", noResponseInvoked); adapter.invoke(messageContext, methodEndpoint); Assert.assertTrue("Method not invoked", noResponseInvoked); @@ -89,7 +88,7 @@ public class PayloadMethodEndpointAdapterTest { public void testResponse() throws Exception { WebServiceMessage request = new MockWebServiceMessage(""); messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); - MethodEndpoint methodEndpoint = new MethodEndpoint(this, "response", new Class[]{StreamSource.class}); + MethodEndpoint methodEndpoint = new MethodEndpoint(this, "response", new Class[] { StreamSource.class }); Assert.assertFalse("Method invoked", responseInvoked); adapter.invoke(messageContext, methodEndpoint); Assert.assertTrue("Method not invoked", responseInvoked); @@ -104,8 +103,7 @@ 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; @@ -115,4 +113,4 @@ public class PayloadMethodEndpointAdapterTest { return null; } -} \ No newline at end of file +} 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 fe2c05a3..e40b947c 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 @@ -16,34 +16,34 @@ package org.springframework.ws.server.endpoint.adapter; +import static org.easymock.EasyMock.*; + import java.util.HashMap; import java.util.Map; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; 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.DocumentBuilderFactoryUtils; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.springframework.xml.DocumentBuilderFactoryUtils; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.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 static org.easymock.EasyMock.*; - public class XPathParamAnnotationMethodEndpointAdapterTest { private static final String CONTENTS = "text42.0"; @@ -64,45 +64,45 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { @Test public void testUnsupportedInvalidParam() throws NoSuchMethodException { - MethodEndpoint endpoint = new MethodEndpoint(this, "unsupportedInvalidParamType", new Class[]{Integer.TYPE}); + MethodEndpoint endpoint = new MethodEndpoint(this, "unsupportedInvalidParamType", new Class[] { Integer.TYPE }); Assert.assertFalse("Method supported", adapter.supports(endpoint)); } @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 }); Assert.assertFalse("Method supported", adapter.supports(endpoint)); } @Test public void testUnsupportedInvalidParams() throws NoSuchMethodException { - MethodEndpoint endpoint = - new MethodEndpoint(this, "unsupportedInvalidParams", new Class[]{String.class, String.class}); + MethodEndpoint endpoint = new MethodEndpoint(this, "unsupportedInvalidParams", + new Class[] { String.class, String.class }); Assert.assertFalse("Method supported", adapter.supports(endpoint)); } @Test public void testSupportedTypes() throws NoSuchMethodException { MethodEndpoint endpoint = new MethodEndpoint(this, "supportedTypes", - new Class[]{Boolean.TYPE, Double.TYPE, Node.class, NodeList.class, String.class}); + new Class[] { Boolean.TYPE, Double.TYPE, Node.class, NodeList.class, String.class }); Assert.assertTrue("Not all types supported", adapter.supports(endpoint)); } @Test public void testSupportsStringSource() throws NoSuchMethodException { - MethodEndpoint endpoint = new MethodEndpoint(this, "supportedStringSource", new Class[]{String.class}); + MethodEndpoint endpoint = new MethodEndpoint(this, "supportedStringSource", new Class[] { String.class }); Assert.assertTrue("StringSource method not supported", adapter.supports(endpoint)); } @Test public void testSupportsSource() throws NoSuchMethodException { - MethodEndpoint endpoint = new MethodEndpoint(this, "supportedSource", new Class[]{String.class}); + MethodEndpoint endpoint = new MethodEndpoint(this, "supportedSource", new Class[] { String.class }); Assert.assertTrue("Source method not supported", adapter.supports(endpoint)); } @Test public void testSupportsVoid() throws NoSuchMethodException { - MethodEndpoint endpoint = new MethodEndpoint(this, "supportedVoid", new Class[]{String.class}); + MethodEndpoint endpoint = new MethodEndpoint(this, "supportedVoid", new Class[] { String.class }); Assert.assertTrue("void method not supported", adapter.supports(endpoint)); } @@ -115,7 +115,7 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { MessageContext messageContext = new DefaultMessageContext(messageMock, factoryMock); MethodEndpoint endpoint = new MethodEndpoint(this, "supportedTypes", - new Class[]{Boolean.TYPE, Double.TYPE, Node.class, NodeList.class, String.class}); + new Class[] { Boolean.TYPE, Double.TYPE, Node.class, NodeList.class, String.class }); adapter.invoke(messageContext, endpoint); Assert.assertTrue("Method not invoked", supportedTypesInvoked); @@ -133,7 +133,7 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { replay(requestMock, responseMock, factoryMock); MessageContext messageContext = new DefaultMessageContext(requestMock, factoryMock); - MethodEndpoint endpoint = new MethodEndpoint(this, "supportedSource", new Class[]{String.class}); + MethodEndpoint endpoint = new MethodEndpoint(this, "supportedSource", new Class[] { String.class }); adapter.invoke(messageContext, endpoint); Assert.assertTrue("Method not invoked", supportedSourceInvoked); @@ -170,28 +170,25 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { adapter.setNamespaces(namespaces); MessageContext messageContext = new DefaultMessageContext(requestMock, factoryMock); - MethodEndpoint endpoint = new MethodEndpoint(this, "namespaces", new Class[]{Node.class}); + MethodEndpoint endpoint = new MethodEndpoint(this, "namespaces", new Class[] { Node.class }); adapter.invoke(messageContext, endpoint); Assert.assertTrue("Method not invoked", namespacesInvoked); } - public void supportedVoid(@XPathParam("/")String param1) { - } + public void supportedVoid(@XPathParam("/") String param1) {} - public Source supportedSource(@XPathParam("/")String param1) { + public Source supportedSource(@XPathParam("/") String param1) { supportedSourceInvoked = true; return new StringSource(""); } - public StringSource supportedStringSource(@XPathParam("/")String param1) { + public StringSource supportedStringSource(@XPathParam("/") String param1) { 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; Assert.assertTrue("Invalid boolean value", param1); Assert.assertEquals("Invalid double value", 42D, param2, 0.00001D); @@ -201,19 +198,18 @@ public class XPathParamAnnotationMethodEndpointAdapterTest { Assert.assertEquals("Invalid Node value", "text", param5); } - public void unsupportedInvalidParams(@XPathParam("/")String param1, String param2) { + public void unsupportedInvalidParams(@XPathParam("/") String param1, String param2) { } - public String unsupportedInvalidReturnType(@XPathParam("/")String param1) { + public String unsupportedInvalidReturnType(@XPathParam("/") String param1) { return null; } - public void unsupportedInvalidParamType(@XPathParam("/")int param1) { - } + public void unsupportedInvalidParamType(@XPathParam("/") int param1) {} - public void namespaces(@XPathParam(".")Node param) { + public void namespaces(@XPathParam(".") Node param) { namespacesInvoked = true; Assert.assertEquals("Invalid parameter", "child", param.getLocalName()); } -} \ No newline at end of file +} 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 16be585d..266beed3 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 @@ -18,6 +18,8 @@ package org.springframework.ws.server.endpoint.adapter.method; import javax.xml.transform.TransformerException; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.soap.SOAPFactory; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -29,9 +31,6 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerObjectSupport; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.soap.SOAPFactory; - public class AbstractMethodArgumentResolverTestCase extends TransformerObjectSupport { protected static final String NAMESPACE_URI = "http://springframework.org/ws"; 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 4d7b0d03..d7f7e6c6 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 @@ -16,18 +16,17 @@ package org.springframework.ws.server.endpoint.adapter.method; -import javax.xml.transform.Source; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import org.springframework.core.MethodParameter; -import org.springframework.ws.context.MessageContext; -import org.springframework.xml.transform.StringResult; +import javax.xml.transform.Source; import org.junit.Before; import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.springframework.core.MethodParameter; +import org.springframework.ws.context.MessageContext; +import org.springframework.xml.transform.StringResult; public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMethodArgumentResolverTestCase { @@ -56,8 +55,7 @@ public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMet assertTrue("processor does not support " + supportedParameter.getParameterType() + " parameter", processor.supportsParameter(supportedParameter)); } - MethodParameter unsupportedParameter = - new MethodParameter(getClass().getMethod("unsupported", String.class), 0); + MethodParameter unsupportedParameter = new MethodParameter(getClass().getMethod("unsupported", String.class), 0); assertFalse("processor supports invalid parameter", processor.supportsParameter(unsupportedParameter)); } @@ -67,8 +65,7 @@ public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMet assertTrue("processor does not support " + supportedReturnType.getParameterType() + " return type", processor.supportsReturnType(supportedReturnType)); } - MethodParameter unsupportedReturnType = - new MethodParameter(getClass().getMethod("unsupported", String.class), -1); + MethodParameter unsupportedReturnType = new MethodParameter(getClass().getMethod("unsupported", String.class), -1); assertFalse("processor supports invalid return type", processor.supportsReturnType(unsupportedReturnType)); } @@ -102,9 +99,7 @@ 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 { @@ -126,7 +121,6 @@ public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMet testHandleReturnValue(createNonCachingAxiomMessageContext()); } - private void testHandleReturnValue(MessageContext messageContext) throws Exception { for (MethodParameter supportedReturnType : supportedReturnTypes) { Object returnValue = getReturnValue(supportedReturnType); @@ -145,4 +139,4 @@ public abstract class AbstractPayloadMethodProcessorTestCase extends AbstractMet return s; } -} \ No newline at end of file +} 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 a4a17702..7d6b23af 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 @@ -16,10 +16,16 @@ package org.springframework.ws.server.endpoint.adapter.method; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + import java.lang.reflect.Type; + import javax.xml.transform.Result; import javax.xml.transform.Source; +import org.junit.Before; +import org.junit.Test; import org.springframework.core.MethodParameter; import org.springframework.oxm.GenericMarshaller; import org.springframework.oxm.GenericUnmarshaller; @@ -27,12 +33,6 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.RequestPayload; import org.springframework.ws.server.endpoint.annotation.ResponsePayload; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; -import static org.junit.Assert.*; - public class MarshallingPayloadMethodProcessorTest extends AbstractMethodArgumentResolverTestCase { private MarshallingPayloadMethodProcessor processor; @@ -124,7 +124,6 @@ public class MarshallingPayloadMethodProcessorTest extends AbstractMethodArgumen verify(marshaller, unmarshaller); } - @Test public void resolveArgument() throws Exception { MyObject expected = new 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 59f52dc9..e9354d37 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 @@ -16,17 +16,15 @@ package org.springframework.ws.server.endpoint.adapter.method; +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - public class MessageContextMethodArgumentResolverTest { private MessageContextMethodArgumentResolver resolver; @@ -52,7 +50,6 @@ public class MessageContextMethodArgumentResolverTest { assertSame("Invalid message context returned", messageContext, result); } - 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 74586626..2cc2ba69 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 @@ -37,20 +37,20 @@ public class SourcePayloadMethodProcessorTest extends AbstractPayloadMethodProce @Override protected MethodParameter[] createSupportedParameters() throws NoSuchMethodException { - return new MethodParameter[]{new MethodParameter(getClass().getMethod("source", Source.class), 0), + return new MethodParameter[] { new MethodParameter(getClass().getMethod("source", Source.class), 0), new MethodParameter(getClass().getMethod("dom", DOMSource.class), 0), new MethodParameter(getClass().getMethod("sax", SAXSource.class), 0), new MethodParameter(getClass().getMethod("stream", StreamSource.class), 0), - new MethodParameter(getClass().getMethod("stax", StAXSource.class), 0)}; + new MethodParameter(getClass().getMethod("stax", StAXSource.class), 0) }; } @Override protected MethodParameter[] createSupportedReturnTypes() throws NoSuchMethodException { - return new MethodParameter[]{new MethodParameter(getClass().getMethod("source", Source.class), -1), + return new MethodParameter[] { new MethodParameter(getClass().getMethod("source", Source.class), -1), new MethodParameter(getClass().getMethod("dom", DOMSource.class), -1), new MethodParameter(getClass().getMethod("sax", SAXSource.class), -1), new MethodParameter(getClass().getMethod("stream", StreamSource.class), -1), - new MethodParameter(getClass().getMethod("stax", StAXSource.class), -1)}; + new MethodParameter(getClass().getMethod("stax", StAXSource.class), -1) }; } @Override 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 62b5f9f0..c23dd415 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 @@ -16,6 +16,8 @@ package org.springframework.ws.server.endpoint.adapter.method; +import static org.junit.Assert.*; + import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; @@ -23,15 +25,12 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.stream.events.StartElement; import javax.xml.stream.events.XMLEvent; +import org.junit.Before; +import org.junit.Test; import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.annotation.RequestPayload; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - /** @author Arjen Poutsma */ @SuppressWarnings("Since15") public class StaxPayloadMethodArgumentResolverTest extends AbstractMethodArgumentResolverTestCase { @@ -131,7 +130,6 @@ public class StaxPayloadMethodArgumentResolverTest extends AbstractMethodArgumen testEventReader(result); } - private void testStreamReader(Object result) throws XMLStreamException { assertTrue("resolver does not return XMLStreamReader", result instanceof XMLStreamReader); XMLStreamReader streamReader = (XMLStreamReader) result; @@ -152,13 +150,9 @@ public class StaxPayloadMethodArgumentResolverTest extends AbstractMethodArgumen assertEquals("Invalid local name", LOCAL_NAME, startElement.getName().getLocalPart()); } + 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 c7bd4419..8f840afd 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 @@ -16,8 +16,12 @@ package org.springframework.ws.server.endpoint.adapter.method; +import static org.junit.Assert.*; + import java.lang.reflect.Method; +import org.junit.Before; +import org.junit.Test; import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -26,14 +30,9 @@ 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.junit.Before; -import org.junit.Test; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import static org.junit.Assert.*; - @Namespaces(@Namespace(prefix = "tns", uri = "http://springframework.org/spring-ws")) public class XPathParamMethodArgumentResolverTest { @@ -62,8 +61,8 @@ public class XPathParamMethodArgumentResolverTest { @Before public void setUp() throws Exception { resolver = new XPathParamMethodArgumentResolver(); - Method supportedTypes = getClass() - .getMethod("supportedTypes", Boolean.TYPE, Double.TYPE, Node.class, NodeList.class, String.class); + Method supportedTypes = getClass().getMethod("supportedTypes", Boolean.TYPE, Double.TYPE, Node.class, + NodeList.class, String.class); booleanParameter = new MethodParameter(supportedTypes, 0); doubleParameter = new MethodParameter(supportedTypes, 1); nodeParameter = new MethodParameter(supportedTypes, 2); @@ -97,6 +96,7 @@ public class XPathParamMethodArgumentResolverTest { Boolean b = (Boolean) result; assertTrue("Invalid boolean value", b); } + @Test public void resolveDouble() throws Exception { MockWebServiceMessage request = new MockWebServiceMessage(CONTENTS); @@ -117,7 +117,7 @@ public class XPathParamMethodArgumentResolverTest { Object result = resolver.resolveArgument(messageContext, nodeParameter); assertTrue("resolver does not return Node", result instanceof Node); - Node node = (Node) result; + Node node = (Node) result; assertEquals("Invalid node value", "child", node.getLocalName()); } @@ -129,7 +129,7 @@ public class XPathParamMethodArgumentResolverTest { Object result = resolver.resolveArgument(messageContext, nodeListParameter); assertTrue("resolver does not return NodeList", result instanceof NodeList); - NodeList nodeList = (NodeList) result; + NodeList nodeList = (NodeList) result; assertEquals("Invalid NodeList value", 1, nodeList.getLength()); assertEquals("Invalid Node value", "child", nodeList.item(0).getLocalName()); } @@ -142,10 +142,10 @@ public class XPathParamMethodArgumentResolverTest { Object result = resolver.resolveArgument(messageContext, stringParameter); assertTrue("resolver does not return String", result instanceof String); - String s = (String) result; + String s = (String) result; assertEquals("Invalid string value", "text", s); } - + @Test public void resolveConvertedType() throws Exception { MockWebServiceMessage request = new MockWebServiceMessage(CONTENTS); @@ -154,7 +154,7 @@ public class XPathParamMethodArgumentResolverTest { Object result = resolver.resolveArgument(messageContext, convertedParameter); assertTrue("resolver does not return String", result instanceof Integer); - Integer i = (Integer) result; + Integer i = (Integer) result; assertEquals("Invalid integer value", new Integer(42), i); } @@ -167,10 +167,10 @@ public class XPathParamMethodArgumentResolverTest { Object result = resolver.resolveArgument(messageContext, namespaceMethodParameter); assertTrue("resolver does not return String", result instanceof String); - String s = (String) result; + String s = (String) result; assertEquals("Invalid string value", "text", s); } - + @Test public void resolveNamespacesClass() throws Exception { MockWebServiceMessage request = new MockWebServiceMessage( @@ -180,28 +180,21 @@ public class XPathParamMethodArgumentResolverTest { Object result = resolver.resolveArgument(messageContext, namespaceClassParameter); assertTrue("resolver does not return String", result instanceof String); - String s = (String) result; + String s = (String) result; assertEquals("Invalid string value", "text", s); } - 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) { - } + 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 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/Dom4jPayloadMethodProcessorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/Dom4jPayloadMethodProcessorTest.java index 59a1d893..443640c2 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/Dom4jPayloadMethodProcessorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/Dom4jPayloadMethodProcessorTest.java @@ -16,35 +16,32 @@ package org.springframework.ws.server.endpoint.adapter.method.dom; +import static org.junit.Assert.*; + +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.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 org.dom4j.Document; -import org.dom4j.DocumentHelper; -import org.dom4j.Element; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class Dom4jPayloadMethodProcessorTest extends AbstractPayloadMethodProcessorTestCase { - @Override + @Override protected AbstractPayloadSourceMethodProcessor createProcessor() { return new Dom4jPayloadMethodProcessor(); } @Override protected MethodParameter[] createSupportedParameters() throws NoSuchMethodException { - return new MethodParameter[]{ - new MethodParameter(getClass().getMethod("element", Element.class), 0)}; + return new MethodParameter[] { new MethodParameter(getClass().getMethod("element", Element.class), 0) }; } @Override protected MethodParameter[] createSupportedReturnTypes() throws NoSuchMethodException { - return new MethodParameter[]{new MethodParameter(getClass().getMethod("element", Element.class), -1)}; + return new MethodParameter[] { new MethodParameter(getClass().getMethod("element", Element.class), -1) }; } @Override @@ -66,4 +63,4 @@ public class Dom4jPayloadMethodProcessorTest extends AbstractPayloadMethodProces return element; } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/DomPayloadMethodProcessorTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/DomPayloadMethodProcessorTest.java index cde7cba5..78dd6bee 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/DomPayloadMethodProcessorTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/adapter/method/dom/DomPayloadMethodProcessorTest.java @@ -16,21 +16,20 @@ package org.springframework.ws.server.endpoint.adapter.method.dom; +import static org.junit.Assert.*; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.w3c.dom.Document; -import org.w3c.dom.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 org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.junit.Assert.*; +import org.w3c.dom.Document; +import org.w3c.dom.Element; public class DomPayloadMethodProcessorTest extends AbstractPayloadMethodProcessorTestCase { @@ -41,13 +40,12 @@ public class DomPayloadMethodProcessorTest extends AbstractPayloadMethodProcesso @Override protected MethodParameter[] createSupportedParameters() throws NoSuchMethodException { - return new MethodParameter[]{ - new MethodParameter(getClass().getMethod("element", Element.class), 0)}; + return new MethodParameter[] { new MethodParameter(getClass().getMethod("element", Element.class), 0) }; } @Override protected MethodParameter[] createSupportedReturnTypes() throws NoSuchMethodException { - return new MethodParameter[]{new MethodParameter(getClass().getMethod("element", Element.class), -1)}; + return new MethodParameter[] { new MethodParameter(getClass().getMethod("element", Element.class), -1) }; } @Override 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 8c207395..d805a507 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 @@ -16,17 +16,15 @@ package org.springframework.ws.server.endpoint.adapter.method.dom; +import static org.junit.Assert.*; + +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 org.jdom2.Element; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class JDomPayloadMethodProcessorTest extends AbstractPayloadMethodProcessorTestCase { @Override @@ -36,12 +34,12 @@ public class JDomPayloadMethodProcessorTest extends AbstractPayloadMethodProcess @Override protected MethodParameter[] createSupportedParameters() throws NoSuchMethodException { - return new MethodParameter[]{new MethodParameter(getClass().getMethod("element", Element.class), 0)}; + return new MethodParameter[] { new MethodParameter(getClass().getMethod("element", Element.class), 0) }; } @Override protected MethodParameter[] createSupportedReturnTypes() throws NoSuchMethodException { - return new MethodParameter[]{new MethodParameter(getClass().getMethod("element", Element.class), -1)}; + return new MethodParameter[] { new MethodParameter(getClass().getMethod("element", Element.class), -1) }; } @Override 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 bcde5149..b4c491d0 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 @@ -16,17 +16,16 @@ package org.springframework.ws.server.endpoint.adapter.method.dom; +import static org.junit.Assert.*; + +import nu.xom.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 nu.xom.Element; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class XomPayloadMethodProcessorTest extends AbstractPayloadMethodProcessorTestCase { @Override @@ -36,12 +35,12 @@ public class XomPayloadMethodProcessorTest extends AbstractPayloadMethodProcesso @Override protected MethodParameter[] createSupportedParameters() throws NoSuchMethodException { - return new MethodParameter[]{new MethodParameter(getClass().getMethod("element", Element.class), 0)}; + return new MethodParameter[] { new MethodParameter(getClass().getMethod("element", Element.class), 0) }; } @Override protected MethodParameter[] createSupportedReturnTypes() throws NoSuchMethodException { - return new MethodParameter[]{new MethodParameter(getClass().getMethod("element", Element.class), -1)}; + return new MethodParameter[] { new MethodParameter(getClass().getMethod("element", Element.class), -1) }; } @Override @@ -61,4 +60,4 @@ public class XomPayloadMethodProcessorTest extends AbstractPayloadMethodProcesso public Element element(@RequestPayload Element element) { return element; } -} \ No newline at end of file +} 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 b45d61f2..30a7f005 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 @@ -16,7 +16,13 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; + import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlElement; @@ -26,7 +32,6 @@ import javax.xml.transform.Transformer; import org.junit.Before; import org.junit.Test; - import org.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -40,11 +45,6 @@ import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class JaxbElementPayloadMethodProcessorTest { private JaxbElementPayloadMethodProcessor processor; @@ -65,8 +65,7 @@ public class JaxbElementPayloadMethodProcessorTest { @Test public void supportsParameter() { - assertTrue("processor does not support @JAXBElement parameter", - processor.supportsParameter(supportedParameter)); + assertTrue("processor does not support @JAXBElement parameter", processor.supportsParameter(supportedParameter)); } @Test @@ -77,7 +76,8 @@ public class JaxbElementPayloadMethodProcessorTest { @Test public void resolveArgument() throws JAXBException { - WebServiceMessage request = new MockWebServiceMessage("Foo"); + WebServiceMessage request = new MockWebServiceMessage( + "Foo"); MessageContext messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); JAXBElement result = processor.resolveArgument(messageContext, supportedParameter); @@ -92,11 +92,13 @@ public class JaxbElementPayloadMethodProcessorTest { MyType type = new MyType(); type.setString("Foo"); - JAXBElement element = new JAXBElement(new QName("http://springframework.org", "type"), MyType.class, type); + JAXBElement element = new JAXBElement(new QName("http://springframework.org", "type"), MyType.class, + type); processor.handleReturnValue(messageContext, supportedReturnType, element); assertTrue("context has no response", messageContext.hasResponse()); MockWebServiceMessage response = (MockWebServiceMessage) messageContext.getResponse(); - assertXMLEqual("Foo", response.getPayloadAsString()); + assertXMLEqual("Foo", + response.getPayloadAsString()); } @Test @@ -104,7 +106,8 @@ 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); assertTrue("context has no response", messageContext.hasResponse()); MockWebServiceMessage response = (MockWebServiceMessage) messageContext.getResponse(); @@ -113,8 +116,7 @@ public class JaxbElementPayloadMethodProcessorTest { @Test public void handleNullReturnValue() throws Exception { - MessageContext messageContext = - new DefaultMessageContext(new MockWebServiceMessageFactory()); + MessageContext messageContext = new DefaultMessageContext(new MockWebServiceMessageFactory()); processor.handleReturnValue(messageContext, stringReturnType, null); assertFalse("context has response", messageContext.hasResponse()); @@ -127,7 +129,8 @@ public class JaxbElementPayloadMethodProcessorTest { MyType type = new MyType(); type.setString("Foo"); - JAXBElement element = new JAXBElement(new QName("http://springframework.org", "type"), MyType.class, type); + JAXBElement element = new JAXBElement(new QName("http://springframework.org", "type"), MyType.class, + type); processor.handleReturnValue(messageContext, supportedReturnType, element); assertTrue("context has no response", messageContext.hasResponse()); @@ -137,20 +140,20 @@ public class JaxbElementPayloadMethodProcessorTest { StringResult payloadResult = new StringResult(); transformer.transform(response.getPayloadSource(), payloadResult); - assertXMLEqual("Foo", - payloadResult.toString()); + assertXMLEqual("Foo", payloadResult.toString()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); response.writeTo(bos); String messageResult = bos.toString("UTF-8"); - assertXMLEqual("" + - "Foo" + - "", messageResult); + assertXMLEqual( + "" + + "Foo" + + "", + messageResult); } - @ResponsePayload public JAXBElement supported(@RequestPayload JAXBElement element) { return element; @@ -161,7 +164,7 @@ public class JaxbElementPayloadMethodProcessorTest { return new JAXBElement(new QName("string"), String.class, "Foo"); } - @XmlType(name="myType", namespace = "http://springframework.org") + @XmlType(name = "myType", namespace = "http://springframework.org") public static class MyType { private 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 14020d24..1ddb9125 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 @@ -16,9 +16,15 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; + import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -30,12 +36,6 @@ import javax.xml.transform.sax.SAXSource; import org.junit.Before; import org.junit.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.springframework.core.MethodParameter; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; @@ -49,11 +49,11 @@ import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory; import org.springframework.xml.sax.AbstractXmlReader; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.TransformerFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +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; public class XmlRootElementPayloadMethodProcessorTest { @@ -77,8 +77,7 @@ public class XmlRootElementPayloadMethodProcessorTest { public void supportsParameter() { assertTrue("processor does not support @XmlRootElement parameter", processor.supportsParameter(rootElementParameter)); - assertTrue("processor does not support @XmlType parameter", processor.supportsParameter( - typeParameter)); + assertTrue("processor does not support @XmlType parameter", processor.supportsParameter(typeParameter)); } @Test @@ -89,7 +88,8 @@ public class XmlRootElementPayloadMethodProcessorTest { @Test public void resolveArgumentRootElement() throws JAXBException { - WebServiceMessage request = new MockWebServiceMessage("Foo"); + WebServiceMessage request = new MockWebServiceMessage( + "Foo"); MessageContext messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); Object result = processor.resolveArgument(messageContext, rootElementParameter); @@ -100,7 +100,8 @@ public class XmlRootElementPayloadMethodProcessorTest { @Test public void resolveArgumentType() throws JAXBException { - WebServiceMessage request = new MockWebServiceMessage("Foo"); + WebServiceMessage request = new MockWebServiceMessage( + "Foo"); MessageContext messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); Object result = processor.resolveArgument(messageContext, typeParameter); @@ -117,12 +118,12 @@ public class XmlRootElementPayloadMethodProcessorTest { public void parse(String systemId) throws IOException, SAXException { parse(); } - + @Override public void parse(InputSource input) throws IOException, SAXException { parse(); } - + private void parse() throws SAXException { ContentHandler handler = getContentHandler(); // Foo @@ -138,19 +139,19 @@ public class XmlRootElementPayloadMethodProcessorTest { } }; final SAXSource source = new SAXSource(xmlReader, new InputSource()); - + // Create a mock WebServiceMessage that returns the SAXSource as payload source. WebServiceMessage request = new WebServiceMessage() { @Override public void writeTo(OutputStream outputStream) throws IOException { throw new UnsupportedOperationException(); } - + @Override public Source getPayloadSource() { return source; } - + @Override public Result getPayloadResult() { throw new UnsupportedOperationException(); @@ -159,7 +160,7 @@ public class XmlRootElementPayloadMethodProcessorTest { // 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()); - + Object result = processor.resolveArgument(messageContext, rootElementParameter); assertTrue("result not a MyRootElement", result instanceof MyRootElement); MyRootElement rootElement = (MyRootElement) result; @@ -175,7 +176,8 @@ public class XmlRootElementPayloadMethodProcessorTest { processor.handleReturnValue(messageContext, rootElementReturnType, rootElement); assertTrue("context has no response", messageContext.hasResponse()); MockWebServiceMessage response = (MockWebServiceMessage) messageContext.getResponse(); - assertXMLEqual("Foo", response.getPayloadAsString()); + assertXMLEqual("Foo", + response.getPayloadAsString()); } @Test @@ -203,16 +205,17 @@ public class XmlRootElementPayloadMethodProcessorTest { StringResult payloadResult = new StringResult(); transformer.transform(response.getPayloadSource(), payloadResult); - assertXMLEqual("Foo", - payloadResult.toString()); + assertXMLEqual("Foo", payloadResult.toString()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); response.writeTo(bos); String messageResult = bos.toString("UTF-8"); - - assertXMLEqual("" + - "Foo" + - "", messageResult); + + assertXMLEqual( + "" + + "Foo" + + "", + messageResult); } @@ -233,9 +236,11 @@ public class XmlRootElementPayloadMethodProcessorTest { response.writeTo(bos); String messageResult = bos.toString("UTF-8"); - assertXMLEqual("" + - "Foo" + - "", messageResult); + assertXMLEqual( + "" + + "Foo" + + "", + messageResult); } @@ -244,8 +249,7 @@ 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 { @@ -277,5 +281,4 @@ public class XmlRootElementPayloadMethodProcessorTest { } } - } 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 ac55888c..049f9d96 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 @@ -16,6 +16,8 @@ package org.springframework.ws.server.endpoint.interceptor; +import static org.custommonkey.xmlunit.XMLAssert.*; + import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPMessage; import javax.xml.transform.Transformer; @@ -26,7 +28,6 @@ import org.custommonkey.xmlunit.XMLUnit; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.ws.MockWebServiceMessage; @@ -42,8 +43,6 @@ import org.springframework.xml.transform.ResourceSource; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.custommonkey.xmlunit.XMLAssert.*; - public class PayloadTransformingInterceptorTest { private PayloadTransformingInterceptor interceptor; @@ -169,8 +168,6 @@ public class PayloadTransformingInterceptorTest { try { interceptor.afterPropertiesSet(); Assert.fail("Should have thrown an Exception"); - } - catch (IllegalArgumentException ex) { - } + } catch (IllegalArgumentException ex) {} } -} \ No newline at end of file +} 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 4d1bdf27..3bffd308 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 @@ -16,9 +16,14 @@ package org.springframework.ws.server.endpoint.mapping; +import static org.junit.Assert.*; + import java.lang.reflect.Method; + import javax.xml.namespace.QName; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -27,21 +32,13 @@ import org.springframework.ws.server.endpoint.MethodEndpoint; import org.springframework.ws.server.endpoint.annotation.Endpoint; import org.springframework.ws.server.endpoint.annotation.PayloadRoot; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - @RunWith(SpringJUnit4ClassRunner.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 { @@ -69,4 +66,4 @@ public class BridgedMethodRegistrationTest { } } -} \ No newline at end of file +} 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 830b6c03..cbaa20d3 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 @@ -16,10 +16,15 @@ package org.springframework.ws.server.endpoint.mapping; +import static org.junit.Assert.*; + import java.lang.reflect.Method; + import javax.xml.namespace.QName; import javax.xml.transform.Source; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -29,21 +34,13 @@ import org.springframework.ws.server.endpoint.annotation.Endpoint; import org.springframework.ws.server.endpoint.annotation.PayloadRoot; import org.springframework.ws.server.endpoint.annotation.RequestPayload; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - @RunWith(SpringJUnit4ClassRunner.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 { @@ -59,9 +56,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) {} } -} \ No newline at end of file +} 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 7d6b0d87..511fd551 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 @@ -16,6 +16,10 @@ package org.springframework.ws.server.endpoint.mapping; +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -25,11 +29,6 @@ import org.springframework.ws.server.EndpointInvocationChain; import org.springframework.ws.server.endpoint.interceptor.DelegatingSmartEndpointInterceptor; import org.springframework.ws.server.endpoint.interceptor.EndpointInterceptorAdapter; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - /** * Test case for {@link AbstractEndpointMapping}. */ @@ -87,7 +86,7 @@ public class EndpointMappingTest { } }; - mapping.setInterceptors(new EndpointInterceptor[]{interceptor}); + mapping.setInterceptors(new EndpointInterceptor[] { interceptor }); EndpointInvocationChain result = mapping.getEndpoint(messageContext); assertEquals("Unexpected amount of EndpointInterceptors returned", 1, result.getInterceptors().length); assertEquals("Unexpected EndpointInterceptor returned", interceptor, result.getInterceptors()[0]); @@ -108,8 +107,8 @@ public class EndpointMappingTest { } }; mapping.setApplicationContext(applicationContext); - mapping.setInterceptors(new EndpointInterceptor[]{interceptor}); - + mapping.setInterceptors(new EndpointInterceptor[] { interceptor }); + EndpointInvocationChain result = mapping.getEndpoint(messageContext); assertEquals("Unexpected amount of EndpointInterceptors returned", 2, result.getInterceptors().length); assertEquals("Unexpected EndpointInterceptor returned", interceptor, result.getInterceptors()[0]); 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 31b4fa92..0c40b23f 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 @@ -16,15 +16,15 @@ package org.springframework.ws.server.endpoint.mapping; +import static org.junit.Assert.*; + import java.lang.reflect.Method; + import javax.xml.namespace.QName; import javax.xml.transform.Source; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import org.junit.Test; import org.junit.runner.RunWith; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -38,11 +38,9 @@ import org.springframework.ws.server.endpoint.annotation.RequestPayload; @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 { @@ -64,9 +62,8 @@ public class JdkProxyRegistrationTest { public static class MyEndpointImpl implements MyEndpoint { @Override - public void doIt(@RequestPayload Source payload) { - } + public void doIt(@RequestPayload Source payload) {} } -} \ No newline at end of file +} 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 5e3fbb1b..79fb6446 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 @@ -45,8 +45,7 @@ public class LogAspect { logger.info("Before: " + joinPoint.getSignature()); 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 e8e7da1c..5e47ca07 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 @@ -20,11 +20,10 @@ import java.util.Arrays; import java.util.Map; import java.util.TreeMap; -import org.springframework.context.support.StaticApplicationContext; -import org.springframework.ws.context.MessageContext; - import org.junit.Assert; import org.junit.Test; +import org.springframework.context.support.StaticApplicationContext; +import org.springframework.ws.context.MessageContext; /** * Test case for AbstractMapBasedEndpointMapping. @@ -38,7 +37,7 @@ public class MapBasedSoapEndpointMappingTest { context.registerSingleton("endpoint", Object.class); context.registerAlias("endpoint", "alias"); MyMapBasedEndpointMapping mapping = new MyMapBasedEndpointMapping(); - mapping.setValidKeys(new String[]{"endpoint", "alias"}); + mapping.setValidKeys(new String[] { "endpoint", "alias" }); mapping.setRegisterBeanNames(true); mapping.setApplicationContext(context); @@ -80,7 +79,7 @@ public class MapBasedSoapEndpointMappingTest { endpointMap.put("endpoint2", endpoint2); MyMapBasedEndpointMapping mapping = new MyMapBasedEndpointMapping(); - mapping.setValidKeys(new String[]{"endpoint1", "endpoint2"}); + mapping.setValidKeys(new String[] { "endpoint1", "endpoint2" }); mapping.setEndpointMap(endpointMap); mapping.setApplicationContext(new StaticApplicationContext()); @@ -124,4 +123,4 @@ public class MapBasedSoapEndpointMappingTest { } } -} \ No newline at end of file +} 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 e11b0d57..8df1d870 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 @@ -16,18 +16,19 @@ package org.springframework.ws.server.endpoint.mapping; +import static org.junit.Assert.*; + import java.lang.reflect.Method; import java.util.Collections; + import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPMessage; import javax.xml.transform.Source; import org.apache.commons.logging.LogFactory; -import static org.junit.Assert.*; import org.junit.Test; import org.junit.runner.RunWith; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -49,13 +50,11 @@ import org.springframework.ws.soap.server.SoapMessageDispatcher; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("payloadRootAnnotationMethodEndpointMapping.xml") -public class PayloadRootAnnotationMethodEndpointMappingTest { +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 { @@ -106,15 +105,15 @@ public class PayloadRootAnnotationMethodEndpointMappingTest { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage request = messageFactory.createMessage(); request.getSOAPBody().addBodyElement(QName.valueOf("{http://springframework.org/spring-ws}Request")); - MessageContext messageContext = - new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory)); + MessageContext messageContext = new DefaultMessageContext(new SaajSoapMessage(request), + new SaajSoapMessageFactory(messageFactory)); DefaultMethodEndpointAdapter adapter = new DefaultMethodEndpointAdapter(); adapter.afterPropertiesSet(); 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); @@ -143,17 +142,12 @@ public class PayloadRootAnnotationMethodEndpointMappingTest { logger.info("In doIt()"); } - @PayloadRoots({@PayloadRoot(localPart = "Request1", - namespace = "http://springframework.org/spring-ws"), - @PayloadRoot(localPart = "Request2", - namespace = "http://springframework.org/spring-ws")}) - public void doItMultiple() { - } + @PayloadRoots({ @PayloadRoot(localPart = "Request1", namespace = "http://springframework.org/spring-ws"), + @PayloadRoot(localPart = "Request2", namespace = "http://springframework.org/spring-ws") }) + public void doItMultiple() {} - @PayloadRoot(localPart = "Request3", - namespace = "http://springframework.org/spring-ws") - @PayloadRoot(localPart = "Request4", - namespace = "http://springframework.org/spring-ws") + @PayloadRoot(localPart = "Request3", namespace = "http://springframework.org/spring-ws") + @PayloadRoot(localPart = "Request4", namespace = "http://springframework.org/spring-ws") public void doItRepeatable() { } @@ -168,4 +162,4 @@ public class PayloadRootAnnotationMethodEndpointMappingTest { } } -} \ No newline at end of file +} 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 84f1c62b..4cdc3c97 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 @@ -18,15 +18,14 @@ package org.springframework.ws.server.endpoint.mapping; import javax.xml.namespace.QName; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class PayloadRootQNameEndpointMappingTest { private PayloadRootQNameEndpointMapping mapping; @@ -55,4 +54,4 @@ public class PayloadRootQNameEndpointMappingTest { Assert.assertNotNull("mapping returns null", qName); Assert.assertEquals("mapping returns invalid method name", new QName("namespace", "localname", "prefix"), qName); } -} \ No newline at end of file +} 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 94ee1980..53d061bb 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 @@ -16,15 +16,14 @@ package org.springframework.ws.server.endpoint.mapping; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class SimpleMethodEndpointMappingTest { private SimpleMethodEndpointMapping mapping; @@ -35,7 +34,7 @@ public class SimpleMethodEndpointMappingTest { mapping.setMethodPrefix("prefix"); mapping.setMethodSuffix("Suffix"); MyBean bean = new MyBean(); - mapping.setEndpoints(new Object[]{bean}); + mapping.setEndpoints(new Object[] { bean }); mapping.afterPropertiesSet(); } @@ -55,8 +54,8 @@ public class SimpleMethodEndpointMappingTest { @Test public void testGetLookupKeyForMessageNamespace() throws Exception { - MockWebServiceMessage request = - new MockWebServiceMessage(""); + MockWebServiceMessage request = new MockWebServiceMessage( + ""); MessageContext messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory()); String result = mapping.getLookupKeyForMessage(messageContext); Assert.assertEquals("Invalid lookup key", "MyRequest", result); @@ -72,4 +71,4 @@ public class SimpleMethodEndpointMappingTest { } } -} \ No newline at end of file +} 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 d384b7dd..90af5c74 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 @@ -16,8 +16,14 @@ package org.springframework.ws.server.endpoint.mapping; +import static org.easymock.EasyMock.*; + import java.net.URI; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; @@ -25,13 +31,6 @@ import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.context.DefaultTransportContext; import org.springframework.ws.transport.context.TransportContextHolder; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class UriEndpointMappingTest { private UriEndpointMapping mapping; @@ -86,4 +85,4 @@ public class UriEndpointMappingTest { Assert.assertTrue("URI not valid", mapping.validateLookupKey("http://example.com/services")); Assert.assertFalse("URI not valid", mapping.validateLookupKey("some string")); } -} \ No newline at end of file +} 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 b03c26f4..c5669909 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 @@ -16,15 +16,14 @@ package org.springframework.ws.server.endpoint.mapping; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class XPathPayloadEndpointMappingTest { private XPathPayloadEndpointMapping mapping; @@ -46,4 +45,4 @@ public class XPathPayloadEndpointMappingTest { Assert.assertNotNull("mapping returns null", result); Assert.assertEquals("mapping returns invalid result", "value", result); } -} \ No newline at end of file +} 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 1f0cb2a5..aa4b1e8b 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 @@ -16,15 +16,16 @@ package org.springframework.ws.server.endpoint.mapping.jaxb; +import static org.junit.Assert.*; + import java.lang.reflect.Method; + import javax.xml.bind.annotation.XmlRootElement; import javax.xml.namespace.QName; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; - public class XmlRootElementEndpointMappingTest { private XmlRootElementEndpointMapping mapping; @@ -41,8 +42,7 @@ public class XmlRootElementEndpointMappingTest { assertEquals(new QName("myNamespace", "myRoot"), name); } - 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/NamespaceUtilsTest.java b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/support/NamespaceUtilsTest.java index 1ab68c8a..a88329e8 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/support/NamespaceUtilsTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/server/endpoint/support/NamespaceUtilsTest.java @@ -16,18 +16,18 @@ package org.springframework.ws.server.endpoint.support; +import static org.junit.Assert.*; + import java.lang.reflect.Method; + import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; +import org.junit.Test; import org.springframework.ws.server.endpoint.annotation.Namespace; import org.springframework.ws.server.endpoint.annotation.Namespaces; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -@Namespaces({@Namespace(prefix = "prefix1", uri = "class1"), @Namespace(uri = "class2")}) +@Namespaces({ @Namespace(prefix = "prefix1", uri = "class1"), @Namespace(uri = "class2") }) public class NamespaceUtilsTest { @Test @@ -38,7 +38,7 @@ public class NamespaceUtilsTest { assertEquals("method2", namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX)); } - + @Test public void getNamespaceContextClass() throws NoSuchMethodException { Method method = getClass().getMethod("getNamespaceContextClass"); @@ -48,7 +48,7 @@ public class NamespaceUtilsTest { } - @Namespaces({@Namespace(prefix = "prefix1", uri = "method1"), @Namespace(uri = "method2")}) + @Namespaces({ @Namespace(prefix = "prefix1", uri = "method1"), @Namespace(uri = "method2") }) public void method() { } 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 a5a9f99d..8c1918ac 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 @@ -17,6 +17,7 @@ package org.springframework.ws.server.endpoint.support; import java.io.StringReader; + import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -30,15 +31,14 @@ import javax.xml.transform.stream.StreamSource; import org.junit.Assert; import org.junit.Test; +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 org.springframework.util.xml.StaxUtils; -import org.springframework.xml.XMLInputFactoryUtils; -import org.springframework.xml.transform.TransformerFactoryUtils; -import org.springframework.xml.DocumentBuilderFactoryUtils; - public class PayloadRootUtilsTest { @Test @@ -109,4 +109,4 @@ public class PayloadRootUtilsTest { QName qName = PayloadRootUtils.getPayloadRootQName(null, TransformerFactoryUtils.newInstance()); Assert.assertNull("Qname returned", qName); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapBodyTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapBodyTestCase.java index aee0c4bf..f9d8910f 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapBodyTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/AbstractSoapBodyTestCase.java @@ -16,20 +16,22 @@ package org.springframework.ws.soap; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Locale; + import javax.xml.transform.dom.DOMResult; +import org.junit.Test; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; - -import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.*; - public abstract class AbstractSoapBodyTestCase extends AbstractSoapElementTestCase { protected SoapBody soapBody; 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 5998c790..a04c3bce 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -24,7 +25,6 @@ import javax.xml.transform.TransformerFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.xml.transform.TransformerFactoryUtils; public abstract class AbstractSoapElementTestCase { @@ -66,5 +66,4 @@ public abstract class AbstractSoapElementTestCase { 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 3d37327c..cf807e17 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 @@ -16,9 +16,9 @@ package org.springframework.ws.soap; -import org.junit.Test; +import static org.junit.Assert.*; -import static org.junit.Assert.assertNotNull; +import org.junit.Test; public abstract class AbstractSoapEnvelopeTestCase extends AbstractSoapElementTestCase { 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 3af56a14..b9992f0a 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 @@ -16,17 +16,20 @@ package org.springframework.ws.soap; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; + import javax.xml.namespace.QName; +import org.junit.Test; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.*; - public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTestCase { protected SoapHeader soapHeader; @@ -124,8 +127,7 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest @Test public void testGetResult() throws Exception { - String content = - ""; + String content = ""; transformer.transform(new StringSource(content), soapHeader.getResult()); Iterator iterator = soapHeader.examineAllHeaderElements(); assertTrue("Header has no children", iterator.hasNext()); @@ -140,5 +142,4 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest assertXMLEqual("Invalid contents of header element", expected, result.toString()); } - } 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 7e5bb0b6..1fafcaa5 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 @@ -16,14 +16,13 @@ package org.springframework.ws.soap; +import static org.junit.Assert.*; + +import org.junit.Test; import org.springframework.ws.AbstractWebServiceMessageFactoryTestCase; import org.springframework.ws.InvalidXmlException; import org.springframework.ws.WebServiceMessage; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - public abstract class AbstractSoapMessageFactoryTestCase extends AbstractWebServiceMessageFactoryTestCase { @Test 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 f317a0ea..87235c5c 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 @@ -16,17 +16,21 @@ package org.springframework.ws.soap; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayOutputStream; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; + import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import org.junit.Test; -import org.xml.sax.SAXParseException; - import org.springframework.core.io.Resource; import org.springframework.util.StringUtils; import org.springframework.ws.mime.AbstractMimeMessageTestCase; @@ -38,11 +42,7 @@ 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 static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.xml.sax.SAXParseException; public abstract class AbstractSoapMessageTestCase extends AbstractMimeMessageTestCase { @@ -64,8 +64,7 @@ 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) { fail(StringUtils.arrayToCommaDelimitedString(errors)); @@ -148,5 +147,4 @@ public abstract class AbstractSoapMessageTestCase extends AbstractMimeMessageTes @Test public abstract void testSetOtherDocument() throws Exception; - } 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 6993b2bf..dd7987a1 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 @@ -16,8 +16,12 @@ package org.springframework.ws.soap.addressing; +import static org.custommonkey.xmlunit.XMLUnit.*; +import static org.junit.Assert.*; + import java.io.IOException; import java.io.InputStream; + import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPConstants; @@ -25,12 +29,8 @@ import javax.xml.soap.SOAPException; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Before; -import org.w3c.dom.Document; - import org.springframework.ws.soap.saaj.SaajSoapMessage; - -import static org.custommonkey.xmlunit.XMLUnit.compareXML; -import static org.junit.Assert.*; +import org.w3c.dom.Document; public abstract class AbstractWsAddressingTestCase { @@ -42,7 +42,6 @@ public abstract class AbstractWsAddressingTestCase { XMLUnit.setIgnoreWhitespace(true); } - protected SaajSoapMessage loadSaajMessage(String fileName) throws SOAPException, IOException { MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addHeader("Content-Type", " application/soap+xml"); @@ -50,8 +49,7 @@ public abstract class AbstractWsAddressingTestCase { assertNotNull("Could not load " + fileName, is); try { return new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, is)); - } - finally { + } finally { is.close(); } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/AbstractActionCallbackTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/AbstractActionCallbackTestCase.java index 94d4e081..b57463ad 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/AbstractActionCallbackTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/client/AbstractActionCallbackTestCase.java @@ -16,7 +16,10 @@ package org.springframework.ws.soap.addressing.client; +import static org.easymock.EasyMock.*; + import java.net.URI; + import javax.xml.namespace.QName; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPBodyElement; @@ -27,7 +30,6 @@ import javax.xml.soap.SOAPMessage; import org.junit.After; import org.junit.Before; import org.junit.Test; - import org.springframework.ws.soap.addressing.AbstractWsAddressingTestCase; import org.springframework.ws.soap.addressing.core.EndpointReference; import org.springframework.ws.soap.addressing.messageid.MessageIdStrategy; @@ -38,8 +40,6 @@ import org.springframework.ws.transport.context.DefaultTransportContext; import org.springframework.ws.transport.context.TransportContext; import org.springframework.ws.transport.context.TransportContextHolder; -import static org.easymock.EasyMock.*; - public abstract class AbstractActionCallbackTestCase extends AbstractWsAddressingTestCase { private ActionCallback callback; @@ -117,4 +117,4 @@ public abstract class AbstractActionCallbackTestCase extends AbstractWsAddressin protected abstract String getTestPath(); -} \ No newline at end of file +} 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 c62b49b3..5c4c962e 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 @@ -30,4 +30,4 @@ public class ActionCallback200408Test extends AbstractActionCallbackTestCase { protected String getTestPath() { return "200408"; } -} \ No newline at end of file +} 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 0b6ddc39..ff6a864e 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 @@ -39,4 +39,4 @@ public class UuidMessageIdStrategyTest { Assert.assertNotNull("Empty messageId", messageId2); Assert.assertFalse("Equal messageIds", messageId1.equals(messageId2)); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AbstractAddressingInterceptorTestCase.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AbstractAddressingInterceptorTestCase.java index a1a169fd..4dd60fd9 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AbstractAddressingInterceptorTestCase.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/addressing/server/AbstractAddressingInterceptorTestCase.java @@ -16,10 +16,15 @@ package org.springframework.ws.soap.addressing.server; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + import java.net.URI; import java.util.Iterator; import java.util.Locale; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapHeaderElement; @@ -32,13 +37,6 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.WebServiceMessageSender; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public abstract class AbstractAddressingInterceptorTestCase extends AbstractWsAddressingTestCase { protected AddressingEndpointInterceptor interceptor; @@ -64,8 +62,7 @@ public abstract class AbstractAddressingInterceptorTestCase extends AbstractWsAd while (iterator.hasNext()) { SoapHeaderElement headerElement = iterator.next(); - assertTrue("Header [" + headerElement.getName() + " not understood", - interceptor.understands(headerElement)); + assertTrue("Header [" + headerElement.getName() + " not understood", interceptor.understands(headerElement)); } verify(strategyMock); @@ -173,9 +170,8 @@ public abstract class AbstractAddressingInterceptorTestCase extends AbstractWsAd URI replyAction = new URI("urn:replyAction"); URI faultAction = new URI("urn:replyAction"); - interceptor = - new AddressingEndpointInterceptor(getVersion(), strategyMock, new WebServiceMessageSender[]{senderMock}, - replyAction, faultAction); + interceptor = new AddressingEndpointInterceptor(getVersion(), strategyMock, + new WebServiceMessageSender[] { senderMock }, replyAction, faultAction); WebServiceConnection connectionMock = createMock(WebServiceConnection.class); 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 e59d0f98..58b781d4 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 @@ -16,6 +16,9 @@ package org.springframework.ws.soap.addressing.server; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + import java.net.URI; import org.springframework.ws.context.DefaultMessageContext; @@ -26,9 +29,6 @@ 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.easymock.EasyMock.*; -import static org.junit.Assert.assertTrue; - public class AddressingInterceptor10Test extends AbstractAddressingInterceptorTestCase { @Override @@ -56,4 +56,4 @@ public class AddressingInterceptor10Test extends AbstractAddressingInterceptorTe verify(strategyMock); } -} \ No newline at end of file +} 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 13ab060b..623e065f 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 @@ -16,6 +16,16 @@ package org.springframework.ws.soap.addressing.server; +import static org.junit.Assert.*; + +import java.io.IOException; +import java.io.InputStream; + +import javax.xml.soap.MessageFactory; +import javax.xml.soap.MimeHeaders; +import javax.xml.soap.SOAPConstants; +import javax.xml.soap.SOAPException; + import org.custommonkey.xmlunit.XMLUnit; import org.junit.Before; import org.junit.Test; @@ -32,15 +42,6 @@ import org.springframework.ws.soap.addressing.server.annotation.Address; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; -import javax.xml.soap.MessageFactory; -import javax.xml.soap.MimeHeaders; -import javax.xml.soap.SOAPConstants; -import javax.xml.soap.SOAPException; -import java.io.IOException; -import java.io.InputStream; - -import static org.junit.Assert.*; - /** * @author Arjen Poutsma * @author Nate Stoddard @@ -87,8 +88,7 @@ public class AnnotationActionMethodEndpointMappingTest { try { SaajSoapMessage message = new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, is)); return new DefaultMessageContext(message, new SaajSoapMessageFactory(messageFactory)); - } - finally { + } finally { is.close(); } } 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 b1387fd7..e0c7edfb 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 @@ -16,10 +16,14 @@ package org.springframework.ws.soap.addressing.server; +import static org.junit.Assert.*; + import java.net.URI; import java.util.HashMap; import java.util.Map; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; @@ -30,11 +34,6 @@ import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - public class SimpleActionEndpointMappingTest extends AbstractWsAddressingTestCase { private SimpleActionEndpointMapping mapping; @@ -49,8 +48,8 @@ public class SimpleActionEndpointMappingTest extends AbstractWsAddressingTestCas Endpoint2 endpoint2 = new Endpoint2(); map.put("http://example.com/fabrikam/mail/Delete", endpoint1); map.put("http://example.com/fabrikam/mail/Add", endpoint2); - mapping.setPreInterceptors(new EndpointInterceptor[]{new PayloadLoggingInterceptor()}); - mapping.setPostInterceptors(new EndpointInterceptor[]{new PayloadValidatingInterceptor()}); + mapping.setPreInterceptors(new EndpointInterceptor[] { new PayloadLoggingInterceptor() }); + mapping.setPostInterceptors(new EndpointInterceptor[] { new PayloadValidatingInterceptor() }); mapping.setAddress(new URI("mailto:fabrikam@example.com")); mapping.setActionMap(map); mapping.afterPropertiesSet(); @@ -87,4 +86,4 @@ public class SimpleActionEndpointMappingTest extends AbstractWsAddressingTestCas private static class Endpoint2 { } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java index 19e75473..c655d989 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java @@ -19,7 +19,6 @@ package org.springframework.ws.soap.axiom; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.soap.SOAPFactory; import org.junit.Test; - import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.soap11.AbstractSoap11BodyTestCase; diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11HeaderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11HeaderTest.java index 766a42dd..303991a9 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11HeaderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11HeaderTest.java @@ -31,6 +31,5 @@ public class AxiomSoap11HeaderTest extends AbstractSoap11HeaderTestCase { } @Override - public void testGetResult() throws Exception { - } + public void testGetResult() throws Exception {} } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java index dc06ba95..e503dfd1 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java @@ -16,15 +16,17 @@ package org.springframework.ws.soap.axiom; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.InputStream; + import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import org.custommonkey.xmlunit.XMLAssert; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Test; - import org.springframework.ws.InvalidXmlException; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; @@ -34,8 +36,6 @@ import org.springframework.ws.transport.TransportInputStream; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.junit.Assert.*; - public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTestCase { private Transformer transformer; @@ -60,8 +60,10 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory(); assertEquals("Invalid charset", "utf-8", messageFactory.getCharSetEncoding("text/html; charset=utf-8")); - assertEquals("Invalid charset", "utf-8", messageFactory.getCharSetEncoding("application/xop+xml;type=text/xml; charset=utf-8")); - assertEquals("Invalid charset", "utf-8", messageFactory.getCharSetEncoding("application/xop+xml;type=\"text/xml; charset=utf-8\"")); + assertEquals("Invalid charset", "utf-8", + messageFactory.getCharSetEncoding("application/xop+xml;type=text/xml; charset=utf-8")); + assertEquals("Invalid charset", "utf-8", + messageFactory.getCharSetEncoding("application/xop+xml;type=\"text/xml; charset=utf-8\"")); } @Test @@ -70,9 +72,8 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT messageFactory.setPayloadCaching(true); messageFactory.afterPropertiesSet(); - String xml = "" + - "" + - ""; + String xml = "" + + "" + ""; TransportInputStream tis = new MockTransportInputStream(new ByteArrayInputStream(xml.getBytes())); WebServiceMessage message = messageFactory.createWebServiceMessage(tis); @@ -87,9 +88,8 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT messageFactory.setPayloadCaching(false); messageFactory.afterPropertiesSet(); - String xml = "" + - "" + - ""; + String xml = "" + + "" + ""; TransportInputStream tis = new MockTransportInputStream(new ByteArrayInputStream(xml.getBytes())); WebServiceMessage message = messageFactory.createWebServiceMessage(tis); @@ -98,8 +98,7 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT try { transformer.transform(message.getPayloadSource(), result); fail("TransformerException expected"); - } - catch (TransformerException expected) { + } catch (TransformerException expected) { // ignore } } @@ -113,15 +112,13 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT messageFactory.setPayloadCaching(false); messageFactory.afterPropertiesSet(); - String envelope = - "" + - "" + - "" + - "" + "" + - "true" + "0" + - "ok]]]]>>" + - "]]>" + "" + - ""; + String envelope = "" + + "" + + "" + + "" + "" + "true" + + "0" + + "ok]]]]>>" + + "]]>" + "" + ""; InputStream inputStream = new ByteArrayInputStream(envelope.getBytes("UTF-8")); AxiomSoapMessage message = messageFactory.createWebServiceMessage(new MockTransportInputStream(inputStream)); @@ -130,15 +127,14 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT transformer.transform(message.getPayloadSource(), result); XMLUnit.setIgnoreWhitespace(true); - String expectedPayload = - "" + - "" + - "" + "" + - "true" + "0" + - "ok]]]]>>" + - "]]>" + ""; + String expectedPayload = "" + + "" + + "" + "" + "true" + + "0" + + "ok]]]]>>" + + "]]>" + ""; XMLAssert.assertXMLEqual(expectedPayload, result.toString()); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11NonCachingMessageTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11NonCachingMessageTest.java index a0ca15d8..7a7345ff 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11NonCachingMessageTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11NonCachingMessageTest.java @@ -16,15 +16,14 @@ package org.springframework.ws.soap.axiom; -import org.apache.axiom.om.OMSourcedElement; +import static org.junit.Assert.*; +import org.apache.axiom.om.OMSourcedElement; import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.soap11.AbstractSoap11MessageTestCase; -import static org.junit.Assert.*; - public class AxiomSoap11NonCachingMessageTest extends AbstractSoap11MessageTestCase { @Override @@ -46,8 +45,7 @@ public class AxiomSoap11NonCachingMessageTest extends AbstractSoap11MessageTestC super.testWriteToTransportOutputStream(); SoapBody body = soapMessage.getSoapBody(); - OMSourcedElement axiomPayloadEle = - (OMSourcedElement) ((AxiomSoapBody) body).getAxiomElement().getFirstElement(); + OMSourcedElement axiomPayloadEle = (OMSourcedElement) ((AxiomSoapBody) body).getAxiomElement().getFirstElement(); assertFalse("Non-cached body should not be expanded now", axiomPayloadEle.isExpanded()); axiomPayloadEle.getFirstElement(); assertTrue("Non-cached body should now be expanded", axiomPayloadEle.isExpanded()); diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12BodyTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12BodyTest.java index c1f78409..c9b45220 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12BodyTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12BodyTest.java @@ -19,7 +19,6 @@ package org.springframework.ws.soap.axiom; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.soap.SOAPFactory; import org.junit.Test; - import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.soap12.AbstractSoap12BodyTestCase; diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12HeaderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12HeaderTest.java index 0aeba450..7335fa9f 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12HeaderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12HeaderTest.java @@ -31,6 +31,5 @@ public class AxiomSoap12HeaderTest extends AbstractSoap12HeaderTestCase { } @Override - public void testGetResult() throws Exception { - } + public void testGetResult() throws Exception {} } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12MessageTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12MessageTest.java index 00ee7e85..2a3c89d2 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12MessageTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12MessageTest.java @@ -34,4 +34,4 @@ public class AxiomSoap12MessageTest extends AbstractSoap12MessageTestCase { return new AxiomSoapMessage(axiomFactory); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12NonCachingMessageTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12NonCachingMessageTest.java index 1385b4ad..6acca36c 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12NonCachingMessageTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12NonCachingMessageTest.java @@ -16,15 +16,14 @@ package org.springframework.ws.soap.axiom; -import org.apache.axiom.om.OMSourcedElement; +import static org.junit.Assert.*; +import org.apache.axiom.om.OMSourcedElement; import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.soap12.AbstractSoap12MessageTestCase; -import static org.junit.Assert.*; - public class AxiomSoap12NonCachingMessageTest extends AbstractSoap12MessageTestCase { @Override @@ -46,8 +45,7 @@ public class AxiomSoap12NonCachingMessageTest extends AbstractSoap12MessageTestC super.testWriteToTransportOutputStream(); SoapBody body = soapMessage.getSoapBody(); - OMSourcedElement axiomPayloadEle = - (OMSourcedElement) ((AxiomSoapBody) body).getAxiomElement().getFirstElement(); + OMSourcedElement axiomPayloadEle = (OMSourcedElement) ((AxiomSoapBody) body).getAxiomElement().getFirstElement(); assertFalse("Non-cached body should not be expanded now", axiomPayloadEle.isExpanded()); axiomPayloadEle.getFirstElement(); assertTrue("Non-cached body should now be expanded", axiomPayloadEle.isExpanded()); diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java index 0ecb7313..00639f02 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java @@ -18,37 +18,31 @@ package org.springframework.ws.soap.axiom; import java.io.StringReader; -import org.springframework.ws.soap.SoapFault; -import org.springframework.ws.soap.SoapFaultDetail; import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axiom.soap.SOAPMessage; import org.apache.axiom.soap.SOAPModelBuilder; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.ws.soap.SoapFault; +import org.springframework.ws.soap.SoapFaultDetail; @SuppressWarnings("Since15") public class AxiomSoapFaultDetailTest { - private static final String FAILING_FAULT = - "\n " + "\n " + - "\n " + "Client\n " + - "Client Error\n " + "\n " + - "\n " + - "\n " + "" + "" + - "" + "" + ""; + private static final String FAILING_FAULT = "\n " + "\n " + "\n " + + "Client\n " + "Client Error\n " + "\n " + + "\n " + "\n " + + "" + "" + "" + "" + ""; - private static final String SUCCEEDING_FAULT = - "\n " + "\n " + - "\n " + "Client\n " + - "Client Error\n " + "" + - "\n " + - "\n " + "" + "" + - "" + "" + ""; + private static final String SUCCEEDING_FAULT = "\n " + "\n " + "\n " + + "Client\n " + "Client Error\n " + "" + + "\n " + "\n " + + "" + "" + "" + "" + ""; private AxiomSoapMessage failingMessage; @@ -89,4 +83,4 @@ public class AxiomSoapFaultDetailTest { detail.getDetailEntries().next(); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/NonCachingPayloadTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/NonCachingPayloadTest.java index fa096d3f..892dba64 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/NonCachingPayloadTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/NonCachingPayloadTest.java @@ -16,18 +16,18 @@ package org.springframework.ws.soap.axiom; -import java.io.StringWriter; -import javax.xml.stream.XMLStreamWriter; +import static org.custommonkey.xmlunit.XMLAssert.*; -import org.springframework.util.xml.StaxUtils; +import java.io.StringWriter; + +import javax.xml.stream.XMLStreamWriter; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.soap.SOAPBody; import org.apache.axiom.soap.SOAPFactory; import org.junit.Before; import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import org.springframework.util.xml.StaxUtils; @SuppressWarnings("Since15") public class NonCachingPayloadTest { @@ -60,9 +60,8 @@ public class NonCachingPayloadTest { StringWriter writer = new StringWriter(); body.serialize(writer); - String expected = "" + - "" + "text" + "" - ; + String expected = "" + + "" + "text" + ""; assertXMLEqual(expected, writer.toString()); } @@ -82,9 +81,8 @@ public class NonCachingPayloadTest { StringWriter writer = new StringWriter(); body.serialize(writer); - String expected = "" + - "" + "text" + "" - ; + String expected = "" + + "" + "text" + ""; assertXMLEqual(expected, writer.toString()); } @@ -103,8 +101,8 @@ public class NonCachingPayloadTest { StringWriter writer = new StringWriter(); body.serialize(writer); - String expected = "" + - "" + "" + ""; + String expected = "" + + "" + "" + ""; assertXMLEqual(expected, writer.toString()); } } diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/support/AxiomUtilsTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/support/AxiomUtilsTest.java index a3b08035..b6141959 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/support/AxiomUtilsTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/axiom/support/AxiomUtilsTest.java @@ -16,8 +16,11 @@ package org.springframework.ws.soap.axiom.support; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.StringWriter; import java.util.Locale; + import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -34,15 +37,12 @@ import org.custommonkey.xmlunit.XMLUnit; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.w3c.dom.Document; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.util.FileCopyUtils; -import org.springframework.xml.sax.SaxUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; +import org.springframework.xml.sax.SaxUtils; +import org.w3c.dom.Document; public class AxiomUtilsTest { 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 6caff600..dfd5f9d4 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,33 +1,33 @@ package org.springframework.ws.soap.client.core; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.*; + import java.io.IOException; + import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPException; import org.junit.Before; import org.junit.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.hamcrest.CoreMatchers.*; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.*; - public class SaajSoapActionCallbackTest { - + private SaajSoapMessageFactory saaj11Factory = new SaajSoapMessageFactory(); - + private SaajSoapMessageFactory saaj12Factory = new SaajSoapMessageFactory(); - + @Before public void init() throws SOAPException { MessageFactory messageFactory11 = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); - + saaj11Factory.setSoapVersion(SoapVersion.SOAP_11); saaj11Factory.setMessageFactory(messageFactory11); saaj11Factory.afterPropertiesSet(); @@ -37,64 +37,70 @@ public class SaajSoapActionCallbackTest { saaj12Factory.setMessageFactory(messageFactory12); saaj12Factory.afterPropertiesSet(); } - + @Test public void noSoapAction11ShouldProduceEmptySoapActionHeader() throws IOException { 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.length, is(1)); assertThat(soapActionHeaders[0], is("\"\"")); } - + @Test public void soapAction11ShouldProduceSoapActionHeader() throws IOException { 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.length, is(1)); assertThat(soapActionHeaders[0], is("\"testAction\"")); } - + @Test public void emptySoapAction11() throws IOException { 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.length, is(1)); assertThat(soapActionHeaders[0], is("\"\"")); } - + @Test public void noSoapAction12() throws IOException { 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, is(nullValue())); } - + @Test public void soapAction12ShouldProduceNoSoapActionHeader() throws IOException { SaajSoapMessage message = saaj12Factory.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); String[] contentTypes = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_CONTENT_TYPE); assertThat(soapActionHeaders, is(nullValue())); assertThat(SoapUtils.extractActionFromContentType(contentTypes[0]), is("\"testAction\"")); } - + @Test public void emptySoapAction12ShouldProduceNoSoapActionHeader() throws IOException { SaajSoapMessage message = saaj12Factory.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); String[] contentTypes = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_CONTENT_TYPE); assertThat(soapActionHeaders, is(nullValue())); 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 39fa04a7..80593c04 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 @@ -16,20 +16,19 @@ package org.springframework.ws.soap.saaj; +import static org.junit.Assert.*; + import java.util.Locale; + import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPMessage; +import org.junit.Test; import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.soap11.AbstractSoap11BodyTestCase; -import org.junit.Test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - public class SaajSoap11BodyTest extends AbstractSoap11BodyTestCase { @Override @@ -57,5 +56,4 @@ public class SaajSoap11BodyTest extends AbstractSoap11BodyTestCase { assertNull("Language set", saajSoapBody.getFault().getFaultStringLocale()); } - } 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 88ece505..a9b06141 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 @@ -16,22 +16,22 @@ package org.springframework.ws.soap.saaj; +import static org.junit.Assert.*; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Collections; import java.util.Map; + import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPMessage; +import org.junit.Test; import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.soap11.AbstractSoap11MessageFactoryTestCase; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - public class SaajSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTestCase { @Override @@ -43,7 +43,7 @@ public class SaajSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTe @Test public void properties() throws IOException { Map properties = Collections.singletonMap(SOAPMessage.WRITE_XML_DECLARATION, "true"); - ((SaajSoapMessageFactory)messageFactory).setMessageProperties(properties); + ((SaajSoapMessageFactory) messageFactory).setMessageProperties(properties); SoapMessage soapMessage = (SoapMessage) messageFactory.createWebServiceMessage(); ByteArrayOutputStream os = new ByteArrayOutputStream(); soapMessage.writeTo(os); @@ -51,5 +51,4 @@ public class SaajSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTe assertTrue("XML declaration not written", result.startsWith("" + - "Content"; + String content = "" + + "Content"; Source source = new StringSource(content); Result result = new SAXResult(handler); transformer.transform(source, result); @@ -72,4 +72,4 @@ public class SaajContentHandlerTest { Name attributeName = envelope.createName("attribute"); Assert.assertEquals("Invalid attribute value", "value", childElement.getAttributeValue(attributeName)); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/support/SaajUtilsTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/support/SaajUtilsTest.java index 88186b77..58b31df3 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/support/SaajUtilsTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/support/SaajUtilsTest.java @@ -16,7 +16,10 @@ package org.springframework.ws.soap.saaj.support; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.InputStream; + import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -30,14 +33,11 @@ import javax.xml.soap.SOAPMessage; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.w3c.dom.Document; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.util.StringUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; +import org.w3c.dom.Document; public class SaajUtilsTest { @@ -124,8 +124,8 @@ public class SaajUtilsTest { factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(getClass().getResourceAsStream("soapMessage.xml")); - SOAPMessage soapMessage = - SaajUtils.loadMessage(new ClassPathResource("soapMessage.xml", getClass()), messageFactory); + SOAPMessage soapMessage = SaajUtils.loadMessage(new ClassPathResource("soapMessage.xml", getClass()), + messageFactory); assertXMLEqual(soapMessage.getSOAPPart(), document); } @@ -143,4 +143,4 @@ public class SaajUtilsTest { SaajUtils.getSaajVersion(soapMessage); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/support/SaajXmlReaderTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/support/SaajXmlReaderTest.java index e8d44c57..307ae06b 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/support/SaajXmlReaderTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/saaj/support/SaajXmlReaderTest.java @@ -16,6 +16,8 @@ package org.springframework.ws.soap.saaj.support; +import static org.custommonkey.xmlunit.XMLAssert.*; + import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPMessage; @@ -27,13 +29,10 @@ import javax.xml.transform.sax.SAXSource; import org.junit.Before; import org.junit.Test; +import org.springframework.xml.transform.TransformerFactoryUtils; import org.w3c.dom.Document; import org.xml.sax.InputSource; -import org.springframework.xml.transform.TransformerFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; - public class SaajXmlReaderTest { private SaajXmlReader saajReader; @@ -74,4 +73,4 @@ public class SaajXmlReaderTest { transformer.transform(new DOMSource(message.getSOAPPart().getEnvelope()), expected); assertXMLEqual((Document) expected.getNode(), (Document) result.getNode()); } -} \ No newline at end of file +} diff --git a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/SoapMessageDispatcherTest.java b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/SoapMessageDispatcherTest.java index 6003566c..c41062e5 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/soap/server/SoapMessageDispatcherTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/soap/server/SoapMessageDispatcherTest.java @@ -16,14 +16,20 @@ package org.springframework.ws.soap.server; +import static org.easymock.EasyMock.*; + import java.util.Iterator; import java.util.Locale; + import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPHeaderElement; import javax.xml.soap.SOAPMessage; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapBody; @@ -36,12 +42,6 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.soap11.Soap11Fault; import org.springframework.ws.soap.soap12.Soap12Fault; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class SoapMessageDispatcherTest { private SoapMessageDispatcher dispatcher; @@ -58,8 +58,8 @@ public class SoapMessageDispatcherTest { public void testProcessMustUnderstandHeadersUnderstoodSoap11() throws Exception { 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")); + SOAPHeaderElement header = request.getSOAPHeader() + .addHeaderElement(new QName("http://www.springframework.org", "Header")); header.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT); header.setMustUnderstand(true); SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory); @@ -68,8 +68,8 @@ public class SoapMessageDispatcherTest { replay(interceptorMock); - SoapEndpointInvocationChain chain = - new SoapEndpointInvocationChain(new Object(), new SoapEndpointInterceptor[]{interceptorMock}); + SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), + new SoapEndpointInterceptor[] { interceptorMock }); boolean result = dispatcher.handleRequest(chain, context); Assert.assertTrue("Header not understood", result); @@ -81,8 +81,8 @@ public class SoapMessageDispatcherTest { public void testProcessMustUnderstandHeadersUnderstoodSoap12() throws Exception { 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")); + SOAPHeaderElement header = request.getSOAPHeader() + .addHeaderElement(new QName("http://www.springframework.org", "Header")); header.setMustUnderstand(true); header.setRole(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT); SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory); @@ -91,8 +91,8 @@ public class SoapMessageDispatcherTest { replay(interceptorMock); - SoapEndpointInvocationChain chain = - new SoapEndpointInvocationChain(new Object(), new SoapEndpointInterceptor[]{interceptorMock}); + SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), + new SoapEndpointInterceptor[] { interceptorMock }); boolean result = dispatcher.handleRequest(chain, context); Assert.assertTrue("Header not understood", result); @@ -114,8 +114,8 @@ public class SoapMessageDispatcherTest { replay(interceptorMock); - SoapEndpointInvocationChain chain = - new SoapEndpointInvocationChain(new Object(), new SoapEndpointInterceptor[]{interceptorMock}); + SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), + new SoapEndpointInterceptor[] { interceptorMock }); boolean result = dispatcher.handleRequest(chain, context); Assert.assertFalse("Header understood", result); @@ -146,8 +146,8 @@ public class SoapMessageDispatcherTest { replay(interceptorMock); - SoapEndpointInvocationChain chain = - new SoapEndpointInvocationChain(new Object(), new SoapEndpointInterceptor[]{interceptorMock}); + SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), + new SoapEndpointInterceptor[] { interceptorMock }); boolean result = dispatcher.handleRequest(chain, context); Assert.assertFalse("Header understood", result); @@ -164,8 +164,8 @@ public class SoapMessageDispatcherTest { Iterator iterator = responseHeader.examineAllHeaderElements(); Assert.assertTrue("Response header has no elements", iterator.hasNext()); SoapHeaderElement headerElement = iterator.next(); - Assert.assertEquals("No NotUnderstood header", - new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood"), headerElement.getName()); + Assert.assertEquals("No NotUnderstood header", new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood"), + headerElement.getName()); verify(interceptorMock); } @@ -186,7 +186,7 @@ public class SoapMessageDispatcherTest { replay(interceptorMock); SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), - new SoapEndpointInterceptor[]{interceptorMock}, new String[]{headerActor}, true); + new SoapEndpointInterceptor[] { interceptorMock }, new String[] { headerActor }, true); boolean result = dispatcher.handleRequest(chain, context); Assert.assertTrue("actor-specific header not understood", result); @@ -210,7 +210,7 @@ public class SoapMessageDispatcherTest { replay(interceptorMock); SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), - new SoapEndpointInterceptor[]{interceptorMock}, new String[]{headerRole}, true); + new SoapEndpointInterceptor[] { interceptorMock }, new String[] { headerRole }, true); boolean result = dispatcher.handleRequest(chain, context); Assert.assertTrue("role-specific header not understood", result); @@ -228,7 +228,7 @@ public class SoapMessageDispatcherTest { replay(interceptorMock); SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), - new SoapEndpointInterceptor[]{interceptorMock}, new String[]{"role"}, true); + new SoapEndpointInterceptor[] { interceptorMock }, new String[] { "role" }, true); boolean result = dispatcher.handleRequest(chain, context); Assert.assertTrue("Invalid result", result); @@ -239,8 +239,8 @@ public class SoapMessageDispatcherTest { public void testProcessMustUnderstandHeadersNoInterceptors() throws Exception { 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")); + SOAPHeaderElement header = request.getSOAPHeader() + .addHeaderElement(new QName("http://www.springframework.org", "Header")); header.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT); header.setMustUnderstand(true); SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory); @@ -254,4 +254,4 @@ public class SoapMessageDispatcherTest { verify(interceptorMock); } -} \ No newline at end of file +} 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 a190d6db..f21310ca 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 @@ -18,6 +18,7 @@ package org.springframework.ws.soap.server.endpoint; import java.io.IOException; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.soap.Detail; import javax.xml.soap.DetailEntry; @@ -30,7 +31,6 @@ import javax.xml.transform.Source; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; @@ -56,8 +56,8 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage request = messageFactory.createMessage(); request.getSOAPBody().addBodyElement(new QName("http://www.springframework.org/spring-ws", "request")); - messageContext = - new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory)); + messageContext = new DefaultMessageContext(new SaajSoapMessage(request), + new SaajSoapMessageFactory(messageFactory)); } @Test @@ -65,15 +65,14 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { Person p = new Person("", -1); PersonMarshaller marshaller = new PersonMarshaller(p); - AbstractFaultCreatingValidatingMarshallingPayloadEndpoint endpoint = - new AbstractFaultCreatingValidatingMarshallingPayloadEndpoint() { + AbstractFaultCreatingValidatingMarshallingPayloadEndpoint endpoint = new AbstractFaultCreatingValidatingMarshallingPayloadEndpoint() { - @Override - protected Object invokeInternal(Object requestObject) throws Exception { - Assert.fail("No expected"); - return null; - } - }; + @Override + protected Object invokeInternal(Object requestObject) throws Exception { + Assert.fail("No expected"); + return null; + } + }; endpoint.setValidator(new PersonValidator()); endpoint.setMessageSource(messageSource); endpoint.setMarshaller(marshaller); @@ -107,14 +106,13 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { public void testValidationCorrect() throws Exception { Person p = new Person("John", 42); PersonMarshaller marshaller = new PersonMarshaller(p); - AbstractFaultCreatingValidatingMarshallingPayloadEndpoint endpoint = - new AbstractFaultCreatingValidatingMarshallingPayloadEndpoint() { + AbstractFaultCreatingValidatingMarshallingPayloadEndpoint endpoint = new AbstractFaultCreatingValidatingMarshallingPayloadEndpoint() { - @Override - protected Object invokeInternal(Object requestObject) throws Exception { - return null; - } - }; + @Override + protected Object invokeInternal(Object requestObject) throws Exception { + return null; + } + }; endpoint.setValidator(new PersonValidator()); endpoint.setMessageSource(messageSource); endpoint.setMarshaller(marshaller); @@ -139,8 +137,7 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { Person p = (Person) obj; 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"); } } @@ -197,8 +194,7 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest { } @Override - public void marshal(Object graph, Result result) throws XmlMappingException, IOException { - } + public void marshal(Object graph, Result result) throws XmlMappingException, IOException {} } -} \ No newline at end of file +} 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 b94927ac..f960cb22 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 @@ -16,8 +16,13 @@ package org.springframework.ws.soap.server.endpoint; +import static org.easymock.EasyMock.*; + import java.util.Locale; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -25,12 +30,6 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.soap11.Soap11Body; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class SimpleSoapExceptionResolverTest { private SimpleSoapExceptionResolver exceptionResolver; @@ -66,4 +65,4 @@ public class SimpleSoapExceptionResolverTest { verify(factoryMock, messageMock, bodyMock); } -} \ No newline at end of file +} 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 cd2e8ff3..f5f30c24 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.server.endpoint; import java.util.Locale; + import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; @@ -25,7 +26,6 @@ import javax.xml.soap.SOAPMessage; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; @@ -246,5 +246,4 @@ public class SoapFaultAnnotationExceptionResolverTest { } - -} \ No newline at end of file +} 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 f047252f..70b78d93 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.server.endpoint; import java.util.Locale; + import javax.xml.namespace.QName; import org.junit.Assert; @@ -74,9 +75,7 @@ public class SoapFaultDefinitionEditorTest { public void testSetAsTextIllegalArgument() throws Exception { try { editor.setAsText("SOAP-ENV:Server"); - } - catch (IllegalArgumentException ex) { - } + } catch (IllegalArgumentException ex) {} } @Test @@ -84,4 +83,4 @@ public class SoapFaultDefinitionEditorTest { editor.setAsText(""); Assert.assertNull("definition not set to null", editor.getValue()); } -} \ No newline at end of file +} 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 6fb8fd61..d2c088e9 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 @@ -19,10 +19,14 @@ package org.springframework.ws.soap.server.endpoint; import java.io.IOException; import java.util.Locale; import java.util.Properties; + import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPMessage; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; @@ -34,10 +38,6 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.soap11.Soap11Fault; import org.springframework.ws.soap.soap12.Soap12Fault; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class SoapFaultMappingExceptionResolverTest { private SoapFaultMappingExceptionResolver resolver; @@ -213,5 +213,4 @@ public class SoapFaultMappingExceptionResolverTest { Assert.assertNull("Detail on fault", fault.getFaultDetail()); } - -} \ No newline at end of file +} 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 14ed4483..7b6e4f48 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 @@ -16,9 +16,14 @@ package org.springframework.ws.soap.server.endpoint.adapter.method; +import static org.junit.Assert.*; + import java.util.List; + import javax.xml.namespace.QName; +import org.junit.Before; +import org.junit.Test; import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.adapter.method.AbstractMethodArgumentResolverTestCase; @@ -26,11 +31,6 @@ import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.server.endpoint.annotation.SoapHeader; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - /** * @author Tareq Abedrabbo */ @@ -63,21 +63,18 @@ public class SoapHeaderElementMethodArgumentResolverTest extends AbstractMethodA SoapHeaderElement element = message.getSoapHeader().addHeaderElement(HEADER_QNAME); element.setText(HEADER_CONTENT + i); } - soapHeaderWithEmptyValue = - new MethodParameter(getClass().getMethod("soapHeaderWithEmptyValue", SoapHeaderElement.class), 0); - 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); + soapHeaderWithEmptyValue = new MethodParameter( + getClass().getMethod("soapHeaderWithEmptyValue", SoapHeaderElement.class), 0); + 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); soapHeaderMismatchList = new MethodParameter(getClass().getMethod("soapHeaderMismatchList", List.class), 0); } @Test public void supportsParameter() throws Exception { - assertTrue("resolver does not support soapHeaderElement", - resolver.supportsParameter(soapHeaderElementParameter)); + assertTrue("resolver does not support soapHeaderElement", resolver.supportsParameter(soapHeaderElementParameter)); assertTrue("resolver does not support List", resolver.supportsParameter(soapHeaderElementListParameter)); } @@ -130,22 +127,16 @@ public class SoapHeaderElementMethodArgumentResolverTest extends AbstractMethodA assertTrue("result List must be empty", ((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) { - } + public void soapHeaderElementList( + @SoapHeader("{http://springframework.org/ws}header") List elements) {} - public void soapHeaderMismatch(@SoapHeader("{http://springframework.org/ws}xxx") SoapHeaderElement element) { - } - - public void soapHeaderMismatchList(@SoapHeader( - "{http://springframework.org/ws}xxx") List elements) { - } + public void soapHeaderMismatch(@SoapHeader("{http://springframework.org/ws}xxx") SoapHeaderElement element) {} + public void soapHeaderMismatchList( + @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 b99f830c..e8b10b05 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 @@ -16,6 +16,10 @@ package org.springframework.ws.soap.server.endpoint.adapter.method; +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; import org.springframework.core.MethodParameter; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.adapter.method.AbstractMethodArgumentResolverTestCase; @@ -24,12 +28,6 @@ import org.springframework.ws.soap.SoapEnvelope; import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapMessage; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** @author Arjen Poutsma */ public class SoapMethodArgumentResolverTest extends AbstractMethodArgumentResolverTestCase { @@ -75,7 +73,7 @@ public class SoapMethodArgumentResolverTest extends AbstractMethodArgumentResolv Object result = resolver.resolveArgument(messageContext, soapEnvelopeParameter); - assertEquals(((SoapMessage)messageContext.getRequest()).getEnvelope(), result); + assertEquals(((SoapMessage) messageContext.getRequest()).getEnvelope(), result); } @Test @@ -84,7 +82,7 @@ public class SoapMethodArgumentResolverTest extends AbstractMethodArgumentResolv Object result = resolver.resolveArgument(messageContext, soapBodyParameter); - assertEquals(((SoapMessage)messageContext.getRequest()).getSoapBody(), result); + assertEquals(((SoapMessage) messageContext.getRequest()).getSoapBody(), result); } @Test @@ -93,19 +91,16 @@ public class SoapMethodArgumentResolverTest extends AbstractMethodArgumentResolv Object result = resolver.resolveArgument(messageContext, soapHeaderParameter); - assertEquals(((SoapMessage)messageContext.getRequest()).getSoapHeader(), result); + assertEquals(((SoapMessage) messageContext.getRequest()).getSoapHeader(), result); } public void soapMessage(SoapMessage soapMessage) { } - 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 48491e87..859cf64d 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 @@ -16,6 +16,10 @@ package org.springframework.ws.soap.server.endpoint.interceptor; +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -23,12 +27,6 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.server.endpoint.interceptor.EndpointInterceptorAdapter; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class PayloadRootSmartSoapEndpointInterceptorTest { private EndpointInterceptor delegate; @@ -57,8 +55,8 @@ public class PayloadRootSmartSoapEndpointInterceptorTest { @Test public void shouldInterceptFullMatch() throws Exception { - PayloadRootSmartSoapEndpointInterceptor interceptor = - new PayloadRootSmartSoapEndpointInterceptor(delegate, namespaceUri, localPart); + PayloadRootSmartSoapEndpointInterceptor interceptor = new PayloadRootSmartSoapEndpointInterceptor(delegate, + namespaceUri, localPart); boolean result = interceptor.shouldIntercept(messageContext, null); assertTrue("Interceptor should apply", result); @@ -66,8 +64,8 @@ public class PayloadRootSmartSoapEndpointInterceptorTest { @Test public void shouldInterceptFullNonMatch() throws Exception { - PayloadRootSmartSoapEndpointInterceptor interceptor = - new PayloadRootSmartSoapEndpointInterceptor(delegate, "http://springframework.org/other", localPart); + PayloadRootSmartSoapEndpointInterceptor interceptor = new PayloadRootSmartSoapEndpointInterceptor(delegate, + "http://springframework.org/other", localPart); boolean result = interceptor.shouldIntercept(messageContext, null); assertFalse("Interceptor should not apply", result); @@ -75,17 +73,17 @@ public class PayloadRootSmartSoapEndpointInterceptorTest { @Test public void shouldInterceptNamespaceUriMatch() throws Exception { - PayloadRootSmartSoapEndpointInterceptor interceptor = - new PayloadRootSmartSoapEndpointInterceptor(delegate, namespaceUri, null); + PayloadRootSmartSoapEndpointInterceptor interceptor = new PayloadRootSmartSoapEndpointInterceptor(delegate, + namespaceUri, null); boolean result = interceptor.shouldIntercept(messageContext, null); assertTrue("Interceptor should apply", result); } - + @Test public void shouldInterceptNamespaceUriNonMatch() throws Exception { - PayloadRootSmartSoapEndpointInterceptor interceptor = - new PayloadRootSmartSoapEndpointInterceptor(delegate, "http://springframework.org/other", null); + PayloadRootSmartSoapEndpointInterceptor interceptor = new PayloadRootSmartSoapEndpointInterceptor(delegate, + "http://springframework.org/other", null); boolean result = interceptor.shouldIntercept(messageContext, null); assertFalse("Interceptor should not apply", result); 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 51ba760e..72b8c606 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 @@ -16,24 +16,22 @@ package org.springframework.ws.soap.server.endpoint.interceptor; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.Locale; + import javax.xml.XMLConstants; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPMessage; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.helpers.LocatorImpl; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.ws.MockWebServiceMessage; @@ -54,8 +52,9 @@ import org.springframework.ws.transport.TransportInputStream; import org.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.validation.ValidationErrorHandler; import org.springframework.xml.xsd.SimpleXsdSchema; - -import static org.custommonkey.xmlunit.XMLAssert.*; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.LocatorImpl; public class PayloadValidatingInterceptorTest { @@ -205,8 +204,8 @@ public class PayloadValidatingInterceptorTest { 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 // See http://opensource.atlassian.com/projects/spring/browse/SWS-35 - String previousSchemaFactory = - System.getProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, ""); + String previousSchemaFactory = System + .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 { @@ -214,16 +213,14 @@ public class PayloadValidatingInterceptorTest { interceptor.setSchema(new ClassPathResource(SCHEMA2, PayloadValidatingInterceptorTest.class)); interceptor.afterPropertiesSet(); MessageFactory messageFactory = MessageFactory.newInstance(); - SOAPMessage saajMessage = - SaajUtils.loadMessage(new ClassPathResource(VALID_SOAP_MESSAGE, getClass()), messageFactory); - context = new DefaultMessageContext(new SaajSoapMessage(saajMessage), - new SaajSoapMessageFactory(messageFactory)); + SOAPMessage saajMessage = SaajUtils.loadMessage(new ClassPathResource(VALID_SOAP_MESSAGE, getClass()), + messageFactory); + context = new DefaultMessageContext(new SaajSoapMessage(saajMessage), new SaajSoapMessageFactory(messageFactory)); boolean result = interceptor.handleRequest(context, null); Assert.assertTrue("Invalid response from interceptor", result); Assert.assertFalse("Response set", context.hasResponse()); - } - finally { + } finally { // Reset the property System.setProperty("javax.xml.validation.SchemaFactory:" + XMLConstants.W3C_XML_SCHEMA_NS_URI, previousSchemaFactory); @@ -236,8 +233,7 @@ public class PayloadValidatingInterceptorTest { interceptor.setSchema(new ClassPathResource("invalid")); interceptor.afterPropertiesSet(); Assert.fail("IllegalArgumentException expected"); - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { // expected } } @@ -297,19 +293,18 @@ public class PayloadValidatingInterceptorTest { LocatorImpl locator = new LocatorImpl(); locator.setLineNumber(0); locator.setColumnNumber(0); - SAXParseException[] exceptions = new SAXParseException[]{new SAXParseException("Message 1", locator), - new SAXParseException("Message 2", locator),}; + SAXParseException[] exceptions = new SAXParseException[] { new SAXParseException("Message 1", locator), + new SAXParseException("Message 2", locator), }; MessageContext messageContext = new DefaultMessageContext(new AxiomSoapMessageFactory()); interceptor.handleRequestValidationErrors(messageContext, exceptions); ByteArrayOutputStream os = new ByteArrayOutputStream(); messageContext.getResponse().writeTo(os); - assertXMLEqual( - "" + "" + "" + - "" + "soapenv:Client" + - "Validation error" + "" + - "Message 1" + - "Message 2" + - "" + "" + "" + "", os.toString()); + assertXMLEqual("" + + "" + "" + "" + "soapenv:Client" + + "Validation error" + "" + + "Message 1" + + "Message 2" + + "" + "" + "" + "", os.toString()); } @@ -375,14 +370,11 @@ 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); SoapMessage invalidMessage = soap11Factory.createWebServiceMessage(); @@ -395,4 +387,4 @@ public class PayloadValidatingInterceptorTest { Assert.assertFalse("Context has response", context.hasResponse()); } -} \ No newline at end of file +} 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 79c47a73..ba429f4e 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 @@ -16,6 +16,10 @@ package org.springframework.ws.soap.server.endpoint.interceptor; +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; @@ -23,12 +27,6 @@ import org.springframework.ws.server.endpoint.interceptor.EndpointInterceptorAda import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class SoapActionSmartEndpointInterceptorTest { private EndpointInterceptor delegate; @@ -65,12 +63,11 @@ public class SoapActionSmartEndpointInterceptorTest { @Test public void shouldInterceptNonMatch() throws Exception { - SoapActionSmartEndpointInterceptor interceptor = - new SoapActionSmartEndpointInterceptor(delegate, "http://springframework.org/other"); + SoapActionSmartEndpointInterceptor interceptor = new SoapActionSmartEndpointInterceptor(delegate, + "http://springframework.org/other"); boolean result = interceptor.shouldIntercept(messageContext, null); assertFalse("Interceptor should apply", result); } - } 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 9e2fbb4d..f8474126 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 @@ -16,6 +16,11 @@ package org.springframework.ws.soap.server.endpoint.mapping; +import static org.easymock.EasyMock.*; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; @@ -23,12 +28,6 @@ import org.springframework.ws.server.EndpointInvocationChain; import org.springframework.ws.server.EndpointMapping; import org.springframework.ws.soap.server.SoapEndpointInvocationChain; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class DelegatingSoapEndpointMappingTest { private DelegatingSoapEndpointMapping endpointMapping; @@ -59,4 +58,4 @@ public class DelegatingSoapEndpointMappingTest { verify(mock); } -} \ No newline at end of file +} 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 b2af407d..0489efe7 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 @@ -16,13 +16,13 @@ package org.springframework.ws.soap.server.endpoint.mapping; +import static org.easymock.EasyMock.*; + import java.lang.reflect.Method; -import static org.easymock.EasyMock.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.WebServiceMessageFactory; import org.springframework.ws.context.DefaultMessageContext; @@ -120,10 +120,9 @@ public class SoapActionAnnotationMethodEndpointMappingTest { } - @SoapActions({@SoapAction("http://springframework.org/spring-ws/SoapAction1"), - @SoapAction("http://springframework.org/spring-ws/SoapAction2")}) - public void doItMultiple() { - } + @SoapActions({ @SoapAction("http://springframework.org/spring-ws/SoapAction1"), + @SoapAction("http://springframework.org/spring-ws/SoapAction2") }) + public void doItMultiple() {} @SoapAction("http://springframework.org/spring-ws/SoapAction3") @SoapAction("http://springframework.org/spring-ws/SoapAction4") @@ -131,6 +130,5 @@ public class SoapActionAnnotationMethodEndpointMappingTest { } - } -} \ No newline at end of file +} 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 d07bfaa4..48ee2bb8 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 @@ -18,15 +18,14 @@ package org.springframework.ws.soap.server.endpoint.mapping; import javax.xml.soap.MessageFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.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 org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class SoapActionEndpointMappingTest { private SoapActionEndpointMapping mapping; @@ -57,4 +56,4 @@ public class SoapActionEndpointMappingTest { public void testValidateLookupKey() throws Exception { Assert.assertTrue("Soapaction not valid", mapping.validateLookupKey("SoapAction")); } -} \ No newline at end of file +} 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 f60c321c..7dc0e3c6 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 @@ -16,9 +16,16 @@ package org.springframework.ws.soap.soap11; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.Locale; + import javax.xml.namespace.QName; +import org.junit.Test; import org.springframework.ws.soap.AbstractSoapBodyTestCase; import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapFaultDetail; @@ -27,11 +34,6 @@ import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.*; - public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCase { @Test @@ -57,9 +59,9 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas SoapFault fault = soapBody.addMustUnderstandFault("SOAP Must Understand Error", null); assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "MustUnderstand"), fault.getFaultCode()); - assertPayloadEqual("" + - "" + soapBody.getName().getPrefix() + ":MustUnderstand" + - "SOAP Must Understand Error"); + assertPayloadEqual("" + "" + + soapBody.getName().getPrefix() + ":MustUnderstand" + + "SOAP Must Understand Error"); } @Test @@ -67,9 +69,9 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas SoapFault fault = soapBody.addClientOrSenderFault("faultString", null); assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "Client"), fault.getFaultCode()); - assertPayloadEqual("" + - "" + soapBody.getName().getPrefix() + ":Client" + - "faultString" + ""); + assertPayloadEqual("" + "" + + soapBody.getName().getPrefix() + ":Client" + "faultString" + + ""); } @Test @@ -77,9 +79,9 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas SoapFault fault = soapBody.addServerOrReceiverFault("faultString", null); assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"), fault.getFaultCode()); - assertPayloadEqual("" + - "" + soapBody.getName().getPrefix() + ":Server" + - "faultString" + ""); + assertPayloadEqual("" + "" + + soapBody.getName().getPrefix() + ":Server" + "faultString" + + ""); } @Test @@ -96,10 +98,10 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas String actor = "http://www.springframework.org/actor"; fault.setFaultActorOrRole(actor); assertEquals("Invalid fault actor", actor, fault.getFaultActorOrRole()); - assertPayloadEqual("" + "spring:fault" + - "" + faultString + "" + "" + actor + - "" + ""); + assertPayloadEqual("" + "spring:fault" + + "" + faultString + "" + "" + actor + "" + + ""); } @Test @@ -132,26 +134,24 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas detailContents = new StringSource(""); transformer.transform(detailContents, detailElement2.getResult()); assertPayloadEqual( - "" + - "spring:fault" + "" + faultString + "" + - "" + - "" + - "" + - "" + ""); + "" + + "spring:fault" + "" + faultString + "" + "" + + "" + + "" + + "" + ""); } @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" + "" + "" + - "" + ""); + assertPayloadEqual("" + + "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 ad22fe06..1d51755d 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 @@ -16,23 +16,21 @@ package org.springframework.ws.soap.soap11; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; + import javax.xml.namespace.QName; +import org.junit.Test; import org.springframework.ws.soap.AbstractSoapEnvelopeTestCase; import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; -import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.assertEquals; - public abstract class AbstractSoap11EnvelopeTestCase extends AbstractSoapEnvelopeTestCase { @Test public void testGetName() throws Exception { - assertEquals("Invalid qualified name", - new QName(SoapVersion.SOAP_11.getEnvelopeNamespaceUri(), "Envelope"), + assertEquals("Invalid qualified name", new QName(SoapVersion.SOAP_11.getEnvelopeNamespaceUri(), "Envelope"), soapEnvelope.getName()); } 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 dccac032..80a8f6ae 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 @@ -16,13 +16,17 @@ package org.springframework.ws.soap.soap11; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; + import javax.xml.namespace.QName; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.*; import org.junit.Test; - import org.springframework.ws.soap.AbstractSoapHeaderTestCase; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapVersion; @@ -62,7 +66,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[]{"role1"}); + Iterator iterator = ((Soap11Header) soapHeader) + .examineHeaderElementsToProcess(new String[] { "role1" }); assertNotNull("header element iterator is null", iterator); assertTrue("header element iterator has no elements", iterator.hasNext()); checkHeaderElement(iterator.next()); @@ -93,8 +98,8 @@ public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTes private void checkHeaderElement(SoapHeaderElement headerElement) { QName name = headerElement.getName(); - assertTrue("Invalid name on header element", new QName(NAMESPACE, "localName1", PREFIX).equals(name) || - new QName(NAMESPACE, "localName3", PREFIX).equals(name)); + assertTrue("Invalid name on header element", new QName(NAMESPACE, "localName1", PREFIX).equals(name) + || new QName(NAMESPACE, "localName3", PREFIX).equals(name)); } } 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 75b6ab1e..3cad2781 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 @@ -16,12 +16,15 @@ package org.springframework.ws.soap.soap11; +import static org.junit.Assert.*; + import java.io.InputStream; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.junit.Test; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.mime.Attachment; import org.springframework.ws.soap.AbstractSoapMessageFactoryTestCase; @@ -30,10 +33,6 @@ import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.transport.MockTransportInputStream; import org.springframework.ws.transport.TransportInputStream; -import org.junit.Test; - -import static org.junit.Assert.*; - public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapMessageFactoryTestCase { @Test @@ -95,9 +94,10 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM public void testCreateSoapMessageMtom() throws Exception { InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11-mtom.bin"); Map headers = new HashMap(); - headers.put("Content-Type", "multipart/related;" + "start-info=\"text/xml\";" + - "type=\"application/xop+xml\";" + "start=\"<0.urn:uuid:492264AB42E57108E01176731445508@apache.org>\";" + - "boundary=\"MIMEBoundaryurn_uuid_492264AB42E57108E01176731445507\""); + headers.put("Content-Type", + "multipart/related;" + "start-info=\"text/xml\";" + "type=\"application/xop+xml\";" + + "start=\"<0.urn:uuid:492264AB42E57108E01176731445508@apache.org>\";" + + "boundary=\"MIMEBoundaryurn_uuid_492264AB42E57108E01176731445507\""); TransportInputStream tis = new MockTransportInputStream(is, headers); WebServiceMessage message = messageFactory.createWebServiceMessage(tis); @@ -116,9 +116,10 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM public void testCreateSoapMessageMtomWeirdStartInfo() throws Exception { InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11-mtom.bin"); Map headers = new HashMap(); - headers.put("Content-Type", "multipart/related;" + "startinfo=\"text/xml\";" + - "type=\"application/xop+xml\";" + "start=\"<0.urn:uuid:492264AB42E57108E01176731445508@apache.org>\";" + - "boundary=\"MIMEBoundaryurn_uuid_492264AB42E57108E01176731445507\""); + headers.put("Content-Type", + "multipart/related;" + "startinfo=\"text/xml\";" + "type=\"application/xop+xml\";" + + "start=\"<0.urn:uuid:492264AB42E57108E01176731445508@apache.org>\";" + + "boundary=\"MIMEBoundaryurn_uuid_492264AB42E57108E01176731445507\""); TransportInputStream tis = new MockTransportInputStream(is, headers); WebServiceMessage message = messageFactory.createWebServiceMessage(tis); @@ -170,12 +171,11 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM public void testCreateSoapMessageMissingContentType() throws Exception { InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11.xml"); TransportInputStream tis = new MockTransportInputStream(is, Collections.emptyMap()); - + WebServiceMessage message = messageFactory.createWebServiceMessage(tis); assertTrue("Not a SoapMessage", message instanceof SoapMessage); SoapMessage soapMessage = (SoapMessage) message; assertEquals("Invalid soap version", SoapVersion.SOAP_11, soapMessage.getVersion()); } - } 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 a0d8d7e6..a75646c9 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 @@ -16,17 +16,20 @@ package org.springframework.ws.soap.soap11; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; import org.junit.Assert; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.InputStreamSource; @@ -35,19 +38,16 @@ import org.springframework.ws.soap.AbstractSoapMessageTestCase; import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.transport.MockTransportOutputStream; -import org.springframework.xml.transform.StringSource; import org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.springframework.xml.transform.StringSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageTestCase { @Override protected final Resource[] getSoapSchemas() { - return new Resource[]{new ClassPathResource("soap11.xsd", AbstractSoap11MessageTestCase.class)}; + return new Resource[] { new ClassPathResource("soap11.xsd", AbstractSoap11MessageTestCase.class) }; } @Override @@ -67,9 +67,9 @@ public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageT soapMessage.setSoapAction(soapAction); soapMessage.writeTo(tos); String result = bos.toString("UTF-8"); - assertXMLEqual( - "<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + getHeader() + "<" + getNS() + ":Body>", - result); + assertXMLEqual("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + + getHeader() + "<" + getNS() + ":Body>", result); String contentType = tos.getHeaders().get("Content-Type"); assertTrue("Invalid Content-Type set", contentType.indexOf(SoapVersion.SOAP_11.getContentType()) != -1); String resultSoapAction = tos.getHeaders().get("SOAPAction"); @@ -132,9 +132,9 @@ public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageT soapMessage.writeTo(bos); String result = bos.toString("UTF-8"); - assertXMLEqual( - "<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + getHeader() + "<" + getNS() + ":Body>", - result); + assertXMLEqual("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + + getHeader() + "<" + getNS() + ":Body>", result); } @Override @@ -157,9 +157,9 @@ public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageT soapMessage.writeTo(bos); String result = bos.toString("UTF-8"); - assertXMLEqual( - "<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + getHeader() + "<" + getNS() + ":Body>", - result); + assertXMLEqual("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://schemas.xmlsoap.org/soap/envelope/'>" + + getHeader() + "<" + getNS() + ":Body>", result); } } 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 a2ce13e1..138426e0 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 @@ -16,10 +16,17 @@ package org.springframework.ws.soap.soap12; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; import java.util.Locale; + import javax.xml.namespace.QName; +import org.junit.Test; import org.springframework.ws.soap.AbstractSoapBodyTestCase; import org.springframework.ws.soap.SoapFault; import org.springframework.ws.soap.SoapFaultDetail; @@ -28,11 +35,6 @@ import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.*; - public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCase { @Test @@ -62,11 +64,11 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas StringResult result = new StringResult(); transformer.transform(fault.getSource(), result); assertXMLEqual("Invalid contents of body", - "" + - "" + soapBody.getName().getPrefix() + - ":MustUnderstand" + - "SOAP Must Understand Error" + - "", result.toString()); + "" + "" + + soapBody.getName().getPrefix() + ":MustUnderstand" + + "SOAP Must Understand Error" + + "", + result.toString()); } @Test @@ -77,11 +79,11 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas StringResult result = new StringResult(); transformer.transform(fault.getSource(), result); assertXMLEqual("Invalid contents of body", - "" + - "" + soapBody.getName().getPrefix() + - ":Sender" + - "faultString" + - "", result.toString()); + "" + "" + + soapBody.getName().getPrefix() + ":Sender" + + "faultString" + + "", + result.toString()); } @Test @@ -92,30 +94,29 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas StringResult result = new StringResult(); transformer.transform(fault.getSource(), result); assertXMLEqual("Invalid contents of body", - "" + - "" + soapBody.getName().getPrefix() + - ":Receiver" + - "faultString" + - "", result.toString()); + "" + "" + + soapBody.getName().getPrefix() + ":Receiver" + + "faultString" + + "", + result.toString()); } @Test public void testAddFaultWithDetail() throws Exception { 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); assertXMLEqual("Invalid source for body", - "" + - "" + soapBody.getName().getPrefix() + ":Receiver" + - "" + - "faultString" + - "" + - "", result.toString()); + "" + "" + + soapBody.getName().getPrefix() + ":Receiver" + "" + + "faultString" + + "" + + "", + result.toString()); } @Test @@ -127,12 +128,12 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas StringResult result = new StringResult(); transformer.transform(fault.getSource(), result); assertXMLEqual("Invalid source for body", - "" + - "" + soapBody.getName().getPrefix() + ":Receiver" + - "" + - "faultString" + - "" + "" + - "" + "", result.toString()); + "" + "" + + soapBody.getName().getPrefix() + ":Receiver" + "" + + "faultString" + + "" + "" + "" + + "", + result.toString()); } @Test @@ -150,14 +151,13 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas assertFalse("Subcode found", iterator.hasNext()); StringResult result = new StringResult(); transformer.transform(fault.getSource(), result); - assertXMLEqual("Invalid source for body", - "" + - "" + soapBody.getName().getPrefix() + ":Receiver" + - "spring-ws:Subcode1" + - "spring-ws:Subcode2" + - "" + - "faultString" + - "", result.toString()); + assertXMLEqual("Invalid source for body", "" + + "" + soapBody.getName().getPrefix() + ":Receiver" + + "spring-ws:Subcode1" + + "spring-ws:Subcode2" + + "" + + "faultString" + + "", result.toString()); } } 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 4e836e29..98facda2 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 @@ -16,17 +16,16 @@ package org.springframework.ws.soap.soap12; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; + import javax.xml.namespace.QName; +import org.junit.Test; import org.springframework.ws.soap.AbstractSoapEnvelopeTestCase; import org.springframework.ws.soap.SoapVersion; import org.springframework.xml.transform.StringResult; -import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.assertEquals; - public abstract class AbstractSoap12EnvelopeTestCase extends AbstractSoapEnvelopeTestCase { @Test 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 df16127e..64f84527 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 @@ -16,13 +16,17 @@ package org.springframework.ws.soap.soap12; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; + import javax.xml.namespace.QName; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.*; import org.junit.Test; - import org.springframework.ws.soap.AbstractSoapHeaderTestCase; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapVersion; @@ -56,29 +60,31 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes soap12Header.addNotUnderstoodHeaderElement(headerName); StringResult result = new StringResult(); transformer.transform(soapHeader.getSource(), result); - assertXMLEqual("Invalid contents of header", "

" + - "" + - "
", result.toString()); + assertXMLEqual("Invalid contents of header", + "
" + + "" + + "
", + result.toString()); } @Test public void testAddUpgrade() throws Exception { - String[] supportedUris = - new String[]{"http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/2003/05/soap-envelope"}; + String[] supportedUris = new String[] { "http://schemas.xmlsoap.org/soap/envelope/", + "http://www.w3.org/2003/05/soap-envelope" }; Soap12Header soap12Header = (Soap12Header) soapHeader; SoapHeaderElement header = soap12Header.addUpgradeHeaderElement(supportedUris); StringResult result = new StringResult(); transformer.transform(soapHeader.getSource(), result); assertEquals("Invalid name", header.getName(), 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 @@ -92,7 +98,8 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes qName = new QName(NAMESPACE, "localName3", PREFIX); headerElement = soapHeader.addHeaderElement(qName); headerElement.setActorOrRole(SoapVersion.SOAP_12.getNextActorOrRoleUri()); - Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[]{"role1"}, false); + Iterator iterator = ((Soap12Header) soapHeader) + .examineHeaderElementsToProcess(new String[] { "role1" }, false); assertNotNull("header element iterator is null", iterator); assertTrue("header element iterator has no elements", iterator.hasNext()); checkHeaderElement(iterator.next()); @@ -112,7 +119,8 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes qName = new QName(NAMESPACE, "localName3", PREFIX); headerElement = soapHeader.addHeaderElement(qName); headerElement.setActorOrRole(SoapVersion.SOAP_12.getNextActorOrRoleUri()); - Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[0], false); + Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[0], + false); assertNotNull("header element iterator is null", iterator); assertTrue("header element iterator has no elements", iterator.hasNext()); checkHeaderElement(iterator.next()); @@ -126,18 +134,18 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes QName qName = new QName(NAMESPACE, "localName", PREFIX); SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName); headerElement.setActorOrRole(SoapVersion.SOAP_12.getUltimateReceiverRoleUri()); - Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[]{"role"}, true); + Iterator iterator = ((Soap12Header) soapHeader) + .examineHeaderElementsToProcess(new String[] { "role" }, true); assertNotNull("header element iterator is null", iterator); headerElement = iterator.next(); - assertEquals("Invalid name on header element", new QName(NAMESPACE, "localName", PREFIX), - headerElement.getName()); + assertEquals("Invalid name on header element", new QName(NAMESPACE, "localName", PREFIX), headerElement.getName()); assertFalse("header element iterator has too many elements", iterator.hasNext()); } private void checkHeaderElement(SoapHeaderElement headerElement) { QName name = headerElement.getName(); - assertTrue("Invalid name on header element", new QName(NAMESPACE, "localName1", PREFIX).equals(name) || - new QName(NAMESPACE, "localName3", PREFIX).equals(name)); + assertTrue("Invalid name on header element", new QName(NAMESPACE, "localName1", PREFIX).equals(name) + || new QName(NAMESPACE, "localName3", PREFIX).equals(name)); } } 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 9d850546..1f137b12 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 @@ -16,6 +16,8 @@ package org.springframework.ws.soap.soap12; +import static org.junit.Assert.*; + import java.io.InputStream; import java.util.Collections; import java.util.HashMap; @@ -31,8 +33,6 @@ import org.springframework.ws.transport.MockTransportInputStream; import org.springframework.ws.transport.TransportConstants; import org.springframework.ws.transport.TransportInputStream; -import static org.junit.Assert.*; - public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapMessageFactoryTestCase { @Override @@ -69,13 +69,12 @@ public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapM messageFactory.createWebServiceMessage(tis); } - @Override public void testCreateSoapMessageSwA() throws Exception { 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); @@ -91,9 +90,10 @@ public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapM public void testCreateSoapMessageMtom() throws Exception { InputStream is = AbstractSoap12MessageFactoryTestCase.class.getResourceAsStream("soap12-mtom.bin"); Map headers = new HashMap(); - headers.put("Content-Type", "multipart/related;" + "start-info=\"application/soap+xml\";" + - "type=\"application/xop+xml\";" + "start=\"<0.urn:uuid:40864869929B855F971176851454456@apache.org>\";" + - "boundary=\"MIMEBoundaryurn_uuid_40864869929B855F971176851454455\""); + headers.put("Content-Type", + "multipart/related;" + "start-info=\"application/soap+xml\";" + "type=\"application/xop+xml\";" + + "start=\"<0.urn:uuid:40864869929B855F971176851454456@apache.org>\";" + + "boundary=\"MIMEBoundaryurn_uuid_40864869929B855F971176851454455\""); TransportInputStream tis = new MockTransportInputStream(is, headers); WebServiceMessage message = messageFactory.createWebServiceMessage(tis); @@ -112,7 +112,7 @@ public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapM public void testCreateSoapMessageMissingContentType() throws Exception { InputStream is = AbstractSoap12MessageFactoryTestCase.class.getResourceAsStream("soap12.xml"); TransportInputStream tis = new MockTransportInputStream(is, Collections.emptyMap()); - + WebServiceMessage message = messageFactory.createWebServiceMessage(tis); assertTrue("Not a SoapMessage", message instanceof SoapMessage); SoapMessage soapMessage = (SoapMessage) message; 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 0ec8c991..bdef836b 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 @@ -16,17 +16,20 @@ package org.springframework.ws.soap.soap12; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; import org.junit.Assert; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.InputStreamSource; @@ -36,13 +39,10 @@ import org.springframework.ws.soap.SoapBody; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.transport.MockTransportOutputStream; import org.springframework.ws.transport.TransportConstants; -import org.springframework.xml.transform.StringSource; import org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.springframework.xml.transform.StringSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageTestCase { @@ -53,8 +53,8 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT @Override protected final Resource[] getSoapSchemas() { - return new Resource[]{new ClassPathResource("xml.xsd", AbstractSoap12MessageTestCase.class), - new ClassPathResource("soap12.xsd", AbstractSoap12MessageTestCase.class)}; + return new Resource[] { new ClassPathResource("xml.xsd", AbstractSoap12MessageTestCase.class), + new ClassPathResource("soap12.xsd", AbstractSoap12MessageTestCase.class) }; } @Override @@ -69,12 +69,11 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT soapMessage.setSoapAction(soapAction); soapMessage.writeTo(tos); String result = bos.toString("UTF-8"); - assertXMLEqual( - "<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + getHeader() + "<" + getNS() + ":Body>", - result); + assertXMLEqual("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + + getHeader() + "<" + getNS() + ":Body>", result); String contentType = tos.getHeaders().get(TransportConstants.HEADER_CONTENT_TYPE); - assertTrue("Invalid Content-Type set", - contentType.contains(SoapVersion.SOAP_12.getContentType())); + assertTrue("Invalid Content-Type set", contentType.contains(SoapVersion.SOAP_12.getContentType())); assertNull(TransportConstants.HEADER_SOAP_ACTION + " header must not be found", tos.getHeaders().get(TransportConstants.HEADER_SOAP_ACTION)); assertTrue("Invalid Content-Type set", contentType.contains(soapAction)); @@ -136,9 +135,9 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT soapMessage.writeTo(bos); String result = bos.toString("UTF-8"); - assertXMLEqual( - "<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + getHeader() + "<" + getNS() + ":Body>", - result); + assertXMLEqual("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + + getHeader() + "<" + getNS() + ":Body>", result); } @Override @@ -161,12 +160,9 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT soapMessage.writeTo(bos); String result = bos.toString("UTF-8"); - assertXMLEqual( - "<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + getHeader() + "<" + getNS() + ":Body>", - result); + assertXMLEqual("<" + getNS() + ":Envelope xmlns:" + getNS() + "='http://www.w3.org/2003/05/soap-envelope'>" + + getHeader() + "<" + getNS() + ":Body>", result); } - - - } 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 59e4df08..bf153be0 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 @@ -73,4 +73,4 @@ public class SoapUtilsTest { } -} \ No newline at end of file +} 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 8adbb9be..a69c3ad3 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 @@ -21,7 +21,6 @@ import java.util.Properties; import org.junit.Assert; import org.junit.Test; - import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.context.ApplicationContext; @@ -85,8 +84,7 @@ public class DefaultStrategiesHelperTest { try { helper.getDefaultStrategy(Strategy.class, applicationContext); Assert.fail("Expected BeanInitializationException"); - } - catch (BeanInitializationException ex) { + } catch (BeanInitializationException ex) { // expected } } @@ -118,4 +116,4 @@ public class DefaultStrategiesHelperTest { this.applicationContext = applicationContext; } } -} \ No newline at end of file +} 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 4d91d67e..64a50784 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 @@ -16,9 +16,13 @@ package org.springframework.ws.support; +import static org.easymock.EasyMock.*; + import javax.xml.transform.Result; import javax.xml.transform.Source; +import org.junit.Assert; +import org.junit.Test; import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.mime.MimeContainer; @@ -29,11 +33,6 @@ import org.springframework.ws.mime.MimeMessage; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.junit.Assert; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class MarshallingUtilsTest { @Test @@ -121,5 +120,4 @@ public class MarshallingUtilsTest { verify(marshallerMock, messageMock); } - -} \ No newline at end of file +} 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 acdce38d..a9172b7e 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 @@ -16,6 +16,9 @@ package org.springframework.ws.transport.http; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Collections; @@ -25,28 +28,23 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.CountingInputStream; import org.easymock.Capture; import org.junit.Test; - import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; -import static org.easymock.EasyMock.*; -import static org.junit.Assert.*; - /** * @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. + * 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. + * @param chunking Specifies whether the test should simulate a response with chunking enabled. * @throws Exception */ private void testSupportsStreaming(boolean chunking) throws Exception { - byte[] content = new byte[16*1024]; + byte[] content = new byte[16 * 1024]; new Random().nextBytes(content); CountingInputStream rawInputStream = new CountingInputStream(new ByteArrayInputStream(content)); @@ -67,10 +65,9 @@ public class AbstractHttpSenderConnectionTest { connection.receive(messageFactory); - assertTrue("The raw input stream has been completely consumed", - rawInputStream.getCount() < content.length); - assertArrayEquals("Unexpected content received by the message factory", - content, IOUtils.toByteArray(inputStreamCapture.getValue())); + assertTrue("The raw input stream has been completely consumed", rawInputStream.getCount() < content.length); + assertArrayEquals("Unexpected content received by the message factory", content, + IOUtils.toByteArray(inputStreamCapture.getValue())); } @Test @@ -82,4 +79,4 @@ public class AbstractHttpSenderConnectionTest { public void testSupportsStreamingWithChunkingDisabled() throws Exception { testSupportsStreaming(false); } -} \ No newline at end of file +} 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 4b83beb4..89fa9e07 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 @@ -16,11 +16,15 @@ package org.springframework.ws.transport.http; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; + import java.io.IOException; import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; import java.util.zip.GZIPOutputStream; + import javax.servlet.Servlet; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -44,7 +48,6 @@ import org.junit.Test; import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.ServletHolder; - import org.springframework.beans.factory.InitializingBean; import org.springframework.util.FileCopyUtils; import org.springframework.ws.WebServiceMessage; @@ -58,9 +61,6 @@ import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; - public abstract class AbstractHttpWebServiceMessageSenderIntegrationTestCase { private Server jettyServer; @@ -75,15 +75,13 @@ public abstract class AbstractHttpWebServiceMessageSenderIntegrationTestCase" + - REQUEST + ""; + private static final String SOAP_REQUEST = "" + + REQUEST + ""; private static final String RESPONSE = ""; - private static final String SOAP_RESPONSE = - "" + - RESPONSE + ""; + private static final String SOAP_RESPONSE = "" + + RESPONSE + ""; private Context jettyContext; @@ -178,15 +176,14 @@ public abstract class AbstractHttpWebServiceMessageSenderIntegrationTestCase" + - CONTENT + ""; + private static final String SOAP_CONTENT = "" + + CONTENT + ""; private SaajSoapMessageFactory messageFactory; @@ -103,8 +102,7 @@ public class HttpServletConnectionTest { connection.send(message); - assertEquals("Invalid header", HEADER_VALUE, - httpServletResponse.getHeader(HEADER_NAME)); + assertEquals("Invalid header", HEADER_VALUE, httpServletResponse.getHeader(HEADER_NAME)); assertXMLEqual("Invalid content", SOAP_CONTENT, httpServletResponse.getContentAsString()); } @@ -123,4 +121,4 @@ public class HttpServletConnectionTest { assertEquals(500, httpServletResponse.getStatus()); } -} \ No newline at end of file +} 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 28b3a514..1fa4c7db 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 @@ -16,12 +16,12 @@ package org.springframework.ws.transport.http; +import static org.assertj.core.api.Assertions.*; + import java.time.Duration; import org.junit.Test; -import static org.assertj.core.api.Assertions.*; - public class HttpUrlConnectionMessageSenderIntegrationTest extends AbstractHttpWebServiceMessageSenderIntegrationTestCase { @@ -36,11 +36,10 @@ 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); } } -} \ No newline at end of file +} 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 582eb43c..f34c6273 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 @@ -24,12 +24,11 @@ import javax.xml.transform.stream.StreamSource; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.w3c.dom.Document; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.xml.transform.ResourceSource; import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.transform.ResourceSource; +import org.w3c.dom.Document; public class LastModifiedHelperTest { @@ -64,4 +63,4 @@ public class LastModifiedHelperTest { long result = LastModifiedHelper.getLastModified(new StreamSource(resource.getFile())); Assert.assertEquals("Invalid last modified", expected, result); } -} \ No newline at end of file +} 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 ee3dc35e..ab06f28c 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 @@ -16,7 +16,10 @@ package org.springframework.ws.transport.http; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.File; + import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConnection; @@ -25,9 +28,6 @@ import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; -import org.springframework.ws.transport.support.EchoPayloadEndpoint; -import org.springframework.ws.transport.support.FreePortScanner; - import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -35,8 +35,8 @@ import org.junit.Test; import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.ServletHolder; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import org.springframework.ws.transport.support.EchoPayloadEndpoint; +import org.springframework.ws.transport.support.FreePortScanner; /** * @author Arjen Poutsma @@ -57,8 +57,8 @@ public class MessageDispatcherServletIntegrationTest { url = "http://localhost:" + port; jettyServer = new Server(port); Context jettyContext = new Context(jettyServer, "/"); - String resourceBase = - new File(MessageDispatcherServletIntegrationTest.class.getResource("WEB-INF").toURI()).getParent(); + String resourceBase = new File(MessageDispatcherServletIntegrationTest.class.getResource("WEB-INF").toURI()) + .getParent(); jettyContext.setResourceBase(resourceBase); ServletHolder servletHolder = new ServletHolder(new MessageDispatcherServlet()); servletHolder.setName("sws"); @@ -82,7 +82,8 @@ public class MessageDispatcherServletIntegrationTest { @Test public void echo() throws SOAPException { SOAPMessage request = messageFactory.createMessage(); - SOAPElement element = request.getSOAPBody().addChildElement(new QName(EchoPayloadEndpoint.NAMESPACE, EchoPayloadEndpoint.LOCAL_PART)); + SOAPElement element = request.getSOAPBody() + .addChildElement(new QName(EchoPayloadEndpoint.NAMESPACE, EchoPayloadEndpoint.LOCAL_PART)); element.setTextContent("Hello World"); SOAPConnection connection = connectionFactory.createConnection(); @@ -92,5 +93,4 @@ public class MessageDispatcherServletIntegrationTest { assertXMLEqual(request.getSOAPPart(), response.getSOAPPart()); } - } 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 522093eb..8f0ffa1d 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 @@ -16,13 +16,20 @@ package org.springframework.ws.transport.http; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.ByteArrayInputStream; import java.util.List; + import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import org.custommonkey.xmlunit.XMLUnit; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; import org.springframework.core.io.ClassPathResource; @@ -37,15 +44,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.custommonkey.xmlunit.XMLUnit; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; import org.w3c.dom.Document; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; - public class MessageDispatcherServletTest { private ServletConfig config; @@ -87,8 +87,7 @@ public class MessageDispatcherServletTest { public void testDetectWsdlDefinitions() throws Exception { 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(); @@ -121,4 +120,4 @@ public class MessageDispatcherServletTest { super.refresh(); } } -} \ No newline at end of file +} 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 a19b1b50..90499ae5 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 @@ -16,15 +16,16 @@ package org.springframework.ws.transport.http; +import static org.easymock.EasyMock.*; + import java.io.InputStream; import java.io.OutputStream; + import javax.servlet.http.HttpServletResponse; -import static org.easymock.EasyMock.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.ws.FaultAwareWebServiceMessage; @@ -37,11 +38,11 @@ import org.springframework.ws.transport.WebServiceMessageReceiver; public class WebServiceMessageReceiverHandlerAdapterTest { - private static final String REQUEST = " \n" + " \n" + - " \n" + " DIS\n" + - " \n" + " \n" + ""; + private static final String REQUEST = " \n" + " \n" + + " \n" + " DIS\n" + + " \n" + " \n" + ""; private WebServiceMessageReceiverHandlerAdapter adapter; @@ -73,8 +74,7 @@ public class WebServiceMessageReceiverHandlerAdapterTest { WebServiceMessageReceiver endpoint = new WebServiceMessageReceiver() { @Override - public void receive(MessageContext messageContext) throws Exception { - } + public void receive(MessageContext messageContext) throws Exception {} }; adapter.handle(httpRequest, httpResponse, endpoint); Assert.assertEquals("METHOD_NOT_ALLOWED expected", HttpServletResponse.SC_METHOD_NOT_ALLOWED, @@ -94,14 +94,12 @@ public class WebServiceMessageReceiverHandlerAdapterTest { WebServiceMessageReceiver endpoint = new WebServiceMessageReceiver() { @Override - public void receive(MessageContext messageContext) throws Exception { - } + public void receive(MessageContext messageContext) throws Exception {} }; adapter.handle(httpRequest, httpResponse, endpoint); - Assert.assertEquals("Invalid status code on response", HttpServletResponse.SC_ACCEPTED, - httpResponse.getStatus()); + Assert.assertEquals("Invalid status code on response", HttpServletResponse.SC_ACCEPTED, httpResponse.getStatus()); Assert.assertEquals("Response written", 0, httpResponse.getContentAsString().length()); verifyMockControls(); } @@ -197,8 +195,7 @@ public class WebServiceMessageReceiverHandlerAdapterTest { WebServiceMessageReceiver endpoint = new WebServiceMessageReceiver() { @Override - public void receive(MessageContext messageContext) throws Exception { - } + public void receive(MessageContext messageContext) throws Exception {} }; adapter.handle(httpRequest, httpResponse, endpoint); diff --git a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapterTest.java b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapterTest.java index 5ba2216c..7b10f74a 100644 --- a/spring-ws-core/src/test/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapterTest.java +++ b/spring-ws-core/src/test/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapterTest.java @@ -16,9 +16,13 @@ package org.springframework.ws.transport.http; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.easymock.EasyMock.*; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.net.URI; + import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -26,18 +30,14 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.w3c.dom.Document; - import org.springframework.core.io.ClassPathResource; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.ws.wsdl.WsdlDefinition; import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition; -import org.springframework.xml.transform.StringSource; import org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.easymock.EasyMock.*; +import org.springframework.xml.transform.StringSource; +import org.w3c.dom.Document; public class WsdlDefinitionHandlerAdapterTest { @@ -79,8 +79,7 @@ public class WsdlDefinitionHandlerAdapterTest { replay(definitionMock); adapter.handle(request, response, definitionMock); - Assert.assertEquals("METHOD_NOT_ALLOWED expected", HttpServletResponse.SC_METHOD_NOT_ALLOWED, - response.getStatus()); + Assert.assertEquals("METHOD_NOT_ALLOWED expected", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getStatus()); verify(definitionMock); } @@ -180,8 +179,8 @@ public class WsdlDefinitionHandlerAdapterTest { request.setPathInfo(null); request.setRequestURI("/context/service.wsdl"); - SimpleWsdl11Definition definition = - new SimpleWsdl11Definition(new ClassPathResource("echo-input.wsdl", getClass())); + SimpleWsdl11Definition definition = new SimpleWsdl11Definition( + new ClassPathResource("echo-input.wsdl", getClass())); adapter.handle(request, response, definition); @@ -210,8 +209,8 @@ public class WsdlDefinitionHandlerAdapterTest { request.setPathInfo(null); request.setRequestURI("/context/service.wsdl"); - SimpleWsdl11Definition definition = - new SimpleWsdl11Definition(new ClassPathResource("echo-input.wsdl", getClass())); + SimpleWsdl11Definition definition = new SimpleWsdl11Definition( + new ClassPathResource("echo-input.wsdl", getClass())); adapter.handle(request, response, definition); @@ -226,4 +225,4 @@ public class WsdlDefinitionHandlerAdapterTest { assertXMLEqual("Invalid WSDL returned", expectedDocument, resultingDocument); } -} \ No newline at end of file +} 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 cb48f246..98b5a4de 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 @@ -16,16 +16,18 @@ package org.springframework.ws.transport.http; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; + import java.io.ByteArrayInputStream; import java.io.InputStream; + import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Before; import org.junit.Test; -import org.w3c.dom.Document; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.mock.web.MockHttpServletRequest; @@ -33,9 +35,7 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.util.FileCopyUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.xsd.SimpleXsdSchema; - -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.junit.Assert.assertEquals; +import org.w3c.dom.Document; public class XsdSchemaHandlerAdapterTest { @@ -110,4 +110,4 @@ public class XsdSchemaHandlerAdapterTest { assertXMLEqual("Invalid WSDL returned", expectedDocument, resultingDocument); } -} \ No newline at end of file +} 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 23b34830..9ff2a376 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 @@ -59,8 +59,7 @@ 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; } @@ -73,8 +72,7 @@ public abstract class FreePortScanner { ServerSocket serverSocket; try { serverSocket = new ServerSocket(); - } - catch (IOException ex) { + } catch (IOException ex) { throw new IllegalStateException("Unable to create ServerSocket.", ex); } @@ -82,15 +80,12 @@ 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-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 d414078c..1dc4aeb0 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 @@ -16,12 +16,13 @@ package org.springframework.ws.transport.support; +import static org.easymock.EasyMock.*; + import javax.xml.namespace.QName; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.springframework.ws.MockWebServiceMessage; import org.springframework.ws.MockWebServiceMessageFactory; import org.springframework.ws.WebServiceMessage; @@ -30,8 +31,6 @@ import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.transport.FaultAwareWebServiceConnection; import org.springframework.ws.transport.WebServiceMessageReceiver; -import static org.easymock.EasyMock.*; - public class WebServiceMessageReceiverObjectSupportTest { private WebServiceMessageReceiverObjectSupport receiverSupport; @@ -92,8 +91,7 @@ public class WebServiceMessageReceiverObjectSupportTest { @Override public void receive(MessageContext messageContext) throws Exception { Assert.assertNotNull("No message context", messageContext); - MockWebServiceMessage response = - (MockWebServiceMessage) messageContext.getResponse(); + MockWebServiceMessage response = (MockWebServiceMessage) messageContext.getResponse(); response.setFaultCode(faultCode); } }; @@ -126,4 +124,4 @@ public class WebServiceMessageReceiverObjectSupportTest { private static class MyReceiverSupport extends WebServiceMessageReceiverObjectSupport { } -} \ No newline at end of file +} 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 c9132302..dbacec12 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 @@ -16,6 +16,8 @@ package org.springframework.ws.wsdl.wsdl11; +import static org.custommonkey.xmlunit.XMLAssert.*; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -25,16 +27,13 @@ import javax.xml.transform.dom.DOMResult; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Before; import org.junit.Test; -import org.w3c.dom.Document; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.xml.transform.TransformerFactoryUtils; 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 static org.custommonkey.xmlunit.XMLAssert.*; +import org.w3c.dom.Document; public class DefaultWsdl11DefinitionTest { @@ -145,5 +144,4 @@ public class DefaultWsdl11DefinitionTest { } - -} \ No newline at end of file +} 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 5658099e..fb457876 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 @@ -16,11 +16,10 @@ package org.springframework.ws.wsdl.wsdl11; -import org.springframework.core.io.ClassPathResource; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.core.io.ClassPathResource; public class SimpleWsdl11DefinitionTest { @@ -37,4 +36,4 @@ public class SimpleWsdl11DefinitionTest { public void testGetSource() throws Exception { Assert.assertNotNull("No source returned", definition.getSource()); } -} \ No newline at end of file +} 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 a9991b59..99495d90 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 @@ -16,7 +16,10 @@ package org.springframework.ws.wsdl.wsdl11; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.InputStream; + import javax.wsdl.Definition; import javax.wsdl.factory.WSDLFactory; import javax.wsdl.xml.WSDLReader; @@ -30,14 +33,11 @@ import org.custommonkey.xmlunit.XMLUnit; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.transform.TransformerFactoryUtils; import org.w3c.dom.Document; import org.xml.sax.InputSource; -import org.springframework.xml.transform.TransformerFactoryUtils; -import org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; - public class Wsdl4jDefinitionTest { private Wsdl4jDefinition definition; @@ -53,8 +53,7 @@ public class Wsdl4jDefinitionTest { try { Definition wsdl4jDefinition = reader.readWSDL(null, new InputSource(is)); definition = new Wsdl4jDefinition(wsdl4jDefinition); - } - finally { + } finally { is.close(); } transformer = TransformerFactoryUtils.newInstance().newTransformer(); @@ -72,4 +71,4 @@ public class Wsdl4jDefinitionTest { Document expected = documentBuilder.parse(getClass().getResourceAsStream("complete.wsdl")); assertXMLEqual(expected, (Document) result.getNode()); } -} \ No newline at end of file +} 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 da97475b..5bb1232e 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 @@ -29,12 +29,11 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.w3c.dom.Document; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.xml.sax.SaxUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.sax.SaxUtils; +import org.w3c.dom.Document; public class DefaultMessagesProviderTest { @@ -66,8 +65,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()); @@ -93,7 +92,6 @@ public class DefaultMessagesProviderTest { Assert.assertNotNull("Message not created", message); part = message.getPart("GetOrderFault"); Assert.assertNotNull("Part not created", part); - Assert.assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderFault"), - part.getElementName()); + Assert.assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderFault"), part.getElementName()); } -} \ No newline at end of file +} 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 b92a262e..b572d348 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 @@ -21,15 +21,14 @@ import javax.wsdl.Types; import javax.wsdl.extensions.schema.Schema; import javax.wsdl.factory.WSDLFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.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 org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - public class InliningXsdSchemaTypesProviderTest { private InliningXsdSchemaTypesProvider provider; @@ -94,4 +93,4 @@ public class InliningXsdSchemaTypesProviderTest { wsdlSchema = (Schema) types.getExtensibilityElements().get(1); Assert.assertNotNull("No element defined", wsdlSchema.getElement()); } -} \ No newline at end of file +} 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 795230cc..ec75f792 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 @@ -17,6 +17,7 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Properties; + import javax.wsdl.Binding; import javax.wsdl.BindingFault; import javax.wsdl.BindingInput; @@ -113,23 +114,20 @@ public class Soap11ProviderTest { BindingInput bindingInput = bindingOperation.getBindingInput(); Assert.assertNotNull("No binding input", bindingInput); Assert.assertEquals("Invalid name", "Input", bindingInput.getName()); - Assert.assertEquals("Invalid amount of extensibility elements", 1, - bindingInput.getExtensibilityElements().size()); + Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingInput.getExtensibilityElements().size()); SOAPBody soapBody = (SOAPBody) bindingInput.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap body use", "literal", soapBody.getUse()); BindingOutput bindingOutput = bindingOperation.getBindingOutput(); Assert.assertNotNull("No binding output", bindingOutput); Assert.assertEquals("Invalid name", "Output", bindingOutput.getName()); - Assert.assertEquals("Invalid amount of extensibility elements", 1, - bindingOutput.getExtensibilityElements().size()); + Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingOutput.getExtensibilityElements().size()); soapBody = (SOAPBody) bindingOutput.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap body use", "literal", soapBody.getUse()); BindingFault bindingFault = bindingOperation.getBindingFault("Fault"); Assert.assertNotNull("No binding fault", bindingFault); - Assert.assertEquals("Invalid amount of extensibility elements", 1, - bindingFault.getExtensibilityElements().size()); + Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingFault.getExtensibilityElements().size()); SOAPFault soapFault = (SOAPFault) bindingFault.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap fault use", "literal", soapFault.getUse()); @@ -146,5 +144,4 @@ public class Soap11ProviderTest { Assert.assertEquals("Invalid soap address", locationUri, soapAddress.getLocationURI()); } - -} \ No newline at end of file +} 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 316f3e07..33e7f9a6 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 @@ -17,6 +17,7 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Properties; + import javax.wsdl.Binding; import javax.wsdl.BindingFault; import javax.wsdl.BindingInput; @@ -113,23 +114,20 @@ public class Soap12ProviderTest { BindingInput bindingInput = bindingOperation.getBindingInput(); Assert.assertNotNull("No binding input", bindingInput); Assert.assertEquals("Invalid name", "Input", bindingInput.getName()); - Assert.assertEquals("Invalid amount of extensibility elements", 1, - bindingInput.getExtensibilityElements().size()); + Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingInput.getExtensibilityElements().size()); SOAP12Body soapBody = (SOAP12Body) bindingInput.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap body use", "literal", soapBody.getUse()); BindingOutput bindingOutput = bindingOperation.getBindingOutput(); Assert.assertNotNull("No binding output", bindingOutput); Assert.assertEquals("Invalid name", "Output", bindingOutput.getName()); - Assert.assertEquals("Invalid amount of extensibility elements", 1, - bindingOutput.getExtensibilityElements().size()); + Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingOutput.getExtensibilityElements().size()); soapBody = (SOAP12Body) bindingOutput.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap body use", "literal", soapBody.getUse()); BindingFault bindingFault = bindingOperation.getBindingFault("Fault"); Assert.assertNotNull("No binding fault", bindingFault); - Assert.assertEquals("Invalid amount of extensibility elements", 1, - bindingFault.getExtensibilityElements().size()); + Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingFault.getExtensibilityElements().size()); SOAP12Fault soapFault = (SOAP12Fault) bindingFault.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap fault use", "literal", soapFault.getUse()); @@ -146,5 +144,4 @@ public class Soap12ProviderTest { Assert.assertEquals("Invalid soap address", locationUri, soapAddress.getLocationURI()); } - -} \ No newline at end of file +} 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 a10f7fe2..768cea8b 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 @@ -17,6 +17,7 @@ package org.springframework.ws.wsdl.wsdl11.provider; import java.util.Properties; + import javax.wsdl.Binding; import javax.wsdl.Definition; import javax.wsdl.Fault; @@ -102,5 +103,4 @@ public class SoapProviderTest { Assert.assertNotNull("No SOAP 1.2 port created", port); } - -} \ No newline at end of file +} 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 6e34c735..781ec316 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 @@ -29,12 +29,11 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.w3c.dom.Document; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.xml.sax.SaxUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.springframework.xml.sax.SaxUtils; +import org.w3c.dom.Document; public class SuffixBasedMessagesProviderTest { @@ -67,8 +66,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()); @@ -90,4 +89,4 @@ public class SuffixBasedMessagesProviderTest { Assert.assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderResponse"), part.getElementName()); } -} \ No newline at end of file +} 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 a2e6e33e..ee4ffb79 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 @@ -70,4 +70,4 @@ public class SuffixBasedPortTypesProviderTest { Assert.assertNotNull("No output created", operation.getOutput()); Assert.assertFalse("No fault created", operation.getFaults().isEmpty()); } -} \ No newline at end of file +} diff --git a/spring-ws-security/pom.xml b/spring-ws-security/pom.xml index ec59a363..9aee83c2 100644 --- a/spring-ws-security/pom.xml +++ b/spring-ws-security/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -174,7 +174,7 @@ ${soap-api.version} provided - + org.apache.ws.commons.axiom axiom-api 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 cacd4ee7..09902894 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 @@ -18,11 +18,11 @@ package org.springframework.ws.soap.security; import java.util.Iterator; import java.util.Locale; + 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; @@ -39,10 +39,11 @@ 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 * {@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}. - * - *

Subclasses of this base class can be configured to secure incoming and secure outgoing messages. By default, both are + * endpoint mapping}; or on the client side, on the + * {@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. * * @author Arjen Poutsma @@ -53,8 +54,8 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter /** Logger available to subclasses. */ protected final Log logger = LogFactory.getLog(getClass()); - protected static final QName WS_SECURITY_NAME = - new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security"); + protected static final QName WS_SECURITY_NAME = new QName( + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security"); private boolean secureResponse = true; @@ -63,7 +64,7 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter private boolean secureRequest = true; private boolean validateResponse = true; - + private boolean skipValidationIfNoHeaderPresent = false; private EndpointExceptionResolver exceptionResolver; @@ -94,8 +95,7 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter } /** Allows skipping validation if no security header is present. */ - public void setSkipValidationIfNoHeaderPresent( - boolean skipValidationIfNoHeaderPresent) { + public void setSkipValidationIfNoHeaderPresent(boolean skipValidationIfNoHeaderPresent) { this.skipValidationIfNoHeaderPresent = skipValidationIfNoHeaderPresent; } @@ -104,11 +104,12 @@ 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}. + * 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}. * * @param messageContext the message context, containing the request to be validated - * @param endpoint chosen endpoint to invoke + * @param endpoint chosen endpoint to invoke * @return {@code true} if the request was valid; {@code false} otherwise. * @throws Exception in case of errors * @see #validateMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext) @@ -117,31 +118,29 @@ 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}. + * 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}. * * @param messageContext the message context, containing the response to be secured - * @param endpoint chosen endpoint to invoke + * @param endpoint chosen endpoint to invoke * @return {@code true} if the response was secured; {@code false} otherwise. * @throws Exception in case of errors * @see #secureMessage(org.springframework.ws.soap.SoapMessage,org.springframework.ws.context.MessageContext) @@ -155,16 +154,13 @@ 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(); } @@ -178,7 +174,6 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter return true; } - @Override public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) { cleanUp(); @@ -194,8 +189,9 @@ 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}. + * 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}. * * @param messageContext the message context, containing the request to be secured * @return {@code true} if the response was secured; {@code false} otherwise. @@ -209,22 +205,20 @@ 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}. + * 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}. * * @param messageContext the message context, containing the response to be validated * @return {@code true} if the request was valid; {@code false} otherwise. @@ -236,21 +230,18 @@ 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.getRequest())){ + if (skipValidationIfNoHeaderPresent && !isSecurityHeaderPresent((SoapMessage) messageContext.getRequest())) { 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; } } @@ -262,16 +253,14 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter } @Override - public void afterCompletion(MessageContext messageContext, Exception ex) - throws WebServiceClientException { + public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException { cleanUp(); } /** - * 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 ex the validation exception * @param messageContext the message context * @return {@code true} to continue processing the message, {@code false} (the default) otherwise */ @@ -283,11 +272,11 @@ 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 ex the validation exception * @param messageContext the message context * @return {@code true} to continue processing the message, {@code false} (the default) otherwise */ @@ -297,8 +286,7 @@ 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"); } @@ -312,7 +300,7 @@ 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}. * - * @param ex the validation exception + * @param ex the validation exception * @param messageContext the message context * @return {@code true} to continue processing the message, {@code false} (the default) otherwise */ @@ -324,8 +312,7 @@ 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()); @@ -333,8 +320,8 @@ 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 @@ -343,8 +330,8 @@ 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 @@ -355,17 +342,17 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter protected abstract void cleanUp(); /** - * Iterates over header elements and returns true if WS-Security header is found. + * Iterates over header elements and returns true if WS-Security header is found. */ private boolean isSecurityHeaderPresent(SoapMessage message) { SoapHeader soapHeader = message.getSoapHeader(); - if(soapHeader == null){ + if (soapHeader == null) { return false; } Iterator elements = soapHeader.examineAllHeaderElements(); - while(elements.hasNext()){ + while (elements.hasNext()) { SoapHeaderElement e = elements.next(); - if(e.getName().equals(WS_SECURITY_NAME)){ + if (e.getName().equals(WS_SECURITY_NAME)) { return true; } } 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 83f4fe1c..0eb36540 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 @@ -18,8 +18,8 @@ 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 + *

+ * 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 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 c3867aab..6154f7f1 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 @@ -18,8 +18,8 @@ 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 + *

+ * 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 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 5ed0b229..e63354a6 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.security.callback; import java.io.IOException; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; @@ -35,8 +36,7 @@ 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. 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 a6a0cf73..590bce4e 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.security.callback; import java.io.IOException; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; @@ -45,10 +46,9 @@ public class CallbackHandlerChain extends AbstractCallbackHandler { boolean allUnsupported = true; for (CallbackHandler callbackHandler : callbackHandlers) { try { - callbackHandler.handle(new Callback[]{callback}); + callbackHandler.handle(new Callback[] { callback }); allUnsupported = false; - } - catch (UnsupportedCallbackException ex) { + } catch (UnsupportedCallbackException ex) { // if an UnsupportedCallbackException occurs, go to the next handler } } @@ -56,4 +56,4 @@ public class CallbackHandlerChain extends AbstractCallbackHandler { throw new UnsupportedCallbackException(callback); } } -} \ No newline at end of file +} 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 f6bedb65..c942fa54 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 @@ -17,11 +17,12 @@ package org.springframework.ws.soap.security.callback; 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 596e2358..e9b8e198 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.security.support; import java.security.KeyStore; + import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; @@ -26,8 +27,8 @@ import org.springframework.util.StringUtils; /** * Spring factory bean for an array of {@link KeyManager}s. - * - *

Uses the {@link KeyManagerFactory} to create the {@code KeyManager}s. + *

+ * Uses the {@link KeyManagerFactory} to create the {@code KeyManager}s. * * @author Stephen More * @author Arjen Poutsma @@ -99,12 +100,11 @@ 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 keyManagerFactory = StringUtils.hasLength(this.provider) + ? KeyManagerFactory.getInstance(algorithm, this.provider) + : KeyManagerFactory.getInstance(algorithm); keyManagerFactory.init(keyStore, password); 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 6ad0fd23..073ee73c 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 @@ -23,7 +23,6 @@ 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,9 +30,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) @@ -106,11 +105,9 @@ 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; @@ -120,13 +117,11 @@ 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 e2800c6d..2ff8086b 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 @@ -37,14 +37,14 @@ 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}. - * - *

If these properties specify a file with an appropriate password, the factory uses this file for the key store. If + *

+ * 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. + *

+ * This behavior corresponds to the standard J2SDK behavior for SSL key stores. * * @see The - * standard J2SDK SSL key store mechanism + * standard J2SDK SSL key store mechanism */ public static KeyStore loadDefaultKeyStore() throws GeneralSecurityException, IOException { Resource location = null; @@ -72,21 +72,23 @@ 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. - * - *

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

  2. 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.
  3. - * Otherwise,
  4. 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. + * 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. + *

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

  2. + *
  3. 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.
  4. Otherwise, + *
  5. 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 + * standard J2SDK SSL trust store mechanism */ public static KeyStore loadDefaultTrustStore() throws GeneralSecurityException, IOException { Resource location = null; @@ -103,8 +105,7 @@ 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 b0369483..cc446eee 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 @@ -32,6 +32,7 @@ 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 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 ecccef15..3a18ac4e 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.security.support; import java.security.KeyStore; + import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; @@ -26,16 +27,15 @@ import org.springframework.util.StringUtils; /** * Spring factory bean for an array of {@link TrustManager}s. - * - *

Uses the {@link TrustManagerFactory} to create the {@code TrustManager}s. + *

+ * Uses the {@link TrustManagerFactory} to create the {@code TrustManager}s. * * @author Arjen Poutsma * @see TrustManager * @see TrustManagerFactory * @since 2.2 */ -public class TrustManagersFactoryBean - implements FactoryBean, InitializingBean { +public class TrustManagersFactoryBean implements FactoryBean, InitializingBean { private TrustManager[] trustManagers; @@ -46,16 +46,15 @@ public class TrustManagersFactoryBean 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) { @@ -64,6 +63,7 @@ public class TrustManagersFactoryBean /** * Sets the source of certificate authorities and related trust material. + * * @see TrustManagerFactory#init(KeyStore) */ public void setKeyStore(KeyStore keyStore) { @@ -87,12 +87,12 @@ public class TrustManagersFactoryBean @Override public void afterPropertiesSet() throws Exception { - String algorithm = StringUtils.hasLength(this.algorithm) ? this.algorithm : - TrustManagerFactory.getDefaultAlgorithm(); + String algorithm = StringUtils.hasLength(this.algorithm) ? this.algorithm + : TrustManagerFactory.getDefaultAlgorithm(); - TrustManagerFactory trustManagerFactory = StringUtils.hasLength(this.provider) ? - TrustManagerFactory.getInstance(algorithm, this.provider) : - TrustManagerFactory.getInstance(algorithm); + TrustManagerFactory trustManagerFactory = StringUtils.hasLength(this.provider) + ? TrustManagerFactory.getInstance(algorithm, this.provider) + : TrustManagerFactory.getInstance(algorithm); trustManagerFactory.init(keyStore); 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 8afa9041..27425d94 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 @@ -26,9 +26,8 @@ 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.ws.context.MessageContext; +import org.w3c.dom.Document; /** * @author Tareq Abed Rabbo @@ -52,14 +51,10 @@ class Wss4jHandler extends WSHandler { options.setProperty(ConfigurationConstants.MUST_UNDERSTAND, Boolean.toString(true)); options.setProperty(ConfigurationConstants.ENABLE_SIGNATURE_CONFIRMATION, Boolean.toString(true)); } - + @Override - public void doSenderAction( - Document doc, - RequestData reqData, - List actions, - boolean isRequest) throws WSSecurityException - { + public void doSenderAction(Document doc, RequestData reqData, List actions, boolean isRequest) + throws WSSecurityException { super.doSenderAction(doc, reqData, actions, isRequest); } 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 01dad04d..e83b2f1e 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 @@ -22,6 +22,7 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collections; import java.util.List; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; @@ -43,9 +44,6 @@ 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; @@ -58,40 +56,80 @@ 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 {@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. - * - *

Valid validation actions are: - * - *

- * - * - * - * - * - * - * - *
Validation actionDescription
{@code UsernameToken}Validates username token
{@code Timestamp}Validates the timestamp
{@code Encrypt}Decrypts the message
{@code Signature}Validates the signature
{@code NoSecurity}No action performed
+ * 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}. *

- * Securement actions are: - * - *

+ * 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:

* - * - * - * - * - * - * - * - *
Securement actionDescription
{@code UsernameToken}Adds a username token
{@code UsernameTokenSignature}Adds a username token and a signature username token secret key
{@code Timestamp}Adds a timestamp
{@code Encrypt}Encrypts the response
{@code Signature}Signs the response
{@code NoSecurity}No action performed
- * - *

The order of the actions that the client performed to secure the messages is significant and is enforced by the + * + * Validation action + * Description + * + * + * {@code UsernameToken} + * Validates username token + * + * + * {@code Timestamp} + * Validates the timestamp + * + * + * {@code Encrypt} + * Decrypts the message + * + * + * {@code Signature} + * Validates the signature + * + * + * {@code NoSecurity} + * No action performed + * + * + *

+ *

+ * Securement actions are:

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Securement actionDescription
{@code UsernameToken}Adds a username token
{@code UsernameTokenSignature}Adds a username token and a signature username token secret key
{@code Timestamp}Adds a timestamp
{@code Encrypt}Encrypts the response
{@code Signature}Signs the response
{@code NoSecurity}No action performed
+ *
+ *

+ * 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 @@ -130,7 +168,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl private int securementTimeToLive = 300; private int futureTimeToLive = 60; - + private WSSConfig wssConfig; private final Wss4jHandler handler = new Wss4jHandler(); @@ -142,9 +180,9 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl private boolean bspCompliant; private boolean securementUseDerivedKey; - + private CallbackHandler samlCallbackHandler; - + // Allow RSA 15 to maintain default behavior private boolean allowRSA15KeyTransportAlgorithm = true; @@ -160,6 +198,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Inject a customize {@link WSSecurityEngine}. + * * @param securityEngine */ public Wss4jSecurityInterceptor(WSSecurityEngine securityEngine) { @@ -172,10 +211,10 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * The actor name of the {@code wsse:Security} header. - * - *

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. + *

+ * 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. */ public void setSecurementActor(String securementActor) { handler.setOption(WSHandlerConstants.ACTOR, securementActor); @@ -184,21 +223,21 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl public void setSecurementEncryptionCrypto(Crypto securementEncryptionCrypto) { handler.setSecurementEncryptionCrypto(securementEncryptionCrypto); } - + /** * 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. + * {@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) { handler.setOption(WSHandlerConstants.ENC_KEY_ID, securementEncryptionKeyIdentifier); } /** - * 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); @@ -206,43 +245,45 @@ 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 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 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: + * *

 	 * <property name="securementEncryptionParts"
 	 *	 value="{Content}{http://example.org/paymentv2}CreditCard;
 	 *			   {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 encryption modifier and the namespace identifier can be omitted. In this case the encryption mode defaults to + * {@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 SOAP namespace. - * - *

To specify an element without a namespace use the string {@code Null} as the namespace name (this is a case + *

+ * 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. + *

+ * 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. + *

+ * 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 + * 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) { @@ -251,19 +292,19 @@ 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. - * - *

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. - * - *

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. - * - *

Placing the username of the encryption certificate in the configuration file is not a security risk, because the + *

+ * 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. + *

+ * 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. + *

+ * 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) { @@ -276,10 +317,10 @@ 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 default setting is PW_DIGEST. + *

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

+ * The default setting is PW_DIGEST. */ public void setSecurementPasswordType(String securementUsernameTokenPasswordType) { handler.setOption(WSHandlerConstants.PASSWORD_TYPE, securementUsernameTokenPasswordType); @@ -287,6 +328,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl /** * Defines which signature algorithm to use. + * * @see WSConstants#RSA * @see WSConstants#DSA */ @@ -307,8 +349,8 @@ 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 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) { @@ -317,26 +359,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 + *

+ * 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. - * - *

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

+ * 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. + *

+ * 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) - * - *

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); @@ -344,13 +388,11 @@ 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. - * - *

If this parameter is not set, then the signature - * function falls back to the alias specified by {@link #setSecurementUsername(String)}. - * + *

+ * 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)}. */ public void setSecurementSignatureUser(String securementSignatureUser) { handler.setOption(WSHandlerConstants.SIGNATURE_USER, securementSignatureUser); @@ -375,7 +417,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl public void setSecurementUseDerivedKey(boolean securementUseDerivedKey) { this.securementUseDerivedKey = securementUseDerivedKey; } - + /** * Sets the SAML Callback used for generating SAML tokens. * @@ -398,8 +440,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl this.validationActions = actions; try { validationActionsVector = WSSecurityUtil.decodeAction(actions); - } - catch (WSSecurityException ex) { + } catch (WSSecurityException ex) { throw new IllegalArgumentException(ex); } } @@ -453,35 +494,31 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * 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) - { + public void setSecurementUsernameTokenCreated(boolean securementUsernameTokenCreated) { handler.setOption(ConfigurationConstants.ADD_USERNAMETOKEN_CREATED, securementUsernameTokenCreated); } - + /** * 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 */ public void setWssConfig(WSSConfig config) { @@ -503,18 +540,17 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl this.handler.setOption(WSHandlerConstants.IS_BSP_COMPLIANT, bspCompliant); this.bspCompliant = bspCompliant; } - + /** * Sets whether the RSA 1.5 key transport algorithm is allowed. */ - public void setAllowRSA15KeyTransportAlgorithm(boolean allow) - { + public void setAllowRSA15KeyTransportAlgorithm(boolean allow) { this.allowRSA15KeyTransportAlgorithm = allow; } /** - * 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) { if (futureTimeToLive <= 0) { @@ -556,11 +592,10 @@ 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); } - + if (securementActionsVector.isEmpty() && !enableSignatureConfirmation) { return; } @@ -572,8 +607,7 @@ 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); } @@ -594,23 +628,22 @@ 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); } requestData.setTimeStampTTL(securementTimeToLive); requestData.setUseDerivedKeyForMAC(securementUseDerivedKey); - + requestData.setWssConfig(wssConfig); messageContext.setProperty(WSHandlerConstants.TTL_TIMESTAMP, Integer.toString(securementTimeToLive)); - + if (this.samlCallbackHandler != null) { messageContext.setProperty(WSHandlerConstants.SAML_CALLBACK_REF, this.samlCallbackHandler); } - + // allow for qualified password types for .Net interoperability requestData.setAllowNamespaceQualifiedPasswordTypes(true); @@ -626,19 +659,19 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl protected RequestData initializeValidationRequestData(MessageContext messageContext) { RequestData requestData = new RequestData(); requestData.setMsgContext(messageContext); - + requestData.setWssConfig(wssConfig); - + requestData.setDecCrypto(validationDecryptionCrypto); - + requestData.setSigVerCrypto(validationSignatureCrypto); - + requestData.setCallbackHandler(validationCallbackHandler); messageContext.setProperty(WSHandlerConstants.TTL_TIMESTAMP, Integer.toString(validationTimeToLive)); requestData.setAllowRSA15KeyTransportAlgorithm(allowRSA15KeyTransportAlgorithm); - + requestData.setDisableBSPEnforcement(!bspCompliant); if (requestData.getBSPEnforcer() != null) { requestData.getBSPEnforcer().setDisableBSPRules(!bspCompliant); @@ -646,7 +679,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl // allow for qualified password types for .Net interoperability requestData.setAllowNamespaceQualifiedPasswordTypes(true); - return requestData; } @@ -669,13 +701,12 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl RequestData validationData = initializeValidationRequestData(messageContext); String actor = validationActor; - if (actor == null) { - actor = ""; - } - - Element elem = WSSecurityUtil.getSecurityHeader(envelopeAsDocument, actor); - WSHandlerResult result = securityEngine - .processSecurityHeader(elem, validationData); + if (actor == null) { + actor = ""; + } + + Element elem = WSSecurityUtil.getSecurityHeader(envelopeAsDocument, actor); + WSHandlerResult result = securityEngine.processSecurityHeader(elem, validationData); // Results verification if (CollectionUtils.isEmpty(result.getResults())) { @@ -693,8 +724,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl verifyTimestamp(result); processPrincipal(result); - } - catch (WSSecurityException ex) { + } catch (WSSecurityException ex) { throw new Wss4jSecurityValidationException(ex.getMessage(), ex); } @@ -709,7 +739,6 @@ 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. * - * * @param results the results of the validation function * @param validationActions the decoded validation actions * @throws Wss4jSecurityValidationException if the results are deemed invalid @@ -722,34 +751,36 @@ 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) { + if ((handlerResults = (List) messageContext + .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*/ + /** + * Verifies the trust of a certificate. + * + * @param result + */ protected void verifyCertificateTrust(WSHandlerResult result) throws WSSecurityException { - List results = - result.getActionResults().get(WSConstants.SIGN); + List results = result.getActionResults().get(WSConstants.SIGN); 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}); + credential.setCertificates(new X509Certificate[] { returnCert }); RequestData requestData = new RequestData(); requestData.setSigVerCrypto(validationSignatureCrypto); @@ -760,11 +791,13 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } } - /** Verifies the timestamp. - * @param result*/ + /** + * Verifies the timestamp. + * + * @param result + */ protected void verifyTimestamp(WSHandlerResult result) throws WSSecurityException { - List results = - result.getActionResults().get(WSConstants.TS); + List results = result.getActionResults().get(WSConstants.TS); if (!CollectionUtils.isEmpty(results)) { WSSecurityEngineResult actionResult = results.get(0); @@ -786,8 +819,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } private void processPrincipal(WSHandlerResult result) { - List results = - result.getActionResults().get(WSConstants.UT); + List results = result.getActionResults().get(WSConstants.UT); if (!CollectionUtils.isEmpty(results)) { WSSecurityEngineResult actionResult = results.get(0); @@ -796,12 +828,10 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl WSUsernameTokenPrincipalImpl usernameTokenPrincipal = (WSUsernameTokenPrincipalImpl) principal; UsernameTokenPrincipalCallback callback = new UsernameTokenPrincipalCallback(usernameTokenPrincipal); try { - validationCallbackHandler.handle(new Callback[]{callback}); - } - catch (IOException ex) { + validationCallbackHandler.handle(new Callback[] { callback }); + } catch (IOException ex) { logger.warn("Principal callback resulted in IOException", ex); - } - catch (UnsupportedCallbackException ex) { + } catch (UnsupportedCallbackException ex) { // ignore } } @@ -813,12 +843,10 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl if (validationCallbackHandler != null) { try { CleanupCallback cleanupCallback = new CleanupCallback(); - validationCallbackHandler.handle(new Callback[]{cleanupCallback}); - } - catch (IOException ex) { + validationCallbackHandler.handle(new Callback[] { cleanupCallback }); + } 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 a6bc748e..45d97558 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 @@ -17,6 +17,7 @@ package org.springframework.ws.soap.security.wss4j2.callback; import java.io.IOException; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; @@ -25,8 +26,8 @@ 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 @@ -39,7 +40,7 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback * code, and calls the various {@code handle*} template methods. * * @param callback the callback - * @throws IOException in case of I/O errors + * @throws IOException in case of I/O errors * @throws UnsupportedCallbackException when the callback is not supported */ @Override @@ -66,30 +67,26 @@ 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); } } /** * 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 + *

+ * 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). - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleDecrypt(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); @@ -97,10 +94,10 @@ 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. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

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

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleUsernameToken(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); @@ -108,12 +105,12 @@ 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 + *

+ * 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. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleSignature(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); @@ -121,10 +118,10 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback /** * 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. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

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

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleSecurityContextToken(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { @@ -133,8 +130,8 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback /** * Invoked when the callback has a {@link WSPasswordCallback#CUSTOM_TOKEN} usage. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleCustomToken(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); @@ -142,8 +139,8 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback /** * Invoked when the callback has a {@link WSPasswordCallback#SECRET_KEY} usage. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleSecretKey(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); @@ -151,8 +148,8 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback /** * Invoked when a {@link CleanupCallback} is passed to {@link #handle(Callback[])}. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleCleanup(CleanupCallback callback) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); @@ -160,8 +157,8 @@ public abstract class AbstractWsPasswordCallbackHandler extends AbstractCallback /** * Invoked when a {@link UsernameTokenPrincipalCallback} is passed to {@link #handle(Callback[])}. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleUsernameTokenPrincipal(UsernameTokenPrincipalCallback callback) throws IOException, UnsupportedCallbackException { 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 27d1e701..03623526 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 @@ -17,11 +17,11 @@ package org.springframework.ws.soap.security.wss4j2.callback; import java.io.IOException; +import java.security.Key; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; -import java.security.Key; import javax.security.auth.callback.UnsupportedCallbackException; @@ -30,8 +30,8 @@ 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 @@ -46,30 +46,30 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i private char[] symmetricKeyPassword; private KeyStore keyStore; - + /** * 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 + *

+ * 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). - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleDecrypt(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { callback.setPassword(privateKeyPassword); } - + /** * Invoked when the callback has a {@link WSPasswordCallback#SECRET_KEY} usage. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleSecretKey(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { String id = callback.getIdentifier(); Key key; - + try { key = keyStore.getKey(id, symmetricKeyPassword != null ? symmetricKeyPassword : privateKeyPassword.toCharArray()); } catch (UnrecoverableKeyException e) { @@ -79,7 +79,7 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i } catch (NoSuchAlgorithmException e) { throw new IOException("Could not get key", e); } - + callback.setKey(key.getEncoded()); } @@ -127,8 +127,7 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i 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 c0703a86..58b599df 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 @@ -28,8 +28,8 @@ 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 @@ -59,12 +59,11 @@ public class SimplePasswordValidationCallbackHandler extends AbstractWsPasswordC public void afterPropertiesSet() throws Exception { Assert.notNull(users, "users is required"); } - + @Override - public void handleUsernameToken(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException - { + public void handleUsernameToken(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { String username = callback.getIdentifier(); String passwd = users.get(username); callback.setPassword(passwd); } -} \ No newline at end of file +} 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 fa1e5efe..f443047f 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 @@ -37,9 +37,9 @@ import org.springframework.ws.soap.security.support.SpringSecurityUtils; /** * 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 @@ -66,15 +66,13 @@ public class SpringSecurityPasswordValidationCallbackHandler extends AbstractWsP public void afterPropertiesSet() throws Exception { Assert.notNull(userDetailsService, "userDetailsService is required"); } - - /** * 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. - * - *

Default implementation throws an {@link UnsupportedCallbackException}. + *

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

+ * Default implementation throws an {@link UnsupportedCallbackException}. */ protected void handleUsernameToken(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException { UserDetails user = loadUserDetails(callback.getIdentifier()); @@ -89,8 +87,8 @@ public class SpringSecurityPasswordValidationCallbackHandler extends AbstractWsP throws IOException, UnsupportedCallbackException { UserDetails user = loadUserDetails(callback.getPrincipal().getName()); WSUsernameTokenPrincipalImpl principal = callback.getPrincipal(); - UsernamePasswordAuthenticationToken authRequest = - new UsernamePasswordAuthenticationToken(principal, principal.getPassword(), user.getAuthorities()); + UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(principal, + principal.getPassword(), user.getAuthorities()); if (logger.isDebugEnabled()) { logger.debug("Authentication success: " + authRequest.toString()); } @@ -108,8 +106,7 @@ 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"); } 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 c8b43b6e..04a73d83 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 @@ -17,14 +17,14 @@ package org.springframework.ws.soap.security.wss4j2.callback; import java.io.Serializable; + 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 diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/package.html b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/package.html index 92fc4969..08abe8df 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/package.html +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/package.html @@ -1,6 +1,7 @@ -Contains classes for using the Apache WSS4J 2.0 WS-Security implementation within +Contains classes for using the Apache WSS4J 2.0 WS-Security implementation +within Spring-WS. \ No newline at end of file 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 c701599f..6f33ee54 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 @@ -31,8 +31,8 @@ import org.springframework.util.Assert; /** * 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 + *

+ * Requires either individual properties, or the {@link #setConfiguration(java.util.Properties) configuration} property * to be set. * * @author Tareq Abed Rabbo @@ -50,8 +50,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) */ @@ -61,10 +61,10 @@ 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}. - * - *

This property maps to the WSS4J {@code org.apache.ws.security.crypto.provider} property. + * 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. * * @param cryptoProviderClass the crypto provider class */ @@ -75,8 +75,8 @@ 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. - * - *

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,13 +89,11 @@ 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; } } @@ -103,8 +101,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 */ @@ -114,8 +112,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 */ @@ -125,8 +123,8 @@ public class CryptoFactoryBean implements FactoryBean, InitializingBean /** * 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 */ @@ -136,10 +134,10 @@ 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}. - * - *

This property maps to the WSS4J {@code org.apache.ws.security.crypto.merlin.cacerts.password} property. + *

+ * 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. * * @param password the trust store password */ @@ -151,8 +149,8 @@ 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. - * - *

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 */ 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 afffedfa..6c73839c 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 @@ -20,7 +20,6 @@ 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; @@ -35,26 +34,27 @@ import org.springframework.util.Assert; import org.springframework.ws.soap.security.x509.cache.NullX509UserCache; import org.springframework.ws.soap.security.x509.cache.X509UserCache; - /** * Processes an X.509 authentication request. - *

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

+ *

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

* * @author Luke Taylor * @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 { @@ -66,20 +66,19 @@ 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 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.

+ * 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. + *

* * @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. */ @Override - public Authentication authenticate(Authentication authentication) - throws AuthenticationException { + public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!supports(authentication.getClass())) { return null; } @@ -91,8 +90,8 @@ public class X509AuthenticationProvider implements AuthenticationProvider, Initi X509Certificate clientCertificate = (X509Certificate) authentication.getCredentials(); if (clientCertificate == null) { - throw new BadCredentialsException(messages.getMessage("X509AuthenticationProvider.certificateNull", - "Certificate is null")); + throw new BadCredentialsException( + messages.getMessage("X509AuthenticationProvider.certificateNull", "Certificate is null")); } UserDetails user = userCache.getUserFromCache(clientCertificate); 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 eced71d4..5378e7df 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 @@ -22,25 +22,26 @@ import java.util.Collection; import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.core.GrantedAuthority; - /** * {@code Authentication} implementation for X.509 client-certificate authentication. - *

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

+ *

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

* * @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 */ @@ -50,22 +51,22 @@ public class X509AuthenticationToken extends AbstractAuthenticationToken { } /** - * Used for an authentication response object. The {@link org.springframework.security.core.Authentication#isAuthenticated()} - * will return {@code true}. + * Used for an authentication response object. The + * {@link org.springframework.security.core.Authentication#isAuthenticated()} will return {@code true}. * - * @param principal the principal, which is generally a - * {@code UserDetails} + * @param principal the principal, which is generally a {@code UserDetails} * @param credentials the certificate * @param authorities the authorities */ - public X509AuthenticationToken(Object principal, X509Certificate credentials, Collection authorities) { + public X509AuthenticationToken(Object principal, X509Certificate credentials, + Collection authorities) { super(authorities); this.principal = principal; this.credentials = credentials; setAuthenticated(true); } - //~ Methods ======================================================================================================== + // ~ Methods ======================================================================================================== @Override public Object getCredentials() { 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 f4f1869e..a5a3a8ed 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 @@ -21,34 +21,32 @@ import java.security.cert.X509Certificate; 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. *

- *

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

* * @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.

+ * Obtains the granted authorities for the specified user. + *

+ * 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. + * application's purpose. */ - UserDetails getUserDetails(X509Certificate userCertificate) - throws AuthenticationException; + 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 c22af038..c9b37c97 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 @@ -16,42 +16,42 @@ 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. - *

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

+ * Caches {@code User} objects using a Spring IoC defined EHCACHE. + *

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

* * @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 { 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 fa87a946..96ffd3e5 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 @@ -20,15 +20,16 @@ import java.security.cert.X509Certificate; import org.springframework.security.core.userdetails.UserDetails; - /** * "Cache" that doesn't do any caching. - *

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

+ *

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

* * @author Luke Taylor */ public class NullX509UserCache implements X509UserCache { - //~ Methods ======================================================================================================== + // ~ Methods ======================================================================================================== @Override public UserDetails getUserFromCache(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 af0c0744..223eb090 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 @@ -20,24 +20,23 @@ 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; import org.springframework.util.Assert; - /** * Caches {@code User} objects using a Spring Framework-based {@link Cache}. - * - *

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

+ *

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

* * @author Luke Taylor * @author Ben Alex * @author Greg Turnquist */ public class SpringBasedX509UserCache implements X509UserCache, InitializingBean { - + private static final Log logger = LogFactory.getLog(SpringBasedX509UserCache.class); private 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 c51ddb4a..f88769a5 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 @@ -20,21 +20,21 @@ import java.security.cert.X509Certificate; 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. *

- *

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

* * @author Luke Taylor */ public interface X509UserCache { - //~ Methods ======================================================================================================== + // ~ Methods ======================================================================================================== UserDetails getUserFromCache(X509Certificate userCertificate); 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 6864a484..38c4be2b 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 @@ -35,21 +35,23 @@ import org.springframework.ws.soap.security.x509.X509AuthoritiesPopulator; /** * 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.

+ *

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

* * @author Luke Taylor * @version $Id: DaoX509AuthoritiesPopulator.java 2544 2008-01-29 11:50:33Z luke_t $ */ 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 { @@ -67,7 +69,7 @@ public class DaoX509AuthoritiesPopulator implements X509AuthoritiesPopulator, In if (!matcher.find()) { throw new BadCredentialsException(messages.getMessage("DaoX509AuthoritiesPopulator.noMatching", - new Object[] {subjectDN}, "No matching pattern was found in subjectDN: {0}")); + new Object[] { subjectDN }, "No matching pattern was found in subjectDN: {0}")); } if (matcher.groupCount() != 1) { @@ -80,7 +82,7 @@ public class DaoX509AuthoritiesPopulator implements X509AuthoritiesPopulator, In if (user == null) { throw new AuthenticationServiceException( - "UserDetailsService returned null, which is an interface contract violation"); + "UserDetailsService returned null, which is an interface contract violation"); } return user; @@ -92,12 +94,15 @@ 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. - *

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"

+ * 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". + *

+ *

+ * 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 */ diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptor.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptor.java index 34707268..9f49aee7 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptor.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptor.java @@ -18,17 +18,12 @@ package org.springframework.ws.soap.security.xwss; import java.io.IOException; import java.io.InputStream; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; import javax.xml.soap.SOAPMessage; -import com.sun.xml.wss.ProcessingContext; -import com.sun.xml.wss.XWSSProcessor; -import com.sun.xml.wss.XWSSProcessorFactory; -import com.sun.xml.wss.XWSSecurityException; -import com.sun.xml.wss.impl.WssSoapFaultException; - import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -40,20 +35,27 @@ import org.springframework.ws.soap.security.WsSecurityValidationException; import org.springframework.ws.soap.security.callback.CleanupCallback; import org.springframework.ws.soap.security.xwss.callback.XwssCallbackHandlerChain; +import com.sun.xml.wss.ProcessingContext; +import com.sun.xml.wss.XWSSProcessor; +import com.sun.xml.wss.XWSSProcessorFactory; +import com.sun.xml.wss.XWSSecurityException; +import com.sun.xml.wss.impl.WssSoapFaultException; + /** - * WS-Security endpoint interceptor that is based on Sun's XML and Web Services Security package (XWSS). This + * WS-Security endpoint interceptor that is based on Sun's XML and Web Services Security package (XWSS). This * WS-Security implementation is part of the Java Web Services Developer Pack (Java WSDP). - * - *

This interceptor needs a {@code CallbackHandler} to operate. This handler is used to retrieve certificates, - * private keys, validate user credentials, etc. Refer to the XWSS Javadoc to learn more about the specific - * {@code Callback}s fired by XWSS. You can also set multiple handlers, each of which will be used in turn. - * - *

Additionally, you must define a XWSS policy file by setting {@code policyConfiguration} property. The format of - * the policy file is documented in the Java - * Web Services Tutorial. - * - *

Note that this interceptor depends on SAAJ, and thus requires {@code SaajSoapMessage}s to operate. This - * means that you must use a {@code SaajSoapMessageFactory} to create the SOAP messages. + *

+ * This interceptor needs a {@code CallbackHandler} to operate. This handler is used to retrieve certificates, private + * keys, validate user credentials, etc. Refer to the XWSS Javadoc to learn more about the specific {@code Callback}s + * fired by XWSS. You can also set multiple handlers, each of which will be used in turn. + *

+ * Additionally, you must define a XWSS policy file by setting {@code policyConfiguration} property. The format of the + * policy file is documented in the + * Java Web Services + * Tutorial. + *

+ * Note that this interceptor depends on SAAJ, and thus requires {@code SaajSoapMessage}s to operate. This means + * that you must use a {@code SaajSoapMessageFactory} to create the SOAP messages. * * @author Arjen Poutsma * @see #setCallbackHandler(javax.security.auth.callback.CallbackHandler) @@ -72,8 +74,7 @@ public class XwsSecurityInterceptor extends AbstractWsSecurityInterceptor implem private Resource policyConfiguration; /** - * Sets the handler to resolve XWSS callbacks. Setting either this propery, or {@code callbackHandlers}, is - * required. + * Sets the handler to resolve XWSS callbacks. Setting either this propery, or {@code callbackHandlers}, is required. * * @see com.sun.xml.wss.impl.callback.XWSSCallback * @see #setCallbackHandlers(javax.security.auth.callback.CallbackHandler[]) @@ -83,8 +84,7 @@ public class XwsSecurityInterceptor extends AbstractWsSecurityInterceptor implem } /** - * Sets the handlers to resolve XWSS callbacks. Setting either this propery, or {@code callbackHandlers}, is - * required. + * Sets the handlers to resolve XWSS callbacks. Setting either this propery, or {@code callbackHandlers}, is required. * * @see com.sun.xml.wss.impl.callback.XWSSCallback * @see #setCallbackHandler(javax.security.auth.callback.CallbackHandler) @@ -111,8 +111,7 @@ public class XwsSecurityInterceptor extends AbstractWsSecurityInterceptor implem } is = policyConfiguration.getInputStream(); processor = processorFactory.createProcessorForSecurityConfiguration(is, callbackHandler); - } - finally { + } finally { if (is != null) { is.close(); } @@ -124,23 +123,21 @@ public class XwsSecurityInterceptor extends AbstractWsSecurityInterceptor implem * * @param soapMessage the message to be secured * @throws XwsSecuritySecurementException in case of errors - * @throws IllegalArgumentException when soapMessage is not a {@code SaajSoapMessage} + * @throws IllegalArgumentException when soapMessage is not a {@code SaajSoapMessage} */ @Override protected void secureMessage(SoapMessage soapMessage, MessageContext messageContext) throws XwsSecuritySecurementException { - Assert.isTrue(soapMessage instanceof SaajSoapMessage, "XwsSecurityInterceptor requires a SaajSoapMessage. " + - "Use a SaajSoapMessageFactory to create the SOAP messages."); + Assert.isTrue(soapMessage instanceof SaajSoapMessage, "XwsSecurityInterceptor requires a SaajSoapMessage. " + + "Use a SaajSoapMessageFactory to create the SOAP messages."); SaajSoapMessage saajSoapMessage = (SaajSoapMessage) soapMessage; try { ProcessingContext context = processor.createProcessingContext(saajSoapMessage.getSaajMessage()); SOAPMessage result = processor.secureOutboundMessage(context); saajSoapMessage.setSaajMessage(result); - } - catch (XWSSecurityException ex) { + } catch (XWSSecurityException ex) { throw new XwsSecuritySecurementException(ex.getMessage(), ex); - } - catch (WssSoapFaultException ex) { + } catch (WssSoapFaultException ex) { throw new XwsSecurityFaultException(ex.getFaultCode(), ex.getFaultString(), ex.getFaultActor()); } } @@ -150,23 +147,21 @@ public class XwsSecurityInterceptor extends AbstractWsSecurityInterceptor implem * * @param soapMessage the message to be validated * @throws XwsSecurityValidationException in case of errors - * @throws IllegalArgumentException when soapMessage is not a {@code SaajSoapMessage} + * @throws IllegalArgumentException when soapMessage is not a {@code SaajSoapMessage} */ @Override protected void validateMessage(SoapMessage soapMessage, MessageContext messageContext) throws WsSecurityValidationException { - Assert.isTrue(soapMessage instanceof SaajSoapMessage, "XwsSecurityInterceptor requires a SaajSoapMessage. " + - "Use a SaajSoapMessageFactory to create the SOAP messages."); + Assert.isTrue(soapMessage instanceof SaajSoapMessage, "XwsSecurityInterceptor requires a SaajSoapMessage. " + + "Use a SaajSoapMessageFactory to create the SOAP messages."); SaajSoapMessage saajSoapMessage = (SaajSoapMessage) soapMessage; try { ProcessingContext context = processor.createProcessingContext(saajSoapMessage.getSaajMessage()); SOAPMessage result = processor.verifyInboundMessage(context); saajSoapMessage.setSaajMessage(result); - } - catch (XWSSecurityException ex) { + } catch (XWSSecurityException ex) { throw new XwsSecurityValidationException(ex.getMessage(), ex); - } - catch (WssSoapFaultException ex) { + } catch (WssSoapFaultException ex) { throw new XwsSecurityFaultException(ex.getFaultCode(), ex.getFaultString(), ex.getFaultActor()); } } @@ -176,12 +171,10 @@ public class XwsSecurityInterceptor extends AbstractWsSecurityInterceptor implem if (callbackHandler != null) { try { CleanupCallback cleanupCallback = new CleanupCallback(); - callbackHandler.handle(new Callback[]{cleanupCallback}); - } - catch (IOException ex) { + callbackHandler.handle(new Callback[] { cleanupCallback }); + } 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/xwss/callback/CryptographyCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/CryptographyCallbackHandler.java index f68c8322..56085115 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/CryptographyCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/CryptographyCallbackHandler.java @@ -17,21 +17,22 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.IOException; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; +import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; + import com.sun.xml.wss.impl.callback.CertificateValidationCallback; import com.sun.xml.wss.impl.callback.DecryptionKeyCallback; import com.sun.xml.wss.impl.callback.EncryptionKeyCallback; import com.sun.xml.wss.impl.callback.SignatureKeyCallback; import com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback; -import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; - /** * Default callback handler that handles cryptographic callback. This handler determines the exact callback passed, and - * calls a template method for it. By default, all template methods throw an {@code UnsupportedCallbackException}, - * so you only need to override those you need. + * calls a template method for it. By default, all template methods throw an {@code UnsupportedCallbackException}, so + * you only need to override those you need. * * @author Arjen Poutsma * @since 1.0.0 @@ -42,20 +43,15 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { protected final void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof CertificateValidationCallback) { handleCertificateValidationCallback((CertificateValidationCallback) callback); - } - else if (callback instanceof DecryptionKeyCallback) { + } else if (callback instanceof DecryptionKeyCallback) { handleDecryptionKeyCallback((DecryptionKeyCallback) callback); - } - else if (callback instanceof EncryptionKeyCallback) { + } else if (callback instanceof EncryptionKeyCallback) { handleEncryptionKeyCallback((EncryptionKeyCallback) callback); - } - else if (callback instanceof SignatureKeyCallback) { + } else if (callback instanceof SignatureKeyCallback) { handleSignatureKeyCallback((SignatureKeyCallback) callback); - } - else if (callback instanceof SignatureVerificationKeyCallback) { + } else if (callback instanceof SignatureVerificationKeyCallback) { handleSignatureVerificationKeyCallback((SignatureVerificationKeyCallback) callback); - } - else { + } else { throw new UnsupportedCallbackException(callback); } @@ -66,8 +62,8 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { // /** - * Template method that handles {@code CertificateValidationCallback}s. Called from - * {@code handleInternal()}. Default implementation throws an {@code UnsupportedCallbackException}. + * Template method that handles {@code CertificateValidationCallback}s. Called from {@code handleInternal()}. Default + * implementation throws an {@code UnsupportedCallbackException}. */ protected void handleCertificateValidationCallback(CertificateValidationCallback callback) throws IOException, UnsupportedCallbackException { @@ -79,23 +75,21 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { // /** - * Method that handles {@code DecryptionKeyCallback}s. Called from {@code handleInternal()}. Default - * implementation delegates to specific handling methods. + * Method that handles {@code DecryptionKeyCallback}s. Called from {@code handleInternal()}. Default implementation + * delegates to specific handling methods. * * @see #handlePrivateKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback, - * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.PrivateKeyRequest) + * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.PrivateKeyRequest) * @see #handleSymmetricKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback, - * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.SymmetricKeyRequest) + * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.SymmetricKeyRequest) */ protected final void handleDecryptionKeyCallback(DecryptionKeyCallback callback) throws IOException, UnsupportedCallbackException { if (callback.getRequest() instanceof DecryptionKeyCallback.PrivateKeyRequest) { handlePrivateKeyRequest(callback, (DecryptionKeyCallback.PrivateKeyRequest) callback.getRequest()); - } - else if (callback.getRequest() instanceof DecryptionKeyCallback.SymmetricKeyRequest) { + } else if (callback.getRequest() instanceof DecryptionKeyCallback.SymmetricKeyRequest) { handleSymmetricKeyRequest(callback, (DecryptionKeyCallback.SymmetricKeyRequest) callback.getRequest()); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } @@ -105,65 +99,54 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { * {@code handleDecryptionKeyCallback()}. Default implementation delegates to specific handling methods. * * @see #handlePublicKeyBasedPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) + * com.sun.xml.wss.impl.callback.SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) * @see #handleX509CertificateBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback, - * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509CertificateBasedRequest) + * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509CertificateBasedRequest) * @see #handleX509IssuerSerialBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback, - * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509IssuerSerialBasedRequest) + * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509IssuerSerialBasedRequest) * @see #handleX509SubjectKeyIdentifierBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback, - * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest) + * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest) */ protected final void handlePrivateKeyRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.PrivateKeyRequest request) - throws IOException, UnsupportedCallbackException { + DecryptionKeyCallback.PrivateKeyRequest request) throws IOException, UnsupportedCallbackException { if (request instanceof DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest) { handlePublicKeyBasedPrivKeyRequest(callback, (DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest) request); - } - else if (request instanceof DecryptionKeyCallback.X509CertificateBasedRequest) { + } else if (request instanceof DecryptionKeyCallback.X509CertificateBasedRequest) { handleX509CertificateBasedRequest(callback, (DecryptionKeyCallback.X509CertificateBasedRequest) request); - } - else if (request instanceof DecryptionKeyCallback.X509IssuerSerialBasedRequest) { + } else if (request instanceof DecryptionKeyCallback.X509IssuerSerialBasedRequest) { handleX509IssuerSerialBasedRequest(callback, (DecryptionKeyCallback.X509IssuerSerialBasedRequest) request); - } - else if (request instanceof DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest) { + } else if (request instanceof DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest) { handleX509SubjectKeyIdentifierBasedRequest(callback, (DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest) request); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } /** - * Template method that handles {@code DecryptionKeyCallback}s with {@code PublicKeyBasedPrivKeyRequest}s. - * Called from {@code handlePrivateKeyRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code DecryptionKeyCallback}s with {@code PublicKeyBasedPrivKeyRequest}s. Called from + * {@code handlePrivateKeyRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handlePublicKeyBasedPrivKeyRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest request) - throws IOException, UnsupportedCallbackException { + DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } /** - * Template method that handles {@code DecryptionKeyCallback}s with {@code X509CertificateBasedRequest}s. - * Called from {@code handlePrivateKeyRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code DecryptionKeyCallback}s with {@code X509CertificateBasedRequest}s. Called from + * {@code handlePrivateKeyRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleX509CertificateBasedRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.X509CertificateBasedRequest request) - throws IOException, UnsupportedCallbackException { + DecryptionKeyCallback.X509CertificateBasedRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } /** - * Template method that handles {@code DecryptionKeyCallback}s with {@code X509IssuerSerialBasedRequest}s. - * Called from {@code handlePrivateKeyRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code DecryptionKeyCallback}s with {@code X509IssuerSerialBasedRequest}s. Called from + * {@code handlePrivateKeyRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleX509IssuerSerialBasedRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.X509IssuerSerialBasedRequest request) - throws IOException, UnsupportedCallbackException { + DecryptionKeyCallback.X509IssuerSerialBasedRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } @@ -173,7 +156,7 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { * {@code UnsupportedCallbackException}. */ protected void handleX509SubjectKeyIdentifierBasedRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest request) + DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } @@ -183,29 +166,24 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { * {@code handleDecryptionKeyCallback()}. Default implementation delegates to specific handling methods. * * @see #handleAliasSymmetricKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback, - * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.AliasSymmetricKeyRequest) + * com.sun.xml.wss.impl.callback.DecryptionKeyCallback.AliasSymmetricKeyRequest) */ protected final void handleSymmetricKeyRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.SymmetricKeyRequest request) - throws IOException, UnsupportedCallbackException { + DecryptionKeyCallback.SymmetricKeyRequest request) throws IOException, UnsupportedCallbackException { if (request instanceof DecryptionKeyCallback.AliasSymmetricKeyRequest) { - DecryptionKeyCallback.AliasSymmetricKeyRequest aliasSymmetricKeyRequest = - (DecryptionKeyCallback.AliasSymmetricKeyRequest) request; + DecryptionKeyCallback.AliasSymmetricKeyRequest aliasSymmetricKeyRequest = (DecryptionKeyCallback.AliasSymmetricKeyRequest) request; handleAliasSymmetricKeyRequest(callback, aliasSymmetricKeyRequest); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } /** - * Template method that handles {@code DecryptionKeyCallback}s with {@code AliasSymmetricKeyRequest}s. - * Called from {@code handleSymmetricKeyRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code DecryptionKeyCallback}s with {@code AliasSymmetricKeyRequest}s. Called from + * {@code handleSymmetricKeyRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleAliasSymmetricKeyRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.AliasSymmetricKeyRequest request) - throws IOException, UnsupportedCallbackException { + DecryptionKeyCallback.AliasSymmetricKeyRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } @@ -214,24 +192,21 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { // /** - * Method that handles {@code EncryptionKeyCallback}s. Called from {@code handleInternal()}. Default - * implementation delegates to specific handling methods. + * Method that handles {@code EncryptionKeyCallback}s. Called from {@code handleInternal()}. Default implementation + * delegates to specific handling methods. * * @see #handleSymmetricKeyRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback, - * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.SymmetricKeyRequest) + * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.SymmetricKeyRequest) * @see #handleX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback, - * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.X509CertificateRequest) + * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.X509CertificateRequest) */ protected final void handleEncryptionKeyCallback(EncryptionKeyCallback callback) throws IOException, UnsupportedCallbackException { if (callback.getRequest() instanceof EncryptionKeyCallback.SymmetricKeyRequest) { handleSymmetricKeyRequest(callback, (EncryptionKeyCallback.SymmetricKeyRequest) callback.getRequest()); - } - else if (callback.getRequest() instanceof EncryptionKeyCallback.X509CertificateRequest) { - handleX509CertificateRequest(callback, - (EncryptionKeyCallback.X509CertificateRequest) callback.getRequest()); - } - else { + } else if (callback.getRequest() instanceof EncryptionKeyCallback.X509CertificateRequest) { + handleX509CertificateRequest(callback, (EncryptionKeyCallback.X509CertificateRequest) callback.getRequest()); + } else { throw new UnsupportedCallbackException(callback); } @@ -242,24 +217,21 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { * {@code handleEncryptionKeyCallback()}. Default implementation delegates to specific handling methods. * * @see #handleAliasSymmetricKeyRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback, - * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasSymmetricKeyRequest) + * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasSymmetricKeyRequest) */ protected final void handleSymmetricKeyRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.SymmetricKeyRequest request) - throws IOException, UnsupportedCallbackException { + EncryptionKeyCallback.SymmetricKeyRequest request) throws IOException, UnsupportedCallbackException { if (request instanceof EncryptionKeyCallback.AliasSymmetricKeyRequest) { handleAliasSymmetricKeyRequest(callback, (EncryptionKeyCallback.AliasSymmetricKeyRequest) request); } } /** - * Template method that handles {@code EncryptionKeyCallback}s with {@code AliasSymmetricKeyRequest}s. - * Called from {@code handleSymmetricKeyRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code EncryptionKeyCallback}s with {@code AliasSymmetricKeyRequest}s. Called from + * {@code handleSymmetricKeyRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleAliasSymmetricKeyRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.AliasSymmetricKeyRequest request) - throws IOException, UnsupportedCallbackException { + EncryptionKeyCallback.AliasSymmetricKeyRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } @@ -268,60 +240,49 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { * {@code handleEncryptionKeyCallback()}. Default implementation delegates to specific handling methods. * * @see #handleAliasX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback, - * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasX509CertificateRequest) + * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasX509CertificateRequest) * @see #handleDefaultX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback, - * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.DefaultX509CertificateRequest) + * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.DefaultX509CertificateRequest) * @see #handlePublicKeyBasedRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback, - * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.PublicKeyBasedRequest) + * com.sun.xml.wss.impl.callback.EncryptionKeyCallback.PublicKeyBasedRequest) */ protected final void handleX509CertificateRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.X509CertificateRequest request) - throws IOException, UnsupportedCallbackException { + EncryptionKeyCallback.X509CertificateRequest request) throws IOException, UnsupportedCallbackException { if (request instanceof EncryptionKeyCallback.AliasX509CertificateRequest) { handleAliasX509CertificateRequest(callback, (EncryptionKeyCallback.AliasX509CertificateRequest) request); - } - else if (request instanceof EncryptionKeyCallback.DefaultX509CertificateRequest) { - handleDefaultX509CertificateRequest(callback, - (EncryptionKeyCallback.DefaultX509CertificateRequest) request); - } - else if (request instanceof EncryptionKeyCallback.PublicKeyBasedRequest) { + } else if (request instanceof EncryptionKeyCallback.DefaultX509CertificateRequest) { + handleDefaultX509CertificateRequest(callback, (EncryptionKeyCallback.DefaultX509CertificateRequest) request); + } else if (request instanceof EncryptionKeyCallback.PublicKeyBasedRequest) { handlePublicKeyBasedRequest(callback, (EncryptionKeyCallback.PublicKeyBasedRequest) request); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } /** - * Template method that handles {@code EncryptionKeyCallback}s with {@code AliasX509CertificateRequest}s. - * Called from {@code handleX509CertificateRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code EncryptionKeyCallback}s with {@code AliasX509CertificateRequest}s. Called from + * {@code handleX509CertificateRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleAliasX509CertificateRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.AliasX509CertificateRequest request) - throws IOException, UnsupportedCallbackException { + EncryptionKeyCallback.AliasX509CertificateRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } /** - * Template method that handles {@code EncryptionKeyCallback}s with {@code DefaultX509CertificateRequest}s. - * Called from {@code handleX509CertificateRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code EncryptionKeyCallback}s with {@code DefaultX509CertificateRequest}s. Called + * from {@code handleX509CertificateRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleDefaultX509CertificateRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.DefaultX509CertificateRequest request) - throws IOException, UnsupportedCallbackException { + EncryptionKeyCallback.DefaultX509CertificateRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } /** - * Template method that handles {@code EncryptionKeyCallback}s with {@code PublicKeyBasedRequest}s. Called - * from {@code handleX509CertificateRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code EncryptionKeyCallback}s with {@code PublicKeyBasedRequest}s. Called from + * {@code handleX509CertificateRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handlePublicKeyBasedRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.PublicKeyBasedRequest request) - throws IOException, UnsupportedCallbackException { + EncryptionKeyCallback.PublicKeyBasedRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } @@ -330,18 +291,17 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { // /** - * Method that handles {@code SignatureKeyCallback}s. Called from {@code handleInternal()}. Default - * implementation delegates to specific handling methods. + * Method that handles {@code SignatureKeyCallback}s. Called from {@code handleInternal()}. Default implementation + * delegates to specific handling methods. * * @see #handlePrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureKeyCallback.PrivKeyCertRequest) + * com.sun.xml.wss.impl.callback.SignatureKeyCallback.PrivKeyCertRequest) */ protected final void handleSignatureKeyCallback(SignatureKeyCallback callback) throws IOException, UnsupportedCallbackException { if (callback.getRequest() instanceof SignatureKeyCallback.PrivKeyCertRequest) { handlePrivKeyCertRequest(callback, (SignatureKeyCallback.PrivKeyCertRequest) callback.getRequest()); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } @@ -351,59 +311,49 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { * {@code handleSignatureKeyCallback()}. Default implementation delegates to specific handling methods. * * @see #handleDefaultPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureKeyCallback.DefaultPrivKeyCertRequest) + * com.sun.xml.wss.impl.callback.SignatureKeyCallback.DefaultPrivKeyCertRequest) * @see #handleAliasPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureKeyCallback.AliasPrivKeyCertRequest) + * com.sun.xml.wss.impl.callback.SignatureKeyCallback.AliasPrivKeyCertRequest) * @see #handlePublicKeyBasedPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) + * com.sun.xml.wss.impl.callback.SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) */ protected final void handlePrivKeyCertRequest(SignatureKeyCallback cb, - SignatureKeyCallback.PrivKeyCertRequest request) - throws IOException, UnsupportedCallbackException { + SignatureKeyCallback.PrivKeyCertRequest request) throws IOException, UnsupportedCallbackException { if (request instanceof SignatureKeyCallback.DefaultPrivKeyCertRequest) { handleDefaultPrivKeyCertRequest(cb, (SignatureKeyCallback.DefaultPrivKeyCertRequest) request); - } - else if (cb.getRequest() instanceof SignatureKeyCallback.AliasPrivKeyCertRequest) { + } else if (cb.getRequest() instanceof SignatureKeyCallback.AliasPrivKeyCertRequest) { handleAliasPrivKeyCertRequest(cb, (SignatureKeyCallback.AliasPrivKeyCertRequest) request); - } - else if (cb.getRequest() instanceof SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) { + } else if (cb.getRequest() instanceof SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) { handlePublicKeyBasedPrivKeyCertRequest(cb, (SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) request); - } - else { + } else { throw new UnsupportedCallbackException(cb); } } /** - * Template method that handles {@code SignatureKeyCallback}s with {@code DefaultPrivKeyCertRequest}s. - * Called from {@code handlePrivKeyCertRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code SignatureKeyCallback}s with {@code DefaultPrivKeyCertRequest}s. Called from + * {@code handlePrivKeyCertRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleDefaultPrivKeyCertRequest(SignatureKeyCallback callback, - SignatureKeyCallback.DefaultPrivKeyCertRequest request) - throws IOException, UnsupportedCallbackException { + SignatureKeyCallback.DefaultPrivKeyCertRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } /** - * Template method that handles {@code SignatureKeyCallback}s with {@code AliasPrivKeyCertRequest}s. - * Called from {@code handlePrivKeyCertRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code SignatureKeyCallback}s with {@code AliasPrivKeyCertRequest}s. Called from + * {@code handlePrivKeyCertRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleAliasPrivKeyCertRequest(SignatureKeyCallback callback, - SignatureKeyCallback.AliasPrivKeyCertRequest request) - throws IOException, UnsupportedCallbackException { + SignatureKeyCallback.AliasPrivKeyCertRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } /** - * Template method that handles {@code SignatureKeyCallback}s with {@code PublicKeyBasedPrivKeyCertRequest}s. - * Called from {@code handlePrivKeyCertRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code SignatureKeyCallback}s with {@code PublicKeyBasedPrivKeyCertRequest}s. Called + * from {@code handlePrivKeyCertRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handlePublicKeyBasedPrivKeyCertRequest(SignatureKeyCallback callback, - SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest request) - throws IOException, UnsupportedCallbackException { + SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } @@ -412,84 +362,75 @@ public class CryptographyCallbackHandler extends AbstractCallbackHandler { // /** - * Method that handles {@code SignatureVerificationKeyCallback}s. Called from {@code handleInternal()}. - * Default implementation delegates to specific handling methods. + * Method that handles {@code SignatureVerificationKeyCallback}s. Called from {@code handleInternal()}. Default + * implementation delegates to specific handling methods. * * @see #handleX509CertificateRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509CertificateRequest) + * com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509CertificateRequest) */ protected final void handleSignatureVerificationKeyCallback(SignatureVerificationKeyCallback callback) throws UnsupportedCallbackException, IOException { if (callback.getRequest() instanceof SignatureVerificationKeyCallback.X509CertificateRequest) { handleX509CertificateRequest(callback, (SignatureVerificationKeyCallback.X509CertificateRequest) callback.getRequest()); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } /** - * Method that handles {@code SignatureVerificationKeyCallback}s with {@code X509CertificateRequest}s. - * Called from {@code handleSignatureVerificationKeyCallback()}. Default implementation delegates to specific - * handling methods. + * Method that handles {@code SignatureVerificationKeyCallback}s with {@code X509CertificateRequest}s. Called from + * {@code handleSignatureVerificationKeyCallback()}. Default implementation delegates to specific handling methods. * * @see #handlePublicKeyBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.PublicKeyBasedRequest) + * com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.PublicKeyBasedRequest) * @see #handleX509IssuerSerialBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest) + * com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest) * @see #handleX509SubjectKeyIdentifierBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback, - * com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest) + * com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest) */ protected final void handleX509CertificateRequest(SignatureVerificationKeyCallback callback, - SignatureVerificationKeyCallback.X509CertificateRequest request) + SignatureVerificationKeyCallback.X509CertificateRequest request) throws UnsupportedCallbackException, IOException { if (request instanceof SignatureVerificationKeyCallback.PublicKeyBasedRequest) { handlePublicKeyBasedRequest(callback, (SignatureVerificationKeyCallback.PublicKeyBasedRequest) request); - } - else if (request instanceof SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest) { + } else if (request instanceof SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest) { handleX509IssuerSerialBasedRequest(callback, (SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest) request); - } - else if (request instanceof SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest) { + } else if (request instanceof SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest) { handleX509SubjectKeyIdentifierBasedRequest(callback, (SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest) request); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } /** - * Template method that handles {@code SignatureKeyCallback}s with {@code PublicKeyBasedPrivKeyCertRequest}s. - * Called from {@code handlePrivKeyCertRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code SignatureKeyCallback}s with {@code PublicKeyBasedPrivKeyCertRequest}s. Called + * from {@code handlePrivKeyCertRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleX509SubjectKeyIdentifierBasedRequest(SignatureVerificationKeyCallback callback, - SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest request) + SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } /** - * Template method that handles {@code SignatureKeyCallback}s with {@code X509IssuerSerialBasedRequest}s. - * Called from {@code handlePrivKeyCertRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code SignatureKeyCallback}s with {@code X509IssuerSerialBasedRequest}s. Called from + * {@code handlePrivKeyCertRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handleX509IssuerSerialBasedRequest(SignatureVerificationKeyCallback callback, - SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest request) + SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } /** - * Template method that handles {@code SignatureKeyCallback}s with {@code PublicKeyBasedRequest}s. Called - * from {@code handlePrivKeyCertRequest()}. Default implementation throws an - * {@code UnsupportedCallbackException}. + * Template method that handles {@code SignatureKeyCallback}s with {@code PublicKeyBasedRequest}s. Called from + * {@code handlePrivKeyCertRequest()}. Default implementation throws an {@code UnsupportedCallbackException}. */ protected void handlePublicKeyBasedRequest(SignatureVerificationKeyCallback callback, - SignatureVerificationKeyCallback.PublicKeyBasedRequest request) - throws IOException, UnsupportedCallbackException { + SignatureVerificationKeyCallback.PublicKeyBasedRequest request) throws IOException, UnsupportedCallbackException { throw new UnsupportedCallbackException(callback); } } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidator.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidator.java index 16f7ac1e..674f7f2d 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidator.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidator.java @@ -25,8 +25,8 @@ import java.util.GregorianCalendar; import com.sun.xml.wss.impl.callback.TimestampValidationCallback; /** - * A default implementation of a {@code TimestampValidationCallback.TimestampValidator}. Based on a version found - * in the JWSDP samples. + * A default implementation of a {@code TimestampValidationCallback.TimestampValidator}. Based on a version found in the + * JWSDP samples. * * @author Arjen Poutsma * @since 1.0.0 @@ -37,8 +37,7 @@ public class DefaultTimestampValidator implements TimestampValidationCallback.Ti public void validate(TimestampValidationCallback.Request request) throws TimestampValidationCallback.TimestampValidationException { if (request instanceof TimestampValidationCallback.UTCTimestampRequest) { - TimestampValidationCallback.UTCTimestampRequest utcRequest = - (TimestampValidationCallback.UTCTimestampRequest) request; + TimestampValidationCallback.UTCTimestampRequest utcRequest = (TimestampValidationCallback.UTCTimestampRequest) request; Date created = parseDate(utcRequest.getCreated()); validateCreationTime(created, utcRequest.getMaxClockSkew(), utcRequest.getTimestampFreshnessLimit()); @@ -47,8 +46,7 @@ public class DefaultTimestampValidator implements TimestampValidationCallback.Ti Date expired = parseDate(utcRequest.getExpired()); validateExpirationTime(expired, utcRequest.getMaxClockSkew()); } - } - else { + } else { throw new TimestampValidationCallback.TimestampValidationException("Unsupport request: [" + request + "]"); } } @@ -78,8 +76,7 @@ public class DefaultTimestampValidator implements TimestampValidationCallback.Ti if (addSkew) { currentTime = currentTime + maxClockSkew; - } - else { + } else { currentTime = currentTime - maxClockSkew; } @@ -94,14 +91,11 @@ public class DefaultTimestampValidator implements TimestampValidationCallback.Ti try { try { return calendarFormatter1.parse(date); - } - catch (ParseException ignored) { + } catch (ParseException ignored) { return calendarFormatter2.parse(date); } - } - catch (ParseException ex) { - throw new TimestampValidationCallback.TimestampValidationException("Could not parse request date: " + date, - ex); + } catch (ParseException ex) { + throw new TimestampValidationCallback.TimestampValidationException("Could not parse request date: " + date, ex); } } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandler.java index ef0db0cc..609a578d 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandler.java @@ -33,39 +33,68 @@ import java.security.cert.X509CertSelector; import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.Enumeration; + import javax.crypto.SecretKey; +import org.apache.xml.security.utils.RFC2253Parser; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.ws.soap.security.support.KeyStoreUtils; + import com.sun.xml.wss.impl.callback.CertificateValidationCallback; import com.sun.xml.wss.impl.callback.DecryptionKeyCallback; import com.sun.xml.wss.impl.callback.EncryptionKeyCallback; import com.sun.xml.wss.impl.callback.SignatureKeyCallback; import com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback; -import org.apache.xml.security.utils.RFC2253Parser; - -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. - * - *

This handler requires one or more key stores to be set. You can configure them in your application context by using a + * 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. + *

+ * This handler requires one or more key stores to be set. You can configure them in your application context by using a * {@code KeyStoreFactoryBean}. The exact stores to be set depends on the cryptographic operations that are to be - * performed by this handler. The table underneath show the key store to be used for each operation: - * - * - * - * - * - *
Cryptographic operation Key store used
Certificate validation first {@code keyStore}, then {@code trustStore}
Decryption based on private key {@code keyStore}
Decryption based on symmetric - * key {@code symmetricStore}
Encryption based on certificate{@code trustStore}
Encryption based on symmetric key{@code symmetricStore}
Signing {@code keyStore}
Signature verification {@code trustStore}
- * - *

Default key stores

If the {@code symmetricStore} is not set, it will default to the - * {@code keyStore}. If the key or trust store is not set, this handler will use the standard Java mechanism to - * load or create it. See {@link #loadDefaultKeyStore()} and {@link #loadDefaultTrustStore()}. - * - *

Examples

For instance, if you want to use the {@code KeyStoreCallbackHandler} to validate incoming + * performed by this handler. The table underneath show the key store to be used for each operation: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Cryptographic operationKey store used
Certificate validationfirst {@code keyStore}, then {@code trustStore}
Decryption based on private key{@code keyStore}
Decryption based on symmetric key{@code symmetricStore}
Encryption based on certificate{@code trustStore}
Encryption based on symmetric key{@code symmetricStore}
Signing{@code keyStore}
Signature verification{@code trustStore}
+ *

+ *

Default key stores

If the {@code symmetricStore} is not set, it will default to the {@code keyStore}. If the + * key or trust store is not set, this handler will use the standard Java mechanism to load or create it. See + * {@link #loadDefaultKeyStore()} and {@link #loadDefaultTrustStore()}. + *

+ *

Examples

For instance, if you want to use the {@code KeyStoreCallbackHandler} to validate incoming * certificates or signatures, you would use a trust store, like so: + * *
  * <bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler">
  *	   <property name="trustStore" ref="trustStore"/>
@@ -76,8 +105,9 @@ import org.springframework.ws.soap.security.support.KeyStoreUtils;
  *	   <property name="password" value="changeit"/>
  * </bean>
  * 
- * If you want to use it to decrypt incoming certificates or sign outgoing messages, you would use a key store, like - * so: + * + * If you want to use it to decrypt incoming certificates or sign outgoing messages, you would use a key store, like so: + * *
  * <bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler">
  *	   <property name="keyStore" ref="keyStore"/>
@@ -90,9 +120,9 @@ import org.springframework.ws.soap.security.support.KeyStoreUtils;
  * </bean>
  * 
* - *

Handled callbacks

This class handles {@code CertificateValidationCallback}s, - * {@code DecryptionKeyCallback}s, {@code EncryptionKeyCallback}s, {@code SignatureKeyCallback}s, and - * {@code SignatureVerificationKeyCallback}s. It throws an {@code UnsupportedCallbackException} for others. + *

Handled callbacks

This class handles {@code CertificateValidationCallback}s, {@code DecryptionKeyCallback}s, + * {@code EncryptionKeyCallback}s, {@code SignatureKeyCallback}s, and {@code SignatureVerificationKeyCallback}s. It + * throws an {@code UnsupportedCallbackException} for others. * * @author Arjen Poutsma * @see KeyStore @@ -103,7 +133,7 @@ import org.springframework.ws.soap.security.support.KeyStoreUtils; * @see SignatureKeyCallback * @see SignatureVerificationKeyCallback * @see The - * standard Java trust store mechanism + * standard Java trust store mechanism * @since 1.0.0 */ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler implements InitializingBean { @@ -129,8 +159,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme private static X509Certificate getCertificate(String alias, KeyStore store) throws IOException { try { return (X509Certificate) store.getCertificate(alias); - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } } @@ -149,8 +178,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme return x509Cert; } } - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } return null; @@ -183,8 +211,8 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme } /** - * Sets the password used to retrieve keys from the symmetric keystore. If this property is not set, it default to - * the private key password. + * Sets the password used to retrieve keys from the symmetric keystore. If this property is not set, it default to the + * private key password. * * @see #setPrivateKeyPassword(String) */ @@ -217,8 +245,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme } /** - * Determines if certificate revocation checking is enabled or not. Default is - * {@code false}. + * Determines if certificate revocation checking is enabled or not. Default is {@code false}. */ public void setRevocationEnabled(boolean revocationEnabled) { this.revocationEnabled = revocationEnabled; @@ -242,8 +269,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme @Override protected final void handleAliasPrivKeyCertRequest(SignatureKeyCallback callback, - SignatureKeyCallback.AliasPrivKeyCertRequest request) - throws IOException { + SignatureKeyCallback.AliasPrivKeyCertRequest request) throws IOException { PrivateKey privateKey = getPrivateKey(request.getAlias()); X509Certificate certificate = getCertificate(request.getAlias()); request.setPrivateKey(privateKey); @@ -252,8 +278,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme @Override protected final void handleAliasSymmetricKeyRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.AliasSymmetricKeyRequest request) - throws IOException { + DecryptionKeyCallback.AliasSymmetricKeyRequest request) throws IOException { SecretKey secretKey = getSymmetricKey(request.getAlias()); request.setSymmetricKey(secretKey); } @@ -264,16 +289,14 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme @Override protected final void handleAliasSymmetricKeyRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.AliasSymmetricKeyRequest request) - throws IOException { + EncryptionKeyCallback.AliasSymmetricKeyRequest request) throws IOException { SecretKey secretKey = getSymmetricKey(request.getAlias()); request.setSymmetricKey(secretKey); } @Override protected final void handleAliasX509CertificateRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.AliasX509CertificateRequest request) - throws IOException { + EncryptionKeyCallback.AliasX509CertificateRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(request.getAlias()); request.setX509Certificate(certificate); } @@ -293,8 +316,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme @Override protected final void handleDefaultPrivKeyCertRequest(SignatureKeyCallback callback, - SignatureKeyCallback.DefaultPrivKeyCertRequest request) - throws IOException { + SignatureKeyCallback.DefaultPrivKeyCertRequest request) throws IOException { PrivateKey privateKey = getPrivateKey(defaultAlias); X509Certificate certificate = getCertificate(defaultAlias); request.setPrivateKey(privateKey); @@ -303,16 +325,14 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme @Override protected final void handleDefaultX509CertificateRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.DefaultX509CertificateRequest request) - throws IOException { + EncryptionKeyCallback.DefaultX509CertificateRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(defaultAlias); request.setX509Certificate(certificate); } @Override protected final void handlePublicKeyBasedPrivKeyCertRequest(SignatureKeyCallback callback, - SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest request) - throws IOException { + SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest request) throws IOException { PrivateKey privateKey = getPrivateKey(request.getPublicKey()); X509Certificate certificate = getCertificate(request.getPublicKey()); request.setPrivateKey(privateKey); @@ -324,56 +344,49 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme // @Override protected final void handlePublicKeyBasedPrivKeyRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest request) - throws IOException { + DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest request) throws IOException { PrivateKey key = getPrivateKey(request.getPublicKey()); request.setPrivateKey(key); } @Override protected final void handlePublicKeyBasedRequest(EncryptionKeyCallback callback, - EncryptionKeyCallback.PublicKeyBasedRequest request) - throws IOException { + EncryptionKeyCallback.PublicKeyBasedRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(request.getPublicKey()); request.setX509Certificate(certificate); } @Override protected final void handlePublicKeyBasedRequest(SignatureVerificationKeyCallback callback, - SignatureVerificationKeyCallback.PublicKeyBasedRequest request) - throws IOException { + SignatureVerificationKeyCallback.PublicKeyBasedRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(request.getPublicKey()); request.setX509Certificate(certificate); } @Override protected final void handleX509CertificateBasedRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.X509CertificateBasedRequest request) - throws IOException { + DecryptionKeyCallback.X509CertificateBasedRequest request) throws IOException { PrivateKey privKey = getPrivateKey(request.getX509Certificate()); request.setPrivateKey(privKey); } @Override protected final void handleX509IssuerSerialBasedRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.X509IssuerSerialBasedRequest request) - throws IOException { + DecryptionKeyCallback.X509IssuerSerialBasedRequest request) throws IOException { PrivateKey key = getPrivateKey(request.getIssuerName(), request.getSerialNumber()); request.setPrivateKey(key); } @Override protected final void handleX509IssuerSerialBasedRequest(SignatureVerificationKeyCallback callback, - SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest request) - throws IOException { + SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(request.getIssuerName(), request.getSerialNumber()); request.setX509Certificate(certificate); } @Override protected final void handleX509SubjectKeyIdentifierBasedRequest(DecryptionKeyCallback callback, - DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest request) - throws IOException { + DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest request) throws IOException { PrivateKey key = getPrivateKey(request.getSubjectKeyIdentifier()); request.setPrivateKey(key); } @@ -384,8 +397,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme @Override protected final void handleX509SubjectKeyIdentifierBasedRequest(SignatureVerificationKeyCallback callback, - SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest request) - throws IOException { + SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(request.getSubjectKeyIdentifier()); request.setX509Certificate(certificate); } @@ -423,8 +435,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme return x509Cert; } } - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } return null; @@ -451,8 +462,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme return x509Cert; } } - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } return null; @@ -463,8 +473,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme protected PrivateKey getPrivateKey(String alias) throws IOException { try { return (PrivateKey) keyStore.getKey(alias, privateKeyPassword); - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } } @@ -479,8 +488,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme return (PrivateKey) keyStore.getKey(alias, privateKeyPassword); } } - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } return null; @@ -499,8 +507,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme return (PrivateKey) keyStore.getKey(alias, privateKeyPassword); } } - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } return null; @@ -528,8 +535,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme return (PrivateKey) keyStore.getKey(alias, privateKeyPassword); } } - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } return null; @@ -554,8 +560,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme return (PrivateKey) keyStore.getKey(alias, privateKeyPassword); } } - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } return null; @@ -580,8 +585,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme protected SecretKey getSymmetricKey(String alias) throws IOException { try { return (SecretKey) symmetricStore.getKey(alias, symmetricKeyPassword); - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } } @@ -593,8 +597,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme if (logger.isDebugEnabled()) { logger.debug("Loaded default key store"); } - } - catch (Exception ex) { + } catch (Exception ex) { logger.warn("Could not open default key store", ex); } } @@ -606,16 +609,14 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme if (logger.isDebugEnabled()) { logger.debug("Loaded default trust store"); } - } - catch (Exception ex) { + } catch (Exception ex) { logger.warn("Could not open default trust store", ex); } } /** - * Creates a {@code PKIXBuilderParameters} instance with the given parameters. - * Default implementation simply instantiates one, without setting additional - * parameters. + * Creates a {@code PKIXBuilderParameters} instance with the given parameters. Default implementation simply + * instantiates one, without setting additional parameters. * * @param trustStore the trust store to use * @param certSelector the certificate selector to use @@ -628,7 +629,6 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme return new PKIXBuilderParameters(trustStore, certSelector); } - // // Inner classes // @@ -640,29 +640,25 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme throws CertificateValidationCallback.CertificateValidationException { if (isOwnedCert(certificate)) { if (logger.isDebugEnabled()) { - logger.debug("Certificate with DN [" + certificate.getSubjectX500Principal().getName() + - "] is in private keystore"); + logger.debug( + "Certificate with DN [" + certificate.getSubjectX500Principal().getName() + "] is in private keystore"); } return true; - } - else if (trustStore == null) { + } else if (trustStore == null) { return false; } try { certificate.checkValidity(); - } - catch (CertificateExpiredException e) { + } catch (CertificateExpiredException e) { if (logger.isDebugEnabled()) { - logger.debug("Certificate with DN [" + certificate.getSubjectX500Principal().getName() + - "] has expired"); + logger.debug("Certificate with DN [" + certificate.getSubjectX500Principal().getName() + "] has expired"); } return false; - } - catch (CertificateNotYetValidException e) { + } catch (CertificateNotYetValidException e) { if (logger.isDebugEnabled()) { - logger.debug("Certificate with DN [" + certificate.getSubjectX500Principal().getName() + - "] is not yet valid"); + logger + .debug("Certificate with DN [" + certificate.getSubjectX500Principal().getName() + "] is not yet valid"); } return false; } @@ -676,26 +672,23 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme parameters = createBuilderParameters(trustStore, certSelector); parameters.setRevocationEnabled(revocationEnabled); builder = CertPathBuilder.getInstance("PKIX"); - } - catch (GeneralSecurityException ex) { - throw new CertificateValidationCallback.CertificateValidationException( - "Could not create PKIX CertPathBuilder", ex); + } catch (GeneralSecurityException ex) { + throw new CertificateValidationCallback.CertificateValidationException("Could not create PKIX CertPathBuilder", + ex); } try { builder.build(parameters); - } - catch (CertPathBuilderException e) { + } catch (CertPathBuilderException e) { if (logger.isDebugEnabled()) { - logger.debug("Certification path of certificate with DN [" + - certificate.getSubjectX500Principal().getName() + "] could not be validated"); + logger.debug("Certification path of certificate with DN [" + certificate.getSubjectX500Principal().getName() + + "] could not be validated"); } return false; - } - catch (InvalidAlgorithmParameterException e) { + } catch (InvalidAlgorithmParameterException e) { if (logger.isDebugEnabled()) { - logger.debug("Algorithm of certificate with DN [" + - certificate.getSubjectX500Principal().getName() + "] could not be validated"); + logger.debug("Algorithm of certificate with DN [" + certificate.getSubjectX500Principal().getName() + + "] could not be validated"); } return false; } @@ -724,8 +717,7 @@ public class KeyStoreCallbackHandler extends CryptographyCallbackHandler impleme } } return false; - } - catch (GeneralSecurityException e) { + } catch (GeneralSecurityException e) { throw new CertificateValidationCallback.CertificateValidationException( "Could not determine whether certificate is contained in main key store", e); } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/MockValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/MockValidationCallbackHandler.java index c037bec0..a65ea4f3 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/MockValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/MockValidationCallbackHandler.java @@ -18,22 +18,23 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.IOException; import java.security.cert.X509Certificate; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; +import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; + import com.sun.xml.wss.impl.callback.CertificateValidationCallback; import com.sun.xml.wss.impl.callback.PasswordValidationCallback; -import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; - /** * Mock implementation of of callback handler that accepts all password and certificate validation callbacks. - * - *

If the {@code valid} property is set to {@code true} (the default), this handler simply accepts and - * validates every password or certificate validation callback that is passed to it. - * - *

This class handles {@code CertificateValidationCallback}s and {@code PasswordValidationCallback}s, and - * throws an {@code UnsupportedCallbackException} for others + *

+ * If the {@code valid} property is set to {@code true} (the default), this handler simply accepts and validates every + * password or certificate validation callback that is passed to it. + *

+ * This class handles {@code CertificateValidationCallback}s and {@code PasswordValidationCallback}s, and throws an + * {@code UnsupportedCallbackException} for others * * @author Arjen Poutsma * @since 1.0.0 @@ -42,8 +43,7 @@ public class MockValidationCallbackHandler extends AbstractCallbackHandler { private boolean isValid = true; - public MockValidationCallbackHandler() { - } + public MockValidationCallbackHandler() {} public MockValidationCallbackHandler(boolean valid) { isValid = valid; @@ -54,12 +54,10 @@ public class MockValidationCallbackHandler extends AbstractCallbackHandler { if (callback instanceof CertificateValidationCallback) { CertificateValidationCallback validationCallback = (CertificateValidationCallback) callback; validationCallback.setValidator(new MockCertificateValidator()); - } - else if (callback instanceof PasswordValidationCallback) { + } else if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; validationCallback.setValidator(new MockPasswordValidator()); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandler.java index c9c3c37b..8288452f 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandler.java @@ -20,22 +20,23 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Properties; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; -import com.sun.xml.wss.impl.callback.PasswordValidationCallback; -import com.sun.xml.wss.impl.callback.TimestampValidationCallback; - import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; +import com.sun.xml.wss.impl.callback.PasswordValidationCallback; +import com.sun.xml.wss.impl.callback.TimestampValidationCallback; + /** - * Simple callback handler that validates passwords agains a in-memory {@code Properties} object. Password - * validation is done on a case-sensitive basis. - * - *

This class only handles {@code PasswordValidationCallback}s, and throws an - * {@code UnsupportedCallbackException} for others + * Simple callback handler that validates passwords agains a in-memory {@code Properties} object. Password validation is + * done on a case-sensitive basis. + *

+ * This class only handles {@code PasswordValidationCallback}s, and throws an {@code UnsupportedCallbackException} for + * others * * @author Arjen Poutsma * @see #setUsers(java.util.Properties) @@ -69,20 +70,17 @@ public class SimplePasswordValidationCallbackHandler extends AbstractCallbackHan PasswordValidationCallback passwordCallback = (PasswordValidationCallback) callback; if (passwordCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { passwordCallback.setValidator(new SimplePlainTextPasswordValidator()); - } - else if (passwordCallback.getRequest() instanceof PasswordValidationCallback.DigestPasswordRequest) { - PasswordValidationCallback.DigestPasswordRequest digestPasswordRequest = - (PasswordValidationCallback.DigestPasswordRequest) passwordCallback.getRequest(); + } else if (passwordCallback.getRequest() instanceof PasswordValidationCallback.DigestPasswordRequest) { + PasswordValidationCallback.DigestPasswordRequest digestPasswordRequest = (PasswordValidationCallback.DigestPasswordRequest) passwordCallback + .getRequest(); String password = users.get(digestPasswordRequest.getUsername()); digestPasswordRequest.setPassword(password); passwordCallback.setValidator(new PasswordValidationCallback.DigestPasswordValidator()); } - } - else if (callback instanceof TimestampValidationCallback) { + } else if (callback instanceof TimestampValidationCallback) { TimestampValidationCallback timestampCallback = (TimestampValidationCallback) callback; timestampCallback.setValidator(new DefaultTimestampValidator()); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } @@ -92,8 +90,7 @@ public class SimplePasswordValidationCallbackHandler extends AbstractCallbackHan @Override public boolean validate(PasswordValidationCallback.Request request) throws PasswordValidationCallback.PasswordValidationException { - PasswordValidationCallback.PlainTextPasswordRequest plainTextPasswordRequest = - (PasswordValidationCallback.PlainTextPasswordRequest) request; + PasswordValidationCallback.PlainTextPasswordRequest plainTextPasswordRequest = (PasswordValidationCallback.PlainTextPasswordRequest) request; String password = users.get(plainTextPasswordRequest.getUsername()); return password != null && password.equals(plainTextPasswordRequest.getPassword()); } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandler.java index 19759c74..d3844421 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandler.java @@ -17,20 +17,21 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.IOException; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; -import com.sun.xml.wss.impl.callback.PasswordCallback; -import com.sun.xml.wss.impl.callback.UsernameCallback; - import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; +import com.sun.xml.wss.impl.callback.PasswordCallback; +import com.sun.xml.wss.impl.callback.UsernameCallback; + /** * Simple callback handler that supplies a username and password to a username token at runtime. - * - *

This class handles {@code UsernameCallback}s and {@code PasswordCallback}s, and throws an + *

+ * This class handles {@code UsernameCallback}s and {@code PasswordCallback}s, and throws an * {@code UnsupportedCallbackException} for others * * @author Arjen Poutsma @@ -44,12 +45,10 @@ public class SimpleUsernamePasswordCallbackHandler extends AbstractCallbackHandl private String password; - /** * Constructs an empty instance of the {@code SimpleUsernamePasswordCallbackHandler}. */ - public SimpleUsernamePasswordCallbackHandler() { - } + public SimpleUsernamePasswordCallbackHandler() {} /** * Constructs an instance of the {@code SimpleUsernamePasswordCallbackHandler} with the given name and password. @@ -78,12 +77,10 @@ public class SimpleUsernamePasswordCallbackHandler extends AbstractCallbackHandl if (callback instanceof UsernameCallback) { UsernameCallback usernameCallback = (UsernameCallback) callback; usernameCallback.setUsername(username); - } - else if (callback instanceof PasswordCallback) { + } else if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword(password); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandler.java index 039555fb..fb2d1765 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandler.java @@ -18,11 +18,10 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.IOException; import java.security.cert.X509Certificate; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; -import com.sun.xml.wss.impl.callback.CertificateValidationCallback; - import org.springframework.beans.factory.InitializingBean; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.core.Authentication; @@ -33,17 +32,20 @@ import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; import org.springframework.ws.soap.security.callback.CleanupCallback; import org.springframework.ws.soap.security.x509.X509AuthenticationToken; +import com.sun.xml.wss.impl.callback.CertificateValidationCallback; + /** - * Callback handler that validates a certificate using an Spring Security {@code AuthenticationManager}. Logic - * based on Spring Security's {@code X509ProcessingFilter}. - * - *

Spring Security {@code X509AuthenticationToken} is created with the certificate as the credentials. - * - *

The configured authentication manager is expected to supply a provider which can handle this token (usually an instance of - * {@code X509AuthenticationProvider}).

- * - *

This class only handles {@code CertificateValidationCallback}s, and throws an - * {@code UnsupportedCallbackException} for others. + * Callback handler that validates a certificate using an Spring Security {@code AuthenticationManager}. Logic based on + * Spring Security's {@code X509ProcessingFilter}. + *

+ * Spring Security {@code X509AuthenticationToken} is created with the certificate as the credentials. + *

+ * The configured authentication manager is expected to supply a provider which can handle this token (usually an + * instance of {@code X509AuthenticationProvider}). + *

+ *

+ * This class only handles {@code CertificateValidationCallback}s, and throws an {@code UnsupportedCallbackException} + * for others. * * @author Arjen Poutsma * @see org.springframework.ws.soap.security.x509.X509AuthenticationToken @@ -72,21 +74,17 @@ public class SpringCertificateValidationCallbackHandler extends AbstractCallback } /** - * Handles {@code CertificateValidationCallback}s, and throws an {@code UnsupportedCallbackException} for - * others + * Handles {@code CertificateValidationCallback}s, and throws an {@code UnsupportedCallbackException} for others * - * @throws javax.security.auth.callback.UnsupportedCallbackException - * when the callback is not supported + * @throws javax.security.auth.callback.UnsupportedCallbackException when the callback is not supported */ @Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof CertificateValidationCallback) { ((CertificateValidationCallback) callback).setValidator(new SpringSecurityCertificateValidator()); - } - else if (callback instanceof CleanupCallback) { + } else if (callback instanceof CleanupCallback) { SecurityContextHolder.clearContext(); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } @@ -98,19 +96,17 @@ public class SpringCertificateValidationCallbackHandler extends AbstractCallback throws CertificateValidationCallback.CertificateValidationException { boolean result; try { - Authentication authResult = - authenticationManager.authenticate(new X509AuthenticationToken(certificate)); + Authentication authResult = authenticationManager.authenticate(new X509AuthenticationToken(certificate)); if (logger.isDebugEnabled()) { - logger.debug("Authentication request for certificate with DN [" + - certificate.getSubjectX500Principal().getName() + "] successful"); + logger.debug("Authentication request for certificate with DN [" + + certificate.getSubjectX500Principal().getName() + "] successful"); } SecurityContextHolder.getContext().setAuthentication(authResult); return true; - } - catch (AuthenticationException failed) { + } catch (AuthenticationException failed) { if (logger.isDebugEnabled()) { - logger.debug("Authentication request for certificate with DN [" + - certificate.getSubjectX500Principal().getName() + "] failed: " + failed.toString()); + logger.debug("Authentication request for certificate with DN [" + + certificate.getSubjectX500Principal().getName() + "] failed: " + failed.toString()); } SecurityContextHolder.clearContext(); result = ignoreFailure; diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandler.java index c4179ceb..00a904ae 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandler.java @@ -17,12 +17,10 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.IOException; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; -import com.sun.xml.wss.impl.callback.PasswordValidationCallback; -import com.sun.xml.wss.impl.callback.TimestampValidationCallback; - import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -37,15 +35,18 @@ import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; import org.springframework.ws.soap.security.callback.CleanupCallback; import org.springframework.ws.soap.security.support.SpringSecurityUtils; +import com.sun.xml.wss.impl.callback.PasswordValidationCallback; +import com.sun.xml.wss.impl.callback.TimestampValidationCallback; + /** - * Callback handler that validates a password digest using an Spring Security {@code UserDetailsService}. Logic - * based on Spring Security's {@code DigestProcessingFilter}. - * - *

An Spring Security {@code UserDetailService} is used to load {@code UserDetails} from. The digest of the - * password contained in this details object is then compared with the digest in the message. - * - *

This class only handles {@code PasswordValidationCallback}s that contain a {@code DigestPasswordRequest}, - * and throws an {@code UnsupportedCallbackException} for others. + * Callback handler that validates a password digest using an Spring Security {@code UserDetailsService}. Logic based on + * Spring Security's {@code DigestProcessingFilter}. + *

+ * An Spring Security {@code UserDetailService} is used to load {@code UserDetails} from. The digest of the password + * contained in this details object is then compared with the digest in the message. + *

+ * This class only handles {@code PasswordValidationCallback}s that contain a {@code DigestPasswordRequest}, and throws + * an {@code UnsupportedCallbackException} for others. * * @author Arjen Poutsma * @see org.springframework.security.core.userdetails.UserDetailsService @@ -78,16 +79,15 @@ public class SpringDigestPasswordValidationCallbackHandler extends AbstractCallb * Handles {@code PasswordValidationCallback}s that contain a {@code DigestPasswordRequest}, and throws an * {@code UnsupportedCallbackException} for others * - * @throws javax.security.auth.callback.UnsupportedCallbackException - * when the callback is not supported + * @throws javax.security.auth.callback.UnsupportedCallbackException when the callback is not supported */ @Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback passwordCallback = (PasswordValidationCallback) callback; if (passwordCallback.getRequest() instanceof PasswordValidationCallback.DigestPasswordRequest) { - PasswordValidationCallback.DigestPasswordRequest request = - (PasswordValidationCallback.DigestPasswordRequest) passwordCallback.getRequest(); + PasswordValidationCallback.DigestPasswordRequest request = (PasswordValidationCallback.DigestPasswordRequest) passwordCallback + .getRequest(); String username = request.getUsername(); UserDetails user = loadUserDetails(username); if (user != null) { @@ -98,13 +98,11 @@ public class SpringDigestPasswordValidationCallbackHandler extends AbstractCallb passwordCallback.setValidator(validator); return; } - } - else if (callback instanceof TimestampValidationCallback) { + } else if (callback instanceof TimestampValidationCallback) { TimestampValidationCallback timestampCallback = (TimestampValidationCallback) callback; timestampCallback.setValidator(new DefaultTimestampValidator()); - } - else if (callback instanceof CleanupCallback) { + } else if (callback instanceof CleanupCallback) { SecurityContextHolder.clearContext(); return; } @@ -117,8 +115,7 @@ public class SpringDigestPasswordValidationCallbackHandler extends AbstractCallb if (user == null) { try { user = userDetailsService.loadUserByUsername(username); - } - catch (UsernameNotFoundException notFound) { + } catch (UsernameNotFoundException notFound) { if (logger.isDebugEnabled()) { logger.debug("Username '" + username + "' not found"); } @@ -141,16 +138,15 @@ public class SpringDigestPasswordValidationCallbackHandler extends AbstractCallb public boolean validate(PasswordValidationCallback.Request request) throws PasswordValidationCallback.PasswordValidationException { if (super.validate(request)) { - UsernamePasswordAuthenticationToken authRequest = - new UsernamePasswordAuthenticationToken(user, user.getPassword()); + UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(user, + user.getPassword()); if (logger.isDebugEnabled()) { logger.debug("Authentication success: " + authRequest.toString()); } SecurityContextHolder.getContext().setAuthentication(authRequest); return true; - } - else { + } else { return false; } } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandler.java index a782ca33..e1ad36f2 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandler.java @@ -17,11 +17,10 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.IOException; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; -import com.sun.xml.wss.impl.callback.PasswordValidationCallback; - import org.springframework.beans.factory.InitializingBean; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -32,16 +31,18 @@ import org.springframework.util.Assert; import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; import org.springframework.ws.soap.security.callback.CleanupCallback; +import com.sun.xml.wss.impl.callback.PasswordValidationCallback; + /** - * Callback handler that validates a certificate uses an Spring Security {@code AuthenticationManager}. Logic based - * on Spring Security's {@code BasicProcessingFilter}. - * - *

This handler requires an Spring Security {@code AuthenticationManager} to operate. It can be set using the - * {@code authenticationManager} property. An Spring Security {@code UsernamePasswordAuthenticationToken} is - * created with the username as principal and password as credentials. - * - *

This class only handles {@code PasswordValidationCallback}s that contain a - * {@code PlainTextPasswordRequest}, and throws an {@code UnsupportedCallbackException} for others. + * Callback handler that validates a certificate uses an Spring Security {@code AuthenticationManager}. Logic based on + * Spring Security's {@code BasicProcessingFilter}. + *

+ * This handler requires an Spring Security {@code AuthenticationManager} to operate. It can be set using the + * {@code authenticationManager} property. An Spring Security {@code UsernamePasswordAuthenticationToken} is created + * with the username as principal and password as credentials. + *

+ * This class only handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and + * throws an {@code UnsupportedCallbackException} for others. * * @author Arjen Poutsma * @see org.springframework.security.authentication.UsernamePasswordAuthenticationToken @@ -71,11 +72,10 @@ public class SpringPlainTextPasswordValidationCallbackHandler extends AbstractCa } /** - * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws - * an {@code UnsupportedCallbackException} for others. + * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws an + * {@code UnsupportedCallbackException} for others. * - * @throws javax.security.auth.callback.UnsupportedCallbackException - * when the callback is not supported + * @throws javax.security.auth.callback.UnsupportedCallbackException when the callback is not supported */ @Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { @@ -85,8 +85,7 @@ public class SpringPlainTextPasswordValidationCallbackHandler extends AbstractCa validationCallback.setValidator(new SpringSecurityPlainTextPasswordValidator()); return; } - } - else if (callback instanceof CleanupCallback) { + } else if (callback instanceof CleanupCallback) { SecurityContextHolder.clearContext(); return; } @@ -98,21 +97,19 @@ public class SpringPlainTextPasswordValidationCallbackHandler extends AbstractCa @Override public boolean validate(PasswordValidationCallback.Request request) throws PasswordValidationCallback.PasswordValidationException { - PasswordValidationCallback.PlainTextPasswordRequest plainTextRequest = - (PasswordValidationCallback.PlainTextPasswordRequest) request; + PasswordValidationCallback.PlainTextPasswordRequest plainTextRequest = (PasswordValidationCallback.PlainTextPasswordRequest) request; try { - Authentication authResult = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken( - plainTextRequest.getUsername(), plainTextRequest.getPassword())); + Authentication authResult = authenticationManager.authenticate( + new UsernamePasswordAuthenticationToken(plainTextRequest.getUsername(), plainTextRequest.getPassword())); if (logger.isDebugEnabled()) { logger.debug("Authentication success: " + authResult.toString()); } SecurityContextHolder.getContext().setAuthentication(authResult); return true; - } - catch (AuthenticationException failed) { + } catch (AuthenticationException failed) { if (logger.isDebugEnabled()) { - logger.debug("Authentication request for user '" + plainTextRequest.getUsername() + "' failed: " + - failed.toString()); + logger.debug( + "Authentication request for user '" + plainTextRequest.getUsername() + "' failed: " + failed.toString()); } SecurityContextHolder.clearContext(); return ignoreFailure; diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandler.java index 7ceba09d..7746c7cd 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandler.java @@ -17,21 +17,22 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.IOException; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; -import com.sun.xml.wss.impl.callback.PasswordCallback; -import com.sun.xml.wss.impl.callback.UsernameCallback; - import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; +import com.sun.xml.wss.impl.callback.PasswordCallback; +import com.sun.xml.wss.impl.callback.UsernameCallback; + /** - * Callback handler that adds username/password information to a mesage using an Spring Security {@link - * org.springframework.security.core.context.SecurityContext}. - * - *

This class handles {@code UsernameCallback}s and {@code PasswordCallback}s, and throws an + * Callback handler that adds username/password information to a mesage using an Spring Security + * {@link org.springframework.security.core.context.SecurityContext}. + *

+ * This class handles {@code UsernameCallback}s and {@code PasswordCallback}s, and throws an * {@code UnsupportedCallbackException} for others * * @author Arjen Poutsma @@ -47,22 +48,17 @@ public class SpringUsernamePasswordCallbackHandler extends AbstractCallbackHandl UsernameCallback usernameCallback = (UsernameCallback) callback; usernameCallback.setUsername(authentication.getName()); return; + } else { + logger.warn("Cannot handle UsernameCallback: Spring Security SecurityContext contains no Authentication"); } - else { - logger.warn( - "Cannot handle UsernameCallback: Spring Security SecurityContext contains no Authentication"); - } - } - else if (callback instanceof PasswordCallback) { + } else if (callback instanceof PasswordCallback) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null && authentication.getName() != null) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword(authentication.getCredentials().toString()); return; - } - else { - logger.warn( - "Canot handle PasswordCallback: Spring Security SecurityContext contains no Authentication"); + } else { + logger.warn("Canot handle PasswordCallback: Spring Security SecurityContext contains no Authentication"); } } throw new UnsupportedCallbackException(callback); diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/XwssCallbackHandlerChain.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/XwssCallbackHandlerChain.java index 88427d15..74d38dde 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/XwssCallbackHandlerChain.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/XwssCallbackHandlerChain.java @@ -18,16 +18,17 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.IOException; import java.security.cert.X509Certificate; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; +import org.springframework.ws.soap.security.callback.CallbackHandlerChain; + import com.sun.xml.wss.impl.callback.CertificateValidationCallback; import com.sun.xml.wss.impl.callback.PasswordValidationCallback; import com.sun.xml.wss.impl.callback.TimestampValidationCallback; -import org.springframework.ws.soap.security.callback.CallbackHandlerChain; - /** * 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. @@ -45,14 +46,11 @@ public class XwssCallbackHandlerChain extends CallbackHandlerChain { protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof CertificateValidationCallback) { handleCertificateValidationCallback((CertificateValidationCallback) callback); - } - else if (callback instanceof PasswordValidationCallback) { + } else if (callback instanceof PasswordValidationCallback) { handlePasswordValidationCallback((PasswordValidationCallback) callback); - } - else if (callback instanceof TimestampValidationCallback) { + } else if (callback instanceof TimestampValidationCallback) { handleTimestampValidationCallback((TimestampValidationCallback) callback); - } - else { + } else { super.handleInternal(callback); } } @@ -83,13 +81,11 @@ public class XwssCallbackHandlerChain extends CallbackHandlerChain { for (int i = 0; i < getCallbackHandlers().length; i++) { CallbackHandler callbackHandler = getCallbackHandlers()[i]; try { - callbackHandler.handle(new Callback[]{callback}); + callbackHandler.handle(new Callback[] { callback }); callback.getResult(); - } - catch (IOException e) { + } catch (IOException e) { throw new TimestampValidationCallback.TimestampValidationException(e); - } - catch (UnsupportedCallbackException e) { + } catch (UnsupportedCallbackException e) { // ignore } } @@ -111,16 +107,14 @@ public class XwssCallbackHandlerChain extends CallbackHandlerChain { for (int i = 0; i < getCallbackHandlers().length; i++) { CallbackHandler callbackHandler = getCallbackHandlers()[i]; try { - callbackHandler.handle(new Callback[]{callback}); + callbackHandler.handle(new Callback[] { callback }); allUnsupported = false; if (!callback.getResult()) { return false; } - } - catch (IOException e) { + } catch (IOException e) { throw new PasswordValidationCallback.PasswordValidationException(e); - } - catch (UnsupportedCallbackException e) { + } catch (UnsupportedCallbackException e) { // ignore } } @@ -143,16 +137,14 @@ public class XwssCallbackHandlerChain extends CallbackHandlerChain { for (int i = 0; i < getCallbackHandlers().length; i++) { CallbackHandler callbackHandler = getCallbackHandlers()[i]; try { - callbackHandler.handle(new Callback[]{callback}); + callbackHandler.handle(new Callback[] { callback }); allUnsupported = false; if (!callback.getResult()) { return false; } - } - catch (IOException e) { + } catch (IOException e) { throw new CertificateValidationCallback.CertificateValidationException(e); - } - catch (UnsupportedCallbackException e) { + } catch (UnsupportedCallbackException e) { // ignore } } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/AbstractJaasValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/AbstractJaasValidationCallbackHandler.java index 68ed46e2..1fef7913 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/AbstractJaasValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/AbstractJaasValidationCallbackHandler.java @@ -31,8 +31,7 @@ public abstract class AbstractJaasValidationCallbackHandler extends AbstractCall private String loginContextName; - protected AbstractJaasValidationCallbackHandler() { - } + protected AbstractJaasValidationCallbackHandler() {} /** Returns the login context name. */ public String getLoginContextName() { diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandler.java index 1773e135..949b55b9 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandler.java @@ -17,6 +17,7 @@ package org.springframework.ws.soap.security.xwss.callback.jaas; import java.security.cert.X509Certificate; + import javax.security.auth.Subject; import javax.security.auth.callback.Callback; import javax.security.auth.callback.UnsupportedCallbackException; @@ -28,9 +29,9 @@ import com.sun.xml.wss.impl.callback.CertificateValidationCallback; /** * Provides basic support for integrating with JAAS and certificates. Requires the {@code loginContextName} to be * set.Requires a {@code LoginContext} which handles {@code X500Principal}s. - * - *

This class only handles {@code CertificateValidationCallback}s, and throws an - * {@code UnsupportedCallbackException} for others. + *

+ * This class only handles {@code CertificateValidationCallback}s, and throws an {@code UnsupportedCallbackException} + * for others. * * @author Arjen Poutsma * @see javax.security.auth.x500.X500Principal @@ -40,8 +41,7 @@ import com.sun.xml.wss.impl.callback.CertificateValidationCallback; public class JaasCertificateValidationCallbackHandler extends AbstractJaasValidationCallbackHandler { /** - * Handles {@code CertificateValidationCallback}s, and throws an {@code UnsupportedCallbackException} for - * others + * Handles {@code CertificateValidationCallback}s, and throws an {@code UnsupportedCallbackException} for others * * @throws UnsupportedCallbackException when the callback is not supported */ @@ -49,8 +49,7 @@ public class JaasCertificateValidationCallbackHandler extends AbstractJaasValida protected final void handleInternal(Callback callback) throws UnsupportedCallbackException { if (callback instanceof CertificateValidationCallback) { ((CertificateValidationCallback) callback).setValidator(new JaasCertificateValidator()); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } @@ -65,11 +64,9 @@ public class JaasCertificateValidationCallbackHandler extends AbstractJaasValida LoginContext loginContext; try { loginContext = new LoginContext(getLoginContextName(), subject); - } - catch (LoginException ex) { + } catch (LoginException ex) { throw new CertificateValidationCallback.CertificateValidationException(ex); - } - catch (SecurityException ex) { + } catch (SecurityException ex) { throw new CertificateValidationCallback.CertificateValidationException(ex); } @@ -78,23 +75,21 @@ public class JaasCertificateValidationCallbackHandler extends AbstractJaasValida Subject subj = loginContext.getSubject(); if (!subj.getPrincipals().isEmpty()) { if (logger.isDebugEnabled()) { - logger.debug("Authentication request for certificate with DN [" + - certificate.getSubjectX500Principal().getName() + "] successful"); + logger.debug("Authentication request for certificate with DN [" + + certificate.getSubjectX500Principal().getName() + "] successful"); } return true; - } - else { + } else { if (logger.isDebugEnabled()) { - logger.debug("Authentication request for certificate with DN [" + - certificate.getSubjectX500Principal().getName() + "] failed"); + logger.debug("Authentication request for certificate with DN [" + + certificate.getSubjectX500Principal().getName() + "] failed"); } return false; } - } - catch (LoginException ex) { + } catch (LoginException ex) { if (logger.isDebugEnabled()) { - logger.debug("Authentication request for certificate with DN [" + - certificate.getSubjectX500Principal().getName() + "] failed"); + logger.debug("Authentication request for certificate with DN [" + + certificate.getSubjectX500Principal().getName() + "] failed"); } return false; } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandler.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandler.java index 08dedd9f..c533b2ce 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandler.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandler.java @@ -24,15 +24,15 @@ import javax.security.auth.callback.UnsupportedCallbackException; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; -import com.sun.xml.wss.impl.callback.PasswordValidationCallback; - import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; +import com.sun.xml.wss.impl.callback.PasswordValidationCallback; + /** * Provides basic support for integrating with JAAS and plain text passwords. - * - *

This class only handles {@code PasswordValidationCallback}s that contain a - * {@code PlainTextPasswordRequest}, and throws an {@code UnsupportedCallbackException} for others. + *

+ * This class only handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and + * throws an {@code UnsupportedCallbackException} for others. * * @author Arjen Poutsma * @see #getLoginContextName() @@ -41,8 +41,8 @@ import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; public class JaasPlainTextPasswordValidationCallbackHandler extends AbstractJaasValidationCallbackHandler { /** - * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws - * an {@code UnsupportedCallbackException} for others. + * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws an + * {@code UnsupportedCallbackException} for others. * * @throws UnsupportedCallbackException when the callback is not supported */ @@ -63,8 +63,7 @@ public class JaasPlainTextPasswordValidationCallbackHandler extends AbstractJaas @Override public boolean validate(PasswordValidationCallback.Request request) throws PasswordValidationCallback.PasswordValidationException { - PasswordValidationCallback.PlainTextPasswordRequest plainTextRequest = - (PasswordValidationCallback.PlainTextPasswordRequest) request; + PasswordValidationCallback.PlainTextPasswordRequest plainTextRequest = (PasswordValidationCallback.PlainTextPasswordRequest) request; final String username = plainTextRequest.getUsername(); final String password = plainTextRequest.getPassword(); @@ -77,20 +76,16 @@ public class JaasPlainTextPasswordValidationCallbackHandler extends AbstractJaas protected void handleInternal(Callback callback) throws UnsupportedCallbackException { if (callback instanceof NameCallback) { ((NameCallback) callback).setName(username); - } - else if (callback instanceof PasswordCallback) { + } else if (callback instanceof PasswordCallback) { ((PasswordCallback) callback).setPassword(password.toCharArray()); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } }); - } - catch (LoginException ex) { + } catch (LoginException ex) { throw new PasswordValidationCallback.PasswordValidationException(ex); - } - catch (SecurityException ex) { + } catch (SecurityException ex) { throw new PasswordValidationCallback.PasswordValidationException(ex); } @@ -102,15 +97,13 @@ public class JaasPlainTextPasswordValidationCallbackHandler extends AbstractJaas logger.debug("Authentication request for user '" + username + "' successful"); } return true; - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("Authentication request for user '" + username + "' failed"); } return false; } - } - catch (LoginException ex) { + } catch (LoginException ex) { if (logger.isDebugEnabled()) { logger.debug("Authentication request for user '" + username + "' failed"); } @@ -118,7 +111,5 @@ public class JaasPlainTextPasswordValidationCallbackHandler extends AbstractJaas } } - } } - 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 43be505c..cffe69f1 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,7 +1,6 @@ package org.springframework.ws.soap.security; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.io.IOException; import java.io.InputStream; @@ -33,21 +32,17 @@ public class SkipValidationWsSecurityInterceptorTest { interceptor = new AbstractWsSecurityInterceptor() { @Override - protected void validateMessage(SoapMessage soapMessage, - MessageContext messageContext) + protected void validateMessage(SoapMessage soapMessage, MessageContext messageContext) throws WsSecurityValidationException { fail("validation must be skipped."); } @Override - protected void secureMessage(SoapMessage soapMessage, - MessageContext messageContext) - throws WsSecuritySecurementException { - } + protected void secureMessage(SoapMessage soapMessage, MessageContext messageContext) + throws WsSecuritySecurementException {} @Override - protected void cleanUp() { - } + protected void cleanUp() {} }; interceptor.setSkipValidationIfNoHeaderPresent(true); } @@ -56,7 +51,7 @@ public class SkipValidationWsSecurityInterceptorTest { public void testSkipValidationOnNoHeader() throws Exception { doTestSkipValidation("noHeader-soap.xml"); } - + @Test public void testSkipValidationOnEmptyHeader() throws Exception { doTestSkipValidation("emptyHeader-soap.xml"); @@ -66,31 +61,25 @@ public class SkipValidationWsSecurityInterceptorTest { public void testSkipValidationOnNoSecurityHeader() throws Exception { doTestSkipValidation("noSecurityHeader-soap.xml"); } - private void doTestSkipValidation(String fileName) throws Exception { SoapMessage message = loadSaajMessage(fileName); - MessageContext messageContext = new DefaultMessageContext(message, - soapMessageFactory); - assertTrue("handeRequest result must be true", interceptor - .handleRequest(messageContext, null)); - + MessageContext messageContext = new DefaultMessageContext(message, soapMessageFactory); + assertTrue("handeRequest result must be true", interceptor.handleRequest(messageContext, null)); + } - - private SaajSoapMessage loadSaajMessage(String fileName) - throws SOAPException, IOException { + + private SaajSoapMessage loadSaajMessage(String fileName) throws SOAPException, IOException { MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addHeader("Content-Type", "text/xml"); Resource resource = new ClassPathResource(fileName, getClass()); InputStream is = resource.getInputStream(); try { - assertTrue("Could not load SAAJ message [" + resource + "]", - resource.exists()); + assertTrue("Could not load SAAJ message [" + resource + "]", resource.exists()); is = resource.getInputStream(); - return new SaajSoapMessage(messageFactory.createMessage( - mimeHeaders, is)); + return new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, is)); } finally { is.close(); } } -} \ No newline at end of file +} 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 22055cfb..cb3df4eb 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 @@ -25,8 +25,7 @@ import org.junit.Test; public class CallbackHandlerChainTest { private CallbackHandler supported = new CallbackHandler() { - public void handle(Callback[] callbacks) { - } + public void handle(Callback[] callbacks) {} }; private CallbackHandler unsupported = new CallbackHandler() { @@ -35,24 +34,23 @@ public class CallbackHandlerChainTest { } }; - private Callback callback = new Callback() { - }; + private Callback callback = new Callback() {}; @Test public void testSupported() throws Exception { - CallbackHandlerChain chain = new CallbackHandlerChain(new CallbackHandler[]{supported}); - chain.handle(new Callback[]{callback}); + CallbackHandlerChain chain = new CallbackHandlerChain(new CallbackHandler[] { supported }); + chain.handle(new Callback[] { callback }); } @Test public void testUnsupportedSupported() throws Exception { - CallbackHandlerChain chain = new CallbackHandlerChain(new CallbackHandler[]{unsupported, supported}); - chain.handle(new Callback[]{callback}); + CallbackHandlerChain chain = new CallbackHandlerChain(new CallbackHandler[] { unsupported, supported }); + chain.handle(new Callback[] { callback }); } @Test(expected = UnsupportedCallbackException.class) public void testUnsupported() throws Exception { - CallbackHandlerChain chain = new CallbackHandlerChain(new CallbackHandler[]{unsupported}); - chain.handle(new Callback[]{callback}); + CallbackHandlerChain chain = new CallbackHandlerChain(new CallbackHandler[] { unsupported }); + chain.handle(new Callback[] { callback }); } -} \ No newline at end of file +} 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 8e1b9313..226b9844 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 @@ -16,10 +16,10 @@ package org.springframework.ws.soap.security.support; +import static org.junit.Assert.*; + import javax.net.ssl.KeyManager; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import org.junit.Test; public class KeyManagersFactoryBeanTest { 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 bbf44ed2..f412d9f6 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 @@ -16,10 +16,10 @@ package org.springframework.ws.soap.security.support; +import static org.junit.Assert.*; + import javax.net.ssl.TrustManager; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import org.junit.Test; public class TrustManagersFactoryBeanTest { diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/AxiomWss4jMessageInterceptorSpringSecurityCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/AxiomWss4jMessageInterceptorSpringSecurityCallbackHandlerTest.java index ff685ce9..9b6120a0 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/AxiomWss4jMessageInterceptorSpringSecurityCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/AxiomWss4jMessageInterceptorSpringSecurityCallbackHandlerTest.java @@ -19,4 +19,4 @@ package org.springframework.ws.soap.security.wss4j2; public class AxiomWss4jMessageInterceptorSpringSecurityCallbackHandlerTest extends Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase { -} \ No newline at end of file +} 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 fbd6ea07..286eb31f 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 @@ -16,9 +16,12 @@ package org.springframework.ws.soap.security.wss4j2; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Iterator; + import javax.xml.namespace.QName; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPHeader; @@ -28,7 +31,6 @@ import javax.xml.transform.Transformer; import javax.xml.transform.dom.DOMResult; import org.junit.Test; - import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; @@ -37,12 +39,9 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerFactoryUtils; -import static org.junit.Assert.*; - public class SaajWss4jMessageInterceptorSignTest extends Wss4jMessageInterceptorSignTestCase { - private static final String PAYLOAD = - "QQQ"; + private static final String PAYLOAD = "QQQ"; @Test public void testSignAndValidate() throws Exception { @@ -54,13 +53,14 @@ public class SaajWss4jMessageInterceptorSignTest extends Wss4jMessageInterceptor SOAPMessage saajMessage = saajSoap11MessageFactory.createMessage(); transformer.transform(new StringSource(PAYLOAD), new DOMResult(saajMessage.getSOAPBody())); SoapMessage message = new SaajSoapMessage(saajMessage, saajSoap11MessageFactory); - MessageContext messageContext = new DefaultMessageContext(message, new SaajSoapMessageFactory(saajSoap11MessageFactory)); + MessageContext messageContext = new DefaultMessageContext(message, + new SaajSoapMessageFactory(saajSoap11MessageFactory)); 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")); assertTrue("No security header", iterator.hasNext()); SOAPHeaderElement securityHeader = (SOAPHeaderElement) iterator.next(); iterator = securityHeader.getChildElements(new QName("http://www.w3.org/2000/09/xmldsig#", "Signature")); diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorSpringSecurityCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorSpringSecurityCallbackHandlerTest.java index 7b774328..5c3671e1 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorSpringSecurityCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/SaajWss4jMessageInterceptorSpringSecurityCallbackHandlerTest.java @@ -19,4 +19,4 @@ package org.springframework.ws.soap.security.wss4j2; public class SaajWss4jMessageInterceptorSpringSecurityCallbackHandlerTest extends Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase { -} \ No newline at end of file +} 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 f737e466..2cfb716c 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 @@ -16,9 +16,10 @@ package org.springframework.ws.soap.security.wss4j2; +import static org.junit.Assert.*; + import org.apache.wss4j.dom.engine.WSSecurityEngine; import org.junit.Test; - import org.springframework.test.util.ReflectionTestUtils; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; @@ -26,8 +27,6 @@ import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.WsSecuritySecurementException; import org.springframework.ws.soap.security.WsSecurityValidationException; -import static org.junit.Assert.*; - public abstract class Wss4jInterceptorTestCase extends Wss4jTestCase { @Test 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 56610ba7..b96fe3f7 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 @@ -19,13 +19,12 @@ package org.springframework.ws.soap.security.wss4j2; import java.util.Properties; import org.junit.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 { @@ -53,10 +52,8 @@ public abstract class Wss4jMessageInterceptorEncryptionTestCase extends Wss4jTes cryptoFactoryBeanConfig.setProperty("org.apache.ws.security.crypto.merlin.file", "private.jks"); cryptoFactoryBean.setConfiguration(cryptoFactoryBeanConfig); cryptoFactoryBean.afterPropertiesSet(); - interceptor.setValidationDecryptionCrypto(cryptoFactoryBean - .getObject()); - interceptor.setSecurementEncryptionCrypto(cryptoFactoryBean - .getObject()); + interceptor.setValidationDecryptionCrypto(cryptoFactoryBean.getObject()); + interceptor.setSecurementEncryptionCrypto(cryptoFactoryBean.getObject()); interceptor.afterPropertiesSet(); } 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 3738aa6f..b3efe407 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 @@ -21,10 +21,10 @@ import static org.junit.Assert.*; import java.io.ByteArrayOutputStream; import java.util.Iterator; import java.util.Properties; + import javax.xml.namespace.QName; import org.junit.Test; - import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapHeaderElement; @@ -63,7 +63,7 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas interceptorThatKeepsSecurityHeader.setRemoveSecurityHeader(false); interceptorThatKeepsSecurityHeader.afterPropertiesSet(); } - + @Test public void testValidateUsernameTokenPlainText() throws Exception { SoapMessage message = loadSoap11Message("usernameTokenPlainTextWithHeaders-soap.xml"); @@ -114,13 +114,13 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas } - @Test(expected=WsSecurityValidationException.class) + @Test(expected = WsSecurityValidationException.class) public void testEmptySecurityHeader() throws Exception { SoapMessage message = loadSoap11Message("emptySecurityHeader-soap.xml"); MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory()); interceptor.validateMessage(message, messageContext); } - + @Test public void testPreserveCustomHeaders() throws Exception { interceptor.setSecurementActions("UsernameToken"); 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 377f7f55..dab50534 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 @@ -2,6 +2,7 @@ package org.springframework.ws.soap.security.wss4j2; import java.io.IOException; import java.security.cert.X509Certificate; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; @@ -15,12 +16,11 @@ 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.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 { @@ -38,18 +38,18 @@ public abstract class Wss4jMessageInterceptorSamlTestCase extends Wss4jTestCase cryptoFactoryBean.setKeyStoreLocation(new ClassPathResource("private.jks")); cryptoFactoryBean.afterPropertiesSet(); Crypto crypto = cryptoFactoryBean.getObject(); - + CryptoType type = new CryptoType(CryptoType.TYPE.ALIAS); type.setAlias("rsaKey"); X509Certificate userCertificate = crypto.getX509Certificates(type)[0]; - + interceptor.setSecurementSignatureCrypto(crypto); interceptor.setValidationSignatureCrypto(crypto); interceptor.setSecurementSamlCallbackHandler(getSamlCalbackHandler(crypto, userCertificate)); interceptor.afterPropertiesSet(); } - + @Test public void testAddSAML() throws Exception { interceptor.setSecurementPassword("123456"); @@ -66,43 +66,43 @@ public abstract class Wss4jMessageInterceptorSamlTestCase extends Wss4jTestCase // lets verify the signature that we've just generated interceptor.validateMessage(message, messageContext); } - + protected CallbackHandler getSamlCalbackHandler(Crypto crypto, X509Certificate userCert) { return new SamlCallbackHandler(crypto, userCert); } - + private class SamlCallbackHandler implements CallbackHandler { - + private Crypto crypto; - + private X509Certificate userCertificate; - + public SamlCallbackHandler(Crypto crypto, X509Certificate userCertificate) { this.crypto = crypto; this.userCertificate = userCertificate; } - + @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { - for (int i = 0; i < callbacks.length; i++) { - if (callbacks[i] instanceof SAMLCallback) { - SAMLCallback callback = (SAMLCallback) callbacks[i]; - callback.setSamlVersion(Version.SAML_20); - callback.setIssuerCrypto(crypto); - callback.setIssuerKeyName("rsaKey"); - callback.setIssuerKeyPassword("123456"); - callback.setIssuer("test-issuer"); - SubjectBean subject = new SubjectBean("test-subject", "", SAML2Constants.CONF_BEARER); - KeyInfoBean keyInfo = new KeyInfoBean(); - keyInfo.setCertificate(userCertificate); - subject.setKeyInfo(keyInfo); - callback.setSubject(subject); - callback.setSignAssertion(true); - } - } + for (int i = 0; i < callbacks.length; i++) { + if (callbacks[i] instanceof SAMLCallback) { + SAMLCallback callback = (SAMLCallback) callbacks[i]; + callback.setSamlVersion(Version.SAML_20); + callback.setIssuerCrypto(crypto); + callback.setIssuerKeyName("rsaKey"); + callback.setIssuerKeyPassword("123456"); + callback.setIssuer("test-issuer"); + SubjectBean subject = new SubjectBean("test-subject", "", SAML2Constants.CONF_BEARER); + KeyInfoBean keyInfo = new KeyInfoBean(); + keyInfo.setCertificate(userCertificate); + subject.setKeyInfo(keyInfo); + callback.setSubject(subject); + callback.setSignAssertion(true); + } + } } - + } } 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 1f20520b..470ac4e9 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 @@ -16,19 +16,18 @@ package org.springframework.ws.soap.security.wss4j2; +import static org.junit.Assert.*; + import java.util.Properties; +import org.junit.Test; 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.junit.Test; import org.w3c.dom.Document; -import static org.junit.Assert.assertNotNull; - public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase { protected Wss4jSecurityInterceptor interceptor; @@ -49,10 +48,8 @@ public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase cryptoFactoryBeanConfig.setProperty("org.apache.ws.security.crypto.merlin.file", "private.jks"); cryptoFactoryBean.setConfiguration(cryptoFactoryBeanConfig); cryptoFactoryBean.afterPropertiesSet(); - interceptor.setValidationSignatureCrypto(cryptoFactoryBean - .getObject()); - interceptor.setSecurementSignatureCrypto(cryptoFactoryBean - .getObject()); + interceptor.setValidationSignatureCrypto(cryptoFactoryBean.getObject()); + interceptor.setSecurementSignatureCrypto(cryptoFactoryBean.getObject()); interceptor.afterPropertiesSet(); } @@ -100,7 +97,6 @@ public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase assertXpathExists("Absent SignatureConfirmation element", "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/ds:Signature", document); - } @Test @@ -118,6 +114,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 1cfda387..3fbdee88 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 @@ -16,18 +16,17 @@ package org.springframework.ws.soap.security.wss4j2; +import static org.junit.Assert.*; + import java.util.Properties; +import org.apache.wss4j.dom.WSConstants; +import org.junit.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 org.apache.wss4j.dom.WSConstants; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTestCase { @@ -103,5 +102,4 @@ public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTes } - } 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 a677763a..fabfdc67 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 @@ -16,8 +16,14 @@ package org.springframework.ws.soap.security.wss4j2; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + import java.util.Properties; +import org.apache.wss4j.dom.WSConstants; +import org.junit.After; +import org.junit.Test; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.provisioning.InMemoryUserDetailsManager; @@ -26,13 +32,6 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j2.callback.SpringSecurityPasswordValidationCallbackHandler; -import org.apache.wss4j.dom.WSConstants; -import org.junit.After; -import org.junit.Test; - -import static org.easymock.EasyMock.*; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase extends Wss4jTestCase { @@ -75,7 +74,6 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa interceptor.setSecurementPassword("Ernie"); interceptor.setSecurementPasswordType(WSConstants.PW_DIGEST); - SoapMessage message = loadSoap11Message("empty-soap.xml"); MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory()); interceptor.handleRequest(messageContext); @@ -104,18 +102,15 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor(); if (validating) { interceptor.setValidationActions(actions); - } - else { + } else { interceptor.setSecurementActions(actions); } - SpringSecurityPasswordValidationCallbackHandler callbackHandler = - new SpringSecurityPasswordValidationCallbackHandler(); + SpringSecurityPasswordValidationCallbackHandler callbackHandler = new SpringSecurityPasswordValidationCallbackHandler(); InMemoryUserDetailsManager userDetailsManager = new InMemoryUserDetailsManager(users); callbackHandler.setUserDetailsService(userDetailsManager); if (digest) { interceptor.setSecurementPasswordType(WSConstants.PW_DIGEST); - } - else { + } else { interceptor.setSecurementPasswordType(WSConstants.PW_TEXT); } interceptor.setValidationCallbackHandler(callbackHandler); 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 d396f0bf..8711b7b5 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 @@ -16,19 +16,18 @@ package org.springframework.ws.soap.security.wss4j2; +import static org.junit.Assert.*; + import java.text.DateFormat; import java.text.SimpleDateFormat; +import org.junit.Test; 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.junit.Test; import org.w3c.dom.Document; -import static org.junit.Assert.assertEquals; - public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTestCase { @Test @@ -40,8 +39,8 @@ public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTest MessageContext context = getSoap11MessageContext(message); 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 @@ -67,7 +66,6 @@ public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTest interceptor.validateMessage(message, context); } - @Test public void testSecureTimestampWithCustomTtl() throws Exception { Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor(); @@ -79,10 +77,12 @@ public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTest SoapMessage message = loadSoap11Message("empty-soap.xml"); MessageContext context = new DefaultMessageContext(message, getSoap11MessageFactory()); interceptor.secureMessage(message, context); - - String created = xpathTemplate.evaluateAsString("/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsu:Timestamp/wsu:Created/text()", + + String created = xpathTemplate.evaluateAsString( + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsu:Timestamp/wsu:Created/text()", message.getEnvelope().getSource()); - String expires = xpathTemplate.evaluateAsString("/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsu:Timestamp/wsu:Expires/text()", + String expires = xpathTemplate.evaluateAsString( + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsu:Timestamp/wsu:Expires/text()", message.getEnvelope().getSource()); DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'"); 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 e99f7a01..afb076ac 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 @@ -16,10 +16,9 @@ package org.springframework.ws.soap.security.wss4j2; +import org.junit.Test; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; - -import org.junit.Test; import org.w3c.dom.Document; public abstract class Wss4jMessageInterceptorUsernameTokenSignatureTestCase extends Wss4jTestCase { 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 be7cda7a..545b5c90 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 @@ -16,7 +16,7 @@ package org.springframework.ws.soap.security.wss4j2; -import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.*; import java.util.Properties; @@ -132,22 +132,20 @@ 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); - + interceptor.setBspCompliant(false); - + 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 3ae55683..04ae99f1 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 @@ -18,12 +18,11 @@ package org.springframework.ws.soap.security.wss4j2; import org.apache.wss4j.common.crypto.Merlin; import org.junit.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 { @@ -41,10 +40,8 @@ public abstract class Wss4jMessageInterceptorX509TestCase extends Wss4jTestCase cryptoFactoryBean.setKeyStoreLocation(new ClassPathResource("private.jks")); cryptoFactoryBean.afterPropertiesSet(); - interceptor.setSecurementSignatureCrypto(cryptoFactoryBean - .getObject()); - interceptor.setValidationSignatureCrypto(cryptoFactoryBean - .getObject()); + interceptor.setSecurementSignatureCrypto(cryptoFactoryBean.getObject()); + interceptor.setValidationSignatureCrypto(cryptoFactoryBean.getObject()); interceptor.afterPropertiesSet(); } 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 8f363ea9..25ae52e8 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 @@ -16,9 +16,12 @@ package org.springframework.ws.soap.security.wss4j2; +import static org.junit.Assert.*; + import java.io.InputStream; import java.util.HashMap; import java.util.Map; + import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPConstants; @@ -29,9 +32,6 @@ import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axiom.soap.SOAPModelBuilder; import org.junit.Assert; import org.junit.Before; -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; @@ -47,8 +47,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 static org.junit.Assert.*; +import org.w3c.dom.Document; +import org.w3c.dom.Node; public abstract class Wss4jTestCase { @@ -71,32 +71,25 @@ public abstract class Wss4jTestCase { saajSoap12MessageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); Map namespaces = new HashMap(); namespaces.put("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"); - namespaces.put("wsse", - "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); + namespaces.put("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); namespaces.put("ds", "http://www.w3.org/2000/09/xmldsig#"); namespaces.put("xenc", "http://www.w3.org/2001/04/xmlenc#"); namespaces.put("wsse11", "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"); namespaces.put("echo", "http://www.springframework.org/spring-ws/samples/echo"); - namespaces.put("wsu", - "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); + namespaces.put("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); namespaces.put("saml", "urn:oasis:names:tc:SAML:2.0:assertion"); namespaces.put("test", "http://test"); xpathTemplate.setNamespaces(namespaces); onSetup(); } - protected void assertXpathEvaluatesTo(String message, - String expectedValue, - String xpathExpression, - Document document) { + protected void assertXpathEvaluatesTo(String message, String expectedValue, String xpathExpression, + Document document) { String actualValue = xpathTemplate.evaluateAsString(xpathExpression, new DOMSource(document)); Assert.assertEquals(message, expectedValue, actualValue); } - 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)); Assert.assertEquals(message, expectedValue, actualValue); } @@ -125,12 +118,11 @@ public abstract class Wss4jTestCase { assertTrue("Could not load SAAJ message [" + resource + "]", resource.exists()); is = resource.getInputStream(); return new SaajSoapMessage(saajSoap11MessageFactory.createMessage(mimeHeaders, is), saajSoap11MessageFactory); - } - finally { + } finally { is.close(); } } - + protected SaajSoapMessage loadSaaj12Message(String fileName) throws Exception { MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addHeader("Content-Type", "application/soap+xml"); @@ -140,8 +132,7 @@ public abstract class Wss4jTestCase { assertTrue("Could not load SAAJ message [" + resource + "]", resource.exists()); is = resource.getInputStream(); return new SaajSoapMessage(saajSoap12MessageFactory.createMessage(mimeHeaders, is), saajSoap12MessageFactory); - } - finally { + } finally { is.close(); } } @@ -157,14 +148,13 @@ public abstract class Wss4jTestCase { org.apache.axiom.soap.SOAPMessage soapMessage = builder.getSOAPMessage(); builder.detach(); return new AxiomSoapMessage(soapMessage, "", true, true); - } - finally { + } finally { is.close(); } } - @SuppressWarnings("Since15") - protected AxiomSoapMessage loadAxiom12Message(String fileName) throws Exception { + @SuppressWarnings("Since15") + protected AxiomSoapMessage loadAxiom12Message(String fileName) throws Exception { Resource resource = new ClassPathResource(fileName, getClass()); InputStream is = resource.getInputStream(); try { @@ -175,8 +165,7 @@ public abstract class Wss4jTestCase { org.apache.axiom.soap.SOAPMessage soapMessage = builder.getSOAPMessage(); builder.detach(); return new AxiomSoapMessage(soapMessage, "", true, true); - } - finally { + } finally { is.close(); } } @@ -204,8 +193,7 @@ 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 { if (axiomTest) { @@ -248,7 +236,7 @@ public abstract class Wss4jTestCase { messageFactory.setSoapVersion(SoapVersion.SOAP_12); return messageFactory; } - + protected Document getDocument(SoapMessage message) throws Exception { if (axiomTest) { return AxiomUtils.toDocument(((AxiomSoapMessage) message).getAxiomMessage().getSOAPEnvelope()); diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/KeyStoreCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/KeyStoreCallbackHandlerTest.java index 40dfe521..f4e38c82 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/KeyStoreCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/KeyStoreCallbackHandlerTest.java @@ -18,12 +18,12 @@ package org.springframework.ws.soap.security.wss4j2.callback; import java.security.KeyStore; -import org.springframework.core.io.ClassPathResource; -import org.springframework.ws.soap.security.support.KeyStoreFactoryBean; import org.apache.wss4j.common.ext.WSPasswordCallback; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.core.io.ClassPathResource; +import org.springframework.ws.soap.security.support.KeyStoreFactoryBean; public class KeyStoreCallbackHandlerTest { 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 11d317ba..58e3d5b4 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 @@ -16,9 +16,16 @@ package org.springframework.ws.soap.security.wss4j2.callback; +import static org.easymock.EasyMock.*; + import java.util.Collection; import java.util.Collections; +import org.apache.wss4j.common.ext.WSPasswordCallback; +import org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; @@ -28,13 +35,6 @@ import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.apache.wss4j.common.ext.WSPasswordCallback; -import org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; /** @author tareq */ public class SpringSecurityPasswordValidationCallbackHandlerTest { @@ -44,7 +44,7 @@ public class SpringSecurityPasswordValidationCallbackHandlerTest { private SimpleGrantedAuthority grantedAuthority; private UsernameTokenPrincipalCallback callback; - + private WSPasswordCallback passwordCallback; private UserDetails user; @@ -58,10 +58,10 @@ public class SpringSecurityPasswordValidationCallbackHandlerTest { WSUsernameTokenPrincipalImpl principal = new WSUsernameTokenPrincipalImpl("Ernie", true); callback = new UsernameTokenPrincipalCallback(principal); - + passwordCallback = new WSPasswordCallback("Ernie", null, "type", WSPasswordCallback.USERNAME_TOKEN); } - + @Test public void testHandleUsernameToken() throws Exception { UserDetailsService userDetailsService = createMock(UserDetailsService.class); @@ -76,13 +76,14 @@ public class SpringSecurityPasswordValidationCallbackHandlerTest { verify(userDetailsService); } - + @Test public void testHandleUsernameTokenUserNotFound() throws Exception { UserDetailsService userDetailsService = createMock(UserDetailsService.class); callbackHandler.setUserDetailsService(userDetailsService); - expect(userDetailsService.loadUserByUsername("Ernie")).andThrow(new UsernameNotFoundException("User 'Ernie' not found")); + expect(userDetailsService.loadUserByUsername("Ernie")) + .andThrow(new UsernameNotFoundException("User 'Ernie' not found")); replay(userDetailsService); @@ -107,8 +108,7 @@ public class SpringSecurityPasswordValidationCallbackHandlerTest { Authentication authentication = context.getAuthentication(); Assert.assertNotNull("Authentication must not be null", authentication); Collection authorities = authentication.getAuthorities(); - Assert.assertTrue("GrantedAuthority[] must not be null or empty", - (authorities != null && authorities.size() > 0)); + Assert.assertTrue("GrantedAuthority[] must not be null or empty", (authorities != null && authorities.size() > 0)); Assert.assertEquals("Unexpected authority", grantedAuthority, authorities.iterator().next()); 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 1c3f1d4d..28f74960 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 @@ -60,4 +60,4 @@ public class CryptoFactoryBeanTest { Assert.assertNotNull("No result", result); Assert.assertTrue("Not a Merlin instance", result instanceof Merlin); } -} \ No newline at end of file +} diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/AbstractXwssMessageInterceptorKeyStoreTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/AbstractXwssMessageInterceptorKeyStoreTestCase.java index 6478dda3..277d6c5f 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/AbstractXwssMessageInterceptorKeyStoreTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/AbstractXwssMessageInterceptorKeyStoreTestCase.java @@ -34,8 +34,7 @@ public abstract class AbstractXwssMessageInterceptorKeyStoreTestCase extends Abs try { is = getClass().getResourceAsStream("test-keystore.jks"); keyStore.load(is, "password".toCharArray()); - } - finally { + } finally { if (is != null) { is.close(); } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/AbstractXwssMessageInterceptorTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/AbstractXwssMessageInterceptorTestCase.java index 9effebd0..2f58a5f3 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/AbstractXwssMessageInterceptorTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/AbstractXwssMessageInterceptorTestCase.java @@ -16,28 +16,28 @@ package org.springframework.ws.soap.security.xwss; +import static org.junit.Assert.*; + import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; + import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; +import org.junit.Assert; +import org.junit.Before; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.xml.xpath.XPathExpression; import org.springframework.xml.xpath.XPathExpressionFactory; - -import org.junit.Assert; -import org.junit.Before; import org.w3c.dom.Document; import org.w3c.dom.Node; -import static org.junit.Assert.assertTrue; - public abstract class AbstractXwssMessageInterceptorTestCase { protected XwsSecurityInterceptor interceptor; @@ -59,10 +59,8 @@ public abstract class AbstractXwssMessageInterceptorTestCase { onSetup(); } - protected void assertXpathEvaluatesTo(String message, - String expectedValue, - String xpathExpression, - SOAPMessage soapMessage) { + protected void assertXpathEvaluatesTo(String message, String expectedValue, String xpathExpression, + SOAPMessage soapMessage) { XPathExpression expression = XPathExpressionFactory.createXPathExpression(xpathExpression, namespaces); Document document = soapMessage.getSOAPPart(); String actualValue = expression.evaluateAsString(document); @@ -92,12 +90,10 @@ public abstract class AbstractXwssMessageInterceptorTestCase { assertTrue("Could not load SAAJ message [" + resource + "]", resource.exists()); is = resource.getInputStream(); return new SaajSoapMessage(messageFactory.createMessage(mimeHeaders, is)); - } - finally { + } finally { is.close(); } } - protected void onSetup() throws Exception { - } + protected void onSetup() throws Exception {} } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptorTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptorTest.java index 13b72b9f..3a7fadd6 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptorTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptorTest.java @@ -16,9 +16,13 @@ package org.springframework.ws.soap.security.xwss; +import static org.junit.Assert.*; + import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPMessage; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; @@ -26,11 +30,6 @@ import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.security.WsSecurityValidationException; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - public class XwsSecurityInterceptorTest { private MessageFactory messageFactory; @@ -61,8 +60,8 @@ public class XwsSecurityInterceptorTest { } }; - MessageContext context = - new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory)); + MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), + new SaajSoapMessageFactory(messageFactory)); interceptor.handleRequest(context, null); assertEquals("Invalid request", validatedRequest, ((SaajSoapMessage) context.getRequest()).getSaajMessage()); } @@ -94,8 +93,8 @@ public class XwsSecurityInterceptorTest { }; SOAPMessage request = messageFactory.createMessage(); - MessageContext context = - new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory)); + MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), + new SaajSoapMessageFactory(messageFactory)); context.getResponse(); interceptor.handleResponse(context, null); interceptor.afterCompletion(context, null, null); @@ -109,7 +108,6 @@ public class XwsSecurityInterceptorTest { cleanupCalled[0] = false; XwsSecurityInterceptor interceptor = new XwsSecurityInterceptor() { - @Override protected void cleanUp() { cleanupCalled[0] = true; @@ -117,8 +115,8 @@ public class XwsSecurityInterceptorTest { }; SOAPMessage request = messageFactory.createMessage(); - MessageContext context = - new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory)); + MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), + new SaajSoapMessageFactory(messageFactory)); context.getResponse(); interceptor.handleFault(context, null); interceptor.afterCompletion(context, null, null); @@ -146,8 +144,8 @@ public class XwsSecurityInterceptorTest { } }; - MessageContext context = - new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory)); + MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), + new SaajSoapMessageFactory(messageFactory)); interceptor.handleRequest(context); assertEquals("Invalid request", securedRequest, ((SaajSoapMessage) context.getRequest()).getSaajMessage()); } @@ -172,11 +170,11 @@ public class XwsSecurityInterceptorTest { }; SOAPMessage request = messageFactory.createMessage(); - MessageContext context = - new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory)); + MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), + new SaajSoapMessageFactory(messageFactory)); context.getResponse(); interceptor.handleResponse(context); assertEquals("Invalid response", validatedResponse, ((SaajSoapMessage) context.getResponse()).getSaajMessage()); } -} \ No newline at end of file +} diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorEncryptTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorEncryptTest.java index 3cb9270e..43c95c75 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorEncryptTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorEncryptTest.java @@ -16,20 +16,20 @@ package org.springframework.ws.soap.security.xwss; +import static org.junit.Assert.*; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.xml.soap.SOAPMessage; +import org.junit.Ignore; +import org.junit.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; import com.sun.xml.wss.impl.callback.DecryptionKeyCallback; import com.sun.xml.wss.impl.callback.EncryptionKeyCallback; -import org.junit.Ignore; -import org.junit.Test; - -import static org.junit.Assert.*; public class XwssMessageInterceptorEncryptTest extends AbstractXwssMessageInterceptorKeyStoreTestCase { @@ -44,16 +44,14 @@ public class XwssMessageInterceptorEncryptTest extends AbstractXwssMessageInterc if (callback instanceof EncryptionKeyCallback) { EncryptionKeyCallback keyCallback = (EncryptionKeyCallback) callback; if (keyCallback.getRequest() instanceof EncryptionKeyCallback.AliasX509CertificateRequest) { - EncryptionKeyCallback.AliasX509CertificateRequest request = - (EncryptionKeyCallback.AliasX509CertificateRequest) keyCallback.getRequest(); + EncryptionKeyCallback.AliasX509CertificateRequest request = (EncryptionKeyCallback.AliasX509CertificateRequest) keyCallback + .getRequest(); assertEquals("Invalid alias", "", request.getAlias()); request.setX509Certificate(certificate); - } - else { + } else { fail("Unexpected request"); } - } - else { + } else { fail("Unexpected callback"); } } @@ -66,8 +64,8 @@ public class XwssMessageInterceptorEncryptTest extends AbstractXwssMessageInterc assertNotNull("No result returned", result); assertXpathExists("BinarySecurityToken does not exist", "SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:BinarySecurityToken", result); - assertXpathExists("Signature does not exist", - "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/xenc:EncryptedKey", result); + assertXpathExists("Signature does not exist", "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/xenc:EncryptedKey", + result); } @Test @@ -81,16 +79,14 @@ public class XwssMessageInterceptorEncryptTest extends AbstractXwssMessageInterc if (callback instanceof EncryptionKeyCallback) { EncryptionKeyCallback keyCallback = (EncryptionKeyCallback) callback; if (keyCallback.getRequest() instanceof EncryptionKeyCallback.AliasX509CertificateRequest) { - EncryptionKeyCallback.AliasX509CertificateRequest request = - (EncryptionKeyCallback.AliasX509CertificateRequest) keyCallback.getRequest(); + EncryptionKeyCallback.AliasX509CertificateRequest request = (EncryptionKeyCallback.AliasX509CertificateRequest) keyCallback + .getRequest(); assertEquals("Invalid alias", "alias", request.getAlias()); request.setX509Certificate(certificate); - } - else { + } else { fail("Unexpected request"); } - } - else { + } else { fail("Unexpected callback"); } } @@ -103,8 +99,8 @@ public class XwssMessageInterceptorEncryptTest extends AbstractXwssMessageInterc assertNotNull("No result returned", result); assertXpathExists("BinarySecurityToken does not exist", "SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:BinarySecurityToken", result); - assertXpathExists("Signature does not exist", - "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/xenc:EncryptedKey", result); + assertXpathExists("Signature does not exist", "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/xenc:EncryptedKey", + result); } @Test @@ -118,16 +114,14 @@ public class XwssMessageInterceptorEncryptTest extends AbstractXwssMessageInterc if (callback instanceof DecryptionKeyCallback) { DecryptionKeyCallback keyCallback = (DecryptionKeyCallback) callback; if (keyCallback.getRequest() instanceof DecryptionKeyCallback.X509CertificateBasedRequest) { - DecryptionKeyCallback.X509CertificateBasedRequest request = - (DecryptionKeyCallback.X509CertificateBasedRequest) keyCallback.getRequest(); + DecryptionKeyCallback.X509CertificateBasedRequest request = (DecryptionKeyCallback.X509CertificateBasedRequest) keyCallback + .getRequest(); assertEquals("Invalid certificate", certificate, request.getX509Certificate()); request.setPrivateKey(privateKey); - } - else { + } else { fail("Unexpected request"); } - } - else { + } else { fail("Unexpected callback"); } } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorSignTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorSignTest.java index d029debd..940013eb 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorSignTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorSignTest.java @@ -16,20 +16,21 @@ package org.springframework.ws.soap.security.xwss; +import static org.junit.Assert.*; + import java.security.cert.X509Certificate; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.xml.soap.SOAPMessage; +import org.junit.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; import com.sun.xml.wss.impl.callback.CertificateValidationCallback; import com.sun.xml.wss.impl.callback.SignatureKeyCallback; -import org.junit.Test; - -import static org.junit.Assert.*; public class XwssMessageInterceptorSignTest extends AbstractXwssMessageInterceptorKeyStoreTestCase { @@ -43,16 +44,14 @@ public class XwssMessageInterceptorSignTest extends AbstractXwssMessageIntercept if (callback instanceof SignatureKeyCallback) { SignatureKeyCallback keyCallback = (SignatureKeyCallback) callback; if (keyCallback.getRequest() instanceof SignatureKeyCallback.DefaultPrivKeyCertRequest) { - SignatureKeyCallback.DefaultPrivKeyCertRequest request = - (SignatureKeyCallback.DefaultPrivKeyCertRequest) keyCallback.getRequest(); + SignatureKeyCallback.DefaultPrivKeyCertRequest request = (SignatureKeyCallback.DefaultPrivKeyCertRequest) keyCallback + .getRequest(); request.setX509Certificate(certificate); request.setPrivateKey(privateKey); - } - else { + } else { fail("Unexpected request"); } - } - else { + } else { fail("Unexpected callback"); } } @@ -79,17 +78,15 @@ public class XwssMessageInterceptorSignTest extends AbstractXwssMessageIntercept if (callback instanceof SignatureKeyCallback) { SignatureKeyCallback keyCallback = (SignatureKeyCallback) callback; if (keyCallback.getRequest() instanceof SignatureKeyCallback.AliasPrivKeyCertRequest) { - SignatureKeyCallback.AliasPrivKeyCertRequest request = - (SignatureKeyCallback.AliasPrivKeyCertRequest) keyCallback.getRequest(); + SignatureKeyCallback.AliasPrivKeyCertRequest request = (SignatureKeyCallback.AliasPrivKeyCertRequest) keyCallback + .getRequest(); assertEquals("Invalid alias", "alias", request.getAlias()); request.setX509Certificate(certificate); request.setPrivateKey(privateKey); - } - else { + } else { fail("Unexpected request"); } - } - else { + } else { fail("Unexpected callback"); } } @@ -121,8 +118,7 @@ public class XwssMessageInterceptorSignTest extends AbstractXwssMessageIntercept return true; } }); - } - else { + } else { fail("Unexpected callback"); } } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorUsernameTokenTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorUsernameTokenTest.java index b62303a5..8b842bc8 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorUsernameTokenTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/XwssMessageInterceptorUsernameTokenTest.java @@ -16,10 +16,13 @@ package org.springframework.ws.soap.security.xwss; +import static org.junit.Assert.*; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.xml.soap.SOAPMessage; +import org.junit.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.security.callback.AbstractCallbackHandler; @@ -28,15 +31,11 @@ import com.sun.xml.wss.impl.callback.PasswordCallback; import com.sun.xml.wss.impl.callback.PasswordValidationCallback; import com.sun.xml.wss.impl.callback.TimestampValidationCallback; import com.sun.xml.wss.impl.callback.UsernameCallback; -import org.junit.Test; - -import static org.junit.Assert.*; public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessageInterceptorTestCase { - @Test - public void testAddUsernameTokenDigest() throws Exception { + public void testAddUsernameTokenDigest() throws Exception { interceptor.setPolicyConfiguration(new ClassPathResource("usernameToken-digest-config.xml", getClass())); CallbackHandler handler = new AbstractCallbackHandler() { @@ -44,12 +43,10 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage protected void handleInternal(Callback callback) { if (callback instanceof UsernameCallback) { ((UsernameCallback) callback).setUsername("Bert"); - } - else if (callback instanceof PasswordCallback) { + } else if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword("Ernie"); - } - else { + } else { fail("Unexpected callback"); } } @@ -61,17 +58,14 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage SOAPMessage result = message.getSaajMessage(); assertNotNull("No result returned", result); assertXpathEvaluatesTo("Invalid Username", "Bert", - "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Username/text()", - result); + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Username/text()", result); assertXpathExists("Password does not exist", "/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']", result); assertXpathExists("Nonce does not exist", - "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Nonce", - result); + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Nonce", result); assertXpathExists("Created does not exist", - "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsu:Created", - result); + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsu:Created", result); } @Test @@ -83,12 +77,10 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage protected void handleInternal(Callback callback) { if (callback instanceof UsernameCallback) { ((UsernameCallback) callback).setUsername("Bert"); - } - else if (callback instanceof PasswordCallback) { + } else if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword("Ernie"); - } - else { + } else { fail("Unexpected callback"); } } @@ -108,21 +100,17 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage @Test public void testAddUsernameTokenPlainTextNonce() throws Exception { - interceptor.setPolicyConfiguration( - new ClassPathResource("usernameToken-plainText-nonce-config.xml", - getClass())); + interceptor.setPolicyConfiguration(new ClassPathResource("usernameToken-plainText-nonce-config.xml", getClass())); CallbackHandler handler = new AbstractCallbackHandler() { @Override protected void handleInternal(Callback callback) { if (callback instanceof UsernameCallback) { ((UsernameCallback) callback).setUsername("Bert"); - } - else if (callback instanceof PasswordCallback) { + } else if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword("Ernie"); - } - else { + } else { fail("Unexpected callback"); } } @@ -134,23 +122,19 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage SOAPMessage result = message.getSaajMessage(); assertNotNull("No result returned", result); assertXpathEvaluatesTo("Invalid Username", "Bert", - "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Username/text()", - result); + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Username/text()", result); assertXpathEvaluatesTo("Invalid Password", "Ernie", "/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#PasswordText']/text()", result); assertXpathExists("Nonce does not exist", - "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Nonce", - result); + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Nonce", result); assertXpathExists("Created does not exist", - "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsu:Created", - result); + "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsu:Created", result); } @Test public void testValidateUsernameTokenPlainText() throws Exception { - interceptor - .setPolicyConfiguration(new ClassPathResource("requireUsernameToken-plainText-config.xml", getClass())); + interceptor.setPolicyConfiguration(new ClassPathResource("requireUsernameToken-plainText-config.xml", getClass())); CallbackHandler handler = new AbstractCallbackHandler() { @Override @@ -160,20 +144,17 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage validationCallback.setValidator(new PasswordValidationCallback.PasswordValidator() { public boolean validate(PasswordValidationCallback.Request request) { if (request instanceof PasswordValidationCallback.PlainTextPasswordRequest) { - PasswordValidationCallback.PlainTextPasswordRequest passwordRequest = - (PasswordValidationCallback.PlainTextPasswordRequest) request; + PasswordValidationCallback.PlainTextPasswordRequest passwordRequest = (PasswordValidationCallback.PlainTextPasswordRequest) request; assertEquals("Invalid username", "Bert", passwordRequest.getUsername()); assertEquals("Invalid password", "Ernie", passwordRequest.getPassword()); return true; - } - else { + } else { fail("Unexpected request"); return false; } } }); - } - else { + } else { fail("Unexpected callback"); } } @@ -200,27 +181,22 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage validationCallback.setValidator(new PasswordValidationCallback.PasswordValidator() { public boolean validate(PasswordValidationCallback.Request request) { if (request instanceof PasswordValidationCallback.PlainTextPasswordRequest) { - PasswordValidationCallback.PlainTextPasswordRequest passwordRequest = - (PasswordValidationCallback.PlainTextPasswordRequest) request; + PasswordValidationCallback.PlainTextPasswordRequest passwordRequest = (PasswordValidationCallback.PlainTextPasswordRequest) request; assertEquals("Invalid username", "Bert", passwordRequest.getUsername()); assertEquals("Invalid password", "Ernie", passwordRequest.getPassword()); return true; - } - else { + } else { fail("Unexpected request"); return false; } } }); - } - else if (callback instanceof TimestampValidationCallback) { + } else if (callback instanceof TimestampValidationCallback) { TimestampValidationCallback validationCallback = (TimestampValidationCallback) callback; validationCallback.setValidator(new TimestampValidationCallback.TimestampValidator() { - public void validate(TimestampValidationCallback.Request request) { - } + public void validate(TimestampValidationCallback.Request request) {} }); - } - else { + } else { fail("Unexpected callback"); } } @@ -244,24 +220,20 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; if (validationCallback.getRequest() instanceof PasswordValidationCallback.DigestPasswordRequest) { - PasswordValidationCallback.DigestPasswordRequest passwordRequest = - (PasswordValidationCallback.DigestPasswordRequest) validationCallback.getRequest(); + PasswordValidationCallback.DigestPasswordRequest passwordRequest = (PasswordValidationCallback.DigestPasswordRequest) validationCallback + .getRequest(); assertEquals("Invalid username", "Bert", passwordRequest.getUsername()); passwordRequest.setPassword("Ernie"); validationCallback.setValidator(new PasswordValidationCallback.DigestPasswordValidator()); - } - else { + } else { fail("Unexpected request"); } - } - else if (callback instanceof TimestampValidationCallback) { + } else if (callback instanceof TimestampValidationCallback) { TimestampValidationCallback validationCallback = (TimestampValidationCallback) callback; validationCallback.setValidator(new TimestampValidationCallback.TimestampValidator() { - public void validate(TimestampValidationCallback.Request request) { - } + public void validate(TimestampValidationCallback.Request request) {} }); - } - else { + } else { fail("Unexpected callback"); } } @@ -275,4 +247,4 @@ public class XwssMessageInterceptorUsernameTokenTest extends AbstractXwssMessage assertXpathNotExists("Security Header not removed", "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security", result); } -} \ No newline at end of file +} diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidatorTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidatorTest.java index b3102378..40b85656 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidatorTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidatorTest.java @@ -16,10 +16,11 @@ package org.springframework.ws.soap.security.xwss.callback; -import com.sun.xml.wss.impl.callback.TimestampValidationCallback; import org.junit.Before; import org.junit.Test; +import com.sun.xml.wss.impl.callback.TimestampValidationCallback; + public class DefaultTimestampValidatorTest { private DefaultTimestampValidator validator; @@ -38,8 +39,8 @@ public class DefaultTimestampValidatorTest { @Test public void testValidateNoExpired() throws Exception { - TimestampValidationCallback.Request request = - new TimestampValidationCallback.UTCTimestampRequest("2006-09-25T20:42:50Z", null, 100, Long.MAX_VALUE); + TimestampValidationCallback.Request request = new TimestampValidationCallback.UTCTimestampRequest( + "2006-09-25T20:42:50Z", null, 100, Long.MAX_VALUE); validator.validate(request); } -} \ No newline at end of file +} diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandlerTest.java index 5725a697..25315892 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandlerTest.java @@ -30,8 +30,7 @@ public class KeyStoreCallbackHandlerTest { @Test public void testLoadDefaultTrustStore() throws Exception { - System.setProperty("javax.net.ssl.trustStore", - "/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/"); + System.setProperty("javax.net.ssl.trustStore", "/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/"); handler.loadDefaultTrustStore(); } -} \ No newline at end of file +} diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandlerTest.java index 1c6985f7..c4c43683 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandlerTest.java @@ -18,11 +18,12 @@ package org.springframework.ws.soap.security.xwss.callback; import java.util.Properties; -import com.sun.xml.wss.impl.callback.PasswordValidationCallback; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.sun.xml.wss.impl.callback.PasswordValidationCallback; + public class SimplePasswordValidationCallbackHandlerTest { private SimplePasswordValidationCallbackHandler handler; @@ -37,8 +38,8 @@ public class SimplePasswordValidationCallbackHandlerTest { @Test public void testPlainTextPasswordValid() throws Exception { - PasswordValidationCallback.PlainTextPasswordRequest request = - new PasswordValidationCallback.PlainTextPasswordRequest("Bert", "Ernie"); + PasswordValidationCallback.PlainTextPasswordRequest request = new PasswordValidationCallback.PlainTextPasswordRequest( + "Bert", "Ernie"); PasswordValidationCallback callback = new PasswordValidationCallback(request); handler.handleInternal(callback); boolean authenticated = callback.getResult(); @@ -47,8 +48,8 @@ public class SimplePasswordValidationCallbackHandlerTest { @Test public void testPlainTextPasswordInvalid() throws Exception { - PasswordValidationCallback.PlainTextPasswordRequest request = - new PasswordValidationCallback.PlainTextPasswordRequest("Bert", "Big bird"); + PasswordValidationCallback.PlainTextPasswordRequest request = new PasswordValidationCallback.PlainTextPasswordRequest( + "Bert", "Big bird"); PasswordValidationCallback callback = new PasswordValidationCallback(request); handler.handleInternal(callback); boolean authenticated = callback.getResult(); @@ -57,8 +58,8 @@ public class SimplePasswordValidationCallbackHandlerTest { @Test public void testPlainTextPasswordNoSuchUser() throws Exception { - PasswordValidationCallback.PlainTextPasswordRequest request = - new PasswordValidationCallback.PlainTextPasswordRequest("Big bird", "Bert"); + PasswordValidationCallback.PlainTextPasswordRequest request = new PasswordValidationCallback.PlainTextPasswordRequest( + "Big bird", "Bert"); PasswordValidationCallback callback = new PasswordValidationCallback(request); handler.handleInternal(callback); boolean authenticated = callback.getResult(); @@ -71,8 +72,8 @@ public class SimplePasswordValidationCallbackHandlerTest { String nonce = "9mdsYDCrjjYRur0rxzYt2oD7"; String passwordDigest = "kwNstEaiFOrI7B31j7GuETYvdgk="; String creationTime = "2006-06-01T23:48:42Z"; - PasswordValidationCallback.DigestPasswordRequest request = - new PasswordValidationCallback.DigestPasswordRequest(username, passwordDigest, nonce, creationTime); + PasswordValidationCallback.DigestPasswordRequest request = new PasswordValidationCallback.DigestPasswordRequest( + username, passwordDigest, nonce, creationTime); PasswordValidationCallback callback = new PasswordValidationCallback(request); handler.handleInternal(callback); boolean authenticated = callback.getResult(); @@ -86,12 +87,12 @@ public class SimplePasswordValidationCallbackHandlerTest { String nonce = "9mdsYDCrjjYRur0rxzYt2oD7"; String passwordDigest = "kwNstEaiFOrI7B31j7GuETYvdgk"; String creationTime = "2006-06-01T23:48:42Z"; - PasswordValidationCallback.DigestPasswordRequest request = - new PasswordValidationCallback.DigestPasswordRequest(username, passwordDigest, nonce, creationTime); + PasswordValidationCallback.DigestPasswordRequest request = new PasswordValidationCallback.DigestPasswordRequest( + username, passwordDigest, nonce, creationTime); PasswordValidationCallback callback = new PasswordValidationCallback(request); handler.handleInternal(callback); boolean authenticated = callback.getResult(); Assert.assertFalse("Authenticated", authenticated); } -} \ No newline at end of file +} diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandlerTest.java index 6e160e99..7956ed46 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandlerTest.java @@ -16,12 +16,13 @@ package org.springframework.ws.soap.security.xwss.callback; -import com.sun.xml.wss.impl.callback.PasswordCallback; -import com.sun.xml.wss.impl.callback.UsernameCallback; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.sun.xml.wss.impl.callback.PasswordCallback; +import com.sun.xml.wss.impl.callback.UsernameCallback; + public class SimpleUsernamePasswordCallbackHandlerTest { private SimpleUsernamePasswordCallbackHandler handler; @@ -46,4 +47,4 @@ public class SimpleUsernamePasswordCallbackHandlerTest { handler.handleInternal(passwordCallback); Assert.assertEquals("Invalid username", "Ernie", passwordCallback.getPassword()); } -} \ No newline at end of file +} diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java index 9633534d..d023963a 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java @@ -16,11 +16,17 @@ package org.springframework.ws.soap.security.xwss.callback; +import static org.easymock.EasyMock.*; + import java.io.InputStream; import java.security.KeyStore; import java.security.cert.X509Certificate; import java.util.Collections; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; @@ -31,12 +37,6 @@ import org.springframework.ws.soap.security.callback.CleanupCallback; import org.springframework.ws.soap.security.x509.X509AuthenticationToken; import com.sun.xml.wss.impl.callback.CertificateValidationCallback; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; public class SpringCertificateValidationCallbackHandlerTest { @@ -58,8 +58,7 @@ public class SpringCertificateValidationCallbackHandlerTest { try { is = new ClassPathResource("/org/springframework/ws/soap/security/xwss/test-keystore.jks").getInputStream(); keyStore.load(is, "password".toCharArray()); - } - finally { + } finally { if (is != null) { is.close(); } @@ -76,7 +75,7 @@ public class SpringCertificateValidationCallbackHandlerTest { @Test public void testValidateCertificateValid() throws Exception { expect(authenticationManager.authenticate(isA(X509AuthenticationToken.class))) - .andReturn(new TestingAuthenticationToken(certificate, null, Collections.emptyList())); + .andReturn(new TestingAuthenticationToken(certificate, null, Collections. emptyList())); replay(authenticationManager); @@ -105,8 +104,8 @@ public class SpringCertificateValidationCallbackHandlerTest { @Test public void testCleanUp() throws Exception { - TestingAuthenticationToken authentication = - new TestingAuthenticationToken(new Object(), new Object(), Collections.emptyList()); + TestingAuthenticationToken authentication = new TestingAuthenticationToken(new Object(), new Object(), + Collections. emptyList()); SecurityContextHolder.getContext().setAuthentication(authentication); CleanupCallback cleanupCallback = new CleanupCallback(); diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java index f89bae2a..aaf72ef8 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java @@ -16,8 +16,14 @@ package org.springframework.ws.soap.security.xwss.callback; +import static org.easymock.EasyMock.*; + import java.util.Collections; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.security.authentication.DisabledException; import org.springframework.security.authentication.TestingAuthenticationToken; import org.springframework.security.core.GrantedAuthority; @@ -28,12 +34,6 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.ws.soap.security.callback.CleanupCallback; import com.sun.xml.wss.impl.callback.PasswordValidationCallback; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; public class SpringDigestPasswordValidationCallbackHandlerTest { @@ -57,8 +57,8 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { String nonce = "9mdsYDCrjjYRur0rxzYt2oD7"; String passwordDigest = "kwNstEaiFOrI7B31j7GuETYvdgk="; String creationTime = "2006-06-01T23:48:42Z"; - PasswordValidationCallback.DigestPasswordRequest request = - new PasswordValidationCallback.DigestPasswordRequest(username, passwordDigest, nonce, creationTime); + PasswordValidationCallback.DigestPasswordRequest request = new PasswordValidationCallback.DigestPasswordRequest( + username, passwordDigest, nonce, creationTime); callback = new PasswordValidationCallback(request); } @@ -83,7 +83,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserDigestValid() throws Exception { - User user = new User(username, password, true, true, true, true, Collections.emptyList()); + User user = new User(username, password, true, true, true, true, Collections. emptyList()); expect(userDetailsService.loadUserByUsername(username)).andReturn(user); replay(userDetailsService); @@ -98,7 +98,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserDigestValidInvalid() throws Exception { - User user = new User(username, "Big bird", true, true, true, true, Collections.emptyList()); + User user = new User(username, "Big bird", true, true, true, true, Collections. emptyList()); expect(userDetailsService.loadUserByUsername(username)).andReturn(user); replay(userDetailsService); @@ -113,7 +113,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserDigestDisabled() throws Exception { - User user = new User(username, "Ernie", false, true, true, true, Collections.emptyList()); + User user = new User(username, "Ernie", false, true, true, true, Collections. emptyList()); expect(userDetailsService.loadUserByUsername(username)).andReturn(user); replay(userDetailsService); @@ -129,8 +129,8 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { @Test public void testCleanUp() throws Exception { - TestingAuthenticationToken authentication = - new TestingAuthenticationToken(new Object(), new Object(), Collections.emptyList()); + TestingAuthenticationToken authentication = new TestingAuthenticationToken(new Object(), new Object(), + Collections. emptyList()); SecurityContextHolder.getContext().setAuthentication(authentication); CleanupCallback cleanupCallback = new CleanupCallback(); diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java index 42f54d07..7935a437 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java @@ -16,8 +16,14 @@ package org.springframework.ws.soap.security.xwss.callback; +import static org.easymock.EasyMock.*; + import java.util.Collections; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.TestingAuthenticationToken; @@ -28,12 +34,6 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.ws.soap.security.callback.CleanupCallback; import com.sun.xml.wss.impl.callback.PasswordValidationCallback; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; public class SpringPlainTextPasswordValidationCallbackHandlerTest { @@ -54,8 +54,8 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest { callbackHandler.setAuthenticationManager(authenticationManager); username = "Bert"; password = "Ernie"; - PasswordValidationCallback.PlainTextPasswordRequest request = - new PasswordValidationCallback.PlainTextPasswordRequest(username, password); + PasswordValidationCallback.PlainTextPasswordRequest request = new PasswordValidationCallback.PlainTextPasswordRequest( + username, password); callback = new PasswordValidationCallback(request); } @@ -66,9 +66,10 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserPlainTextValid() throws Exception { - Authentication authResult = new TestingAuthenticationToken(username, password, Collections - .emptyList()); - expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))).andReturn(authResult); + Authentication authResult = new TestingAuthenticationToken(username, password, + Collections. emptyList()); + expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))) + .andReturn(authResult); replay(authenticationManager); @@ -82,7 +83,8 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserPlainTextInvalid() throws Exception { - expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))).andThrow(new BadCredentialsException("")); + expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))) + .andThrow(new BadCredentialsException("")); replay(authenticationManager); @@ -96,8 +98,8 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest { @Test public void testCleanUp() throws Exception { - TestingAuthenticationToken authentication = - new TestingAuthenticationToken(new Object(), new Object(), Collections.emptyList()); + TestingAuthenticationToken authentication = new TestingAuthenticationToken(new Object(), new Object(), + Collections. emptyList()); SecurityContextHolder.getContext().setAuthentication(authentication); CleanupCallback cleanupCallback = new CleanupCallback(); diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandlerTest.java index e4d56e4c..940649d2 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandlerTest.java @@ -16,16 +16,16 @@ package org.springframework.ws.soap.security.xwss.callback; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; - -import com.sun.xml.wss.impl.callback.PasswordCallback; -import com.sun.xml.wss.impl.callback.UsernameCallback; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +import com.sun.xml.wss.impl.callback.PasswordCallback; +import com.sun.xml.wss.impl.callback.UsernameCallback; public class SpringUsernamePasswordCallbackHandlerTest { diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/CertificateLoginModule.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/CertificateLoginModule.java index 16d02b83..e3f69024 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/CertificateLoginModule.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/CertificateLoginModule.java @@ -48,10 +48,8 @@ public class CertificateLoginModule implements LoginModule { } @Override - public void initialize(Subject subject, - CallbackHandler callbackHandler, - Map sharedState, - Map options) { + public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, + Map options) { this.subject = subject; } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandlerTest.java index d28eb4f6..aefe3aff 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandlerTest.java @@ -20,12 +20,12 @@ import java.io.InputStream; import java.security.KeyStore; import java.security.cert.X509Certificate; -import org.springframework.core.io.ClassPathResource; - -import com.sun.xml.wss.impl.callback.CertificateValidationCallback; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.core.io.ClassPathResource; + +import com.sun.xml.wss.impl.callback.CertificateValidationCallback; public class JaasCertificateValidationCallbackHandlerTest { @@ -43,8 +43,7 @@ public class JaasCertificateValidationCallbackHandlerTest { try { is = new ClassPathResource("/org/springframework/ws/soap/security/xwss/test-keystore.jks").getInputStream(); keyStore.load(is, "password".toCharArray()); - } - finally { + } finally { if (is != null) { is.close(); } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandlerTest.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandlerTest.java index 9d95ea06..d69c6bd9 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandlerTest.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandlerTest.java @@ -16,11 +16,12 @@ package org.springframework.ws.soap.security.xwss.callback.jaas; -import com.sun.xml.wss.impl.callback.PasswordValidationCallback; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.sun.xml.wss.impl.callback.PasswordValidationCallback; + public class JaasPlainTextPasswordValidationCallbackHandlerTest { private JaasPlainTextPasswordValidationCallbackHandler callbackHandler; @@ -34,8 +35,8 @@ public class JaasPlainTextPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserPlainTextValid() throws Exception { - PasswordValidationCallback.PlainTextPasswordRequest request = - new PasswordValidationCallback.PlainTextPasswordRequest("Bert", "Ernie"); + PasswordValidationCallback.PlainTextPasswordRequest request = new PasswordValidationCallback.PlainTextPasswordRequest( + "Bert", "Ernie"); PasswordValidationCallback callback = new PasswordValidationCallback(request); callbackHandler.handleInternal(callback); boolean authenticated = callback.getResult(); @@ -44,12 +45,12 @@ public class JaasPlainTextPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserPlainTextInvalid() throws Exception { - PasswordValidationCallback.PlainTextPasswordRequest request = - new PasswordValidationCallback.PlainTextPasswordRequest("Bert", "Big bird"); + PasswordValidationCallback.PlainTextPasswordRequest request = new PasswordValidationCallback.PlainTextPasswordRequest( + "Bert", "Big bird"); PasswordValidationCallback callback = new PasswordValidationCallback(request); callbackHandler.handleInternal(callback); boolean authenticated = callback.getResult(); Assert.assertFalse("Authenticated", authenticated); } -} \ No newline at end of file +} diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/PlainTextLoginModule.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/PlainTextLoginModule.java index d84f1302..fe9fa7ab 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/PlainTextLoginModule.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/PlainTextLoginModule.java @@ -57,22 +57,18 @@ public class PlainTextLoginModule implements LoginModule { subject.getPrincipals().addAll(principals); principals.clear(); return true; - } - catch (Exception e) { + } catch (Exception e) { throw new LoginException(e.getMessage()); } - } - else { + } else { principals.clear(); } return true; } @Override - public void initialize(Subject subject, - CallbackHandler callbackHandler, - Map sharedState, - Map options) { + public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, + Map options) { this.subject = subject; this.callbackHandler = callbackHandler; } @@ -85,7 +81,7 @@ public class PlainTextLoginModule implements LoginModule { try { NameCallback nameCallback = new NameCallback("Username: "); PasswordCallback passwordCallback = new PasswordCallback("Password: ", false); - Callback[] callbacks = new Callback[]{nameCallback, passwordCallback}; + Callback[] callbacks = new Callback[] { nameCallback, passwordCallback }; callbackHandler.handle(callbacks); @@ -104,11 +100,9 @@ public class PlainTextLoginModule implements LoginModule { } return true; - } - catch (LoginException ex) { + } catch (LoginException ex) { throw ex; - } - catch (Exception ex) { + } catch (Exception ex) { success = false; throw new LoginException(ex.getMessage()); } @@ -118,8 +112,7 @@ public class PlainTextLoginModule implements LoginModule { if ("Bert".equals(username) && "Ernie".equals(password)) { this.principals.add(new SimplePrincipal(username)); return true; - } - else { + } else { return false; } } @@ -137,5 +130,4 @@ public class PlainTextLoginModule implements LoginModule { return true; } - } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/SimplePrincipal.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/SimplePrincipal.java index 62d4194a..2bd9524b 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/SimplePrincipal.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/SimplePrincipal.java @@ -49,4 +49,4 @@ public final class SimplePrincipal implements Principal { public String toString() { return name; } -} \ No newline at end of file +} diff --git a/spring-ws-support/pom.xml b/spring-ws-support/pom.xml index 0ca8db0e..3923733d 100644 --- a/spring-ws-support/pom.xml +++ b/spring-ws-support/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -14,7 +14,7 @@ jar Spring WS Support - + 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 bc7e9e3a..af80aa2f 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 @@ -25,11 +25,10 @@ import java.net.URISyntaxException; import java.util.Collections; import java.util.Iterator; import java.util.List; + import javax.xml.namespace.QName; import javax.xml.soap.SOAPConstants; -import com.sun.net.httpserver.HttpExchange; - import org.springframework.util.Assert; import org.springframework.util.FileCopyUtils; import org.springframework.ws.WebServiceMessage; @@ -38,6 +37,8 @@ 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}. * @@ -107,7 +108,7 @@ public class HttpExchangeConnection extends AbstractReceiverConnection @Override public Iterator getRequestHeaders(String name) throws IOException { List headers = httpExchange.getRequestHeaders().get(name); - return headers != null ? headers.iterator() : Collections.emptyList().iterator(); + return headers != null ? headers.iterator() : Collections. emptyList().iterator(); } @Override @@ -129,8 +130,7 @@ public class HttpExchangeConnection extends AbstractReceiverConnection if (chunkedEncoding) { httpExchange.sendResponseHeaders(responseStatusCode, 0); return httpExchange.getResponseBody(); - } - else { + } else { if (responseBuffer == null) { responseBuffer = new ByteArrayOutputStream(); } @@ -151,8 +151,8 @@ public class HttpExchangeConnection extends AbstractReceiverConnection @Override public void onClose() throws IOException { - if (responseStatusCode == HttpTransportConstants.STATUS_ACCEPTED || - responseStatusCode == HttpTransportConstants.STATUS_NOT_FOUND) { + if (responseStatusCode == HttpTransportConstants.STATUS_ACCEPTED + || responseStatusCode == HttpTransportConstants.STATUS_NOT_FOUND) { httpExchange.sendResponseHeaders(responseStatusCode, -1); } httpExchange.close(); @@ -172,8 +172,7 @@ 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,12 +182,10 @@ 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/HttpsUrlConnectionMessageSender.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/http/HttpsUrlConnectionMessageSender.java index d6e0d7c1..6d0c9fd7 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 @@ -22,6 +22,7 @@ import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SecureRandom; + import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.KeyManager; @@ -81,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) */ @@ -92,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) */ @@ -153,25 +154,20 @@ 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 [" + - StringUtils.arrayToCommaDelimitedString(keyManagers) + "] trust managers [" + - StringUtils.arrayToCommaDelimitedString(trustManagers) + "] secure random [" + rnd + - "]"); + logger.debug("Initialized SSL Context with key managers [" + + StringUtils.arrayToCommaDelimitedString(keyManagers) + "] trust managers [" + + StringUtils.arrayToCommaDelimitedString(trustManagers) + "] secure random [" + rnd + "]"); } return sslContext.getSocketFactory(); - } - catch (NoSuchAlgorithmException ex) { + } catch (NoSuchAlgorithmException ex) { throw new HttpsTransportException("Could not create SSLContext: " + ex.getMessage(), ex); - } - catch (NoSuchProviderException ex) { + } catch (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 e21d7999..d72f1f19 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 @@ -18,19 +18,19 @@ 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. - * - *

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}. + *

+ * 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}. * * @author Arjen Poutsma * @see org.springframework.remoting.support.SimpleHttpServerFactoryBean @@ -53,12 +53,10 @@ 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 0e033a0e..b6455668 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 @@ -18,19 +18,20 @@ package org.springframework.ws.transport.http; import java.io.ByteArrayOutputStream; 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 @@ -41,8 +42,7 @@ public class WsdlDefinitionHttpHandler extends TransformerObjectSupport implemen private WsdlDefinition definition; - public WsdlDefinitionHttpHandler() { - } + public WsdlDefinitionHttpHandler() {} public WsdlDefinitionHttpHandler(WsdlDefinition definition) { this.definition = definition; @@ -68,15 +68,12 @@ 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 523ff291..22aa932c 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 @@ -18,6 +18,7 @@ package org.springframework.ws.transport.jms; import java.io.IOException; import java.io.InputStream; + import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.MessageEOFException; @@ -43,8 +44,7 @@ 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,12 +54,10 @@ 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); } } @@ -68,11 +66,9 @@ 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 42904226..2959aaf6 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 @@ -18,6 +18,7 @@ package org.springframework.ws.transport.jms; import java.io.IOException; import java.io.OutputStream; + import javax.jms.BytesMessage; import javax.jms.JMSException; @@ -42,8 +43,7 @@ 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,8 +52,7 @@ 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); } } @@ -62,8 +61,7 @@ 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 1ff90770..bfc13ff0 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 @@ -30,8 +30,8 @@ import org.springframework.ws.transport.support.SimpleWebServiceMessageReceiverO * 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}. + *

+ * Used by {@link WebServiceMessageListener}. * * @author Arjen Poutsma * @since 1.5.0 @@ -51,8 +51,8 @@ public class JmsMessageReceiver extends SimpleWebServiceMessageReceiverObjectSup } /** - * 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; @@ -69,13 +69,11 @@ 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); 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 eff415a2..a4326373 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 @@ -18,6 +18,7 @@ package org.springframework.ws.transport.jms; import java.io.IOException; import java.net.URI; + import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -41,54 +42,54 @@ 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. - * - *

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

jms:destination[?param-name=param-value][&param-name=param-value]* + * {@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: - * - *
- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
param-nameDescription
deliveryModeIndicates whether the request message is persistent or not. This may be PERSISTENT or - * NON_PERSISTENT. See {@link MessageProducer#setDeliveryMode(int)}
messageTypeThe message type. This may be BINARY_MESSAGE (the default) or TEXT_MESSAGE
priorityThe JMS priority (0-9) associated with the request message. See - * {@link 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}.
timeToLiveThe lifetime, in milliseconds, of the request message. See - * {@link MessageProducer#setTimeToLive(long)}
+ * the {@link #getDestinationResolver() destination resolver}. Valid param-name include:
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
param-nameDescription
deliveryModeIndicates whether the request message is persistent or not. This may be PERSISTENT or + * NON_PERSISTENT. See {@link MessageProducer#setDeliveryMode(int)}
messageTypeThe message type. This may be BINARY_MESSAGE (the default) or TEXT_MESSAGE
priorityThe JMS priority (0-9) associated with the request message. See {@link 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}.
timeToLiveThe lifetime, in milliseconds, of the request message. See {@link MessageProducer#setTimeToLive(long)}
*
- * - *

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

This class uses {@link BytesMessage} messages by default, but can be configured to send {@link 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
- * jms:RequestQueue?replyToName=ResponseQueueName
jms:Queue?messageType=TEXT_MESSAGE
+ *

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

+ * This class uses {@link BytesMessage} messages by default, but can be configured to send {@link 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
+ * jms:RequestQueue?replyToName=ResponseQueueName
+ * jms:Queue?messageType=TEXT_MESSAGE
* * @author Arjen Poutsma * @see IRI Scheme for Java(tm) Message Service 1.0 @@ -110,15 +111,14 @@ 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. @@ -144,8 +144,8 @@ public class JmsMessageSender extends JmsDestinationAccessor implements WebServi } /** - * 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; @@ -160,9 +160,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); @@ -172,8 +171,7 @@ 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); @@ -198,15 +196,12 @@ 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 73bcfcba..51b41127 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 @@ -22,6 +22,7 @@ import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; import java.util.Iterator; + import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.Message; @@ -38,10 +39,10 @@ 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. - * - *

The response message type is equal to the request message type, i.e. if a {@code BytesMessage} is received as + * 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. * @@ -72,7 +73,7 @@ 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 + * @param session the JMS session */ protected JmsReceiverConnection(BytesMessage requestMessage, Session session) { this((Message) requestMessage, session); @@ -82,7 +83,7 @@ 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 + * @param session the JMS session */ protected JmsReceiverConnection(TextMessage requestMessage, String encoding, Session session) { this(requestMessage, session); @@ -93,16 +94,16 @@ public class JmsReceiverConnection extends AbstractReceiverConnection { this.postProcessor = postProcessor; } - - - /** 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,8 +117,7 @@ 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()); } } @@ -144,8 +144,7 @@ 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); } } @@ -154,8 +153,7 @@ 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); } } @@ -164,11 +162,9 @@ 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 + "]"); } } @@ -182,11 +178,9 @@ 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(); @@ -194,8 +188,7 @@ 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); } } @@ -204,8 +197,7 @@ 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); } } @@ -214,11 +206,9 @@ 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 + "]"); } } @@ -236,11 +226,9 @@ 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 75c2b99f..71e9d804 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 @@ -22,6 +22,7 @@ import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; import java.util.Iterator; + import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -44,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 @@ -84,11 +85,8 @@ public class JmsSenderConnection extends AbstractSenderConnection { private boolean temporaryResponseQueueCreated = false; /** Constructs a new JMS connection with the given parameters. */ - protected JmsSenderConnection(ConnectionFactory connectionFactory, - Connection connection, - Session session, - Destination requestDestination, - Message requestMessage) throws JMSException { + protected JmsSenderConnection(ConnectionFactory connectionFactory, Connection connection, Session session, + Destination requestDestination, Message requestMessage) throws JMSException { Assert.notNull(connectionFactory, "'connectionFactory' must not be null"); Assert.notNull(connection, "'connection' must not be null"); Assert.notNull(session, "'session' must not be null"); @@ -101,14 +99,16 @@ public class JmsSenderConnection extends AbstractSenderConnection { this.requestMessage = requestMessage; } - /** 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; @@ -158,8 +158,7 @@ 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()); } } @@ -186,8 +185,7 @@ 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); } } @@ -196,11 +194,9 @@ 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 + "]"); } @@ -227,11 +223,9 @@ 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); } } @@ -251,8 +245,7 @@ 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); @@ -260,23 +253,18 @@ 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) { + throw new IllegalArgumentException("Wrong message type: [" + message.getClass() + "]. " + + "Only BytesMessages or TextMessages can be handled."); } - 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 } } @@ -292,8 +280,7 @@ 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); } } @@ -302,8 +289,7 @@ 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); } } @@ -312,15 +298,12 @@ 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 + "]"); } - } @Override 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 b3703f3d..e06d9747 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 @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; + import javax.jms.JMSException; import javax.jms.TextMessage; @@ -44,8 +45,7 @@ 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 3f4a42d2..f3c22148 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 @@ -19,6 +19,7 @@ package org.springframework.ws.transport.jms; import java.io.ByteArrayOutputStream; import java.io.FilterOutputStream; import java.io.IOException; + import javax.jms.JMSException; import javax.jms.TextMessage; @@ -51,8 +52,7 @@ class TextMessageOutputStream extends FilterOutputStream { ByteArrayOutputStream baos = (ByteArrayOutputStream) out; String text = new String(baos.toByteArray(), 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 995f5bf0..4594ed74 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 @@ -28,10 +28,10 @@ import org.springframework.ws.transport.WebServiceMessageReceiver; /** * 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 BytesMessage} into a - * {@link WebServiceMessage}, and passes that to the {@link WebServiceMessageReceiver} {@link - * #setMessageReceiver(WebServiceMessageReceiver) registered}. + *

+ * Requires a {@link WebServiceMessageFactory} which is used to convert the incoming JMS {@link 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) @@ -44,11 +44,9 @@ 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 7ad71346..d4299d20 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 @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; + import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; @@ -35,19 +36,19 @@ import javax.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 */ public abstract class JmsTransportUtils { - private static final String[] CONVERSION_TABLE = new String[]{JmsTransportConstants.HEADER_CONTENT_TYPE, + private static final String[] CONVERSION_TABLE = new String[] { JmsTransportConstants.HEADER_CONTENT_TYPE, JmsTransportConstants.PROPERTY_CONTENT_TYPE, JmsTransportConstants.HEADER_CONTENT_LENGTH, JmsTransportConstants.PROPERTY_CONTENT_LENGTH, JmsTransportConstants.HEADER_SOAP_ACTION, JmsTransportConstants.PROPERTY_SOAP_ACTION, JmsTransportConstants.HEADER_ACCEPT_ENCODING, - JmsTransportConstants.PROPERTY_ACCEPT_ENCODING}; + JmsTransportConstants.PROPERTY_ACCEPT_ENCODING }; private static final Pattern DESTINATION_NAME_PATTERN = Pattern.compile("^([^\\?]+)"); @@ -61,8 +62,7 @@ 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. @@ -77,7 +77,7 @@ public abstract class JmsTransportUtils { } } return headerName; - } + } /** * Converts the given JMS property name to a transport header name. Returns the given property name if no match is @@ -92,7 +92,7 @@ public abstract class JmsTransportUtils { return CONVERSION_TABLE[i - 1]; } } - return propertyName; + return propertyName; } /** @@ -108,12 +108,10 @@ 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); @@ -131,8 +129,7 @@ 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(); @@ -148,17 +145,16 @@ 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 { - return Collections.emptyList().iterator(); + } else { + return Collections. emptyList().iterator(); } } @@ -173,11 +169,9 @@ 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; } } @@ -192,8 +186,7 @@ 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; } } @@ -238,8 +231,7 @@ 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 } } @@ -251,8 +243,7 @@ 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 77fdb3d7..01ab3f05 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 @@ -17,6 +17,7 @@ package org.springframework.ws.transport.mail; import java.util.Properties; + import javax.mail.Folder; import javax.mail.FolderClosedException; import javax.mail.Message; @@ -38,13 +39,13 @@ 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) + * 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 @@ -73,11 +74,11 @@ 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. - * - *

Non-default properties in this instance will override given JavaMail properties. + *

+ * 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. */ public void setJavaMailProperties(Properties javaMailProperties) { session = Session.getInstance(javaMailProperties, null); @@ -85,12 +86,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. - * - *

If using a pre-configured {@code Session}, non-default properties in this instance will override the - * settings in the {@code Session}. + *

+ * 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}. * * @see #setJavaMailProperties */ @@ -102,8 +102,8 @@ 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. - * - *

For example, {@code imap://john:secret@imap.example.com/INBOX} + *

+ * For example, {@code imap://john:secret@imap.example.com/INBOX} * * @see Session#getStore(URLName) */ @@ -114,8 +114,8 @@ 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. - * - *

For example, {@code smtp://john:secret@smtp.example.com} + *

+ * For example, {@code smtp://john:secret@smtp.example.com} * * @see Session#getTransport(URLName) */ @@ -124,8 +124,7 @@ 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; @@ -139,13 +138,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 { - throw new IllegalArgumentException("Cannot determine monitoring strategy for \"" + protocol + "\". " + - "Set the 'monitoringStrategy' explicitly."); + } else { + throw new IllegalArgumentException("Cannot determine monitoring strategy for \"" + protocol + "\". " + + "Set the 'monitoringStrategy' explicitly."); } } super.afterPropertiesSet(); @@ -225,23 +222,19 @@ 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); } } @@ -267,8 +260,7 @@ 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); } } 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 1d6b35b9..f35eb8b5 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 @@ -19,6 +19,7 @@ package org.springframework.ws.transport.mail; import java.io.IOException; import java.net.URI; import java.util.Properties; + import javax.mail.Session; import javax.mail.URLName; import javax.mail.internet.AddressException; @@ -34,26 +35,35 @@ 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. - * - *

Calling {@link WebServiceConnection#receive(WebServiceMessageFactory)} on connections created by this message sender + * {@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. - * - *

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

mailto:to[?param-name=param-value][&param-name=param-value]* + *

+ * 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: - * - *
- *
param-nameDescription
subjectThe subject of the request message.
- * - *

Some examples of email URIs are: - * - *

mailto:john@example.com
mailto:john@example.com@?subject=SOAP%20Test
+ * themselves. The to represents a RFC 822 mailbox. Valid param-name include:
+ * + * + * + * + * + * + * + * + * + *
param-nameDescription
subjectThe subject of the request message.
+ *
+ *

+ * Some examples of email URIs are:

mailto:john@example.com
+ * mailto:john@example.com@?subject=SOAP%20Test
+ *
* * @author Arjen Poutsma * @see The mailto URL scheme @@ -85,19 +95,19 @@ 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. - * - *

Non-default properties in this instance will override given JavaMail properties. + *

+ * 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. */ public void setJavaMailProperties(Properties javaMailProperties) { session = Session.getInstance(javaMailProperties, null); } /** - * 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; @@ -105,12 +115,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. - * - *

If using a pre-configured {@code Session}, non-default properties in this instance will override the - * settings in the {@code Session}. + *

+ * 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}. * * @see #setJavaMailProperties */ @@ -122,8 +131,8 @@ 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. - * - *

For example, {@code imap://john:secret@imap.example.com/INBOX} + *

+ * For example, {@code imap://john:secret@imap.example.com/INBOX} * * @see Session#getStore(URLName) */ @@ -134,8 +143,8 @@ 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. - * - *

For example, {@code smtp://john:secret@smtp.example.com} + *

+ * For example, {@code smtp://john:secret@smtp.example.com} * * @see Session#getTransport(URLName) */ @@ -152,8 +161,7 @@ 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); } 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 8f5ab2a6..22353cf1 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 @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.Enumeration; import java.util.Iterator; import java.util.List; + import javax.activation.DataHandler; import javax.activation.DataSource; import javax.mail.Address; @@ -110,18 +111,16 @@ 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 { @@ -147,8 +146,7 @@ public class MailReceiverConnection extends AbstractReceiverConnection { headers.add(header.getName()); } return headers.iterator(); - } - catch (MessagingException ex) { + } catch (MessagingException ex) { throw new IOException(ex.getMessage()); } } @@ -158,8 +156,7 @@ 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); } } @@ -168,8 +165,7 @@ public class MailReceiverConnection extends AbstractReceiverConnection { protected InputStream getRequestInputStream() throws IOException { try { return requestMessage.getInputStream(); - } - catch (MessagingException ex) { + } catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -181,8 +177,7 @@ public class MailReceiverConnection extends AbstractReceiverConnection { if (TransportConstants.HEADER_CONTENT_TYPE.equals(name)) { responseContentType = value; } - } - catch (MessagingException ex) { + } catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -203,8 +198,7 @@ public class MailReceiverConnection extends AbstractReceiverConnection { responseMessage.setFrom(from); responseBuffer = new ByteArrayOutputStream(); - } - catch (MessagingException ex) { + } catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -213,17 +207,15 @@ 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); } } 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 af4212ba..4439f4e4 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 @@ -29,6 +29,7 @@ import java.util.Date; import java.util.Enumeration; import java.util.Iterator; import java.util.List; + import javax.activation.DataHandler; import javax.activation.DataSource; import javax.mail.Flags; @@ -47,7 +48,6 @@ import javax.mail.search.SearchTerm; 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; @@ -97,11 +97,8 @@ public class MailSenderConnection extends AbstractSenderConnection { private Folder folder; /** Constructs a new Mail connection with the given parameters. */ - protected MailSenderConnection(Session session, - URLName transportUri, - URLName storeUri, - InternetAddress to, - long receiveTimeout) { + protected MailSenderConnection(Session session, URLName transportUri, URLName storeUri, InternetAddress to, + long receiveTimeout) { Assert.notNull(session, "'session' must not be null"); Assert.notNull(transportUri, "'transportUri' must not be null"); Assert.notNull(storeUri, "'storeUri' must not be null"); @@ -159,8 +156,7 @@ public class MailSenderConnection extends AbstractSenderConnection { requestMessage.setSubject(subject); } requestBuffer = new ByteArrayOutputStream(); - } - catch (MessagingException ex) { + } catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -172,8 +168,7 @@ public class MailSenderConnection extends AbstractSenderConnection { if (TransportConstants.HEADER_CONTENT_TYPE.equals(name)) { requestContentType = value; } - } - catch (MessagingException ex) { + } catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -187,17 +182,15 @@ 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); } } @@ -213,8 +206,7 @@ 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(); } @@ -230,8 +222,7 @@ public class MailSenderConnection extends AbstractSenderConnection { if (deleteAfterReceive) { responseMessage.setFlag(Flags.Flag.DELETED, true); } - } - catch (MessagingException ex) { + } catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -245,8 +236,7 @@ public class MailSenderConnection extends AbstractSenderConnection { } if (deleteAfterReceive) { folder.open(Folder.READ_WRITE); - } - else { + } else { folder.open(Folder.READ_ONLY); } } @@ -266,8 +256,7 @@ public class MailSenderConnection extends AbstractSenderConnection { headers.add(header.getName()); } return headers.iterator(); - } - catch (MessagingException ex) { + } catch (MessagingException ex) { throw new MailTransportException(ex); } } @@ -277,8 +266,7 @@ 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); } @@ -288,8 +276,7 @@ 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); } } 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 3c265843..2502b3a7 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 @@ -43,8 +43,8 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { private boolean deleteMessages = true; /** - * Sets whether messages should be marked as {@link javax.mail.Flags.Flag#DELETED DELETED} after they have been - * read. Default is {@code true}. + * Sets whether messages should be marked as {@link javax.mail.Flags.Flag#DELETED DELETED} after they have been read. + * Default is {@code true}. */ public void setDeleteMessages(boolean deleteMessages) { this.deleteMessages = deleteMessages; @@ -56,14 +56,15 @@ 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 + * @throws MessagingException in case of JavaMail errors * @throws InterruptedException when a thread is interrupted */ @Override @@ -83,20 +84,20 @@ 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 MessagingException in case of JavaMail errors * @throws InterruptedException when a thread is interrupted */ 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 javax.mail.Flags.Flag#RECENT RECENT}, not {@link - * javax.mail.Flags.Flag#ANSWERED ANSWERED}, and not {@link javax.mail.Flags.Flag#DELETED DELETED}. The search term - * is used to {@link Folder#search(SearchTerm) search} for new messages. + * all messages in the folder that are {@link javax.mail.Flags.Flag#RECENT RECENT}, not + * {@link javax.mail.Flags.Flag#ANSWERED ANSWERED}, and not {@link javax.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 @@ -116,8 +117,7 @@ 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,8 +125,7 @@ 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,10 +134,10 @@ 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}. + * Fetches the specified messages from the specified folder. Default implementation + * {@link Folder#fetch(Message[], FetchProfile) fetches} every {@link javax.mail.FetchProfile.Item}. * - * @param folder the folder to fetch messages from + * @param folder the folder to fetch messages from * @param messages the messages to fetch * @throws MessagingException in case of JavMail errors */ @@ -154,7 +153,7 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy { * 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 folder the folder to delete messages from * @param messages the messages to delete * @throws MessagingException in case of JavaMail errors */ 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 493516d3..1a4505d2 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 @@ -30,8 +30,8 @@ import com.sun.mail.imap.IMAPFolder; /** * 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. + *

+ * 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 @@ -55,8 +55,7 @@ public class ImapIdleMonitoringStrategy extends AbstractMonitoringStrategy { folder.addMessageCountListener(messageCountListener); try { imapFolder.idle(); - } - finally { + } finally { folder.removeMessageCountListener(messageCountListener); } } @@ -70,8 +69,7 @@ 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 a17e2614..538c5411 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 @@ -33,14 +33,14 @@ public interface MonitoringStrategy { * * @param folder the folder in which to look for new messages * @return the new messages - * @throws MessagingException in case of JavaMail errors + * @throws MessagingException in case of JavaMail errors * @throws InterruptedException if a thread is interrupted */ 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 457389de..4cbdaa8f 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 @@ -20,11 +20,11 @@ import javax.mail.Folder; import javax.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. - * - *

Note that this implementation is not suitable for use with POP3 servers. Use the {@link - * Pop3PollingMonitoringStrategy} instead. + * 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. * * @author Arjen Poutsma * @since 1.5.0 @@ -51,8 +51,8 @@ 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 24d31bb3..62dec553 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 @@ -28,8 +28,8 @@ import org.springframework.ws.transport.mail.support.MailTransportUtils; * 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 + *

+ * Setting the {@link #setDeleteMessages(boolean) deleteMessages} property is therefore ignored: messages are always * deleted. * * @author Arjen Poutsma @@ -42,8 +42,7 @@ public class Pop3PollingMonitoringStrategy extends PollingMonitoringStrategy { } @Override - public void setDeleteMessages(boolean deleteMessages) { - } + public void setDeleteMessages(boolean deleteMessages) {} /** * Re-opens the folder, if it closed. @@ -66,7 +65,7 @@ public class Pop3PollingMonitoringStrategy extends PollingMonitoringStrategy { /** * Deletes the given messages from the given folder, and closes it to expunge deleted messages. * - * @param folder the folder to delete messages from + * @param folder the folder to delete messages from * @param messages the messages to delete * @throws MessagingException in case of JavaMail errors */ @@ -79,4 +78,4 @@ public class Pop3PollingMonitoringStrategy extends PollingMonitoringStrategy { } MailTransportUtils.closeFolder(folder, true); } -} \ No newline at end of file +} 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 22bd7ba9..f1a64c3e 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 @@ -20,6 +20,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.regex.Matcher; import java.util.regex.Pattern; + import javax.mail.Folder; import javax.mail.MessagingException; import javax.mail.Service; @@ -29,11 +30,10 @@ import javax.mail.URLName; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; -import org.springframework.util.StringUtils; -import org.springframework.ws.transport.mail.MailTransportConstants; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.util.StringUtils; +import org.springframework.ws.transport.mail.MailTransportConstants; /** * Collection of utility methods to work with Mail transports. @@ -49,8 +49,7 @@ 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()); @@ -60,8 +59,7 @@ public abstract class MailTransportUtils { if (group != null) { try { return new InternetAddress(group); - } - catch (AddressException e) { + } catch (AddressException e) { // try next group } } @@ -79,8 +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 Transport @@ -90,16 +88,15 @@ 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}) */ @@ -109,18 +106,17 @@ 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 folder the JavaMail Folder to close (may be {@code null}) * @param expunge whether all deleted messages should be expunged from the folder */ public static void closeFolder(Folder folder, boolean expunge) { if (folder != null && folder.isOpen()) { try { folder.close(expunge); - } - catch (MessagingException ex) { + } catch (MessagingException ex) { logger.debug("Could not close JavaMail Folder", ex); } } @@ -171,18 +167,16 @@ public abstract class MailTransportUtils { /** * Converts the given internet address into a {@code mailto} URI. * - * @param to the To: address + * @param to the To: address * @param subject the subject, may be {@code null} * @return a mailto URI */ 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 45e5da38..0916bfbd 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 @@ -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,11 @@ 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. - * - *

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. + * 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. */ public void setTaskExecutor(TaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; @@ -63,8 +63,8 @@ public abstract class AbstractAsyncStandaloneMessageReceiver extends AbstractSta /** * 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 + *

+ * 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) 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 7f1eaa6d..e01930f5 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 @@ -54,8 +54,8 @@ public abstract class AbstractStandaloneMessageReceiver extends SimpleWebService /** * Set whether to automatically start the receiver after initialization. - * - *

Default is {@code true}; set this to {@code false} to allow for manual startup. + *

+ * Default is {@code true}; set this to {@code false} to allow for manual startup. */ public void setAutoStartup(boolean autoStartup) { this.autoStartup = autoStartup; @@ -74,8 +74,7 @@ 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) { diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/MessageInputStream.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/MessageInputStream.java index e85acf98..22ab2b50 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/MessageInputStream.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/MessageInputStream.java @@ -21,9 +21,8 @@ import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; -import org.springframework.util.Assert; - import org.jivesoftware.smack.packet.Message; +import org.springframework.util.Assert; /** * Input stream that wraps a {@link Message}. @@ -46,5 +45,4 @@ class MessageInputStream extends FilterInputStream { return new ByteArrayInputStream(contents); } - } 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 943fd29e..be74cc38 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 @@ -20,9 +20,8 @@ import java.io.ByteArrayOutputStream; import java.io.FilterOutputStream; import java.io.IOException; -import org.springframework.util.Assert; - import org.jivesoftware.smack.packet.Message; +import org.springframework.util.Assert; /** * Output stream that wraps a {@link Message}. @@ -52,4 +51,4 @@ class MessageOutputStream extends FilterOutputStream { String text = new String(bos.toByteArray(), encoding); message.setBody(text); } -} \ No newline at end of file +} 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 a04f4587..7efa4dc2 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 @@ -27,11 +27,10 @@ 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) + * 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. @@ -53,8 +52,7 @@ 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) { @@ -112,8 +110,7 @@ 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 0dc49971..4c6f5e0f 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 @@ -21,7 +21,6 @@ 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; @@ -31,8 +30,8 @@ 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. - * - *

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

xmpp:to
+ *

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

xmpp:to
* The to represents a Jabber ID. * * @author Gildas Cuisinier 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 747aaedf..bbc4205d 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 @@ -26,7 +26,6 @@ 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; 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 ab946889..93a07430 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 @@ -34,7 +34,6 @@ 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; diff --git a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppTransportConstants.java b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppTransportConstants.java index 3b234119..ab092768 100644 --- a/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppTransportConstants.java +++ b/spring-ws-support/src/main/java/org/springframework/ws/transport/xmpp/XmppTransportConstants.java @@ -31,4 +31,4 @@ public interface XmppTransportConstants extends TransportConstants { */ String XMPP_URI_SCHEME = "xmpp"; -} \ No newline at end of file +} 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 de59b080..c58acd4d 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 @@ -24,7 +24,6 @@ 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; @@ -63,8 +62,8 @@ public class XmppConnectionFactoryBean implements FactoryBean /** * Sets the server port to connect to. - * - *

Defaults to {@code 5222}. + *

+ * Defaults to {@code 5222}. */ public void setPort(int port) { Assert.isTrue(port > 0, "'port' must be larger than 0"); @@ -131,26 +130,18 @@ 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 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} */ - protected XMPPTCPConnectionConfiguration createConnectionConfiguration(String host, int port, String serviceName) throws XmppStringprepException { + protected XMPPTCPConnectionConfiguration createConnectionConfiguration(String host, int port, String serviceName) + 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) - .build(); + return XMPPTCPConnectionConfiguration.builder().setHost(host).setPort(port).setXmppDomain(serviceName).build(); + } else { + return XMPPTCPConnectionConfiguration.builder().setHost(host).setPort(port).build(); } } - -} \ No newline at end of file +} 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 5cb64b6d..f4998a81 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 @@ -23,7 +23,6 @@ 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; @@ -35,15 +34,13 @@ 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. */ public static URI toUri(Message requestMessage) throws URISyntaxException { - return new URI(XmppTransportConstants.XMPP_URI_SCHEME, - requestMessage.getTo().asUnescapedString(), null); + return new URI(XmppTransportConstants.XMPP_URI_SCHEME, requestMessage.getTo().asUnescapedString(), null); } public static String getTo(URI uri) { @@ -57,8 +54,7 @@ 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(); } } @@ -77,9 +73,8 @@ public abstract class XmppTransportUtils { String value = JivePropertiesManager.getProperty(message, name).toString(); if (value != null) { return Collections.singletonList(value).iterator(); - } - else { - return Collections.emptyList().iterator(); + } else { + return Collections. emptyList().iterator(); } } 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 2797e01c..818495ce 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 @@ -29,4 +29,4 @@ public class FaultEndpoint implements MessageEndpoint { SoapMessage response = (SoapMessage) messageContext.getResponse(); response.getSoapBody().addServerOrReceiverFault("Something went wrong", Locale.ENGLISH); } -} \ No newline at end of file +} 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 8bbdf3dd..44a26efb 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 @@ -23,6 +23,5 @@ import org.springframework.ws.server.endpoint.MessageEndpoint; public class NoResponseEndpoint implements MessageEndpoint { @Override - public void invoke(MessageContext messageContext) throws Exception { - } -} \ No newline at end of file + public void invoke(MessageContext messageContext) throws Exception {} +} 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 b62bc1fe..56971464 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 @@ -26,4 +26,4 @@ public class ResponseEndpoint implements MessageEndpoint { public void invoke(MessageContext messageContext) throws Exception { messageContext.getResponse(); } -} \ No newline at end of file +} 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 5b9991b4..0b621f62 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 @@ -16,14 +16,9 @@ package org.springframework.ws.transport.http; -import java.io.IOException; +import static org.junit.Assert.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.ws.transport.TransportConstants; +import java.io.IOException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.GetMethod; @@ -32,9 +27,12 @@ import org.apache.commons.httpclient.methods.PostMethod; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.ws.transport.TransportConstants; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("httpserver-applicationContext.xml") @@ -42,8 +40,7 @@ public class WebServiceHttpHandlerIntegrationTest { private HttpClient client; - @Autowired - private int port; + @Autowired private int port; private String url; @@ -57,8 +54,7 @@ public class WebServiceHttpHandlerIntegrationTest { public void testInvalidMethod() throws IOException { GetMethod getMethod = new GetMethod(url); client.executeMethod(getMethod); - assertEquals("Invalid Response Code", HttpTransportConstants.STATUS_METHOD_NOT_ALLOWED, - getMethod.getStatusCode()); + assertEquals("Invalid Response Code", HttpTransportConstants.STATUS_METHOD_NOT_ALLOWED, getMethod.getStatusCode()); assertEquals("Response retrieved", 0, getMethod.getResponseContentLength()); } @@ -79,8 +75,7 @@ public class WebServiceHttpHandlerIntegrationTest { public void testResponse() throws IOException { 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); @@ -105,8 +100,7 @@ public class WebServiceHttpHandlerIntegrationTest { public void testFault() throws IOException { 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())); client.executeMethod(postMethod); @@ -115,4 +109,4 @@ public class WebServiceHttpHandlerIntegrationTest { assertTrue("No Response retrieved", postMethod.getResponseContentLength() > 0); } -} \ No newline at end of file +} 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 d138105c..e2ae46a1 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 @@ -16,6 +16,9 @@ package org.springframework.ws.transport.jms; +import org.custommonkey.xmlunit.XMLAssert; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -23,17 +26,11 @@ import org.springframework.ws.client.core.WebServiceTemplate; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.custommonkey.xmlunit.XMLAssert; -import org.junit.Test; -import org.junit.runner.RunWith; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("jms-applicationContext.xml") public class JmsIntegrationTest { - @Autowired - private WebServiceTemplate webServiceTemplate; - + @Autowired private WebServiceTemplate webServiceTemplate; public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) { this.webServiceTemplate = webServiceTemplate; 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 887ac2d6..17f334bf 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 @@ -16,8 +16,11 @@ package org.springframework.ws.transport.jms; +import static org.junit.Assert.*; + import java.io.ByteArrayOutputStream; import java.net.URI; + import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.Message; @@ -26,6 +29,9 @@ import javax.jms.TextMessage; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.MessageCreator; @@ -38,21 +44,13 @@ import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.transport.WebServiceConnection; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - @RunWith(SpringJUnit4ClassRunner.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; @@ -84,8 +82,7 @@ public class JmsMessageSenderIntegrationTest { public Message createMessage(Session session) throws JMSException { 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; } @@ -94,8 +91,7 @@ public class JmsMessageSenderIntegrationTest { assertNotNull("No response received", response); assertEquals("Invalid SOAPAction", SOAP_ACTION, response.getSoapAction()); assertFalse("Message is fault", response.hasFault()); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -107,8 +103,7 @@ public class JmsMessageSenderIntegrationTest { WebServiceConnection connection = null; try { String responseQueueName = "SenderResponseQueue"; - URI uri = new URI( - "jms:SenderRequestQueue?replyToName=" + responseQueueName + "&deliveryMode=NON_PERSISTENT"); + URI uri = new URI("jms:SenderRequestQueue?replyToName=" + responseQueueName + "&deliveryMode=NON_PERSISTENT"); connection = messageSender.createConnection(uri); SoapMessage soapRequest = new SaajSoapMessage(messageFactory.createMessage()); soapRequest.setSoapAction(SOAP_ACTION); @@ -126,8 +121,7 @@ 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; } @@ -136,8 +130,7 @@ public class JmsMessageSenderIntegrationTest { assertNotNull("No response received", response); assertEquals("Invalid SOAPAction", SOAP_ACTION, response.getSoapAction()); assertFalse("Message is fault", response.hasFault()); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -165,8 +158,7 @@ public class JmsMessageSenderIntegrationTest { public Message createMessage(Session session) throws JMSException { 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; } @@ -175,8 +167,7 @@ public class JmsMessageSenderIntegrationTest { assertNotNull("No response received", response); assertEquals("Invalid SOAPAction", SOAP_ACTION, response.getSoapAction()); assertFalse("Message is fault", response.hasFault()); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -199,8 +190,7 @@ public class JmsMessageSenderIntegrationTest { messageFactory.createMessage().writeTo(bos); SoapMessage response = (SoapMessage) connection.receive(new SaajSoapMessageFactory(messageFactory)); assertNull("Response received", response); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -226,12 +216,11 @@ public class JmsMessageSenderIntegrationTest { BytesMessage request = (BytesMessage) jmsTemplate.receive(); assertNotNull("No message received", request); assertTrue("Message not processed", request.getBooleanProperty("processed")); - } - finally { + } finally { if (connection != null) { connection.close(); } } } -} \ No newline at end of file +} 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 1705b212..6aaa04c1 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 @@ -16,6 +16,8 @@ package org.springframework.ws.transport.jms; +import static org.junit.Assert.*; + import javax.annotation.Resource; import javax.jms.BytesMessage; import javax.jms.JMSException; @@ -25,38 +27,29 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.MessageCreator; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertNotNull; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("jms-receiver-applicationContext.xml") public class WebServiceMessageListenerIntegrationTest { - private static final String CONTENT = - "" + "\n" + - "\n" + - "DIS\n" + "\n" + ""; + private static final String CONTENT = "" + + "\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; - - @Autowired - private Topic requestTopic; + @Resource private Queue requestQueue; + @Autowired private Topic requestTopic; @Test public void testReceiveQueueBytesMessage() throws Exception { 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 9300c1e4..4c994380 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 @@ -16,16 +16,16 @@ package org.springframework.ws.transport.jms.support; +import static org.junit.Assert.*; + import java.net.URI; + import javax.jms.DeliveryMode; import javax.jms.Message; -import org.springframework.ws.transport.jms.JmsTransportConstants; - import org.junit.Assert; import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.springframework.ws.transport.jms.JmsTransportConstants; public class JmsTransportUtilsTest { @@ -112,4 +112,4 @@ public class JmsTransportUtilsTest { String replyTo = JmsTransportUtils.getReplyToName(uri); assertEquals("Invalid reply to name", "jms/REPLY_QUEUE", replyTo); } -} \ No newline at end of file +} 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 986af38f..f2593e6c 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 @@ -16,6 +16,13 @@ package org.springframework.ws.transport.mail; +import static org.junit.Assert.*; + +import org.custommonkey.xmlunit.XMLAssert; +import org.junit.After; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.jvnet.mock_javamail.Mailbox; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.support.GenericApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -24,30 +31,19 @@ import org.springframework.ws.client.core.WebServiceTemplate; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.custommonkey.xmlunit.XMLAssert; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.jvnet.mock_javamail.Mailbox; - -import static org.junit.Assert.assertEquals; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("mail-applicationContext.xml") public class MailIntegrationTest { - @Autowired - private WebServiceTemplate webServiceTemplate; + @Autowired private WebServiceTemplate webServiceTemplate; - @Autowired - private GenericApplicationContext applicationContext; + @Autowired private GenericApplicationContext applicationContext; @After public void clearMailbox() throws Exception { Mailbox.clearAll(); } - @Test public void testMailTransport() throws Exception { String 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 feab1085..a7568689 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 @@ -17,20 +17,20 @@ package org.springframework.ws.transport.mail; import java.net.URI; + import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPMessage; -import org.springframework.ws.soap.SoapMessage; -import org.springframework.ws.soap.saaj.SaajSoapMessage; -import org.springframework.ws.transport.WebServiceConnection; - import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.jvnet.mock_javamail.Mailbox; +import org.springframework.ws.soap.SoapMessage; +import org.springframework.ws.soap.saaj.SaajSoapMessage; +import org.springframework.ws.transport.WebServiceConnection; public class MailMessageSenderIntegrationTest { @@ -67,12 +67,11 @@ public class MailMessageSenderIntegrationTest { soapRequest.setSoapAction(SOAP_ACTION); connection.send(soapRequest); Assert.assertEquals("No mail message sent", 1, Mailbox.get("server@example.com").size()); - } - finally { + } finally { if (connection != null) { connection.close(); } } } -} \ No newline at end of file +} 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 8035b9c8..299fb7b0 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 @@ -17,6 +17,7 @@ package org.springframework.ws.transport.mail.support; import java.net.URI; + import javax.mail.URLName; import javax.mail.internet.InternetAddress; @@ -53,4 +54,4 @@ public class MailTransportUtilsTest { subject = MailTransportUtils.getSubject(uri); Assert.assertNull("Invalid destination", subject); } -} \ No newline at end of file +} 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 b4a6768e..a3c1c706 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 @@ -59,8 +59,7 @@ 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; } @@ -73,8 +72,7 @@ public abstract class FreePortScanner { ServerSocket serverSocket; try { serverSocket = new ServerSocket(); - } - catch (IOException ex) { + } catch (IOException ex) { throw new IllegalStateException("Unable to create ServerSocket.", ex); } @@ -82,15 +80,12 @@ 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 7f35ab7d..020599b4 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 @@ -32,6 +32,7 @@ public class XmppConnectionFactoryBeanTest { public void createFactoryBean() { factoryBean = new XmppConnectionFactoryBean(); } + @Test(expected = IllegalArgumentException.class) public void noHost() throws XMPPException, IOException, SmackException { factoryBean.afterPropertiesSet(); diff --git a/spring-ws-support/src/test/resources/log4j.properties b/spring-ws-support/src/test/resources/log4j.properties index 86d178da..51bcb860 100644 --- a/spring-ws-support/src/test/resources/log4j.properties +++ b/spring-ws-support/src/test/resources/log4j.properties @@ -1,6 +1,5 @@ log4j.rootCategory=WARN, stdout log4j.logger.org.springframework.ws=DEBUG - log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n \ No newline at end of file diff --git a/spring-ws-support/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml b/spring-ws-support/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml index 8238729c..213c9709 100644 --- a/spring-ws-support/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml +++ b/spring-ws-support/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml @@ -2,50 +2,50 @@ - - - - + + + + - - - - - - - - + + + + + + + + - - - - - + + + + + - + - - - + + + - - - - noResponseEndpoint - responseEndpoint - faultEndpoint - - - + + + + noResponseEndpoint + responseEndpoint + faultEndpoint + + + - + - + - + diff --git a/spring-ws-support/src/test/resources/org/springframework/ws/transport/http/soapRequest.xml b/spring-ws-support/src/test/resources/org/springframework/ws/transport/http/soapRequest.xml index 199de8ec..ce13d0d9 100644 --- a/spring-ws-support/src/test/resources/org/springframework/ws/transport/http/soapRequest.xml +++ b/spring-ws-support/src/test/resources/org/springframework/ws/transport/http/soapRequest.xml @@ -1,7 +1,7 @@ - - - DIS - - + + + DIS + + \ No newline at end of file diff --git a/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-applicationContext.xml b/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-applicationContext.xml index a133ed53..dfc7f640 100644 --- a/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-applicationContext.xml +++ b/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-applicationContext.xml @@ -1,42 +1,42 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> - - - + + + - + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-receiver-applicationContext.xml b/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-receiver-applicationContext.xml index bacd4ae0..40473d88 100644 --- a/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-receiver-applicationContext.xml +++ b/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-receiver-applicationContext.xml @@ -2,46 +2,46 @@ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + + - + \ No newline at end of file diff --git a/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-sender-applicationContext.xml b/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-sender-applicationContext.xml index f9c085c5..a3f84df4 100644 --- a/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-sender-applicationContext.xml +++ b/spring-ws-support/src/test/resources/org/springframework/ws/transport/jms/jms-sender-applicationContext.xml @@ -2,26 +2,26 @@ - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - + + + + \ No newline at end of file diff --git a/spring-ws-support/src/test/resources/org/springframework/ws/transport/mail/mail-applicationContext.xml b/spring-ws-support/src/test/resources/org/springframework/ws/transport/mail/mail-applicationContext.xml index 538ee3d3..03fae1f1 100644 --- a/spring-ws-support/src/test/resources/org/springframework/ws/transport/mail/mail-applicationContext.xml +++ b/spring-ws-support/src/test/resources/org/springframework/ws/transport/mail/mail-applicationContext.xml @@ -2,51 +2,51 @@ - - - - - + + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - diff --git a/spring-ws-test/pom.xml b/spring-ws-test/pom.xml index 3b542fdc..667a9285 100644 --- a/spring-ws-test/pom.xml +++ b/spring-ws-test/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 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 f2a1dd80..41a97095 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 @@ -24,9 +24,9 @@ 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 @@ -34,9 +34,8 @@ import org.springframework.ws.WebServiceMessageFactory; abstract class AbstractResponseCreator implements ResponseCreator { @Override - public final WebServiceMessage createResponse(URI uri, - WebServiceMessage request, - WebServiceMessageFactory messageFactory) throws IOException { + public final WebServiceMessage createResponse(URI uri, WebServiceMessage request, + WebServiceMessageFactory messageFactory) throws IOException { WebServiceMessage response = messageFactory.createWebServiceMessage(); doWithResponse(uri, request, response); return response; @@ -45,8 +44,8 @@ abstract class AbstractResponseCreator implements ResponseCreator { /** * Execute any number of operations on the supplied response, given the request and URI. * - * @param uri the URI - * @param request the request message + * @param uri the URI + * @param request the request message * @param response the response message * @throws IOException in case of I/O errors */ 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 d1660d84..539059d1 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 @@ -38,9 +38,8 @@ class ErrorResponseCreator implements ResponseCreator { } @Override - public WebServiceMessage createResponse(URI uri, - WebServiceMessage request, - WebServiceMessageFactory factory) throws IOException { + public WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory factory) + throws IOException { // Do nothing return null; } 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 eab4e654..93c9a9f9 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 @@ -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 @@ -42,13 +42,11 @@ class ExceptionResponseCreator implements ResponseCreator { } @Override - public WebServiceMessage createResponse(URI uri, - WebServiceMessage request, - WebServiceMessageFactory factory) throws IOException { + public WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory factory) + 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 c2a576cb..2b37064d 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 @@ -75,8 +75,7 @@ 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; @@ -86,8 +85,7 @@ 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; } } @@ -106,8 +104,7 @@ 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 1bf29361..13347537 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 @@ -80,8 +80,8 @@ public class MockWebServiceMessageSender implements WebServiceMessageSender { } void reset() { - expectedConnections.clear(); - connectionIterator = null; - } + expectedConnections.clear(); + connectionIterator = null; + } } 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 5a1db499..e6e5d010 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 @@ -23,26 +23,28 @@ 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. - * - *

The typical usage of this class is: + * 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 {@link ResponseCreators} (which can be statically imported).
  5. + *
  6. 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).
  7. *
  8. Use the {@code WebServiceTemplate} as normal, either directly of through client code.
  9. - *
  10. Call {@link #verify()}.
+ *
  • 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. - * - *

    For example: - *

    + * 

    + * For example:

    + * + *
      * import org.junit.*;
      * import org.springframework.beans.factory.annotation.Autowired;
      * import org.springframework.test.context.ContextConfiguration;
    @@ -84,7 +86,9 @@ import org.springframework.ws.test.support.MockStrategiesHelper;
      *	   mockServer.verify();
      *	 }
      * }
    - * 
    + *
    + * + *
    * * @author Arjen Poutsma * @author Lukas Krecan @@ -128,15 +132,15 @@ public class MockWebServiceServer { /** * 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); @@ -153,8 +157,8 @@ 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 @@ -174,12 +178,11 @@ public class MockWebServiceServer { mockMessageSender.verifyConnections(); } - /** - * Reset the {@link MockWebServiceMessageSender}'s expectations. - */ - public void reset() { - mockMessageSender.reset(); - } - + /** + * Reset the {@link MockWebServiceMessageSender}'s expectations. + */ + public void reset() { + mockMessageSender.reset(); + } } 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 5c96e7e5..9e1223cc 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 @@ -34,11 +34,11 @@ public interface RequestMatcher { * Matches the given request message against the expectations. Implementations typically make use of JUnit-based * assertions. * - * @param uri the uri connected to + * @param uri the uri connected to * @param request the request message to make assertions on - * @throws IOException in case of I/O errors + * @throws IOException in case of I/O errors * @throws AssertionError if expectations are not met */ void match(URI uri, WebServiceMessage request) throws IOException, AssertionError; -} \ No newline at end of file +} 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 514027fd..47286a92 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 @@ -19,6 +19,7 @@ package org.springframework.ws.test.client; import java.io.IOException; import java.net.URI; import java.util.Map; + import javax.xml.namespace.QName; import javax.xml.transform.Source; @@ -32,26 +33,24 @@ import org.springframework.ws.test.support.matcher.SoapHeaderMatcher; import org.springframework.xml.transform.ResourceSource; /** - * Factory methods for {@link RequestMatcher} classes. Typically used to provide input for {@link - * MockWebServiceServer#expect(RequestMatcher)}. + * Factory methods for {@link RequestMatcher} classes. Typically used to provide input for + * {@link MockWebServiceServer#expect(RequestMatcher)}. * * @author Arjen Poutsma * @since 2.0 */ public abstract class RequestMatchers { - private RequestMatchers() { - } + private RequestMatchers() {} - /** + /** * Expects any request. * * @return the request matcher */ public static RequestMatcher anything() { return new RequestMatcher() { - public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError { - } + public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {} }; } @@ -82,7 +81,7 @@ public abstract class RequestMatchers { /** * Expects the payload to validate against the given XSD schema(s). * - * @param schema the schema + * @param schema the schema * @param furtherSchemas further schemas, if necessary * @return the request matcher */ @@ -103,7 +102,7 @@ public abstract class RequestMatchers { /** * Expects the given XPath expression to (not) exist or be evaluated to a value. * - * @param xpathExpression the XPath expression + * @param xpathExpression the XPath expression * @param namespaceMapping the namespaces * @return the XPath expectations, to be further configured */ 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 6e2f0497..816af8f9 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 @@ -18,10 +18,10 @@ 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 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 71270a51..2f175c79 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 @@ -17,7 +17,7 @@ package org.springframework.ws.test.client; /** - * Allows for setting up responses and additional expectations. Implementations of this interface are returned by + * Allows for setting up responses and additional expectations. Implementations of this interface are returned by * {@link MockWebServiceServer#expect(RequestMatcher)}. * * @author Arjen Poutsma @@ -39,4 +39,4 @@ public interface ResponseActions { */ void andRespond(ResponseCreator responseCreator); -} \ No newline at end of file +} 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 1b7fb4fe..42289aee 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 @@ -34,11 +34,12 @@ public interface ResponseCreator { /** * Create a response for the given the request and URI. * - * @param uri the URI - * @param request the request message + * @param uri the URI + * @param request the request message * @param messageFactory the message that can be used to create responses * @throws IOException in case of I/O errors */ - WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory messageFactory) throws IOException; + WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory messageFactory) + throws IOException; } 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 7246e076..41758820 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 @@ -19,6 +19,7 @@ package org.springframework.ws.test.client; import java.io.IOException; import java.net.URI; import java.util.Locale; + import javax.xml.transform.Source; import org.springframework.core.io.Resource; @@ -32,16 +33,15 @@ 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 @@ -68,7 +68,7 @@ public abstract class ResponseCreators { } // Error/Exception - + /** * Respond with an error. * @@ -130,12 +130,11 @@ public abstract class ResponseCreators { return withSoapEnvelope(new ResourceSource(soapEnvelope)); } - /** * 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 + * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @see SoapBody#addMustUnderstandFault(String, java.util.Locale) */ public static ResponseCreator withMustUnderstandFault(final String faultStringOrReason, final Locale locale) { @@ -152,7 +151,7 @@ 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 + * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale) */ public static ResponseCreator withClientOrSenderFault(final String faultStringOrReason, final Locale locale) { @@ -169,7 +168,7 @@ 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 + * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @see org.springframework.ws.soap.SoapBody#addServerOrReceiverFault(String, Locale) */ public static ResponseCreator withServerOrReceiverFault(final String faultStringOrReason, final Locale locale) { @@ -186,7 +185,7 @@ 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 + * @param locale the language of faultStringOrReason. Optional for SOAP 1.1 * @see org.springframework.ws.soap.SoapBody#addVersionMismatchFault(String, Locale) */ public static ResponseCreator withVersionMismatchFault(final String faultStringOrReason, final Locale locale) { @@ -211,12 +210,10 @@ 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 dbef33b2..66fda1e8 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 @@ -16,6 +16,8 @@ package org.springframework.ws.test.client; +import static org.springframework.ws.test.support.AssertionErrors.*; + import java.io.IOException; import java.net.URI; @@ -23,8 +25,6 @@ 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. * 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 f7717311..bc75baba 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 @@ -16,9 +16,9 @@ package org.springframework.ws.test.client; -import java.net.URI; +import static org.springframework.ws.test.support.AssertionErrors.*; -import static org.springframework.ws.test.support.AssertionErrors.assertEquals; +import java.net.URI; import org.springframework.ws.WebServiceMessage; 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 5ed8358b..d54b8239 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 @@ -16,12 +16,12 @@ 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 static org.springframework.ws.test.support.AssertionErrors.fail; - import org.springframework.context.ApplicationContext; import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; @@ -34,25 +34,27 @@ import org.springframework.ws.test.support.MockStrategiesHelper; import org.springframework.ws.transport.WebServiceMessageReceiver; /** - * 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 + * 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: + *

    + * The typical usage of this class is: *

      *
    1. Create a {@code MockWebServiceClient} instance by using {@link #createClient(ApplicationContext)} or * {@link #createClient(WebServiceMessageReceiver, WebServiceMessageFactory)}
    2. *
    3. 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).
    4. - *
    5. 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.
    6. + *
    7. 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.
    8. *
    * 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: - *

    + * 

    + * For example:

    + * + *
      * import org.junit.*;
      * import org.springframework.beans.factory.annotation.Autowired;
      * import org.springframework.context.ApplicationContext;
    @@ -94,7 +96,9 @@ import org.springframework.ws.transport.WebServiceMessageReceiver;
      *	   mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(expectedResponsePayload));
      *	 }
      * }
    - * 
    + *
    + * + *
    * * @author Arjen Poutsma * @author Lukas Krecan @@ -120,28 +124,27 @@ public class MockWebServiceClient { // Factory methods /** - * Creates a {@code MockWebServiceClient} instance based on the given {@link WebServiceMessageReceiver} and {@link - * WebServiceMessageFactory}. + * 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 + * @param messageFactory the message factory * @return the created client */ public static MockWebServiceClient createClient(WebServiceMessageReceiver messageReceiver, - WebServiceMessageFactory messageFactory) { + WebServiceMessageFactory messageFactory) { return new MockWebServiceClient(messageReceiver, messageFactory); } /** - * 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: + * 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 @@ -152,10 +155,10 @@ public class MockWebServiceClient { MockStrategiesHelper strategiesHelper = new MockStrategiesHelper(applicationContext); - WebServiceMessageReceiver messageReceiver = - strategiesHelper.getStrategy(WebServiceMessageReceiver.class, SoapMessageDispatcher.class); - WebServiceMessageFactory messageFactory = - strategiesHelper.getStrategy(WebServiceMessageFactory.class, SaajSoapMessageFactory.class); + WebServiceMessageReceiver messageReceiver = strategiesHelper.getStrategy(WebServiceMessageReceiver.class, + SoapMessageDispatcher.class); + WebServiceMessageFactory messageFactory = strategiesHelper.getStrategy(WebServiceMessageFactory.class, + SaajSoapMessageFactory.class); return new MockWebServiceClient(messageReceiver, messageFactory); } @@ -178,8 +181,7 @@ 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; @@ -208,8 +210,7 @@ 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; @@ -217,5 +218,4 @@ public class MockWebServiceClient { } } - } 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 b4c9d28b..d047acc8 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 @@ -38,5 +38,4 @@ public interface RequestCreator { */ WebServiceMessage createRequest(WebServiceMessageFactory messageFactory) throws IOException; - } 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 0e8e0808..8a83df44 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 @@ -17,6 +17,7 @@ package org.springframework.ws.test.server; import java.io.IOException; + import javax.xml.transform.Source; import org.springframework.core.io.Resource; @@ -29,16 +30,15 @@ import org.springframework.ws.test.support.creator.WebServiceMessageCreator; import org.springframework.xml.transform.ResourceSource; /** - * Factory methods for {@link RequestCreator} classes. Typically used to provide input for {@link - * MockWebServiceClient#sendRequest(RequestCreator)}. + * Factory methods for {@link RequestCreator} classes. Typically used to provide input for + * {@link MockWebServiceClient#sendRequest(RequestCreator)}. * * @author Arjen Poutsma * @since 2.0 */ public abstract class RequestCreators { - private RequestCreators() { - } + private RequestCreators() {} // Payload @@ -65,7 +65,7 @@ public abstract class RequestCreators { } // SOAP - + /** * Create a request with the given {@link Source} XML as SOAP envelope. * @@ -107,5 +107,4 @@ public abstract class RequestCreators { } } - } 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 8a2048dd..55dcbb59 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 @@ -35,7 +35,7 @@ public interface ResponseMatcher { * * @param request the request message * @param response the response message to make assertions on - * @throws IOException in case of I/O errors + * @throws IOException in case of I/O errors * @throws AssertionError if expectations are not met */ void match(WebServiceMessage request, WebServiceMessage response) throws IOException, AssertionError; 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 10926645..a49fd3bb 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 @@ -16,9 +16,12 @@ package org.springframework.ws.test.server; +import static org.springframework.ws.test.support.AssertionErrors.*; + import java.io.IOException; import java.util.Locale; import java.util.Map; + import javax.xml.namespace.QName; import javax.xml.transform.Source; @@ -33,20 +36,17 @@ import org.springframework.ws.test.support.matcher.SoapEnvelopeDiffMatcher; import org.springframework.ws.test.support.matcher.SoapHeaderMatcher; 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 /** @@ -72,7 +72,7 @@ public abstract class ResponseMatchers { /** * Expects the payload to validate against the given XSD schema(s). * - * @param schema the schema + * @param schema the schema * @param furtherSchemas further schemas, if necessary * @return the response matcher */ @@ -93,7 +93,7 @@ public abstract class ResponseMatchers { /** * Expects the given XPath expression to (not) exist or be evaluated to a value. * - * @param xpathExpression the XPath expression + * @param xpathExpression the XPath expression * @param namespaceMapping the namespaces * @return the XPath expectations, to be further configured */ @@ -143,8 +143,7 @@ public abstract class ResponseMatchers { */ 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()) { @@ -169,7 +168,7 @@ 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 + * reason text will not be verified * @see org.springframework.ws.soap.SoapBody#addMustUnderstandFault(String, Locale) */ public static ResponseMatcher mustUnderstandFault(String faultStringOrReason) { @@ -194,7 +193,7 @@ 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 + * reason text will not be verified * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale) */ public static ResponseMatcher clientOrSenderFault(String faultStringOrReason) { @@ -219,7 +218,7 @@ public abstract class ResponseMatchers { * 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 + * reason text will not be verified * @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale) */ public static ResponseMatcher serverOrReceiverFault(String faultStringOrReason) { @@ -244,7 +243,7 @@ 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 + * 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 b3119c10..9d084d80 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 @@ -18,10 +18,11 @@ package org.springframework.ws.test.server; /** * Allows for setting up expectations on XPath expressions. - * - *

    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. + *

    + * 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. * * @author Lukas Krecan * @author Arjen Poutsma 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 eecb5af9..ecf8169b 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 @@ -16,11 +16,11 @@ package org.springframework.ws.test.server; -import java.io.IOException; -import javax.xml.namespace.QName; +import static org.springframework.ws.test.support.AssertionErrors.*; -import static org.springframework.ws.test.support.AssertionErrors.assertEquals; -import static org.springframework.ws.test.support.AssertionErrors.assertTrue; +import java.io.IOException; + +import javax.xml.namespace.QName; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapBody; @@ -53,8 +53,7 @@ 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/support/AssertionErrors.java b/spring-ws-test/src/main/java/org/springframework/ws/test/support/AssertionErrors.java index 9bdfe966..c4ffe685 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 @@ -27,8 +27,7 @@ import javax.xml.transform.Source; */ public abstract class AssertionErrors { - private AssertionErrors() { - } + private AssertionErrors() {} /** * Fails a test with the given message. @@ -43,13 +42,12 @@ public abstract class AssertionErrors { * Fails a test with the given message and source. * * @param message the message - * @param source the source + * @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); } } @@ -57,7 +55,7 @@ public abstract class AssertionErrors { /** * Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message. * - * @param message the message + * @param message the message * @param condition the condition to test for */ public static void assertTrue(String message, boolean condition) { @@ -68,7 +66,7 @@ public abstract class AssertionErrors { * Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message and * source. * - * @param message the message + * @param message the message * @param condition the condition to test for */ public static void assertTrue(String message, boolean condition, String sourceLabel, Source source) { @@ -80,9 +78,9 @@ public abstract class AssertionErrors { /** * Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message. * - * @param message the message + * @param message the message * @param expected the expected value - * @param actual the actual value + * @param actual the actual value */ public static void assertEquals(String message, Object expected, Object actual) { assertEquals(message, expected, actual, null, null); @@ -91,10 +89,10 @@ public abstract class AssertionErrors { /** * Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message. * - * @param message the message + * @param message the message * @param expected the expected value - * @param actual the actual value - * @param source the source + * @param actual the actual value + * @param source the source */ public static void assertEquals(String message, Object expected, Object actual, String sourceLabel, Source source) { if (expected == null && actual == null) { 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 d89834af..cbc7d285 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 @@ -18,6 +18,8 @@ package org.springframework.ws.test.support; 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; @@ -27,9 +29,6 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * Helper class for for loading default implementations of an interface. * @@ -71,15 +70,13 @@ 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"); } @@ -99,11 +96,10 @@ 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) { @@ -114,8 +110,7 @@ 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); } } @@ -123,5 +118,4 @@ public class MockStrategiesHelper { } } - } 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 d75810f8..cc3cf7f1 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 @@ -30,7 +30,7 @@ import org.springframework.xml.transform.TransformerHelper; * * @author Lukas Krecan * @author Arjen Poutsma - * @since 2.0.1 + * @since 2.0.1 */ @SuppressWarnings("serial") public class SourceAssertionError extends AssertionError { @@ -52,6 +52,7 @@ public class SourceAssertionError extends AssertionError { /** * Returns the source context of this error. + * * @return the source */ public Source getSource() { @@ -81,8 +82,7 @@ public class SourceAssertionError extends AssertionError { Transformer transformer = createNonIndentingTransformer(); transformer.transform(source, result); return result.toString(); - } - catch (TransformerException ex) { + } catch (TransformerException ex) { // Ignore } } @@ -96,5 +96,4 @@ public class SourceAssertionError extends AssertionError { return transformer; } - } 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 bad6bf5f..923ff7a2 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 @@ -23,9 +23,9 @@ import org.springframework.ws.WebServiceMessageFactory; /** * Abstract base class for the {@link WebServiceMessageCreator} interface. - * - *

    Creates a message using the given {@link WebServiceMessageFactory}, and passes it on to {@link - * #doWithMessage(WebServiceMessage)}. + *

    + * Creates a message using the given {@link WebServiceMessageFactory}, and passes it on to + * {@link #doWithMessage(WebServiceMessage)}. * * @author Arjen Poutsma * @since 2.0 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 f37306de..4b353c40 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 @@ -16,7 +16,10 @@ 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; @@ -24,8 +27,6 @@ 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}. * @@ -52,8 +53,7 @@ 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 d237175f..81c509d3 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 @@ -16,7 +16,10 @@ 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; @@ -25,12 +28,8 @@ 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}. * @@ -38,11 +37,11 @@ import static org.springframework.ws.test.support.AssertionErrors.fail; * @since 2.1.1 */ public class SoapEnvelopeMessageCreator extends AbstractMessageCreator { - + private final Source soapEnvelope; private final TransformerHelper transformerHelper = new TransformerHelper(); - + /** * Creates a new instance of the {@code SoapEnvelopeMessageCreator} with the given SOAP envelope source. * @@ -61,10 +60,9 @@ 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 5a493d7b..eaf7ff80 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 @@ -37,5 +37,4 @@ public interface WebServiceMessageCreator { */ WebServiceMessage createMessage(WebServiceMessageFactory messageFactory) throws IOException; - } 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 7e00dd65..7aaeab34 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,7 @@ */ /** - * Provides the generic {@link org.springframework.ws.test.support.creator.WebServiceMessageCreator WebServiceMessageCreator} - * interface, and implementations. + * 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 d31d8b90..f24cfa81 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 @@ -16,18 +16,18 @@ package org.springframework.ws.test.support.matcher; -import java.io.IOException; +import static org.springframework.ws.test.support.AssertionErrors.*; -import static org.springframework.ws.test.support.AssertionErrors.assertTrue; +import java.io.IOException; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapMessage; /** * 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 @@ -45,7 +45,7 @@ public abstract class AbstractSoapMessageMatcher implements WebServiceMessageMat * {@link SoapMessage}. * * @param soapMessage the soap message - * @throws IOException in case of I/O errors + * @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 937f1e65..540caec9 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 @@ -16,12 +16,12 @@ package org.springframework.ws.test.support.matcher; +import static org.springframework.ws.test.support.AssertionErrors.*; + import java.io.IOException; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; -import static org.springframework.ws.test.support.AssertionErrors.assertTrue; - import org.springframework.ws.WebServiceMessage; /** 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 2021f21c..347e0695 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 @@ -16,19 +16,18 @@ package org.springframework.ws.test.support.matcher; +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.custommonkey.xmlunit.Diff; import org.springframework.util.Assert; import org.springframework.ws.WebServiceMessage; import org.springframework.xml.transform.TransformerHelper; - -import org.custommonkey.xmlunit.Diff; import org.w3c.dom.Document; -import static org.springframework.ws.test.support.AssertionErrors.fail; - /** * Matches {@link Source} payloads. * @@ -67,10 +66,9 @@ 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; } } -} \ No newline at end of file +} 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 17815f89..a2e29916 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 @@ -16,18 +16,18 @@ package org.springframework.ws.test.support.matcher; +import static org.springframework.ws.test.support.AssertionErrors.*; + import java.io.IOException; import java.util.Arrays; -import static org.springframework.ws.test.support.AssertionErrors.fail; -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; /** * Uses the {@link XmlValidator} to validate request payload. @@ -43,7 +43,7 @@ public class SchemaValidatingMatcher implements WebServiceMessageMatcher { /** * Creates a {@code SchemaValidatingMatcher} based on the given schema resource(s). * - * @param schema the schema + * @param schema the schema * @param furtherSchemas further schemas, if necessary * @throws IOException in case of I/O errors */ 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 78338955..f9f04b4c 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 @@ -16,22 +16,21 @@ package org.springframework.ws.test.support.matcher; +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.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.XMLUnit; import org.springframework.util.Assert; import org.springframework.ws.soap.SoapMessage; import org.springframework.xml.transform.TransformerHelper; - -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.XMLUnit; 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. * @@ -39,7 +38,7 @@ import static org.springframework.ws.test.support.AssertionErrors.fail; * @since 2.1.1 */ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher { - + private final Source expected; private final TransformerHelper transformerHelper = new TransformerHelper(); @@ -52,7 +51,7 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher { Assert.notNull(expected, "'expected' must not be null"); this.expected = expected; } - + @Override protected void match(SoapMessage soapMessage) throws IOException, AssertionError { Document actualDocument = soapMessage.getDocument(); @@ -66,8 +65,7 @@ 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 2183b670..d1df188b 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 @@ -16,8 +16,11 @@ package org.springframework.ws.test.support.matcher; +import static org.springframework.ws.test.support.AssertionErrors.*; + import java.io.IOException; import java.util.Iterator; + import javax.xml.namespace.QName; import org.springframework.util.Assert; @@ -25,8 +28,6 @@ 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. * @@ -38,8 +39,7 @@ 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 */ 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 7f251a12..6945c189 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 @@ -29,11 +29,10 @@ 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 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 97a46f69..1e6e24fa 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 @@ -16,8 +16,11 @@ 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; @@ -26,12 +29,8 @@ 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. * @@ -55,6 +54,7 @@ public class XPathExpectationsHelper { public XPathExpectationsHelper(String expression) { this(expression, null); } + /** * Creates a new instance of the {@code XPathExpectationsSupport} with the given XPath expression and namespaces. * @@ -96,8 +96,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 +112,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 +125,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,12 +136,10 @@ 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 fea27d57..f2d218d4 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,7 @@ */ /** - * Provides the generic {@link org.springframework.ws.test.support.matcher.WebServiceMessageMatcher WebServiceMessageMatcher} - * interface, and implementations. + * 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/test/java/org/springframework/ws/test/client/ErrorResponseCreatorTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/ErrorResponseCreatorTest.java index 1c86aeb9..9aa0ce8a 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 @@ -16,12 +16,12 @@ package org.springframework.ws.test.client; +import static org.junit.Assert.*; + import java.io.IOException; import org.junit.Test; -import static org.junit.Assert.assertEquals; - public class ErrorResponseCreatorTest { @Test 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 d4ec4efb..a068ca6d 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 @@ -35,4 +35,4 @@ public class ExceptionResponseCreatorTest { callback.createResponse(null, null, null); } -} \ No newline at end of file +} 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 833ddb5c..61315c60 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 @@ -16,15 +16,13 @@ package org.springframework.ws.test.client; +import static org.junit.Assert.*; +import static org.springframework.ws.test.client.ResponseCreators.*; + import java.io.IOException; -import org.springframework.xml.transform.StringSource; - import org.junit.Test; - -import static org.junit.Assert.*; -import static org.springframework.ws.test.client.ResponseCreators.withError; -import static org.springframework.ws.test.client.ResponseCreators.withPayload; +import org.springframework.xml.transform.StringSource; public class MockSenderConnectionTest { 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 ee78d578..23496279 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 @@ -16,16 +16,25 @@ package org.springframework.ws.test.client; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.assertNotNull; +import static org.springframework.ws.test.client.RequestMatchers.*; +import static org.springframework.ws.test.client.ResponseCreators.*; + import java.io.IOException; import java.net.URI; import java.util.Collections; import java.util.Locale; import java.util.Map; + import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; +import org.junit.Before; +import org.junit.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; @@ -40,16 +49,6 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; -import org.junit.Before; -import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.easymock.EasyMock.*; -import static org.junit.Assert.assertNotNull; -import static org.springframework.ws.test.client.RequestMatchers.*; -import static org.springframework.ws.test.client.ResponseCreators.withClientOrSenderFault; -import static org.springframework.ws.test.client.ResponseCreators.withPayload; - public class MockWebServiceServerTest { private WebServiceTemplate template; @@ -214,7 +213,8 @@ public class MockWebServiceServerTest { @Test public void xsdMatch() throws Exception { Resource schema = new ByteArrayResource( - "".getBytes()); + "" + .getBytes()); server.expect(validPayload(schema)); @@ -226,7 +226,8 @@ public class MockWebServiceServerTest { @Test(expected = AssertionError.class) public void xsdNonMatch() throws Exception { Resource schema = new ByteArrayResource( - "".getBytes()); + "" + .getBytes()); server.expect(validPayload(schema)); @@ -304,7 +305,7 @@ public class MockWebServiceServerTest { StringResult result = new StringResult(); template.sendSourceAndReceiveToResult(request, result); } - + public static class MyClient extends WebServiceGatewaySupport { } 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 b6591ff5..afa4e057 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 @@ -16,13 +16,21 @@ package org.springframework.ws.test.client; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.util.Locale; + import javax.xml.namespace.QName; import javax.xml.transform.Result; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; +import org.junit.Before; +import org.junit.Test; import org.springframework.core.io.ByteArrayResource; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapMessage; @@ -33,12 +41,6 @@ import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerHelper; -import org.junit.Before; -import org.junit.Test; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.*; - public class ResponseCreatorsTest { private final TransformerHelper transformerHelper = new TransformerHelper(); @@ -65,14 +67,13 @@ public class ResponseCreatorsTest { @Test public void withPayloadResource() throws Exception { String payload = ""; - ResponseCreator responseCreator = - ResponseCreators.withPayload(new ByteArrayResource(payload.getBytes("UTF-8"))); + ResponseCreator responseCreator = ResponseCreators.withPayload(new ByteArrayResource(payload.getBytes("UTF-8"))); WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory); assertXMLEqual(payload, getPayloadAsString(response)); } - + @Test public void withSoapEnvelopeSource() throws Exception { StringBuilder xmlBuilder = new StringBuilder(); @@ -84,9 +85,9 @@ public class ResponseCreatorsTest { String envelope = xmlBuilder.toString(); ResponseCreator responseCreator = ResponseCreators.withSoapEnvelope(new StringSource(envelope)); WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory); - assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage)response)); + assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage) response)); } - + @Test public void withSoapEnvelopeResource() throws Exception { StringBuilder xmlBuilder = new StringBuilder(); @@ -96,9 +97,10 @@ public class ResponseCreatorsTest { xmlBuilder.append(""); xmlBuilder.append(""); String envelope = xmlBuilder.toString(); - ResponseCreator responseCreator = ResponseCreators.withSoapEnvelope(new ByteArrayResource(envelope.getBytes("UTF-8"))); + ResponseCreator responseCreator = ResponseCreators + .withSoapEnvelope(new ByteArrayResource(envelope.getBytes("UTF-8"))); WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory); - assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage)response)); + assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage) response)); } @Test @@ -108,12 +110,11 @@ public class ResponseCreatorsTest { try { responseCreator.createResponse(null, null, null); - } - catch (IOException actual) { + } catch (IOException actual) { assertSame(expected, actual); } } - + @Test public void withRuntimeException() throws Exception { RuntimeException expected = new RuntimeException("Foo"); @@ -121,8 +122,7 @@ public class ResponseCreatorsTest { try { responseCreator.createResponse(null, null, null); - } - catch (RuntimeException actual) { + } catch (RuntimeException actual) { assertSame(expected, actual); } } @@ -158,7 +158,7 @@ public class ResponseCreatorsTest { testFault(responseCreator, faultString, SoapVersion.SOAP_11.getVersionMismatchFaultName()); } - + private void testFault(ResponseCreator responseCreator, String faultString, QName faultCode) throws IOException { SoapMessage response = (SoapMessage) responseCreator.createResponse(null, null, messageFactory); @@ -174,7 +174,7 @@ public class ResponseCreatorsTest { transformerHelper.transform(message.getPayloadSource(), result); return result.toString(); } - + private String getSoapEnvelopeAsString(SoapMessage message) throws TransformerException { DOMSource source = new DOMSource(message.getDocument()); Result result = new StringResult(); 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 a414a3da..3e247675 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 @@ -16,13 +16,12 @@ package org.springframework.ws.test.client; +import static org.easymock.EasyMock.*; + import java.net.URI; -import org.springframework.ws.WebServiceMessage; - import org.junit.Test; - -import static org.easymock.EasyMock.*; +import org.springframework.ws.WebServiceMessage; public class UriMatcherTest { 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 d4cb4401..870f3a2b 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 @@ -16,15 +16,14 @@ package org.springframework.ws.test.client; -import java.io.IOException; +import static org.easymock.EasyMock.*; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher; +import java.io.IOException; import org.junit.Before; import org.junit.Test; - -import static org.easymock.EasyMock.*; +import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher; /** * @author Arjen Poutsma @@ -43,7 +42,7 @@ public class WebServiceMessageMatcherAdapterTest { adaptee = createMock(WebServiceMessageMatcher.class); adapter = new WebServiceMessageMatcherAdapter(adaptee); } - + @Test public void match() throws IOException { adaptee.match(message); 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 0c475226..6bdd9c9a 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 @@ -16,22 +16,21 @@ package org.springframework.ws.test.client.integration; +import static org.junit.Assert.*; +import static org.springframework.ws.test.client.RequestMatchers.*; +import static org.springframework.ws.test.client.ResponseCreators.*; + import javax.xml.transform.Source; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.ws.test.client.MockWebServiceServer; import org.springframework.xml.transform.StringSource; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; -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. @@ -42,8 +41,7 @@ import static org.springframework.ws.test.client.ResponseCreators.withPayload; @ContextConfiguration("integration-test.xml") public class ClientIntegrationTest { - @Autowired - private CustomerClient client; + @Autowired private CustomerClient client; private MockWebServiceServer mockServer; @@ -55,11 +53,10 @@ public class ClientIntegrationTest { @Test public void basic() throws Exception { Source expectedRequestPayload = new StringSource( - "" + - "John Doe" + ""); - Source responsePayload = new StringSource( - "" + - "10" + ""); + "" + "John Doe" + + ""); + Source responsePayload = new StringSource("" + + "10" + ""); mockServer.expect(payload(expectedRequestPayload)).andRespond(withPayload(responsePayload)); diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/client/integration/CustomerClient.java b/spring-ws-test/src/test/java/org/springframework/ws/test/client/integration/CustomerClient.java index d8a103f0..c2d6019e 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/client/integration/CustomerClient.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/client/integration/CustomerClient.java @@ -20,7 +20,6 @@ import org.springframework.ws.client.core.support.WebServiceGatewaySupport; import org.springframework.ws.test.integration.CustomerCountRequest; import org.springframework.ws.test.integration.CustomerCountResponse; - public class CustomerClient extends WebServiceGatewaySupport { public int getCustomerCount() { 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 f667ef09..b6b2b308 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 @@ -32,4 +32,4 @@ public class CustomerCountRequest { public void setCustomerName(String name) { this.customerName = name; } -} \ No newline at end of file +} 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 44bb318e..61435a83 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 @@ -32,4 +32,4 @@ public class CustomerCountResponse { public void setCustomerCount(int customerCount) { this.customerCount = customerCount; } -} \ No newline at end of file +} 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 93e342b6..072d5c35 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 @@ -16,14 +16,13 @@ package org.springframework.ws.test.server; +import static org.junit.Assert.*; + +import org.junit.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.soap.server.SoapMessageDispatcher; -import org.junit.Test; - -import static org.junit.Assert.assertNotNull; - public class MockWebServiceClientTest { @Test @@ -36,7 +35,7 @@ public class MockWebServiceClientTest { MockWebServiceClient client = MockWebServiceClient.createClient(applicationContext); assertNotNull(client); } - + @Test public void createServerApplicationContextDefaults() throws Exception { StaticApplicationContext applicationContext = new StaticApplicationContext(); 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 2a1ec5b1..b067421f 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 @@ -16,15 +16,14 @@ package org.springframework.ws.test.server; -import java.io.IOException; +import static org.easymock.EasyMock.*; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher; +import java.io.IOException; import org.junit.Before; import org.junit.Test; - -import static org.easymock.EasyMock.*; +import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher; /** * @author Arjen Poutsma @@ -43,7 +42,7 @@ public class WebServiceMessageMatcherAdapterTest { adaptee = createMock(WebServiceMessageMatcher.class); adapter = new WebServiceMessageMatcherAdapter(adaptee); } - + @Test public void match() throws IOException { adaptee.match(message); 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 3ba35537..2eb78788 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 @@ -16,8 +16,14 @@ 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.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; @@ -25,13 +31,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.ws.test.server.MockWebServiceClient; import org.springframework.xml.transform.StringSource; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.springframework.ws.test.server.RequestCreators.withPayload; -import static org.springframework.ws.test.server.ResponseMatchers.payload; - /** * @author Arjen Poutsma */ @@ -39,8 +38,7 @@ import static org.springframework.ws.test.server.ResponseMatchers.payload; @ContextConfiguration("integration-test.xml") public class ServerIntegrationTest { - @Autowired - private ApplicationContext applicationContext; + @Autowired private ApplicationContext applicationContext; private MockWebServiceClient mockClient; @@ -51,14 +49,13 @@ public class ServerIntegrationTest { @Test public void basic() throws Exception { - Source requestPayload = new StringSource("" + - "John Doe" + ""); + 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/MockStrategiesHelperTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/support/MockStrategiesHelperTest.java index 8f084f96..8aa78932 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/support/MockStrategiesHelperTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/support/MockStrategiesHelperTest.java @@ -16,13 +16,11 @@ package org.springframework.ws.test.support; -import org.springframework.beans.factory.BeanInitializationException; -import org.springframework.context.support.StaticApplicationContext; +import static org.junit.Assert.*; import org.junit.Test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import org.springframework.beans.factory.BeanInitializationException; +import org.springframework.context.support.StaticApplicationContext; public class MockStrategiesHelperTest { @@ -52,17 +50,15 @@ public class MockStrategiesHelperTest { MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext); helper.getStrategy(IMyBean.class); } - + @Test public void noneWithDefault() { StaticApplicationContext applicationContext = new StaticApplicationContext(); - MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext); assertNotNull(helper.getStrategy(IMyBean.class, MyBean.class)); } - public interface IMyBean { } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/PayloadDiffMatcherTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/PayloadDiffMatcherTest.java index a781e9b5..51b6b804 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/PayloadDiffMatcherTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/PayloadDiffMatcherTest.java @@ -16,17 +16,16 @@ package org.springframework.ws.test.support.matcher; +import static org.easymock.EasyMock.*; + import javax.xml.soap.MessageFactory; +import org.junit.Test; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessage; import org.springframework.xml.transform.StringSource; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class PayloadDiffMatcherTest { @Test 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 c5f51d96..9d9dbf35 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 @@ -16,18 +16,17 @@ package org.springframework.ws.test.support.matcher; +import static org.easymock.EasyMock.*; + import java.io.IOException; +import org.junit.Before; +import org.junit.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 org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.*; - public class SchemaValidatingMatcherTest { private Resource schema; @@ -48,8 +47,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); @@ -62,8 +61,9 @@ public class SchemaValidatingMatcherTest { @Test(expected = AssertionError.class) public void singleSchemaNonMatch() throws IOException, AssertionError { - expect(message.getPayloadSource()).andReturn(new StringSource( - "atext")).times(2); + expect(message.getPayloadSource()).andReturn( + new StringSource("atext")) + .times(2); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema); @@ -76,8 +76,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); @@ -90,8 +90,9 @@ public class SchemaValidatingMatcherTest { @Test(expected = AssertionError.class) public void multipleSchemaNotOk() throws IOException, AssertionError { - expect(message.getPayloadSource()).andReturn(new StringSource( - "atext")).times(2); + expect(message.getPayloadSource()).andReturn( + new StringSource("atext")) + .times(2); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema1, schema2); @@ -104,8 +105,9 @@ public class SchemaValidatingMatcherTest { @Test(expected = AssertionError.class) public void multipleSchemaDifferentOrderNotOk() throws IOException, AssertionError { - expect(message.getPayloadSource()).andReturn(new StringSource( - "atext")).times(2); + expect(message.getPayloadSource()).andReturn( + new StringSource("atext")) + .times(2); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema1, schema2); @@ -118,8 +120,9 @@ public class SchemaValidatingMatcherTest { @Test(expected = AssertionError.class) public void xmlValidatorNotOk() throws IOException, AssertionError { - expect(message.getPayloadSource()).andReturn(new StringSource( - "atext")).times(2); + expect(message.getPayloadSource()).andReturn( + new StringSource("atext")) + .times(2); SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema); 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 e06b2634..1afeb99a 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 @@ -16,19 +16,18 @@ package org.springframework.ws.test.support.matcher; +import static org.easymock.EasyMock.*; + import javax.xml.transform.dom.DOMResult; +import org.junit.Test; import org.springframework.ws.soap.SoapMessage; import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.TransformerHelper; - -import org.junit.Test; import org.w3c.dom.Document; -import static org.easymock.EasyMock.*; - public class SoapEnvelopeDiffMatcherTest { - + @Test public void match() throws Exception { StringBuilder xmlBuilder = new StringBuilder(); @@ -42,7 +41,7 @@ public class SoapEnvelopeDiffMatcherTest { TransformerHelper transformerHelper = new TransformerHelper(); transformerHelper.transform(new StringSource(xml), result); SoapMessage message = createMock(SoapMessage.class); - expect(message.getDocument()).andReturn((Document)result.getNode()).once(); + expect(message.getDocument()).andReturn((Document) result.getNode()).once(); replay(message); SoapEnvelopeDiffMatcher matcher = new SoapEnvelopeDiffMatcher(new StringSource(xml)); @@ -50,7 +49,7 @@ public class SoapEnvelopeDiffMatcherTest { verify(message); } - + @Test(expected = AssertionError.class) public void nonMatch() throws Exception { StringBuilder xmlBuilder = new StringBuilder(); @@ -65,12 +64,12 @@ public class SoapEnvelopeDiffMatcherTest { TransformerHelper transformerHelper = new TransformerHelper(); transformerHelper.transform(new StringSource(actual), result); SoapMessage message = createMock(SoapMessage.class); - expect(message.getDocument()).andReturn((Document)result.getNode()).once(); + expect(message.getDocument()).andReturn((Document) result.getNode()).once(); replay(message); String expected = String.format(xml, "2"); SoapEnvelopeDiffMatcher matcher = new SoapEnvelopeDiffMatcher(new StringSource(expected)); matcher.match(message); } - + } diff --git a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SoapHeaderMatcherTest.java b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SoapHeaderMatcherTest.java index 692df069..f4994b95 100644 --- a/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SoapHeaderMatcherTest.java +++ b/spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/SoapHeaderMatcherTest.java @@ -16,19 +16,18 @@ package org.springframework.ws.test.support.matcher; +import static org.easymock.EasyMock.*; + import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPMessage; +import org.junit.Before; +import org.junit.Test; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.saaj.SaajSoapMessage; -import org.junit.Before; -import org.junit.Test; - -import static org.easymock.EasyMock.createMock; - public class SoapHeaderMatcherTest { private SoapHeaderMatcher matcher; @@ -67,4 +66,4 @@ public class SoapHeaderMatcherTest { matcher.match(message); } -} \ No newline at end of file +} 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 6d009e0a..9fa08530 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 @@ -16,18 +16,17 @@ package org.springframework.ws.test.support.matcher; +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + import java.io.IOException; import java.util.Collections; import java.util.Map; +import org.junit.Test; import org.springframework.ws.WebServiceMessage; import org.springframework.xml.transform.StringSource; -import org.junit.Test; - -import static org.easymock.EasyMock.*; -import static org.junit.Assert.assertNotNull; - public class XPathExpectationsHelperTest { @Test @@ -188,8 +187,7 @@ public class XPathExpectationsHelperTest { assertNotNull(matcher); WebServiceMessage message = createMock(WebServiceMessage.class); - expect(message.getPayloadSource()) - .andReturn(new StringSource("")); + expect(message.getPayloadSource()).andReturn(new StringSource("")); replay(message); @@ -206,8 +204,8 @@ public class XPathExpectationsHelperTest { assertNotNull(matcher); WebServiceMessage message = createMock(WebServiceMessage.class); - expect(message.getPayloadSource()) - .andReturn(new StringSource("")).times(2); + expect(message.getPayloadSource()).andReturn(new StringSource("")) + .times(2); replay(message); diff --git a/spring-ws-test/src/test/resources/log4j.properties b/spring-ws-test/src/test/resources/log4j.properties index 92e896c8..7e8683dd 100644 --- a/spring-ws-test/src/test/resources/log4j.properties +++ b/spring-ws-test/src/test/resources/log4j.properties @@ -1,6 +1,5 @@ log4j.rootCategory=INFO, stdout log4j.logger.org.springframework.ws=DEBUG - log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n \ No newline at end of file diff --git a/spring-ws-test/src/test/resources/org/springframework/ws/test/client/integration/integration-test.xml b/spring-ws-test/src/test/resources/org/springframework/ws/test/client/integration/integration-test.xml index a24a8d9b..3ecdae97 100644 --- a/spring-ws-test/src/test/resources/org/springframework/ws/test/client/integration/integration-test.xml +++ b/spring-ws-test/src/test/resources/org/springframework/ws/test/client/integration/integration-test.xml @@ -3,23 +3,23 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - - + + + - - - - - - - - - - org.springframework.ws.test.integration.CustomerCountRequest - org.springframework.ws.test.integration.CustomerCountResponse - - - + + + + + + + + + + org.springframework.ws.test.integration.CustomerCountRequest + org.springframework.ws.test.integration.CustomerCountResponse + + + \ No newline at end of file diff --git a/spring-ws-test/src/test/resources/org/springframework/ws/test/client/schemaValidatingRequestMatcherTest.xsd b/spring-ws-test/src/test/resources/org/springframework/ws/test/client/schemaValidatingRequestMatcherTest.xsd index a0bc71eb..33b97abd 100644 --- a/spring-ws-test/src/test/resources/org/springframework/ws/test/client/schemaValidatingRequestMatcherTest.xsd +++ b/spring-ws-test/src/test/resources/org/springframework/ws/test/client/schemaValidatingRequestMatcherTest.xsd @@ -1,12 +1,13 @@ - + - - - - - - - - + + + + + + + + diff --git a/spring-ws-test/src/test/resources/org/springframework/ws/test/server/integration/integration-test.xml b/spring-ws-test/src/test/resources/org/springframework/ws/test/server/integration/integration-test.xml index 5a29e832..ac47a7af 100644 --- a/spring-ws-test/src/test/resources/org/springframework/ws/test/server/integration/integration-test.xml +++ b/spring-ws-test/src/test/resources/org/springframework/ws/test/server/integration/integration-test.xml @@ -3,17 +3,17 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + - - - - org.springframework.ws.test.integration.CustomerCountRequest - org.springframework.ws.test.integration.CustomerCountResponse - - - + + + + org.springframework.ws.test.integration.CustomerCountRequest + org.springframework.ws.test.integration.CustomerCountResponse + + + \ No newline at end of file diff --git a/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest-1.xsd b/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest-1.xsd index 2c83de72..33b97abd 100644 --- a/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest-1.xsd +++ b/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest-1.xsd @@ -1,12 +1,13 @@ - + - + - - - - - - + + + + + + diff --git a/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest-2.xsd b/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest-2.xsd index 408e9057..2b3fa0b6 100644 --- a/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest-2.xsd +++ b/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest-2.xsd @@ -1,5 +1,6 @@ - + diff --git a/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest.xsd b/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest.xsd index a0bc71eb..33b97abd 100644 --- a/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest.xsd +++ b/spring-ws-test/src/test/resources/org/springframework/ws/test/support/matcher/schemaValidatingMatcherTest.xsd @@ -1,12 +1,13 @@ - + - - - - - - - - + + + + + + + + diff --git a/spring-ws-test/src/test/resources/org/springframework/ws/test/support/schemaValidatingMatcherTest.xsd b/spring-ws-test/src/test/resources/org/springframework/ws/test/support/schemaValidatingMatcherTest.xsd index a0bc71eb..33b97abd 100644 --- a/spring-ws-test/src/test/resources/org/springframework/ws/test/support/schemaValidatingMatcherTest.xsd +++ b/spring-ws-test/src/test/resources/org/springframework/ws/test/support/schemaValidatingMatcherTest.xsd @@ -1,12 +1,13 @@ - + - - - - - - - - + + + + + + + + diff --git a/spring-xml/pom.xml b/spring-xml/pom.xml index b24ee6a6..b71d3b40 100644 --- a/spring-xml/pom.xml +++ b/spring-xml/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -40,5 +40,5 @@ - + \ No newline at end of file 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 49953ff3..9515988f 100644 --- a/spring-xml/src/main/java/org/springframework/xml/DocumentBuilderFactoryUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/DocumentBuilderFactoryUtils.java @@ -42,7 +42,8 @@ public class DocumentBuilderFactoryUtils { factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); } 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()); } } @@ -50,7 +51,8 @@ public class DocumentBuilderFactoryUtils { factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); } catch (IllegalArgumentException e) { if (log.isWarnEnabled()) { - log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + factory.getClass().getCanonicalName()); + log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + + factory.getClass().getCanonicalName()); } } @@ -58,7 +60,8 @@ public class DocumentBuilderFactoryUtils { factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); } 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()); + log.warn("FEATURE 'http://apache.org/xml/features/disallow-doctype-decl' is probably not supported by " + + factory.getClass().getCanonicalName()); } } @@ -66,7 +69,8 @@ public class DocumentBuilderFactoryUtils { factory.setFeature("http://xml.org/sax/features/external-general-entities", false); } 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()); + log.warn("FEATURE 'http://xml.org/sax/features/external-general-entities' is probably not supported by " + + factory.getClass().getCanonicalName()); } } @@ -74,7 +78,8 @@ public class DocumentBuilderFactoryUtils { factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); } 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()); } } @@ -82,7 +87,9 @@ public class DocumentBuilderFactoryUtils { factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); } catch (ParserConfigurationException e) { if (log.isWarnEnabled()) { - log.warn("FEATURE 'http://apache.org/xml/features/nonvalidating/load-external-dtd' is probably not supported by " + factory.getClass().getCanonicalName()); + log.warn( + "FEATURE 'http://apache.org/xml/features/nonvalidating/load-external-dtd' is probably not supported by " + + factory.getClass().getCanonicalName()); } } 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 a04d8103..6599d6e2 100644 --- a/spring-xml/src/main/java/org/springframework/xml/JaxpVersion.java +++ b/spring-xml/src/main/java/org/springframework/xml/JaxpVersion.java @@ -21,8 +21,8 @@ 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. - * - *

    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 + *

    + * 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 @@ -57,7 +57,7 @@ public abstract class JaxpVersion { public static final int JAXP_15 = 5; private static final String JAXP_14_CLASS_NAME = "javax.xml.transform.stax.StAXSource"; - + private static final String JAXP_15_CLASS_NAME = "javax.xml.validation.SchemaFactoryConfigurationError"; private static int jaxpVersion; @@ -104,4 +104,4 @@ public abstract class JaxpVersion { return getJaxpVersion() >= JAXP_14; } -} \ No newline at end of file +} 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 73060477..86d0d2d6 100644 --- a/spring-xml/src/main/java/org/springframework/xml/XMLInputFactoryUtils.java +++ b/spring-xml/src/main/java/org/springframework/xml/XMLInputFactoryUtils.java @@ -25,14 +25,14 @@ public class XMLInputFactoryUtils { /** * Build an {@link XMLInputFactory} and set properties to prevent external entities from accessing. * - * @see XMLInputFactory#newInstance() + * @see XMLInputFactory#newInstance() */ public static XMLInputFactory newInstance() { XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.SUPPORT_DTD, false); factory.setProperty("javax.xml.stream.isSupportingExternalEntities", false); - + return factory; } 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 a7b637f1..ba7f09fc 100644 --- a/spring-xml/src/main/java/org/springframework/xml/XmlException.java +++ b/spring-xml/src/main/java/org/springframework/xml/XmlException.java @@ -39,7 +39,7 @@ public abstract class XmlException extends NestedRuntimeException { /** * Constructs a new instance of the {@code XmlException} with the specific detail message and exception. * - * @param message the detail message + * @param message the detail message * @param throwable the wrapped exception */ protected XmlException(String message, Throwable 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 cf26eba1..6e2614d9 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 @@ -19,6 +19,7 @@ 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; @@ -29,8 +30,6 @@ 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. * @@ -56,8 +55,7 @@ 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"); @@ -66,8 +64,7 @@ public class DomContentHandler implements ContentHandler { private Node getParent() { if (!elements.isEmpty()) { return elements.get(elements.size() - 1); - } - else { + } else { return node; } } @@ -100,8 +97,7 @@ 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); } @@ -119,30 +115,23 @@ 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 8328b421..b84ffd56 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 @@ -17,27 +17,34 @@ package org.springframework.xml.namespace; import java.beans.PropertyEditorSupport; + 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. - * - *

    Expects the syntax + *

    + * Expects the syntax + * *

      * localPart
      * 
    + * * or + * *
      * {namespace}localPart
      * 
    + * * or + * *
      * {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 @@ -57,17 +64,14 @@ public class QNameEditor extends PropertyEditorSupport { Object value = getValue(); if (value == null || !(value instanceof QName)) { return ""; - } - else { + } else { QName qName = (QName) value; 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(); } } 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 3950f169..edbe0760 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 @@ -18,10 +18,9 @@ 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}. @@ -34,12 +33,12 @@ 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. + * {@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. + * @param localPart local part of the {@code QName} + * @param prefix prefix of the {@code QName}. May be ignored. * @return the created {@code QName} * @see QName#QName(String,String,String) * @deprecated in favor of {@link QName#QName(String, String, String)} @@ -92,16 +91,12 @@ public abstract class QNameUtils { */ 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) { + return new QName(node.getNamespaceURI(), node.getLocalName(), node.getPrefix()); + } 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()); } @@ -118,17 +113,16 @@ 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 namespaceUri the namespace URI * @param qualifiedName the qualified name * @return a QName */ @@ -136,18 +130,15 @@ public abstract class QNameUtils { int idx = qualifiedName.indexOf(':'); if (idx == -1) { return new QName(namespaceUri, qualifiedName); - } - else { - return new QName(namespaceUri, qualifiedName.substring(idx + 1), - qualifiedName.substring(0, idx)); + } 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. + * {@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. @@ -156,19 +147,16 @@ 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 82ea5649..aeef8bec 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 @@ -23,15 +23,15 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; + import javax.xml.XMLConstants; 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,11 +47,9 @@ 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; @@ -93,21 +91,20 @@ public class SimpleNamespaceContext implements NamespaceContext { /** * Binds the given prefix to the given namespace. * - * @param prefix the namespace prefix + * @param prefix the namespace prefix * @param namespaceUri the namespace uri */ public void bindNamespaceUri(String prefix, String namespaceUri) { 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 + "\")"); + 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 { + Assert.isTrue(XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceUri), + "Prefix \"" + prefix + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + + XMLConstants.XMLNS_ATTRIBUTE_NS_URI + "\")"); + } else { prefixToNamespaceUri.put(prefix, namespaceUri); getPrefixesInternal(namespaceUri).add(prefix); } @@ -134,11 +131,9 @@ 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); - } - else { + } else { Set set = namespaceUriToPrefixes.get(namespaceUri); if (set == null) { set = new LinkedHashSet(); diff --git a/spring-xml/src/main/java/org/springframework/xml/package.html b/spring-xml/src/main/java/org/springframework/xml/package.html index 3f016dd9..e8045ac6 100644 --- a/spring-xml/src/main/java/org/springframework/xml/package.html +++ b/spring-xml/src/main/java/org/springframework/xml/package.html @@ -1,6 +1,7 @@ - -Provides classes for XML handling: version detection and a base XML exception class. Mostly for internal use by the -framework. - + + Provides classes for XML handling: version detection and a base XML exception class. Mostly for internal use by + the + framework. + 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 7b52866a..6684a66a 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 @@ -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) @@ -95,8 +95,7 @@ public abstract class AbstractXmlReader implements XMLReader { /** * Throws a {@code SAXNotRecognizedException} exception. * - * @throws org.xml.sax.SAXNotRecognizedException - * always + * @throws org.xml.sax.SAXNotRecognizedException always */ @Override public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException { @@ -114,29 +113,27 @@ 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 7ca5dbf9..89ea94c3 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 @@ -20,10 +20,9 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import org.springframework.core.io.Resource; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.io.Resource; import org.xml.sax.InputSource; /** @@ -56,12 +55,10 @@ public abstract class SaxUtils { public static String getSystemId(Resource resource) { try { return new URI(resource.getURL().toExternalForm()).toString(); - } - catch (IOException ex) { + } catch (IOException ex) { logger.debug("Could not get System ID from [" + resource + "], ex"); return null; - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { 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 70217597..9ddf8d81 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 @@ -17,11 +17,11 @@ package org.springframework.xml.transform; 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; /** 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 ca03ebc3..100c19a4 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 @@ -17,11 +17,12 @@ package org.springframework.xml.transform; 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 99459238..dede715a 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 @@ -19,13 +19,14 @@ package org.springframework.xml.transform; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; + 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 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 4bc936f0..c79f92ab 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 @@ -59,15 +59,17 @@ public class TransformerFactoryUtils { factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); } 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) { if (log.isWarnEnabled()) { - log.warn(XMLConstants.ACCESS_EXTERNAL_STYLESHEET + " property not supported by " + factory.getClass().getCanonicalName()); + log.warn(XMLConstants.ACCESS_EXTERNAL_STYLESHEET + " property not supported by " + + factory.getClass().getCanonicalName()); } } 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 feec4857..d852c8fe 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 @@ -26,8 +26,8 @@ import javax.xml.transform.TransformerFactory; import org.springframework.util.Assert; /** - * Helper class for {@link Transformer} usage. Provides {@link #createTransformer()} and {@link #transform(Source, - * Result)}. + * Helper class for {@link Transformer} usage. Provides {@link #createTransformer()} and + * {@link #transform(Source, Result)}. * * @author Arjen Poutsma * @since 3.0 @@ -41,8 +41,7 @@ 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}. @@ -68,12 +67,12 @@ 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. - * - *

    Can be overridden in subclasses. + *

    + * 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 @@ -112,16 +111,15 @@ public class TransformerHelper { * 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 + * @throws TransformerConfigurationException if thrown by JAXP methods */ public Transformer createTransformer() throws TransformerConfigurationException { return getTransformerFactory().newTransformer(); } /** - * 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 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 0ef62c60..1cb8cab7 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 @@ -27,9 +27,9 @@ 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 @@ -52,10 +52,13 @@ 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.

    Can be overridden - * in subclasses. + * 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. + *

    + * Can be overridden in subclasses. * * @param transformerFactoryClass the specified factory class (if any) * @return the new TransactionFactory instance @@ -77,16 +80,15 @@ public abstract class TransformerObjectSupport { * 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 + * @throws TransformerConfigurationException if thrown by JAXP methods */ protected final Transformer createTransformer() throws TransformerConfigurationException { return transformerHelper.createTransformer(); } /** - * 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 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 be216674..259a476d 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 @@ -20,6 +20,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; + import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLStreamReader; @@ -37,7 +38,6 @@ 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; @@ -63,11 +63,9 @@ 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; } } @@ -76,40 +74,35 @@ public abstract class TraxUtils { * 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 source source to look at * @param callback the callback to invoke for each kind of source */ public static void doWithSource(Source source, SourceCallback callback) throws Exception { 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; } @@ -117,50 +110,45 @@ 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 result result to look at * @param callback the callback to invoke for each kind of result */ public static void doWithResult(Result result, ResultCallback callback) throws Exception { 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; } @@ -168,8 +156,7 @@ 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()); } } @@ -191,7 +178,7 @@ public abstract class TraxUtils { /** * Perform an operation on the {@code XMLReader} and {@code InputSource} contained in a {@link SAXSource}. * - * @param reader the reader, can be {@code null} + * @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; @@ -233,7 +220,6 @@ public abstract class TraxUtils { */ void source(String systemId) throws Exception; - } /** @@ -251,8 +237,7 @@ public abstract class TraxUtils { 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} @@ -298,5 +283,4 @@ public abstract class TraxUtils { } - } 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 189f631a..3fe2f415 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 @@ -19,15 +19,15 @@ package org.springframework.xml.validation; import java.io.IOException; import java.util.ArrayList; import java.util.List; + 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,8 +41,7 @@ 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); } } @@ -70,8 +69,7 @@ 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); } } @@ -88,8 +86,7 @@ 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 { 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 680075b0..77a6f3a0 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 @@ -19,6 +19,7 @@ package org.springframework.xml.validation; import java.io.IOException; import java.util.ArrayList; import java.util.List; + import javax.xml.XMLConstants; import javax.xml.transform.Source; import javax.xml.validation.Schema; @@ -26,16 +27,15 @@ 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 @@ -45,13 +45,11 @@ abstract class Jaxp15ValidatorFactory { private static final Log log = LogFactory.getLog(Jaxp15ValidatorFactory.class); - static XmlValidator createValidator(Resource[] resources, String schemaLanguage) throws IOException { 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); } } @@ -80,7 +78,8 @@ abstract class Jaxp15ValidatorFactory { validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); } catch (SAXNotRecognizedException | SAXNotSupportedException e) { if (log.isWarnEnabled()) { - log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + validator.getClass().getCanonicalName()); + log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + + validator.getClass().getCanonicalName()); } } @@ -88,7 +87,8 @@ abstract class Jaxp15ValidatorFactory { validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); } catch (SAXNotRecognizedException | SAXNotSupportedException e) { if (log.isWarnEnabled()) { - log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + validator.getClass().getCanonicalName()); + log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + + validator.getClass().getCanonicalName()); } } @@ -96,8 +96,7 @@ 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); } } @@ -114,8 +113,7 @@ 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 { 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 9481fb90..74e10afe 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 @@ -35,7 +35,7 @@ public class SchemaFactoryUtils { /** * Build a {@link SchemaFactory} and set properties to prevent external entities from accessing. * - * @see SchemaFactory#newInstance(String) + * @see SchemaFactory#newInstance(String) */ public static SchemaFactory newInstance(String schemaLanguage) { SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage); @@ -44,16 +44,19 @@ public class SchemaFactoryUtils { schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); } catch (SAXNotRecognizedException | SAXNotSupportedException e) { if (log.isWarnEnabled()) { - log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + schemaFactory.getClass().getCanonicalName()); + log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by " + + schemaFactory.getClass().getCanonicalName()); } } try { - schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ResourceUtils.URL_PROTOCOL_FILE + "," + "jar:file" + "," + ResourceUtils.URL_PROTOCOL_WSJAR); + schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, + ResourceUtils.URL_PROTOCOL_FILE + "," + "jar:file" + "," + ResourceUtils.URL_PROTOCOL_WSJAR); } catch (SAXNotRecognizedException | SAXNotSupportedException e) { if (log.isWarnEnabled()) { - log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + schemaFactory.getClass().getCanonicalName()); + log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by " + + schemaFactory.getClass().getCanonicalName()); } } 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 9242e022..4475ad58 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 @@ -17,16 +17,16 @@ package org.springframework.xml.validation; import java.io.IOException; + import javax.xml.transform.Source; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; -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; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; /** * Convenient utility methods for loading of {@link Schema} objects, performing standard handling of input streams. @@ -39,25 +39,25 @@ public abstract class SchemaLoaderUtils { /** * Load schema from the given resource. * - * @param resource the resource to load from + * @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}. - * @throws IOException if loading failed + * {@code XMLConstants.RELAXNG_NS_URI}. + * @throws IOException if loading failed * @throws SAXException if loading failed * @see javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI * @see javax.xml.XMLConstants#RELAXNG_NS_URI */ public static Schema loadSchema(Resource resource, String schemaLanguage) throws IOException, SAXException { - return loadSchema(new Resource[]{resource}, schemaLanguage); + return loadSchema(new Resource[] { resource }, schemaLanguage); } /** * Load schema from the given resource. * - * @param resources the resources to load from + * @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}. - * @throws IOException if loading failed + * {@code XMLConstants.RELAXNG_NS_URI}. + * @throws IOException if loading failed * @throws SAXException if loading failed * @see javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI * @see javax.xml.XMLConstants#RELAXNG_NS_URI @@ -81,10 +81,9 @@ public abstract class SchemaLoaderUtils { public static String getSystemId(Resource resource) { try { return resource.getURL().toString(); - } - catch (IOException e) { + } catch (IOException e) { return null; } } -} \ No newline at end of file +} 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 80dc3e95..2da2394d 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 @@ -21,6 +21,7 @@ import org.xml.sax.SAXParseException; /** * Subinterface of {@link ErrorHandler} that allows the registered errors to be retrieved. + * * @author Arjen Poutsma * @since 2.0.1 */ @@ -28,6 +29,7 @@ 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 723912c6..f2b6cfda 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 @@ -28,7 +28,7 @@ public class XMLReaderFactoryUtils { /** * Build a {@link XMLReader} and set properties to prevent external entity access. * - * @see XMLReaderFactory#createXMLReader() + * @see XMLReaderFactory#createXMLReader() */ public static XMLReader createXMLReader() throws SAXException { XMLReader xmlReader = XMLReaderFactory.createXMLReader(); 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 27c82794..345a972f 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 @@ -17,14 +17,15 @@ package org.springframework.xml.validation; import java.io.IOException; + 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}. - * - *

    Instances of this class are designed to be thread safe. + *

    + * Instances of this class are designed to be thread safe. * * @author Arjen Poutsma * @see XmlValidatorFactory#createValidator(org.springframework.core.io.Resource, String) @@ -33,26 +34,26 @@ 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 + * @throws IOException if the {@code source} cannot be read * @throws XmlValidationException if the {@code source} cannot be validated */ 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. * @return an array of {@code SAXParseException}s - * @throws IOException if the {@code source} cannot be read + * @throws IOException if the {@code source} cannot be read * @throws XmlValidationException if the {@code source} cannot be validated */ SAXParseException[] validate(Source source, ValidationErrorHandler errorHandler) throws IOException; -} \ No newline at end of file +} 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 c5ba3ad4..dc86f1e3 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 @@ -17,11 +17,11 @@ package org.springframework.xml.validation; import java.io.IOException; + 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; @@ -29,8 +29,8 @@ 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. - * - *

    The goal of this class is to avoid runtime dependencies on JAXP 1.3 by using the best validation implementation that + *

    + * 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 @@ -48,34 +48,34 @@ 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 - * @throws IOException if the schema resource cannot be read + * @throws IOException if the schema resource cannot be read * @throws IllegalArgumentException if the schema language is not supported - * @throws IllegalStateException if JAXP 1.0 cannot be located - * @throws XmlValidationException if a {@code XmlValidator} cannot be created + * @throws IllegalStateException if JAXP 1.0 cannot be located + * @throws XmlValidationException if a {@code XmlValidator} cannot be created * @see #SCHEMA_RELAX_NG * @see #SCHEMA_W3C_XML */ public static XmlValidator createValidator(Resource schemaResource, String schemaLanguage) throws IOException { - return createValidator(new Resource[]{schemaResource}, schemaLanguage); + return createValidator(new Resource[] { schemaResource }, schemaLanguage); } /** - * 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. + * 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 + * @param schemaLanguage the language of the schemas * @return a validator - * @throws IOException if the schema resource cannot be read + * @throws IOException if the schema resource cannot be read * @throws IllegalArgumentException if the schema language is not supported - * @throws IllegalStateException if JAXP 1.0 cannot be located - * @throws XmlValidationException if a {@code XmlValidator} cannot be created + * @throws IllegalStateException if JAXP 1.0 cannot be located + * @throws XmlValidationException if a {@code XmlValidator} cannot be created * @see #SCHEMA_RELAX_NG * @see #SCHEMA_W3C_XML */ @@ -91,12 +91,10 @@ 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 0c42f938..013b71b5 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 @@ -17,17 +17,17 @@ package org.springframework.xml.xpath; import java.util.Map; + 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. * 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 d9265504..4b000e57 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 @@ -48,8 +48,7 @@ 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); } @@ -68,8 +67,7 @@ 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); } @@ -95,8 +93,7 @@ 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); } } @@ -105,8 +102,7 @@ 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); } } @@ -115,8 +111,7 @@ 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); } } @@ -125,8 +120,7 @@ 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); } } @@ -136,8 +130,7 @@ 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); } } @@ -149,16 +142,13 @@ 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); } } @@ -172,14 +162,12 @@ 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 166113f1..0a1b5a2b 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 @@ -18,6 +18,7 @@ package org.springframework.xml.xpath; import java.util.ArrayList; import java.util.List; + import javax.xml.transform.Source; import javax.xml.transform.TransformerException; @@ -31,8 +32,8 @@ import org.w3c.dom.Node; /** * Implementation of {@link XPathOperations} that uses Jaxen. - * - *

    Namespaces can be set using the {@code namespaces} property. + *

    + * Namespaces can be set using the {@code namespaces} property. * * @author Arjen Poutsma * @see Jaxen @@ -46,11 +47,9 @@ 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); } } @@ -61,11 +60,9 @@ 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); } } @@ -77,11 +74,9 @@ 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); } } @@ -92,11 +87,9 @@ 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); } } @@ -107,11 +100,9 @@ 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); } } @@ -125,20 +116,16 @@ 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); } } @@ -154,17 +141,14 @@ 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); } } 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 3b06e2db..e9f3ecbd 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 @@ -19,18 +19,18 @@ package org.springframework.xml.xpath; import java.util.ArrayList; import java.util.List; import java.util.Map; + import javax.xml.namespace.QName; import javax.xml.xpath.XPath; 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. * @@ -55,8 +55,7 @@ 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); } @@ -78,8 +77,7 @@ 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); } @@ -89,7 +87,6 @@ abstract class Jaxp13XPathExpressionFactory { return xpathFactory.newXPath(); } - /** JAXP 1.3 implementation of the {@code XPathExpression} interface. */ private static class Jaxp13XPathExpression implements XPathExpression { @@ -123,8 +120,7 @@ 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); } } @@ -158,12 +154,10 @@ 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; } } @@ -175,8 +169,7 @@ 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); } } 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 4b4bcfea..2535a9c0 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 @@ -20,6 +20,7 @@ import java.io.InputStream; import java.io.Reader; import java.util.ArrayList; import java.util.List; + import javax.xml.namespace.QName; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLStreamException; @@ -33,6 +34,10 @@ 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; @@ -41,15 +46,10 @@ 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. - * - *

    Namespaces can be set using the {@code namespaces} property. + *

    + * Namespaces can be set using the {@code namespaces} property. * * @author Arjen Poutsma * @see #setNamespaces(java.util.Map) @@ -66,8 +66,7 @@ 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); } } @@ -110,12 +109,10 @@ 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; } } @@ -127,8 +124,7 @@ 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); } } @@ -146,14 +142,11 @@ 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); } } @@ -231,6 +224,4 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate { } - - } 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 29b36ff3..43c2013b 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 @@ -23,8 +23,8 @@ 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. - * - *

    Consider using a {@link NodeMapper} instead if you need to map exactly result object per node, assembling them in a + *

    + * Consider using a {@link NodeMapper} instead if you need to map exactly result object per node, assembling them in a * List. * * @author Arjen Poutsma 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 94087084..1e75aa3d 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 @@ -36,7 +36,7 @@ public interface NodeMapper { /** * Maps a single node to an arbitrary object. * - * @param node the node to map + * @param node the node to map * @param nodeNum the number of the current node * @return object for the current node * @throws DOMException in case of DOM errors 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 634591d4..72eb3992 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 @@ -39,7 +39,7 @@ public class XPathException extends XmlException { /** * Constructs a new instance of the {@code XPathException} with the specific detail message and exception. * - * @param message the detail message + * @param message the detail message * @param throwable the wrapped exception */ public XPathException(String message, Throwable 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 413023a3..8929baa6 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 @@ -21,10 +21,10 @@ 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}. - * - *

    Implementations of this interface are precompiled, and thus faster, but less flexible, than the XPath expressions + * 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. * * @author Arjen Poutsma @@ -35,13 +35,12 @@ 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. - * - *

    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 @@ -51,8 +50,8 @@ public interface XPathExpression { 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 @@ -73,11 +72,11 @@ 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. - * - *

    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. + * 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. * * @param node the starting point * @return the result of the evaluation @@ -88,9 +87,9 @@ public interface XPathExpression { /** * 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 @@ -102,7 +101,7 @@ public interface XPathExpression { /** * Evaluates the given expression, mapping a single {@link Node} result to a Java object via a {@link NodeMapper}. * - * @param node the starting point + * @param node the starting point * @param nodeMapper object that will map one object per node * @return the single mapped object * @throws XPathException in case of XPath errors @@ -111,10 +110,9 @@ 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 node the starting point * @param nodeMapper object that will map one object per node * @return the result list, containing mapped objects * @throws XPathException in case of XPath errors 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 364756c4..4ad31df2 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 @@ -19,16 +19,15 @@ package org.springframework.xml.xpath; import java.util.Collections; import java.util.Map; -import org.springframework.util.Assert; - 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. - * - *

    The goal of this class is to avoid runtime dependencies a specific XPath engine, simply using the best XPath + * 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. * * @author Arjen Poutsma @@ -45,11 +44,11 @@ public abstract class XPathExpressionFactory { * @param expression the XPath expression * @return the compiled XPath expression * @throws IllegalStateException if neither JAXP 1.3+, or Jaxen are available - * @throws XPathParseException if the given expression cannot be parsed + * @throws XPathParseException if the given expression cannot be parsed */ public static XPathExpression createXPathExpression(String expression) throws IllegalStateException, XPathParseException { - return createXPathExpression(expression, Collections.emptyMap()); + return createXPathExpression(expression, Collections. emptyMap()); } /** @@ -60,7 +59,7 @@ public abstract class XPathExpressionFactory { * @param namespaces a map that binds string prefixes to string namespaces * @return the compiled XPath expression * @throws IllegalStateException if neither JAXP 1.3+, or Jaxen are available - * @throws XPathParseException if the given expression cannot be parsed + * @throws XPathParseException if the given expression cannot be parsed */ public static XPathExpression createXPathExpression(String expression, Map namespaces) throws IllegalStateException, XPathParseException { @@ -71,11 +70,9 @@ 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 7b548b28..4e859cae 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 @@ -26,8 +26,8 @@ import org.springframework.util.CollectionUtils; /** * 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) @@ -56,8 +56,7 @@ 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); } } 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 7a1b6e05..1df74e78 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 @@ -17,6 +17,7 @@ package org.springframework.xml.xpath; import java.util.List; + import javax.xml.transform.Source; import org.w3c.dom.Node; @@ -24,9 +25,10 @@ import org.w3c.dom.Node; /** * 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,16 +40,15 @@ 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. - * - *

    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 + * @param context the context starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors * @see XPath specification - boolean() function @@ -55,11 +56,11 @@ public interface XPathOperations { 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 + * @param context the context starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors * @see XPath specification @@ -71,7 +72,7 @@ public interface XPathOperations { * empty list if no results are found. * * @param expression the XPath expression - * @param context the context starting point + * @param context the context starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors * @see XPath specification @@ -79,14 +80,14 @@ 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. - * - *

    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. + * 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. * * @param expression the XPath expression - * @param context the context starting point + * @param context the context starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors * @see XPath specification - number() function @@ -94,14 +95,14 @@ public interface XPathOperations { 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. - * - *

    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. + * 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. * * @param expression the XPath expression - * @param context the context starting point + * @param context the context starting point * @return the result of the evaluation * @throws XPathException in case of XPath errors * @see XPath specification - string() function @@ -112,7 +113,7 @@ public interface XPathOperations { * 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 context the context starting point * @param nodeMapper object that will map one object per node * @return the single mapped object * @throws XPathException in case of XPath errors @@ -121,11 +122,10 @@ 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 context the context starting point * @param nodeMapper object that will map one object per node * @return the result list, containing mapped objects * @throws XPathException in case of XPath errors @@ -134,11 +134,11 @@ 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 expression the XPath expression + * @param context the context starting point * @param callbackHandler object that will extract results, one row at a time * @throws XPathException in case of XPath errors * @see XPath specification 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 f2f04757..c91f2f5c 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 @@ -35,10 +35,9 @@ 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 message the detail message * @param throwable the wrapped exception */ public XPathParseException(String message, Throwable 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 d7305d57..1fe5309d 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 @@ -17,6 +17,7 @@ package org.springframework.xml.xsd; import java.io.IOException; + import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -24,10 +25,6 @@ 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; @@ -35,11 +32,14 @@ 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) + *

    + * Allows a XSD to be set by the {@link #setXsd(Resource)}, or directly in the {@link #SimpleXsdSchema(Resource) * constructor}. * * @author Mark LaFond @@ -65,14 +65,13 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean { /** * Create a new instance of the {@link SimpleXsdSchema} class. - * - *

    A subsequent call to the {@link #setXsd(Resource)} method is required. + *

    + * 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} @@ -94,8 +93,9 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean { @Override public String getTargetNamespace() { - Assert.notNull(schemaElement, "schemaElement must not be null! Did you run afterPropertiesSet() or register this as a Spring bean?"); - + Assert.notNull(schemaElement, + "schemaElement must not be null! Did you run afterPropertiesSet() or register this as a Spring bean?"); + return schemaElement.getAttribute("targetNamespace"); } @@ -108,8 +108,7 @@ 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); } } @@ -127,9 +126,9 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean { schemaElement = schemaDocument.getDocumentElement(); Assert.isTrue(SCHEMA_NAME.getLocalPart().equals(schemaElement.getLocalName()), xsdResource + " has invalid root element : [" + schemaElement.getLocalName() + "] instead of [schema]"); - Assert.isTrue(SCHEMA_NAME.getNamespaceURI().equals(schemaElement.getNamespaceURI()), xsdResource + - " has invalid root element: [" + schemaElement.getNamespaceURI() + "] instead of [" + - SCHEMA_NAME.getNamespaceURI() + "]"); + Assert.isTrue(SCHEMA_NAME.getNamespaceURI().equals(schemaElement.getNamespaceURI()), + xsdResource + " has invalid root element: [" + schemaElement.getNamespaceURI() + "] instead of [" + + SCHEMA_NAME.getNamespaceURI() + "]"); Assert.hasText(getTargetNamespace(), xsdResource + " has no targetNamespace"); } @@ -141,4 +140,4 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean { return builder.toString(); } -} \ No newline at end of file +} 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 e1e378e5..44c1545c 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 @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; + import javax.xml.namespace.QName; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; @@ -30,8 +31,6 @@ 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; @@ -40,6 +39,7 @@ 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. @@ -55,7 +55,7 @@ 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,10 +65,10 @@ 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 schema the Commons {@code XmlSchema} object; must not be {@code null} * @param collection the Commons {@code XmlSchemaCollection} object; can be {@code null} * @throws IllegalArgumentException if the supplied {@code schema} is {@code null} */ @@ -98,18 +98,15 @@ public class CommonsXsdSchema implements XsdSchema { } Document[] serializedSchemas = serializer.serializeSchema(schema, false); return new DOMSource(serializedSchemas[0]); - } - catch (BeanInstantiationException ex) { + } catch (BeanInstantiationException ex) { // ignore - } - catch (XmlSchemaSerializer.XmlSchemaSerializerException ex) { + } catch (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()); @@ -120,15 +117,13 @@ public class CommonsXsdSchema implements XsdSchema { public XmlValidator createValidator() { try { Resource resource = new UrlResource(schema.getSourceURI()); - return XmlValidatorFactory - .createValidator(resource, XmlValidatorFactory.SCHEMA_W3C_XML); - } - catch (IOException ex) { + return XmlValidatorFactory.createValidator(resource, XmlValidatorFactory.SCHEMA_W3C_XML); + } catch (IOException ex) { throw new CommonsXsdSchemaException(ex.getMessage(), ex); } } - /** Returns the wrapped Commons {@code XmlSchema} object. */ + /** Returns the wrapped Commons {@code XmlSchema} object. */ public XmlSchema getSchema() { return schema; } 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 bf8a48b0..de855a54 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 @@ -32,8 +32,6 @@ 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; @@ -46,13 +44,14 @@ 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. - * - *

    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 @@ -76,11 +75,10 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali /** * Constructs a new, empty instance of the {@code CommonsXsdSchemaCollection}. - * - *

    A subsequent call to the {@link #setXsds(Resource[])} is required. + *

    + * 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. @@ -102,8 +100,8 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali /** * Defines whether included schemas should be inlined into the including schema. - * - *

    Defaults to {@code false}. + *

    + * Defaults to {@code false}. */ public void setInline(boolean inline) { this.inline = inline; @@ -111,8 +109,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"); @@ -136,16 +134,14 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali for (Resource xsdResource : xsdResources) { Assert.isTrue(xsdResource.exists(), xsdResource + " does not exist"); try { - XmlSchema xmlSchema = - schemaCollection.read(SaxUtils.createInputSource(xsdResource)); + XmlSchema xmlSchema = schemaCollection.read(SaxUtils.createInputSource(xsdResource)); xmlSchemas.add(xmlSchema); if (inline) { inlineIncludes(xmlSchema, processedIncludes, processedImports); findImports(xmlSchema, processedImports, processedIncludes); } - } - catch (Exception ex) { + } catch (Exception ex) { throw new CommonsXsdSchemaException("Schema [" + xsdResource + "] could not be loaded", ex); } } @@ -176,8 +172,7 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali resources[i] = new UrlResource(sourceUri); } } - return XmlValidatorFactory - .createValidator(resources, XmlValidatorFactory.SCHEMA_W3C_XML); + return XmlValidatorFactory.createValidator(resources, XmlValidatorFactory.SCHEMA_W3C_XML); } catch (IOException ex) { throw new CommonsXsdSchemaException(ex.getMessage(), ex); } @@ -213,8 +208,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); @@ -247,8 +242,7 @@ 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); @@ -256,8 +250,7 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali if (resource.exists()) { return createInputSource(resource); } - } - catch (IOException e) { + } catch (IOException e) { // fall through } } @@ -274,8 +267,7 @@ 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/test/java/org/springframework/xml/dom/DomContentHandlerTest.java b/spring-xml/src/test/java/org/springframework/xml/dom/DomContentHandlerTest.java index 2f52973f..9abbe65a 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 @@ -16,34 +16,33 @@ package org.springframework.xml.dom; +import static org.custommonkey.xmlunit.XMLAssert.*; + import java.io.StringReader; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Before; import org.junit.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.custommonkey.xmlunit.XMLAssert.assertXMLEqual; - public class DomContentHandlerTest { - private static final String XML_1 = "" + "" + - "" + - "content" + - ""; + private static final String XML_1 = "" + "" + + "" + + "content" + + ""; - private static final String XML_2_EXPECTED = "" + "" + - "" + ""; + private static final String XML_2_EXPECTED = "" + "" + + "" + ""; - private static final String XML_2_SNIPPET = - "" + ""; + private static final String XML_2_SNIPPET = "" + ""; private Document expected; @@ -94,4 +93,4 @@ public class DomContentHandlerTest { assertXMLEqual("Invalid result", expected, result); } -} \ No newline at end of file +} 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 82a12239..61ea07be 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 @@ -56,9 +56,10 @@ public class QNameEditorTest { editor.setAsText(text); QName result = (QName) editor.getValue(); Assert.assertNotNull("getValue returns null", result); - Assert.assertEquals("Parsed QName local part is not equal to original", qname.getLocalPart(), result.getLocalPart()); + Assert.assertEquals("Parsed QName local part is not equal to original", qname.getLocalPart(), + result.getLocalPart()); Assert.assertEquals("Parsed QName prefix is not equal to original", qname.getPrefix(), result.getPrefix()); Assert.assertEquals("Parsed QName namespace is not equal to original", qname.getNamespaceURI(), result.getNamespaceURI()); } -} \ No newline at end of file +} diff --git a/spring-xml/src/test/java/org/springframework/xml/namespace/QNameUtilsTest.java b/spring-xml/src/test/java/org/springframework/xml/namespace/QNameUtilsTest.java index 63d66dc4..a49358a0 100644 --- a/spring-xml/src/test/java/org/springframework/xml/namespace/QNameUtilsTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/namespace/QNameUtilsTest.java @@ -22,11 +22,10 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Assert; import org.junit.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - import org.springframework.util.StringUtils; import org.springframework.xml.DocumentBuilderFactoryUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Element; public class QNameUtilsTest { @@ -114,5 +113,4 @@ public class QNameUtilsTest { Assert.assertEquals("invalid localname", "localName", result.getLocalPart()); } - } 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 f0c42a5e..96d46781 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 @@ -18,6 +18,7 @@ package org.springframework.xml.namespace; import java.util.Collections; import java.util.Iterator; + import javax.xml.XMLConstants; import org.junit.Assert; @@ -36,31 +37,32 @@ public class SimpleNamespaceContextTest { @Test public void testGetNamespaceURI() { - Assert.assertEquals("Invalid namespaceURI for default namespace", "", context - .getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX)); + Assert.assertEquals("Invalid namespaceURI for default namespace", "", + context.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX)); String defaultNamespaceUri = "defaultNamespace"; context.bindNamespaceUri(XMLConstants.DEFAULT_NS_PREFIX, defaultNamespaceUri); - Assert.assertEquals("Invalid namespaceURI for default namespace", defaultNamespaceUri, context - .getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX)); + Assert.assertEquals("Invalid namespaceURI for default namespace", defaultNamespaceUri, + context.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX)); Assert.assertEquals("Invalid namespaceURI for bound prefix", "namespaceURI", context.getNamespaceURI("prefix")); Assert.assertEquals("Invalid namespaceURI for unbound prefix", "", context.getNamespaceURI("unbound")); - Assert.assertEquals("Invalid namespaceURI for namespace prefix", XMLConstants.XML_NS_URI, context - .getNamespaceURI(XMLConstants.XML_NS_PREFIX)); - Assert.assertEquals("Invalid namespaceURI for attribute prefix", XMLConstants.XMLNS_ATTRIBUTE_NS_URI, context - .getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE)); + Assert.assertEquals("Invalid namespaceURI for namespace prefix", XMLConstants.XML_NS_URI, + context.getNamespaceURI(XMLConstants.XML_NS_PREFIX)); + Assert.assertEquals("Invalid namespaceURI for attribute prefix", XMLConstants.XMLNS_ATTRIBUTE_NS_URI, + context.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE)); } @Test public void testGetPrefix() { context.bindDefaultNamespaceUri("defaultNamespaceURI"); - Assert.assertEquals("Invalid prefix for default namespace", XMLConstants.DEFAULT_NS_PREFIX, context.getPrefix("defaultNamespaceURI")); + Assert.assertEquals("Invalid prefix for default namespace", XMLConstants.DEFAULT_NS_PREFIX, + context.getPrefix("defaultNamespaceURI")); Assert.assertEquals("Invalid prefix for bound namespace", "prefix", context.getPrefix("namespaceURI")); Assert.assertNull("Invalid prefix for unbound namespace", context.getPrefix("unbound")); - Assert.assertEquals("Invalid prefix for namespace", XMLConstants.XML_NS_PREFIX, context - .getPrefix(XMLConstants.XML_NS_URI)); - Assert.assertEquals("Invalid prefix for attribute namespace", XMLConstants.XMLNS_ATTRIBUTE, context - .getPrefix(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)); + Assert.assertEquals("Invalid prefix for namespace", XMLConstants.XML_NS_PREFIX, + context.getPrefix(XMLConstants.XML_NS_URI)); + Assert.assertEquals("Invalid prefix for attribute namespace", XMLConstants.XMLNS_ATTRIBUTE, + context.getPrefix(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)); } @Test @@ -130,8 +132,8 @@ public class SimpleNamespaceContextTest { String prefix1 = "prefix1"; String prefix2 = "prefix2"; String namespaceUri = "namespaceUri"; - context.bindNamespaceUri(prefix1, namespaceUri); - context.bindNamespaceUri(prefix2, namespaceUri); + context.bindNamespaceUri(prefix1, namespaceUri); + context.bindNamespaceUri(prefix2, namespaceUri); Iterator iter = context.getPrefixes(namespaceUri); Assert.assertTrue("iterator is empty", iter.hasNext()); Assert.assertEquals(prefix1, iter.next()); 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 5f6d9320..731576ac 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 @@ -16,11 +16,10 @@ package org.springframework.xml.sax; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; - import org.junit.Assert; import org.junit.Test; +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; public class SaxUtilsTest { @@ -31,4 +30,4 @@ public class SaxUtilsTest { Assert.assertNotNull("No systemId returned", systemId); Assert.assertTrue("Invalid system id", systemId.endsWith("path%20with%20spaces/file%20with%20spaces.txt")); } -} \ No newline at end of file +} diff --git a/spring-xml/src/test/java/org/springframework/xml/transform/ResourceSourceTest.java b/spring-xml/src/test/java/org/springframework/xml/transform/ResourceSourceTest.java index 8ec8c86d..78dcaa9c 100644 --- a/spring-xml/src/test/java/org/springframework/xml/transform/ResourceSourceTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/transform/ResourceSourceTest.java @@ -21,9 +21,8 @@ import javax.xml.transform.dom.DOMResult; import org.junit.Assert; import org.junit.Test; -import org.w3c.dom.Element; - import org.springframework.core.io.ClassPathResource; +import org.w3c.dom.Element; public class ResourceSourceTest { @@ -39,4 +38,4 @@ public class ResourceSourceTest { Assert.assertEquals("Invalid namespace", "namespace", rootElement.getNamespaceURI()); } -} \ No newline at end of file +} 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 0ad0a9b5..6823d583 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 @@ -16,17 +16,16 @@ package org.springframework.xml.transform; +import static org.custommonkey.xmlunit.XMLAssert.*; + import javax.xml.transform.Transformer; import javax.xml.transform.dom.DOMSource; import org.junit.Test; +import org.springframework.xml.DocumentBuilderFactoryUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.custommonkey.xmlunit.XMLAssert.*; - public class StringResultTest { @Test @@ -40,4 +39,4 @@ public class StringResultTest { assertXMLEqual("Invalid result", "", result.toString()); } -} \ No newline at end of file +} 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 3d2f47a6..a7275866 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 @@ -18,7 +18,6 @@ package org.springframework.xml.transform; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; import org.junit.Assert; @@ -38,4 +37,4 @@ public class StringSourceTest { Assert.assertEquals("Invalid prefix", "prefix", rootElement.getPrefix()); Assert.assertEquals("Invalid namespace", "namespace", rootElement.getNamespaceURI()); } -} \ No newline at end of file +} 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 d86681d1..a322ad91 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 @@ -16,7 +16,11 @@ package org.springframework.xml.transform; +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.easymock.EasyMock.*; + import java.io.IOException; + import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -26,9 +30,6 @@ import org.junit.Before; import org.junit.Test; import org.xml.sax.SAXException; -import static org.custommonkey.xmlunit.XMLAssert.*; -import static org.easymock.EasyMock.*; - public class TransformerHelperTest { private TransformerHelper helper; @@ -45,12 +46,12 @@ public class TransformerHelperTest { doTest(); } -// @Ignore -// @Test -// public void customTransformerFactory() throws TransformerException, IOException, SAXException { -// helper.setTransformerFactoryClass(TransformerFactoryImpl.class); -// doTest(); -// } + // @Ignore + // @Test + // public void customTransformerFactory() throws TransformerException, IOException, SAXException { + // helper.setTransformerFactoryClass(TransformerFactoryImpl.class); + // doTest(); + // } private void doTest() throws TransformerException, SAXException, IOException { String xml = "text"; 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 7d0640ca..34e044c7 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 @@ -16,6 +16,8 @@ package org.springframework.xml.transform; +import static org.easymock.EasyMock.*; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -24,6 +26,7 @@ import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.stream.XMLEventReader; @@ -43,6 +46,9 @@ import javax.xml.transform.stream.StreamSource; import org.junit.Assert; import org.junit.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; @@ -53,12 +59,6 @@ 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.XMLInputFactoryUtils; -import org.springframework.xml.DocumentBuilderFactoryUtils; - -import static org.easymock.EasyMock.*; - public class TraxUtilsTest { @Test @@ -283,13 +283,11 @@ public class TraxUtilsTest { verify(mock); } - @Test public void testDoWithInvalidSource() throws Exception { Source source = new Source() { - public void setSystemId(String systemId) { - } + public void setSystemId(String systemId) {} public String getSystemId() { return null; @@ -299,8 +297,7 @@ public class TraxUtilsTest { try { TraxUtils.doWithSource(source, null); Assert.fail("IllegalArgumentException expected"); - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { // expected } } @@ -309,8 +306,7 @@ 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; @@ -320,9 +316,8 @@ public class TraxUtilsTest { try { TraxUtils.doWithResult(result, null); Assert.fail("IllegalArgumentException expected"); - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { // expected } } -} \ No newline at end of file +} 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 f2ae9aab..a8051518 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 @@ -17,6 +17,7 @@ package org.springframework.xml.validation; import java.io.InputStream; + import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; @@ -27,16 +28,15 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.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.transform.ResourceSource; -import org.springframework.xml.DocumentBuilderFactoryUtils; - public abstract class AbstractValidatorFactoryTestCase { private XmlValidator validator; @@ -47,8 +47,8 @@ public abstract class AbstractValidatorFactoryTestCase { @Before public void setUp() throws Exception { - Resource[] schemaResource = - new Resource[]{new ClassPathResource("schema.xsd", AbstractValidatorFactoryTestCase.class)}; + Resource[] schemaResource = new Resource[] { + new ClassPathResource("schema.xsd", AbstractValidatorFactoryTestCase.class) }; validator = createValidator(schemaResource, XmlValidatorFactory.SCHEMA_W3C_XML); validInputStream = AbstractValidatorFactoryTestCase.class.getResourceAsStream("validDocument.xml"); invalidInputStream = AbstractValidatorFactoryTestCase.class.getResourceAsStream("invalidDocument.xml"); @@ -101,8 +101,7 @@ public abstract class AbstractValidatorFactoryTestCase { public void testHandleValidMessageDom() throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance(); documentBuilderFactory.setNamespaceAware(true); - Document document = documentBuilderFactory.newDocumentBuilder() - .parse(new InputSource(validInputStream)); + Document document = documentBuilderFactory.newDocumentBuilder().parse(new InputSource(validInputStream)); SAXParseException[] errors = validator.validate(new DOMSource(document)); Assert.assertNotNull("Null returned for errors", errors); Assert.assertEquals("ValidationErrors returned", 0, errors.length); @@ -112,8 +111,7 @@ public abstract class AbstractValidatorFactoryTestCase { public void testHandleInvalidMessageDom() throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance(); documentBuilderFactory.setNamespaceAware(true); - Document document = documentBuilderFactory.newDocumentBuilder() - .parse(new InputSource(invalidInputStream)); + Document document = documentBuilderFactory.newDocumentBuilder().parse(new InputSource(invalidInputStream)); SAXParseException[] errors = validator.validate(new DOMSource(document)); Assert.assertNotNull("Null returned for errors", errors); Assert.assertEquals("ValidationErrors returned", 3, errors.length); @@ -121,9 +119,9 @@ public abstract class AbstractValidatorFactoryTestCase { @Test public void testMultipleSchemasValidMessage() throws Exception { - Resource[] schemaResources = new Resource[]{ + Resource[] schemaResources = new Resource[] { new ClassPathResource("multipleSchemas1.xsd", AbstractValidatorFactoryTestCase.class), - new ClassPathResource("multipleSchemas2.xsd", AbstractValidatorFactoryTestCase.class)}; + new ClassPathResource("multipleSchemas2.xsd", AbstractValidatorFactoryTestCase.class) }; validator = createValidator(schemaResources, XmlValidatorFactory.SCHEMA_W3C_XML); Source document = new ResourceSource( @@ -144,14 +142,11 @@ 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); Assert.assertNotNull("Null returned for errors", errors); 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 58b1dc41..95b09e32 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 @@ -26,4 +26,4 @@ public class Jaxp13ValidatorFactoryTest extends AbstractValidatorFactoryTestCase protected XmlValidator createValidator(Resource[] schemaResources, String schemaLanguage) throws IOException { return Jaxp13ValidatorFactory.createValidator(schemaResources, schemaLanguage); } -} \ No newline at end of file +} 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 93d1fb37..10f218ec 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 @@ -26,4 +26,4 @@ public class Jaxp15ValidatorFactoryTest extends AbstractValidatorFactoryTestCase protected XmlValidator createValidator(Resource[] schemaResources, String schemaLanguage) throws IOException { return Jaxp15ValidatorFactory.createValidator(schemaResources, schemaLanguage); } -} \ No newline at end of file +} 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 e032e246..3760607c 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 @@ -19,11 +19,10 @@ package org.springframework.xml.validation; import javax.xml.XMLConstants; import javax.xml.validation.Schema; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - import org.junit.Assert; import org.junit.Test; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; public class SchemaLoaderUtilsTest { @@ -41,8 +40,7 @@ public class SchemaLoaderUtilsTest { Resource nonExistant = new ClassPathResource("bla"); SchemaLoaderUtils.loadSchema(nonExistant, XMLConstants.W3C_XML_SCHEMA_NS_URI); Assert.fail("Should have thrown an IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // expected } } @@ -52,8 +50,7 @@ public class SchemaLoaderUtilsTest { try { SchemaLoaderUtils.loadSchema((Resource) null, XMLConstants.W3C_XML_SCHEMA_NS_URI); Assert.fail("Should have thrown an IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // expected } } @@ -62,10 +59,10 @@ public class SchemaLoaderUtilsTest { public void testLoadMultipleSchemas() throws Exception { Resource envelope = new ClassPathResource("envelope.xsd", getClass()); Resource encoding = new ClassPathResource("encoding.xsd", getClass()); - Schema schema = - SchemaLoaderUtils.loadSchema(new Resource[]{envelope, encoding}, XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = SchemaLoaderUtils.loadSchema(new Resource[] { envelope, encoding }, + XMLConstants.W3C_XML_SCHEMA_NS_URI); Assert.assertNotNull("No schema returned", schema); Assert.assertFalse("Resource not closed", envelope.isOpen()); Assert.assertFalse("Resource not closed", encoding.isOpen()); } -} \ No newline at end of file +} 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 67f97a17..b6460561 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 @@ -24,7 +24,6 @@ import java.net.URL; import org.junit.Assert; import org.junit.Test; - import org.springframework.core.io.AbstractResource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -44,8 +43,7 @@ public class XmlValidatorFactoryTest { try { XmlValidatorFactory.createValidator(resource, XmlValidatorFactory.SCHEMA_W3C_XML); Assert.fail("IllegalArgumentException expected"); - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { // expected } } @@ -56,8 +54,7 @@ public class XmlValidatorFactoryTest { try { XmlValidatorFactory.createValidator(resource, "bla"); Assert.fail("IllegalArgumentException expected"); - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { // expected } } @@ -114,4 +111,4 @@ public class XmlValidatorFactoryTest { return false; } } -} \ No newline at end of file +} 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 c2a5b78b..498c4984 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 @@ -21,20 +21,20 @@ import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.util.StringUtils; +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.util.StringUtils; -import org.springframework.xml.DocumentBuilderFactoryUtils; - public abstract class AbstractXPathExpressionFactoryTestCase { private Document noNamespacesDocument; @@ -53,15 +53,13 @@ public abstract class AbstractXPathExpressionFactoryTestCase { InputStream inputStream = getClass().getResourceAsStream("nonamespaces.xml"); try { noNamespacesDocument = documentBuilder.parse(inputStream); - } - finally { + } finally { inputStream.close(); } inputStream = getClass().getResourceAsStream("namespaces.xml"); try { namespacesDocument = documentBuilder.parse(inputStream); - } - finally { + } finally { inputStream.close(); } } @@ -88,8 +86,8 @@ public abstract class AbstractXPathExpressionFactoryTestCase { @Test public void testEvaluateAsBooleanNamespaces() throws IOException, SAXException { - XPathExpression expression = - createXPathExpression("/prefix1:root/prefix2:child/prefix2:boolean/text()", namespaces); + XPathExpression expression = createXPathExpression("/prefix1:root/prefix2:child/prefix2:boolean/text()", + namespaces); boolean result = expression.evaluateAsBoolean(namespacesDocument); Assert.assertTrue("Invalid result", result); } @@ -117,8 +115,7 @@ 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); Assert.assertEquals("Invalid result", 42D, result, 0D); } @@ -192,8 +189,7 @@ public abstract class AbstractXPathExpressionFactoryTestCase { @Test public void testEvaluateAsStringNamespaces() throws IOException, SAXException { - 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); Assert.assertEquals("Invalid result", "text", result); } @@ -237,8 +233,7 @@ public abstract class AbstractXPathExpressionFactoryTestCase { try { createXPathExpression("\\"); Assert.fail("No XPathParseException thrown"); - } - catch (XPathParseException ex) { + } catch (XPathParseException ex) { // Expected behaviour } } 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 66ae16ea..0a972636 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 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.List; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -31,14 +32,13 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamSource; -import org.springframework.core.io.ClassPathResource; -import org.springframework.xml.sax.SaxUtils; -import org.springframework.xml.transform.ResourceSource; -import org.springframework.xml.DocumentBuilderFactoryUtils; - import org.junit.Assert; import org.junit.Before; import org.junit.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; @@ -57,8 +57,7 @@ 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; @@ -132,8 +131,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)); Assert.assertEquals("Invalid result", "text", result); @@ -176,8 +175,7 @@ public abstract class AbstractXPathTemplateTestCase { try { template.evaluateAsBoolean("\\", namespaces); Assert.fail("No XPathException thrown"); - } - catch (XPathException ex) { + } catch (XPathException ex) { // Expected behaviour } } diff --git a/spring-xml/src/test/java/org/springframework/xml/xpath/JaxenXPathTemplateTest.java b/spring-xml/src/test/java/org/springframework/xml/xpath/JaxenXPathTemplateTest.java index 78f3f0fc..5fd597e3 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xpath/JaxenXPathTemplateTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/xpath/JaxenXPathTemplateTest.java @@ -31,4 +31,4 @@ public class JaxenXPathTemplateTest extends AbstractXPathTemplateTestCase { return template; } -} \ No newline at end of file +} 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 61b0db32..bda893cc 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 @@ -29,4 +29,4 @@ public class Jaxp13XPathExpressionFactoryTest extends AbstractXPathExpressionFac protected XPathExpression createXPathExpression(String expression, Map namespaces) { return Jaxp13XPathExpressionFactory.createXPathExpression(expression, namespaces); } -} \ No newline at end of file +} diff --git a/spring-xml/src/test/java/org/springframework/xml/xpath/Jaxp13XPathTemplateTest.java b/spring-xml/src/test/java/org/springframework/xml/xpath/Jaxp13XPathTemplateTest.java index a3050856..8d53fbce 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xpath/Jaxp13XPathTemplateTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/xpath/Jaxp13XPathTemplateTest.java @@ -31,4 +31,4 @@ public class Jaxp13XPathTemplateTest extends AbstractXPathTemplateTestCase { return template; } -} \ No newline at end of file +} 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 39ac5e2b..2660c3ef 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 @@ -39,4 +39,4 @@ public class XPathExpressionFactoryBeanTest { Assert.assertTrue("Not a singleton", factoryBean.isSingleton()); Assert.assertEquals("Not a XPathExpresison", XPathExpression.class, factoryBean.getObjectType()); } -} \ No newline at end of file +} 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 70452fba..44b461fe 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 @@ -32,9 +32,8 @@ public class XPathExpressionFactoryTest { try { XPathExpressionFactory.createXPathExpression(""); Assert.fail("Should have thrown an Exception"); - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { // expected } } -} \ No newline at end of file +} 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 14959d91..693c797e 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 @@ -16,6 +16,8 @@ package org.springframework.xml.xsd; +import static org.custommonkey.xmlunit.XMLAssert.*; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -26,16 +28,13 @@ import org.custommonkey.xmlunit.XMLUnit; import org.junit.Assert; import org.junit.Before; import org.junit.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.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.validation.XmlValidator; - -import static org.custommonkey.xmlunit.XMLAssert.*; +import org.w3c.dom.Document; public abstract class AbstractXsdSchemaTestCase { diff --git a/spring-xml/src/test/java/org/springframework/xml/xsd/SimpleXsdSchemaTest.java b/spring-xml/src/test/java/org/springframework/xml/xsd/SimpleXsdSchemaTest.java index d06a5452..43725f3e 100644 --- a/spring-xml/src/test/java/org/springframework/xml/xsd/SimpleXsdSchemaTest.java +++ b/spring-xml/src/test/java/org/springframework/xml/xsd/SimpleXsdSchemaTest.java @@ -17,7 +17,6 @@ package org.springframework.xml.xsd; import org.junit.Test; - import org.springframework.core.io.Resource; public class SimpleXsdSchemaTest extends AbstractXsdSchemaTestCase { @@ -36,4 +35,4 @@ public class SimpleXsdSchemaTest extends AbstractXsdSchemaTestCase { schema.toString(); } -} \ No newline at end of file +} 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 ec4a8013..cf626d4e 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 @@ -16,6 +16,8 @@ package org.springframework.xml.xsd.commons; +import static org.custommonkey.xmlunit.XMLAssert.*; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -26,18 +28,15 @@ import org.custommonkey.xmlunit.XMLUnit; import org.junit.Assert; import org.junit.Before; import org.junit.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.springframework.xml.transform.TransformerFactoryUtils; import org.springframework.xml.validation.XmlValidator; import org.springframework.xml.xsd.AbstractXsdSchemaTestCase; -import org.springframework.xml.DocumentBuilderFactoryUtils; import org.springframework.xml.xsd.XsdSchema; - -import static org.custommonkey.xmlunit.XMLAssert.*; +import org.w3c.dom.Document; public class CommonsXsdSchemaCollectionTest { @@ -128,8 +127,7 @@ public class CommonsXsdSchemaCollectionTest { try { collection.afterPropertiesSet(); Assert.fail("CommonsXsdSchemaException expected"); - } - catch (CommonsXsdSchemaException ex) { + } catch (CommonsXsdSchemaException ex) { // expected } } @@ -151,7 +149,8 @@ public class CommonsXsdSchemaCollectionTest { transformer.transform(schemas[0].getSource(), domResult); assertXMLEqual("Invalid XSD generated", expected, (Document) domResult.getNode()); - Assert.assertEquals("Invalid target namespace", "http://mycompany.com/hr/schemas/holiday", schemas[1].getTargetNamespace()); + Assert.assertEquals("Invalid target namespace", "http://mycompany.com/hr/schemas/holiday", + schemas[1].getTargetNamespace()); Resource holiday = new ClassPathResource("holiday.xsd", getClass()); expected = documentBuilder.parse(SaxUtils.createInputSource(holiday)); domResult = new DOMResult(); @@ -159,4 +158,4 @@ public class CommonsXsdSchemaCollectionTest { assertXMLEqual("Invalid XSD generated", expected, (Document) domResult.getNode()); } -} \ No newline at end of file +} 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 5d4fc567..f7a690cc 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 @@ -16,23 +16,21 @@ package org.springframework.xml.xsd.commons; +import static org.junit.Assert.*; + import javax.xml.transform.dom.DOMSource; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaCollection; +import org.junit.Test; 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.apache.ws.commons.schema.XmlSchema; -import org.apache.ws.commons.schema.XmlSchemaCollection; -import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - public class CommonsXsdSchemaTest extends AbstractXsdSchemaTestCase { @Override @@ -55,5 +53,4 @@ public class CommonsXsdSchemaTest extends AbstractXsdSchemaTestCase { elementElement.getAttributeNS("http://www.w3.org/2005/05/xmlmime", "expectedContentTypes")); } - -} \ No newline at end of file +} diff --git a/spring-xml/src/test/resources/log4j.properties b/spring-xml/src/test/resources/log4j.properties index 17f4d6bf..8da72571 100644 --- a/spring-xml/src/test/resources/log4j.properties +++ b/spring-xml/src/test/resources/log4j.properties @@ -1,6 +1,5 @@ log4j.rootCategory=INFO, stdout log4j.logger.org.springframework.xml=DEBUG - log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/validation/encoding.xsd b/spring-xml/src/test/resources/org/springframework/xml/validation/encoding.xsd index db2fc5ee..2b0bd73e 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/validation/encoding.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/validation/encoding.xsd @@ -4,501 +4,501 @@ xmlns:tns="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://schemas.xmlsoap.org/soap/encoding/"> - - - - 'root' can be used to distinguish serialization roots from other - elements that are present in a serialization but are not roots of - a serialized value graph - - - - - - - - + + + + 'root' can be used to distinguish serialization roots from other + elements that are present in a serialization but are not roots of + a serialized value graph + + + + + + + + - - - - Attributes common to all elements that function as accessors or - represent independent (multi-ref) values. The href attribute is - intended to be used in a manner like CONREF. That is, the element - content should be empty iff the href attribute appears - - - - - - + + + + Attributes common to all elements that function as accessors or + represent independent (multi-ref) values. The href attribute is + intended to be used in a manner like CONREF. That is, the element + content should be empty iff the href attribute appears + + + + + + - + - + - - - + + + - - + + - - - - + + + + - + - - - + + + - - - - - + + + + + - - - - - 'Array' is a complex type for accessors identified by position - - - - - - + + + + + 'Array' is a complex type for accessors identified by position + + + + + + - - + - - - - - + + + + + - - - - + + + + - - - - + + + - - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - + diff --git a/spring-xml/src/test/resources/org/springframework/xml/validation/envelope.xsd b/spring-xml/src/test/resources/org/springframework/xml/validation/envelope.xsd index 39e3867f..669d3ec4 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/validation/envelope.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/validation/envelope.xsd @@ -5,87 +5,87 @@ targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"> - - - - - - - - - - + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - Prose in the spec does not specify that attributes are allowed on the Body element - - - - + + + + + + + + + Prose in the spec does not specify that attributes are allowed on the Body element + + + + - - - - - - - - - + + + + + + + + + - - - - 'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing - element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern - described in SOAP specification - - - - + + + + 'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing + element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern + described in SOAP specification + + + + - - - - + + + + - - - - - Fault reporting structure - - - - - - - - - + + + + + Fault reporting structure + + + + + + + + + - - - - - - + + + + + + diff --git a/spring-xml/src/test/resources/org/springframework/xml/validation/invalidDocument.xml b/spring-xml/src/test/resources/org/springframework/xml/validation/invalidDocument.xml index a7551338..8f55d77c 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/validation/invalidDocument.xml +++ b/spring-xml/src/test/resources/org/springframework/xml/validation/invalidDocument.xml @@ -1,4 +1,4 @@ - 20 + 20 \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/validation/multipleSchemas1.xsd b/spring-xml/src/test/resources/org/springframework/xml/validation/multipleSchemas1.xsd index 5d474711..f2f21204 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/validation/multipleSchemas1.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/validation/multipleSchemas1.xsd @@ -3,12 +3,12 @@ targetNamespace="http://www.springframework.org/spring-ws/test/multipleSchemas1" elementFormDefault="qualified"> - - - - - - - + + + + + + + diff --git a/spring-xml/src/test/resources/org/springframework/xml/validation/multipleSchemas2.xsd b/spring-xml/src/test/resources/org/springframework/xml/validation/multipleSchemas2.xsd index e6ecc97e..6154b530 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/validation/multipleSchemas2.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/validation/multipleSchemas2.xsd @@ -3,12 +3,12 @@ targetNamespace="http://www.springframework.org/spring-ws/test/multipleSchemas2" elementFormDefault="qualified"> - - - - - - - + + + + + + + diff --git a/spring-xml/src/test/resources/org/springframework/xml/validation/schema.xsd b/spring-xml/src/test/resources/org/springframework/xml/validation/schema.xsd index 60d338c5..aa045d49 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/validation/schema.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/validation/schema.xsd @@ -3,20 +3,20 @@ targetNamespace="http://www.springframework.org/spring-ws/test/validation" xmlns:tns="http://www.springframework.org/spring-ws/test/validation" elementFormDefault="qualified"> - + - - - - - - - + + + + + + + - - - - - - + + + + + + diff --git a/spring-xml/src/test/resources/org/springframework/xml/validation/validDocument.xml b/spring-xml/src/test/resources/org/springframework/xml/validation/validDocument.xml index ccd9449b..038fb547 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/validation/validDocument.xml +++ b/spring-xml/src/test/resources/org/springframework/xml/validation/validDocument.xml @@ -1,5 +1,5 @@ - 42 - 10 + 42 + 10 \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xpath/namespaces.xml b/spring-xml/src/test/resources/org/springframework/xml/xpath/namespaces.xml index bf3da70a..b8560778 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xpath/namespaces.xml +++ b/spring-xml/src/test/resources/org/springframework/xml/xpath/namespaces.xml @@ -1,8 +1,8 @@ - - text - 42.0 - 1 - + + text + 42.0 + 1 + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xpath/nonamespaces.xml b/spring-xml/src/test/resources/org/springframework/xml/xpath/nonamespaces.xml index 5072aac3..18aa5211 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xpath/nonamespaces.xml +++ b/spring-xml/src/test/resources/org/springframework/xml/xpath/nonamespaces.xml @@ -1,8 +1,8 @@ - - text - 42.0 - 1 - + + text + 42.0 + 1 + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/A.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/A.xsd index a2561e02..b4cc36d3 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/A.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/A.xsd @@ -3,10 +3,10 @@ targetNamespace="urn:1" xmlns:tns="urn:1" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - - - - + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/ABC.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/ABC.xsd index 0e7a89b3..03b6bfb7 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/ABC.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/ABC.xsd @@ -1,19 +1,19 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/B.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/B.xsd index cb797af5..cd8901d5 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/B.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/B.xsd @@ -3,12 +3,12 @@ targetNamespace="urn:1" xmlns="urn:1" xmlns:imported="urn:2" elementFormDefault="qualified"> - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/C.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/C.xsd index 932c8dcc..0db8b0be 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/C.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/C.xsd @@ -1,7 +1,7 @@ - - - + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/CD.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/CD.xsd index 0bb5b178..3be64e30 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/CD.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/CD.xsd @@ -1,10 +1,10 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/D.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/D.xsd index 0f15daf5..53e34154 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/D.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/D.xsd @@ -2,8 +2,8 @@ - - - - + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-1.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-1.xsd index 673bce49..f68976e2 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-1.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-1.xsd @@ -3,11 +3,11 @@ targetNamespace="urn:1" xmlns:tns="urn:1" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-2.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-2.xsd index 00015897..e57bc9d1 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-2.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-2.xsd @@ -3,8 +3,8 @@ targetNamespace="urn:1" xmlns:tns="urn:1" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - - + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-3.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-3.xsd index df7a3991..04d2967d 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-3.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/circular-3.xsd @@ -3,11 +3,11 @@ targetNamespace="urn:1" xmlns:tns="urn:1" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/employee.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/employee.xsd index b7e91690..6a48329b 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/employee.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/employee.xsd @@ -1,14 +1,13 @@ - - - - - - - + elementFormDefault="qualified" + targetNamespace="http://mycompany.com/hr/schemas"> + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/holiday.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/holiday.xsd index 3f16a51a..a42528c9 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/holiday.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/holiday.xsd @@ -1,14 +1,13 @@ - - - - - - + attributeFormDefault="unqualified" + elementFormDefault="qualified" + targetNamespace="http://mycompany.com/hr/schemas/holiday"> + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/hr.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/hr.xsd index fa13389a..4e97f493 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/hr.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/hr.xsd @@ -1,18 +1,18 @@ + xmlns:hr="http://mycompany.com/hr/schemas" + xmlns:hrh="http://mycompany.com/hr/schemas/holiday" + elementFormDefault="qualified" + targetNamespace="http://mycompany.com/hr/schemas"> - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/hr_employee.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/hr_employee.xsd index 4fb3e0a6..dcd435cf 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/hr_employee.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/commons/hr_employee.xsd @@ -1,25 +1,25 @@ + xmlns:hr="http://mycompany.com/hr/schemas" + xmlns:hrh="http://mycompany.com/hr/schemas/holiday" + attributeFormDefault="unqualified" + elementFormDefault="qualified" + targetNamespace="http://mycompany.com/hr/schemas"> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/imported.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/imported.xsd index 22dcb834..7e049d0b 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/imported.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/imported.xsd @@ -4,12 +4,12 @@ xmlns="http://www.springframework.org/spring-ws/imported/schema" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/importing.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/importing.xsd index 421f6aa7..5697d008 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/importing.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/importing.xsd @@ -4,14 +4,14 @@ xmlns="http://www.springframework.org/spring-ws/importing/schema" elementFormDefault="qualified" attributeFormDefault="unqualified"> - + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/included.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/included.xsd index fc508ca7..8b026ae7 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/included.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/included.xsd @@ -4,12 +4,12 @@ xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/including.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/including.xsd index 78dd1daf..5dc61670 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/including.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/including.xsd @@ -4,15 +4,15 @@ xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified" attributeFormDefault="unqualified"> - + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/invalid.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/invalid.xsd index f4fef802..340ad67e 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/invalid.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/invalid.xsd @@ -3,12 +3,12 @@ targetNamespace="urn:1" xmlns="urn:1" xmlns:imported="urn:2" elementFormDefault="qualified"> - - - - - - - - + + + + + + + + diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/single.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/single.xsd index df338465..6499a86e 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/single.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/single.xsd @@ -4,32 +4,32 @@ xmlns="http://www.springframework.org/spring-ws/single/schema" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/xmime.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/xmime.xsd index 394b4871..9be9489b 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/xmime.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/xmime.xsd @@ -6,6 +6,6 @@ attributeFormDefault="unqualified" xmlns:xmime="http://www.w3.org/2005/05/xmlmime"> - + diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/xml.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/xml.xsd index aea7d0db..fa64417a 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/xml.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/xml.xsd @@ -1,287 +1,321 @@ - + - - -

    -

    About the XML namespace

    + + +
    +

    About the XML namespace

    -
    -

    - This schema document describes the XML namespace, in a form - suitable for import by other schema documents. -

    -

    - See - http://www.w3.org/XML/1998/namespace.html and - - http://www.w3.org/TR/REC-xml for information - about this namespace. -

    -

    - Note that local names in this namespace are intended to be - defined only by the World Wide Web Consortium or its subgroups. - The names currently defined in this namespace are listed below. - They should not be used with conflicting semantics by any Working - Group, specification, or document instance. -

    -

    - See further below in this document for more information about how to refer to this schema document from your own - XSD schema documents and about the - namespace-versioning policy governing this schema document. -

    -
    -
    -
    -
    +
    +

    + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. +

    +

    + See + http://www.w3.org/XML/1998/namespace.html + and + + http://www.w3.org/TR/REC-xml + + for information + about this namespace. +

    +

    + Note that local names in this namespace are intended to be + defined only by the World Wide Web Consortium or its subgroups. + The names currently defined in this namespace are listed below. + They should not be used with conflicting semantics by any Working + Group, specification, or document instance. +

    +

    + See further below in this document for more information about how to refer to this schema document from your own + XSD schema documents + and about the + namespace-versioning policy governing this schema document. +

    +
    +
    + + - - - -
    - -

    lang (as an attribute name)

    -

    - denotes an attribute whose value - is a language code for the natural language of the content of - any element; its value is inherited. This name is reserved - by virtue of its definition in the XML specification.

    - -
    -
    -

    Notes

    -

    - Attempting to install the relevant ISO 2- and 3-letter - codes as the enumerated possible values is probably never - going to be a realistic possibility. -

    -

    - See BCP 47 at - http://www.rfc-editor.org/rfc/bcp/bcp47.txt - and the IANA language subtag registry at - - http://www.iana.org/assignments/language-subtag-registry - for further information. -

    -

    - The union allows for the 'un-declaration' of xml:lang with - the empty string. -

    -
    -
    -
    - - - - - - - - - -
    + + + +
    - - - -
    - -

    space (as an attribute name)

    -

    - denotes an attribute whose - value is a keyword indicating what whitespace processing - discipline is intended for the content of the element; its - value is inherited. This name is reserved by virtue of its - definition in the XML specification.

    - -
    -
    -
    - - - - - - -
    - - - -
    - -

    base (as an attribute name)

    -

    - denotes an attribute whose value - provides a URI to be used as the base for interpreting any - relative URIs in the scope of the element on which it - appears; its value is inherited. This name is reserved - by virtue of its definition in the XML Base specification.

    - -

    - See http://www.w3.org/TR/xmlbase/ - for information about this attribute. -

    -
    -
    -
    -
    - - - - -
    - -

    id (as an attribute name)

    -

    - denotes an attribute whose value - should be interpreted as if declared to be of type ID. - This name is reserved by virtue of its definition in the - xml:id specification.

    - -

    - See http://www.w3.org/TR/xml-id/ - for information about this attribute. -

    -
    -
    -
    -
    +

    lang (as an attribute name)

    +

    + denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. +

    - - - - - - +
    +
    +

    Notes

    +

    + Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. +

    +

    + See BCP 47 at + + http://www.rfc-editor.org/rfc/bcp/bcp47.txt + + and the IANA language subtag registry at + + http://www.iana.org/assignments/language-subtag-registry + + for further information. +

    +

    + The union allows for the 'un-declaration' of xml:lang with + the empty string. +

    +
    +
    +
    + + + + + + + + + +
    - - -
    - -

    Father (in any context at all)

    + + + +
    -
    -

    - denotes Jon Bosak, the chair of - the original XML Working Group. This name is reserved by - the following decision of the W3C XML Plenary and - XML Coordination groups: -

    -
    -

    - In appreciation for his vision, leadership and - dedication the W3C XML Plenary on this 10th day of - February, 2000, reserves for Jon Bosak in perpetuity - the XML name "xml:Father". -

    -
    -
    -
    -
    -
    +

    space (as an attribute name)

    +

    + denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. +

    - - - + + + + + + + + +
    -
    -

    - This schema defines attributes and an attribute group suitable - for use by schemas wishing to allow xml:base, - xml:lang, xml:space or - xml:id attributes on elements they define. -

    -

    - To enable this, such a schema must import this schema for - the XML namespace, e.g. as follows: -

    -
    -          <schema . . .>
    -           . . .
    -           <import namespace="http://www.w3.org/XML/1998/namespace"
    -                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
    -     
    -

    - or -

    -
    -           <import namespace="http://www.w3.org/XML/1998/namespace"
    -                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
    -     
    -

    - Subsequently, qualified reference to any of the attributes or the - group defined below will have the desired effect, e.g. -

    -
    -          <type . . .>
    -           . . .
    -           <attributeGroup ref="xml:specialAttrs"/>
    -     
    -

    - will define a type which will schema-validate an instance element - with any of those attributes. -

    -
    -
    -
    -
    + + + +
    - - -
    -

    Versioning policy for this schema document

    -
    -

    - In keeping with the XML Schema WG's standard versioning - policy, this schema document will persist at - - http://www.w3.org/2009/01/xml.xsd. -

    -

    - At the date of issue it can also be found at - - http://www.w3.org/2001/xml.xsd. -

    -

    - The schema document at that URI may however change in the future, - in order to remain compatible with the latest version of XML - Schema itself, or with the XML namespace itself. In other words, - if the XML Schema or XML namespaces change, the version of this - document at - http://www.w3.org/2001/xml.xsd - - will change accordingly; the version at - - http://www.w3.org/2009/01/xml.xsd - - will not change. -

    -

    - Previous dated (and unchanging) versions of this schema - document are at: -

    - -
    -
    -
    -
    +

    base (as an attribute name)

    +

    + denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. +

    + +

    + See + http://www.w3.org/TR/xmlbase/ + + for information about this attribute. +

    +
    +
    +
    +
    + + + + +
    + +

    id (as an attribute name)

    +

    + denotes an attribute whose value + should be interpreted as if declared to be of type ID. + This name is reserved by virtue of its definition in the + xml:id specification. +

    + +

    + See + http://www.w3.org/TR/xml-id/ + + for information about this attribute. +

    +
    +
    +
    +
    + + + + + + + + + + +
    + +

    Father (in any context at all)

    + +
    +

    + denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: +

    +
    +

    + In appreciation for his vision, leadership and + dedication the W3C XML Plenary on this 10th day of + February, 2000, reserves for Jon Bosak in perpetuity + the XML name "xml:Father". +

    +
    +
    +
    +
    +
    + + + +
    +

    + About this schema document +

    + +
    +

    + This schema defines attributes and an attribute group suitable + for use by schemas wishing to allow xml:base, + xml:lang, xml:space or + xml:id + attributes on elements they define. +

    +

    + To enable this, such a schema must import this schema for + the XML namespace, e.g. as follows: +

    +
    +						<schema . . .>
    +						. . .
    +						<import namespace="http://www.w3.org/XML/1998/namespace"
    +						schemaLocation="http://www.w3.org/2001/xml.xsd"/>
    +					
    +

    + or +

    +
    +						<import namespace="http://www.w3.org/XML/1998/namespace"
    +						schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
    +					
    +

    + Subsequently, qualified reference to any of the attributes or the + group defined below will have the desired effect, e.g. +

    +
    +						<type . . .>
    +						. . .
    +						<attributeGroup ref="xml:specialAttrs"/>
    +					
    +

    + will define a type which will schema-validate an instance element + with any of those attributes. +

    +
    +
    +
    +
    + + + +
    +

    + Versioning policy for this schema document +

    +
    +

    + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + + http://www.w3.org/2009/01/xml.xsd. +

    +

    + At the date of issue it can also be found at + + http://www.w3.org/2001/xml.xsd. +

    +

    + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML + Schema itself, or with the XML namespace itself. In other words, + if the XML Schema or XML namespaces change, the version of this + document at + + http://www.w3.org/2001/xml.xsd + + will change accordingly; the version at + + http://www.w3.org/2009/01/xml.xsd + + will not change. +

    +

    + Previous dated (and unchanging) versions of this schema + document are at: +

    + +
    +
    +
    +
    diff --git a/spring-xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd b/spring-xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd index a94f7491..79b8b5ec 100644 --- a/spring-xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd +++ b/spring-xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd @@ -4,15 +4,15 @@ xmlns="http://www.springframework.org/spring-ws/xmlNamespace" elementFormDefault="qualified" attributeFormDefault="unqualified"> - + - - - - - - - - + + + + + + + + \ No newline at end of file