KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > functional > TestMimeHeaders


1 package test.functional;
2
3 import javax.xml.messaging.URLEndpoint;
4 import javax.xml.soap.MessageFactory JavaDoc;
5 import javax.xml.soap.SOAPConnection JavaDoc;
6 import javax.xml.soap.SOAPConnectionFactory JavaDoc;
7 import javax.xml.soap.SOAPMessage JavaDoc;
8
9 import junit.framework.TestCase;
10
11 /**
12  * Test MIME headers.
13  */

14 public class TestMimeHeaders extends TestCase {
15
16     public TestMimeHeaders(String JavaDoc s) {
17         super(s);
18     }
19
20     public void testTransferMimeHeadersToHttpHeaders() throws Exception JavaDoc {
21         SOAPConnectionFactory JavaDoc scFactory = SOAPConnectionFactory.newInstance();
22         SOAPConnection JavaDoc con = scFactory.createConnection();
23
24         MessageFactory JavaDoc factory = MessageFactory.newInstance();
25         SOAPMessage JavaDoc message = factory.createMessage();
26         String JavaDoc headerName = "foo";
27         String JavaDoc headerValue = "bar";
28         message.getMimeHeaders().addHeader(headerName, headerValue);
29
30         URLEndpoint endpoint = new URLEndpoint("http://localhost:8080/axis/services/TestMimeHeaderService");
31         SOAPMessage JavaDoc response = con.call(message, endpoint);
32         String JavaDoc[] responseHeader = response.getMimeHeaders().getHeader(headerName);
33         assertTrue("Response header was null", responseHeader != null);
34         assertEquals("ResponseHeader.length wasn't 1", 1, responseHeader.length);
35         assertEquals("Header value didn't match", headerValue, responseHeader[0]);
36     }
37 }
38
Popular Tags