01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.xmlhttp.clientTests.dispatch.datasource;
20:
21: import java.awt.Image;
22: import java.io.File;
23:
24: import javax.activation.DataSource;
25: import javax.imageio.ImageIO;
26: import javax.imageio.stream.FileImageInputStream;
27: import javax.imageio.stream.ImageInputStream;
28: import javax.xml.namespace.QName;
29: import javax.xml.ws.Dispatch;
30: import javax.xml.ws.Service;
31: import javax.xml.ws.http.HTTPBinding;
32:
33: import org.apache.axis2.jaxws.provider.DataSourceImpl;
34:
35: import junit.framework.TestCase;
36:
37: public class DispatchXMessageDataSource extends TestCase {
38:
39: public String HOSTPORT = "http://localhost:8080";
40:
41: private String ENDPOINT_URL = HOSTPORT
42: + "/axis2/services/XMessageDataSourceProvider";
43: private QName SERVICE_NAME = new QName(
44: "http://ws.apache.org/axis2", "XMessageDataSourceProvider");
45: private QName PORT_NAME = new QName("http://ws.apache.org/axis2",
46: "XMessageDataSourceProviderPort");
47:
48: private DataSource imageDS;
49:
50: public void setUp() throws Exception {
51: String imageResourceDir = System.getProperty("basedir", ".")
52: + "/" + "test-resources" + File.separator + "image";
53:
54: //Create a DataSource from an image
55: File file = new File(imageResourceDir + File.separator
56: + "test.jpg");
57: ImageInputStream fiis = new FileImageInputStream(file);
58: Image image = ImageIO.read(fiis);
59: imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
60: }
61:
62: public Dispatch<DataSource> getDispatch() {
63: Service service = Service.create(SERVICE_NAME);
64: service.addPort(PORT_NAME, HTTPBinding.HTTP_BINDING,
65: ENDPOINT_URL);
66: Dispatch<DataSource> dispatch = service.createDispatch(
67: PORT_NAME, DataSource.class, Service.Mode.MESSAGE);
68: return dispatch;
69: }
70:
71: /**
72: * Simple XML/HTTP Message Test
73: * @throws Exception
74: */
75: public void testSimple() throws Exception {
76: Dispatch<DataSource> dispatch = getDispatch();
77: DataSource request = imageDS;
78:
79: // TODO NOT IMPLEMENTED
80:
81: //DataSource response = dispatch.invoke(request);
82: //assertTrue(response != null);
83: //assertTrue(request.equals(response));
84: }
85: }
|