1 7 package org.jboss.test.remoting.transport.http.ssl.basic; 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 31 try 32 { 33 String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); 36 System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); 37 System.setProperty(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); 39 40 String locatorURI = transport + "://" + host + ":" + port; 41 InvokerLocator locator = new InvokerLocator(locatorURI); 42 System.out.println("Calling remoting server with locator uri of: " + locatorURI); 43 44 remotingClient = new Client(locator); 45 46 Map metadata = new HashMap (); 47 metadata.put(Client.RAW, Boolean.TRUE); 48 metadata.put("TYPE", "POST"); 49 50 Properties headerProps = new Properties (); 51 headerProps.put("SOAPAction", "http://www.example.com/fibonacci"); 52 headerProps.put("Content-type", "application/soap+xml"); 53 54 metadata.put("HEADER", headerProps); 55 56 Object response = null; 57 58 response = remotingClient.invoke(HTTPInvokerTestServer.NULL_RETURN_PARAM, metadata); 60 61 assertNull(response); 62 63 response = remotingClient.invoke("Do something", metadata); 64 65 assertEquals(HTTPInvokerTestServer.RESPONSE_VALUE, response); 66 67 headerProps.put("Content-type", HTTPServerInvoker.BINARY); 68 response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata); 69 70 assertEquals(HTTPInvokerTestServer.OBJECT_RESPONSE_VALUE, response); 71 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 |