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.openejb.server.webservices.saaj;
17:
18: import junit.framework.TestCase;
19:
20: import javax.xml.soap.MessageFactory;
21:
22: public class SaajUniverseTest extends TestCase {
23: private static final String SUN_MESSAGE_CLASS = "com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl";
24:
25: private static final String AXIS1_MESSAGE_CLASS = "org.apache.axis.Message";
26:
27: private static final String DEFAULT_MESSAGE_CLASS = SUN_MESSAGE_CLASS;
28:
29: public void testBasic() throws Exception {
30: // case 1, universe not set
31: //assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
32:
33: // case 2, default universe set
34: SaajUniverse u = new SaajUniverse();
35: u.set(SaajUniverse.DEFAULT);
36: assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory
37: .newInstance().createMessage().getClass().getName());
38: u.unset();
39:
40: // case 3, Sun universe set
41: u.set(SaajUniverse.SUN);
42: assertEquals(SUN_MESSAGE_CLASS, MessageFactory.newInstance()
43: .createMessage().getClass().getName());
44: u.unset();
45:
46: // case 4, Axis1 universe set
47: u.set(SaajUniverse.AXIS1);
48: assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance()
49: .createMessage().getClass().getName());
50: u.unset();
51: }
52:
53: public void testNested() throws Exception {
54: assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory
55: .newInstance().createMessage().getClass().getName());
56:
57: SaajUniverse u = new SaajUniverse();
58:
59: // set axis1
60: u.set(SaajUniverse.AXIS1);
61: assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance()
62: .createMessage().getClass().getName());
63:
64: // set sun, nested
65: u.set(SaajUniverse.SUN);
66: assertEquals(SUN_MESSAGE_CLASS, MessageFactory.newInstance()
67: .createMessage().getClass().getName());
68:
69: // unset sun
70: u.unset();
71:
72: // should be axis
73: assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance()
74: .createMessage().getClass().getName());
75:
76: u.unset();
77:
78: assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory
79: .newInstance().createMessage().getClass().getName());
80: }
81:
82: }
|