1   /*
2    * Copyright 2005-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.ws.server.endpoint;
18  
19  import org.dom4j.Document;
20  import org.dom4j.Element;
21  
22  import static org.junit.Assert.*;
23  
24  public class Dom4jPayloadEndpointTest extends AbstractPayloadEndpointTestCase {
25  
26      @Override
27      protected PayloadEndpoint createResponseEndpoint() {
28          return new AbstractDom4jPayloadEndpoint() {
29  
30              @Override
31              protected Element invokeInternal(Element requestElement, Document responseDocument) throws Exception {
32                  assertNotNull("No requestElement passed", requestElement);
33                  assertNotNull("No responseDocument passed", responseDocument);
34                  assertEquals("Invalid request element", REQUEST_ELEMENT, requestElement.getName());
35                  assertEquals("Invalid request element", NAMESPACE_URI, requestElement.getNamespaceURI());
36                  return responseDocument.addElement(RESPONSE_ELEMENT, NAMESPACE_URI);
37              }
38          };
39      }
40  
41      @Override
42      protected PayloadEndpoint createNoResponseEndpoint() throws Exception {
43          return new AbstractDom4jPayloadEndpoint() {
44  
45              @Override
46              protected Element invokeInternal(Element requestElement, Document responseDocument) throws Exception {
47                  return null;
48              }
49          };
50      }
51  
52      @Override
53      protected PayloadEndpoint createNoRequestEndpoint() throws Exception {
54          return new AbstractDom4jPayloadEndpoint() {
55  
56              @Override
57              protected Element invokeInternal(Element requestElement, Document responseDocument) throws Exception {
58                  assertNull("RequestElement passed", requestElement);
59                  return null;
60              }
61          };
62      }
63  
64  
65  }