1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ksb.messaging;
18
19 import org.junit.Assert;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.kuali.rice.ksb.api.KsbApiConstants;
23 import org.kuali.rice.ksb.api.KsbApiServiceLocator;
24 import org.kuali.rice.ksb.api.bus.Endpoint;
25 import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
26 import org.kuali.rice.ksb.api.bus.support.JavaServiceConfiguration;
27 import org.kuali.rice.ksb.messaging.remotedservices.EchoService;
28 import org.kuali.rice.ksb.messaging.serviceconnectors.HttpInvokerConnector;
29 import org.kuali.rice.ksb.server.TestClient1;
30 import org.kuali.rice.ksb.test.KSBTestCase;
31
32 import javax.xml.namespace.QName;
33 import java.net.MalformedURLException;
34 import java.net.URL;
35
36
37
38
39
40
41
42
43
44
45 public class HttpInvokerConnectorTest extends KSBTestCase {
46
47 public boolean startClient1() {
48 return true;
49 }
50
51 private static final QName serviceName = new QName("urn:TestCl1", "httpInvoker-echoServiceSecure");
52
53
54
55
56 @Before
57 public void setup() {
58 KsbApiServiceLocator.getServiceBus().synchronize();
59 }
60
61
62
63
64 @Test
65 public void testHttpInvokerServiceCall() {
66 Endpoint endpoint = KsbApiServiceLocator.getServiceBus().getEndpoint(serviceName);
67
68 Assert.assertTrue(KsbApiConstants.ServiceTypes.HTTP_INVOKER.equals(
69 endpoint.getServiceConfiguration().getType()));
70
71 EchoService echoService = (EchoService)KsbApiServiceLocator.getServiceBus().getService(serviceName);
72
73 Assert.assertTrue("foo".equals(echoService.echo("foo")));
74 }
75
76
77
78
79 @Test
80 public void testSecureHttpInvokerServiceCall() throws MalformedURLException {
81 Endpoint endpoint = KsbApiServiceLocator.getServiceBus().getEndpoint(serviceName);
82
83 Assert.assertTrue(KsbApiConstants.ServiceTypes.HTTP_INVOKER.equals(endpoint.getServiceConfiguration().getType()));
84
85
86
87 ServiceConfiguration serviceConfiguration = endpoint.getServiceConfiguration();
88 URL endpointUrl = serviceConfiguration.getEndpointUrl();
89 TestClient1.ConfigConstants configConstants = new TestClient1.ConfigConstants();
90
91 URL httpsUrl = new URL("https", endpointUrl.getHost(), configConstants.SERVER_HTTPS_PORT, endpointUrl.getFile());
92
93
94 HttpInvokerConnector connector = new HttpInvokerConnector((JavaServiceConfiguration)serviceConfiguration, httpsUrl);
95 EchoService httpsEchoService = (EchoService) connector.getService();
96
97
98 Assert.assertTrue("foo".equals(httpsEchoService.echo("foo")));
99 }
100
101 }