1   /*
2    * Copyright 2007 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.soap;
18  
19  import java.util.Iterator;
20  import javax.xml.namespace.QName;
21  import javax.xml.transform.Transformer;
22  import javax.xml.transform.TransformerFactory;
23  
24  import org.custommonkey.xmlunit.XMLTestCase;
25  
26  public abstract class AbstractSoapElementTestCase extends XMLTestCase {
27  
28      private SoapElement soapElement;
29  
30      protected Transformer transformer;
31  
32      protected final void setUp() throws Exception {
33          TransformerFactory transformerFactory = TransformerFactory.newInstance();
34          transformer = transformerFactory.newTransformer();
35          soapElement = createSoapElement();
36      }
37  
38      protected abstract SoapElement createSoapElement() throws Exception;
39  
40      public void testAttributes() throws Exception {
41          QName name = new QName("http://springframework.org/spring-ws", "attribute");
42          String value = "value";
43          soapElement.addAttribute(name, value);
44          assertEquals("Invalid attribute value", value, soapElement.getAttributeValue(name));
45          Iterator allAttributes = soapElement.getAllAttributes();
46          assertTrue("Iterator is empty", allAttributes.hasNext());
47      }
48  
49      public void testAddNamespaceDeclaration() throws Exception {
50          String prefix = "p";
51          String namespace = "http://springframework.org/spring-ws";
52          soapElement.addNamespaceDeclaration(prefix, namespace);
53      }
54  
55      public void testAddDefaultNamespaceDeclaration() throws Exception {
56          String prefix = "";
57          String namespace = "http://springframework.org/spring-ws";
58          soapElement.addNamespaceDeclaration(prefix, namespace);
59      }
60  
61  
62  }