1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.server.endpoint.adapter.method.dom;
18
19 import org.springframework.core.MethodParameter;
20 import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadMethodProcessorTestCase;
21 import org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadSourceMethodProcessor;
22 import org.springframework.ws.server.endpoint.annotation.RequestPayload;
23 import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
24
25 import org.jdom2.Element;
26
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.assertTrue;
29
30 public class JDomPayloadMethodProcessorTest extends AbstractPayloadMethodProcessorTestCase {
31
32 @Override
33 protected AbstractPayloadSourceMethodProcessor createProcessor() {
34 return new JDomPayloadMethodProcessor();
35 }
36
37 @Override
38 protected MethodParameter[] createSupportedParameters() throws NoSuchMethodException {
39 return new MethodParameter[]{new MethodParameter(getClass().getMethod("element", Element.class), 0)};
40 }
41
42 @Override
43 protected MethodParameter[] createSupportedReturnTypes() throws NoSuchMethodException {
44 return new MethodParameter[]{new MethodParameter(getClass().getMethod("element", Element.class), -1)};
45 }
46
47 @Override
48 protected void testArgument(Object argument, MethodParameter parameter) {
49 assertTrue("argument not a element", argument instanceof Element);
50 Element node = (Element) argument;
51 assertEquals("Invalid namespace", NAMESPACE_URI, node.getNamespaceURI());
52 assertEquals("Invalid local name", LOCAL_NAME, node.getName());
53 }
54
55 @Override
56 protected Element getReturnValue(MethodParameter returnType) {
57 return new Element(LOCAL_NAME, NAMESPACE_URI);
58 }
59
60 @ResponsePayload
61 public Element element(@RequestPayload Element element) {
62 return element;
63 }
64 }