1
package org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh;
3
import junit.framework.TestCase;
5
import org.jboss.logging.Logger;
6
import org.jboss.remoting.Client;
7
import org.jboss.remoting.InvokerLocator;
8
import org.jboss.remoting.security.SSLSocketBuilder;
10
import java.util.HashMap;
14
* @author Michael Voss
17
public class TestClient extends TestCase{
18
private static Logger log = Logger.getLogger(TestClient.class);
19
private String keyStorePath="src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/clientKeyStore";
20
private String trustStorePath="src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/clientTrustStore";
21
private String keyStorePassword="testpw";
22
private String trustStorePassword="testpw";
23
InvokerLocator locator;
27
public void setUp() throws Exception{
28
log.info("entering setUp()");
29
locator=new InvokerLocator(getTransport() + "://localHost:2001");
31
//the client side connection endpoint
32
configuration = new HashMap();
34
//String keyStorePath = this.getClass().getResource("certificate/serverKeyStore").getFile();
35
//String trustStorePath = this.getClass().getResource("certificate/serverTrustStore").getFile();
36
String keyStorePath = this.getClass().getResource("certificate/clientKeyStore").getFile();
37
String trustStorePath = this.getClass().getResource("certificate/clientTrustStore").getFile();
39
configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS");
40
configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStorePath);
41
configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, keyStorePassword);
42
configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509");
44
configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
45
configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStorePath);
46
configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, trustStorePassword);
47
configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509");
49
client=new Client(locator,"Sample",configuration);
52
log.info("leaving setUp()");
56
public void tearDown() throws Exception{
57
log.info("entering tearDown()");
58
Thread.sleep(10000);//let the server fetch his new truststore and refresh serversocket
59
log.info("finished first sleep in tearDown()");
61
log.info("disconnected client in tearDown()");
63
log.info("finished second sleep in tearDown()");
66
setUp();//secondPass -> client is not accepted by new truststore
67
test();//secondPass -> client is not accepted by new truststore
68
} catch (Throwable e) {
69
log.error("expected Exception", e);
75
throw new Exception("should not reach this point");//because client should not be accepted by new server truststore
82
public void test() throws Throwable{
83
log.info("Invoking server with 'something'");
84
log.info("Server answer is: "+client.invoke("something"));
87
protected String getTransport()