1 7 package org.jboss.test.remoting.transport.http.ssl.custom; 8 9 import java.util.HashMap ; 10 import java.util.Map ; 11 import java.util.Properties ; 12 import org.jboss.remoting.Client; 13 import org.jboss.remoting.InvokerLocator; 14 import org.jboss.remoting.transport.http.HTTPServerInvoker; 15 import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; 16 import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; 17 import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants; 18 import org.jboss.test.remoting.transport.web.ComplexObject; 19 20 import junit.framework.TestCase; 21 22 25 public class HTTPSInvokerTestClient extends TestCase implements SSLInvokerConstants 26 { 27 public void testInvocation() throws Exception 28 { 29 Client remotingClient = null; 30 try 31 { 32 String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); 35 System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); 36 System.setProperty(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); 38 39 String locatorURI = transport + "://" + host + ":" + port; 40 InvokerLocator locator = new InvokerLocator(locatorURI); 41 System.out.println("Calling remoting server with locator uri of: " + locatorURI); 42 43 remotingClient = new Client(locator, null); 46 47 Map metadata = new HashMap (); 48 metadata.put(Client.RAW, Boolean.TRUE); 49 metadata.put("TYPE", "POST"); 50 51 Properties headerProps = new Properties (); 52 headerProps.put("SOAPAction", "http://www.example.com/fibonacci"); 53 headerProps.put("Content-type", "application/soap+xml"); 54 55 metadata.put("HEADER", headerProps); 56 57 Object response = null; 58 59 response = remotingClient.invoke(HTTPInvokerTestServer.NULL_RETURN_PARAM, metadata); 61 62 assertNull(response); 63 64 response = remotingClient.invoke("Do something", metadata); 65 66 assertEquals(HTTPInvokerTestServer.RESPONSE_VALUE, response); 67 68 headerProps.put("Content-type", HTTPServerInvoker.BINARY); 69 response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata); 70 71 assertEquals(HTTPInvokerTestServer.OBJECT_RESPONSE_VALUE, response); 72 } 73 catch(Throwable throwable) 74 { 75 throw new Exception (throwable); 76 } 77 finally 78 { 79 if(remotingClient != null) 80 { 81 remotingClient.disconnect(); 82 } 83 } 84 85 86 } 87 88 89 } | Popular Tags |