KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > functional > TestJWSGlobalTypes


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
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 /**
18  * @author Glen Daniels (gdaniels@apache.org)
19  */

20 package test.functional;
21
22 import junit.framework.TestCase;
23 import org.apache.axis.client.AdminClient;
24 import org.apache.axis.client.Call;
25 import org.apache.axis.deployment.wsdd.WSDDConstants;
26 import org.apache.axis.encoding.ser.BeanDeserializerFactory;
27 import org.apache.axis.encoding.ser.BeanSerializerFactory;
28 import org.apache.axis.utils.Options;
29
30 import javax.xml.namespace.QName JavaDoc;
31 import java.io.ByteArrayInputStream JavaDoc;
32
33 public class TestJWSGlobalTypes extends TestCase {
34     private static final String JavaDoc TYPEMAPPING_WSDD =
35             "<deployment xmlns=\"" + WSDDConstants.URI_WSDD + "\" " +
36                         "xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\" " +
37                         "xmlns:ns=\"http://globalTypeTest\">\n" +
38             " <beanMapping type=\"java:test.functional.GlobalBean\" " +
39                         "qname=\"ns:GlobalType\"/>\n" +
40             "</deployment>";
41
42     public TestJWSGlobalTypes(String JavaDoc s) {
43         super(s);
44     }
45
46     protected void setUp() throws Exception JavaDoc {
47         // Deploy the type mapping
48
AdminClient client = new AdminClient();
49         Options opts = new Options(null);
50         ByteArrayInputStream JavaDoc bis =
51                 new ByteArrayInputStream JavaDoc(TYPEMAPPING_WSDD.getBytes());
52         client.process(opts, bis);
53     }
54
55     public void testGlobalTypes() throws Exception JavaDoc {
56         Call call = new Call("http://localhost:8080/jws/GlobalTypeTest.jws");
57         QName JavaDoc qname = new QName JavaDoc("http://globalTypeTest", "GlobalType");
58         call.registerTypeMapping(GlobalBean.class, qname,
59                     new BeanSerializerFactory(GlobalBean.class, qname),
60                     new BeanDeserializerFactory(GlobalBean.class, qname));
61         GlobalBean bean = new GlobalBean();
62         bean.setIntValue(4);
63         GlobalBean ret = (GlobalBean)call.invoke("echo", new Object JavaDoc [] { bean });
64         assertEquals(4, ret.getIntValue());
65     }
66 }
67
Popular Tags