01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.webservices.saaj;
17:
18: import javax.xml.soap.MessageFactory;
19:
20: import org.apache.geronimo.testsupport.TestSupport;
21:
22: public class SAAJUniverseTest extends TestSupport {
23:
24: private static final String SUN_MESSAGE_CLASS = "com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl";
25:
26: private static final String AXIS1_MESSAGE_CLASS = "org.apache.axis.Message";
27:
28: private static final String DEFAULT_MESSAGE_CLASS = SUN_MESSAGE_CLASS;
29:
30: public void testBasic() throws Exception {
31: SAAJGBean b = new SAAJGBean();
32: b.doStart();
33:
34: // case 1, universe not set
35: assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory
36: .newInstance().createMessage().getClass().getName());
37:
38: // case 2, default universe set
39: SAAJUniverse u = new SAAJUniverse();
40: u.set(SAAJUniverse.DEFAULT);
41: assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory
42: .newInstance().createMessage().getClass().getName());
43: u.unset();
44:
45: // case 3, Sun universe set
46: u.set(SAAJUniverse.SUN);
47: assertEquals(SUN_MESSAGE_CLASS, MessageFactory.newInstance()
48: .createMessage().getClass().getName());
49: u.unset();
50:
51: // case 4, Axis1 universe set
52: u.set(SAAJUniverse.AXIS1);
53: assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance()
54: .createMessage().getClass().getName());
55: u.unset();
56: }
57:
58: public void testNested() throws Exception {
59: SAAJGBean b = new SAAJGBean();
60: b.doStart();
61:
62: assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory
63: .newInstance().createMessage().getClass().getName());
64:
65: SAAJUniverse u = new SAAJUniverse();
66:
67: // set axis1
68: u.set(SAAJUniverse.AXIS1);
69: assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance()
70: .createMessage().getClass().getName());
71:
72: // set sun, nested
73: u.set(SAAJUniverse.SUN);
74: assertEquals(SUN_MESSAGE_CLASS, MessageFactory.newInstance()
75: .createMessage().getClass().getName());
76:
77: // unset sun
78: u.unset();
79:
80: // should be axis
81: assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance()
82: .createMessage().getClass().getName());
83:
84: u.unset();
85:
86: assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory
87: .newInstance().createMessage().getClass().getName());
88: }
89:
90: }
|