~ubuntu-branches/ubuntu/wily/libjboss-remoting-java/wily

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/transport/http/ssl/custom/CustomHTTPSInvokerTestClient.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.jboss.test.remoting.transport.http.ssl.custom;
 
2
 
 
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;
 
12
 
 
13
import java.util.HashMap;
 
14
import java.util.Map;
 
15
import java.util.Properties;
 
16
 
 
17
/**
 
18
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
19
 */
 
20
public class CustomHTTPSInvokerTestClient extends TestCase implements SSLInvokerConstants
 
21
{
 
22
   public void testInvocation() throws Exception
 
23
   {
 
24
      Client remotingClient = null;
 
25
      try
 
26
      {
 
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");
 
32
 
 
33
         String locatorURI = transport + "://" + host + ":" + port;
 
34
         InvokerLocator locator = new InvokerLocator(locatorURI);
 
35
         System.out.println("Calling remoting server with locator uri of: " + locatorURI);
 
36
 
 
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();
 
41
 
 
42
         Map metadata = new HashMap();
 
43
         metadata.put(Client.RAW, Boolean.TRUE);
 
44
         metadata.put("TYPE", "POST");
 
45
 
 
46
         Properties headerProps = new Properties();
 
47
         headerProps.put("SOAPAction", "http://www.example.com/fibonacci");
 
48
         headerProps.put("Content-type", "application/soap+xml");
 
49
 
 
50
         metadata.put("HEADER", headerProps);
 
51
 
 
52
         Object response = null;
 
53
 
 
54
         // test with null return expected
 
55
         response = remotingClient.invoke(HTTPInvokerTestServer.NULL_RETURN_PARAM, metadata);
 
56
 
 
57
         assertNull(response);
 
58
 
 
59
         response = remotingClient.invoke("Do something", metadata);
 
60
 
 
61
         assertEquals(HTTPInvokerTestServer.RESPONSE_VALUE, response);
 
62
 
 
63
         // test with small object
 
64
         headerProps.put("Content-type", WebUtil.BINARY);
 
65
         response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata);
 
66
 
 
67
         assertEquals(org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestServer.OBJECT_RESPONSE_VALUE, response);
 
68
 
 
69
         // test with large object
 
70
         response = remotingClient.invoke(new ComplexObject(2, "foo", true, 8000), metadata);
 
71
 
 
72
         assertEquals(HTTPSInvokerTestServer.LARGE_OBJECT_RESPONSE_VALUE, response);
 
73
 
 
74
      }
 
75
      catch(Throwable throwable)
 
76
      {
 
77
         throw new Exception(throwable);
 
78
      }
 
79
      finally
 
80
      {
 
81
         if(remotingClient != null)
 
82
         {
 
83
            remotingClient.disconnect();
 
84
         }
 
85
      }
 
86
 
 
87
 
 
88
   }
 
89
 
 
90
 
 
91
}