1 package org.kuali.rice.ksb.messaging;
2
3 import org.junit.Assert;
4 import org.junit.Test;
5 import org.kuali.rice.core.api.config.property.Config;
6 import org.kuali.rice.core.api.config.property.ConfigContext;
7 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
8 import org.kuali.rice.ksb.impl.cxf.interceptors.ServiceCallVersioningHelper;
9 import org.kuali.rice.ksb.messaging.remotedservices.BaseballCard;
10 import org.kuali.rice.ksb.messaging.remotedservices.BaseballCardCollectionService;
11 import org.kuali.rice.ksb.messaging.remotedservices.EchoService;
12 import org.kuali.rice.ksb.messaging.remotedservices.JaxWsEchoService;
13 import org.kuali.rice.ksb.messaging.remotedservices.ServiceCallInformationHolder;
14 import org.kuali.rice.ksb.test.KSBTestCase;
15
16 import javax.xml.namespace.QName;
17 import java.util.List;
18 import java.util.Map;
19
20
21
22
23 public class ServiceCallVersioningTest extends KSBTestCase {
24 @Override
25 public void setUp() throws Exception {
26 super.setUp();
27 Config c = ConfigContext.getCurrentContextConfig();
28 c.putProperty(Config.APPLICATION_NAME, "ServiceCallVersioningTest");
29 c.putProperty(Config.APPLICATION_VERSION, "99.99-SNAPSHOT");
30 }
31
32 public boolean startClient1() {
33 return true;
34 }
35
36 private String getClient1Port() {
37 return ConfigContext.getCurrentContextConfig().getProperty("ksb.client1.port");
38 }
39
40 @Test
41 public void testSimpleSOAPService() throws Exception {
42 EchoService echoService = GlobalResourceLoader.getService(new QName("TestCl1", "soap-echoService"));
43 echoService.captureHeaders();
44 assertHeadersCaptured();
45 }
46
47 @Test
48 public void testJaxWsSOAPService() {
49 JaxWsEchoService jaxwsEchoService = GlobalResourceLoader.getService(new QName("TestCl1",
50 "jaxwsEchoService"));
51 jaxwsEchoService.captureHeaders();
52 assertHeadersCaptured();
53 }
54
55 @Test
56 public void testJaxRsService() {
57 BaseballCardCollectionService service = GlobalResourceLoader.getService(new QName("test", "baseballCardCollectionService"));
58
59 List<BaseballCard> allCards = service.getAll();
60 Assert.assertNotNull(allCards);
61 assertHeadersCaptured();
62 }
63
64 public void assertHeadersCaptured() {
65 Map<String, List<String>> headers = ServiceCallInformationHolder.multiValues;
66 Assert.assertNotNull(headers);
67 System.out.println("HEADERS");
68 System.out.println(headers);
69 Assert.assertTrue(headers.get(ServiceCallVersioningHelper.KUALI_RICE_ENVIRONMENT_HEADER).contains("dev"));
70 Assert.assertTrue(headers.get(ServiceCallVersioningHelper.KUALI_RICE_VERSION_HEADER).contains(
71 ConfigContext.getCurrentContextConfig().getRiceVersion()));
72 Assert.assertTrue(headers.get(ServiceCallVersioningHelper.KUALI_APP_NAME_HEADER).contains(
73 "ServiceCallVersioningTest"));
74 Assert.assertTrue(headers.get(ServiceCallVersioningHelper.KUALI_APP_VERSION_HEADER).contains("99.99-SNAPSHOT"));
75 }
76
77 }