1
package org.jboss.test.remoting.transport.http.ssl.custom;
3
import junit.framework.TestCase;
4
import org.jboss.remoting.Client;
5
import org.jboss.remoting.InvokerLocator;
6
import org.jboss.remoting.security.SSLSocketBuilder;
7
import org.jboss.remoting.transport.web.WebUtil;
8
import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer;
9
import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants;
10
import org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestServer;
11
import org.jboss.test.remoting.transport.web.ComplexObject;
13
import java.util.HashMap;
15
import java.util.Properties;
18
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
20
public class CustomHTTPSInvokerTestClient extends TestCase implements SSLInvokerConstants
22
public void testInvocation() throws Exception
24
Client remotingClient = null;
27
Map config = new HashMap();
28
config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
29
String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile();
30
config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
31
config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");
33
String locatorURI = transport + "://" + host + ":" + port;
34
InvokerLocator locator = new InvokerLocator(locatorURI);
35
System.out.println("Calling remoting server with locator uri of: " + locatorURI);
37
// This could have been new Client(locator), but want to show that subsystem param is null
38
// Could have also been new Client(locator, "sample");
39
remotingClient = new Client(locator, config);
40
remotingClient.connect();
42
Map metadata = new HashMap();
43
metadata.put(Client.RAW, Boolean.TRUE);
44
metadata.put("TYPE", "POST");
46
Properties headerProps = new Properties();
47
headerProps.put("SOAPAction", "http://www.example.com/fibonacci");
48
headerProps.put("Content-type", "application/soap+xml");
50
metadata.put("HEADER", headerProps);
52
Object response = null;
54
// test with null return expected
55
response = remotingClient.invoke(HTTPInvokerTestServer.NULL_RETURN_PARAM, metadata);
59
response = remotingClient.invoke("Do something", metadata);
61
assertEquals(HTTPInvokerTestServer.RESPONSE_VALUE, response);
63
// test with small object
64
headerProps.put("Content-type", WebUtil.BINARY);
65
response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata);
67
assertEquals(org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestServer.OBJECT_RESPONSE_VALUE, response);
69
// test with large object
70
response = remotingClient.invoke(new ComplexObject(2, "foo", true, 8000), metadata);
72
assertEquals(HTTPSInvokerTestServer.LARGE_OBJECT_RESPONSE_VALUE, response);
75
catch(Throwable throwable)
77
throw new Exception(throwable);
81
if(remotingClient != null)
83
remotingClient.disconnect();