01: /*
02: * Copyright 2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.server.endpoint;
18:
19: import java.util.Locale;
20: import javax.xml.namespace.QName;
21:
22: import junit.framework.TestCase;
23:
24: public class SoapFaultDefinitionEditorTest extends TestCase {
25:
26: private SoapFaultDefinitionEditor editor;
27:
28: protected void setUp() throws Exception {
29: editor = new SoapFaultDefinitionEditor();
30: }
31:
32: public void testSetAsTextNoLocale() throws Exception {
33: editor.setAsText("Server, Server error");
34: SoapFaultDefinition definition = (SoapFaultDefinition) editor
35: .getValue();
36: assertNotNull("fault not set", definition);
37: assertEquals("Invalid fault code", new QName("Server"),
38: definition.getFaultCode());
39: assertEquals("Invalid fault string", "Server error", definition
40: .getFaultStringOrReason());
41: assertEquals("Invalid fault string locale", Locale.ENGLISH,
42: definition.getLocale());
43: }
44:
45: public void testSetAsTextLocale() throws Exception {
46: editor.setAsText("Server, Server error, nl");
47: SoapFaultDefinition definition = (SoapFaultDefinition) editor
48: .getValue();
49: assertNotNull("fault not set", definition);
50: assertEquals("Invalid fault code", new QName("Server"),
51: definition.getFaultCode());
52: assertEquals("Invalid fault string", "Server error", definition
53: .getFaultStringOrReason());
54: assertEquals("Invalid fault string locale", new Locale("nl"),
55: definition.getLocale());
56: }
57:
58: public void testSetAsTextSender() throws Exception {
59: editor.setAsText("SENDER, Server error");
60: SoapFaultDefinition definition = (SoapFaultDefinition) editor
61: .getValue();
62: assertNotNull("fault not set", definition);
63: assertEquals("Invalid fault code", SoapFaultDefinition.SENDER,
64: definition.getFaultCode());
65: assertEquals("Invalid fault string", "Server error", definition
66: .getFaultStringOrReason());
67: }
68:
69: public void testSetAsTextReceiver() throws Exception {
70: editor.setAsText("RECEIVER, Server error");
71: SoapFaultDefinition definition = (SoapFaultDefinition) editor
72: .getValue();
73: assertNotNull("fault not set", definition);
74: assertEquals("Invalid fault code",
75: SoapFaultDefinition.RECEIVER, definition.getFaultCode());
76: assertEquals("Invalid fault string", "Server error", definition
77: .getFaultStringOrReason());
78: }
79:
80: public void testSetAsTextIllegalArgument() throws Exception {
81: try {
82: editor.setAsText("SOAP-ENV:Server");
83: } catch (IllegalArgumentException ex) {
84: }
85: }
86:
87: public void testSetAsTextEmpty() throws Exception {
88: editor.setAsText("");
89: assertNull("definition not set to null", editor.getValue());
90: }
91: }
|