KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > itests > HttpJmsRoundtripTest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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  */

17 package org.apache.servicemix.itests;
18
19 import java.io.ByteArrayOutputStream JavaDoc;
20 import java.io.InputStream JavaDoc;
21 import java.io.OutputStream JavaDoc;
22 import java.net.URL JavaDoc;
23 import java.net.URLConnection JavaDoc;
24
25 import org.apache.servicemix.jbi.util.FileUtil;
26 import org.apache.servicemix.tck.SpringTestSupport;
27 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
28 import org.springframework.context.support.AbstractXmlApplicationContext;
29
30 public class HttpJmsRoundtripTest extends SpringTestSupport {
31
32     @Override JavaDoc
33     protected AbstractXmlApplicationContext createBeanFactory() {
34         return new ClassPathXmlApplicationContext("org/apache/servicemix/itests/httpjms.xml");
35     }
36     
37     public void test() throws Exception JavaDoc {
38         URLConnection JavaDoc connection = new URL JavaDoc("http://localhost:8192/Service/").openConnection();
39         connection.setDoOutput(true);
40         connection.setDoInput(true);
41         OutputStream JavaDoc os = connection.getOutputStream();
42         // Post the request file.
43
InputStream JavaDoc fis = getClass().getResourceAsStream("soap-request.xml");
44         FileUtil.copyInputStream(fis, os);
45         // Read the response.
46
InputStream JavaDoc is = connection.getInputStream();
47         ByteArrayOutputStream JavaDoc baos = new ByteArrayOutputStream JavaDoc();
48         FileUtil.copyInputStream(is, baos);
49         System.err.println(baos.toString());
50     }
51
52 }
53
Popular Tags