cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1133913 [4/13] - in /cxf/trunk: rt/core/src/test/java/org/apache/cxf/endpoint/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/client/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/client/ rt/frontend/jaxw...
Date Thu, 09 Jun 2011 15:08:27 GMT
Modified: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java?rev=1133913&r1=1133912&r2=1133913&view=diff
==============================================================================
--- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java (original)
+++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java Thu Jun  9 15:08:22 2011
@@ -1,456 +1,456 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.jms.testsuite.testcases;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jms.DeliveryMode;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.WebServiceException;
-
-import org.apache.cxf.jms.testsuite.services.Server;
-import org.apache.cxf.jms.testsuite.util.JMSTestUtil;
-import org.apache.cxf.jms_simple.JMSSimplePortType;
-import org.apache.cxf.jms_simple.JMSSimpleService0001;
-import org.apache.cxf.jms_simple.JMSSimpleService0003;
-import org.apache.cxf.jms_simple.JMSSimpleService0005;
-import org.apache.cxf.jms_simple.JMSSimpleService0006;
-import org.apache.cxf.jms_simple.JMSSimpleService0008;
-import org.apache.cxf.jms_simple.JMSSimpleService0009;
-import org.apache.cxf.jms_simple.JMSSimpleService0010;
-import org.apache.cxf.jms_simple.JMSSimpleService0011;
-import org.apache.cxf.jms_simple.JMSSimpleService0012;
-import org.apache.cxf.jms_simple.JMSSimpleService0013;
-import org.apache.cxf.jms_simple.JMSSimpleService0014;
-import org.apache.cxf.jms_simple.JMSSimpleService0101;
-import org.apache.cxf.jms_simple.JMSSimpleService1001;
-import org.apache.cxf.jms_simple.JMSSimpleService1009;
-import org.apache.cxf.jms_simple.JMSSimpleService1101;
-import org.apache.cxf.jms_simple.JMSSimpleService1105;
-import org.apache.cxf.jms_simple.JMSSimpleService1109;
-import org.apache.cxf.testsuite.testcase.TestCaseType;
-import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
-import org.apache.cxf.transport.jms.JMSConstants;
-import org.apache.cxf.transport.jms.JMSMessageHeadersType;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * 
- */
-public class SOAPJMSTestSuiteTest extends AbstractSOAPJMSTestSuite {
-    static final String JMS_PORT = EmbeddedJMSBrokerLauncher.PORT;
-    
-    @BeforeClass
-    public static void startServers() throws Exception {
-        Map<String, String> props = new HashMap<String, String>();
-        if (System.getProperty("org.apache.activemq.default.directory.prefix") != null) {
-            props.put("org.apache.activemq.default.directory.prefix", 
-                      System.getProperty("org.apache.activemq.default.directory.prefix"));
-        }
-        props.put("java.util.logging.config.file", System
-            .getProperty("java.util.logging.config.file"));
-        assertTrue("server did not launch correctly", launchServer(EmbeddedJMSBrokerLauncher.class,
-                                                                   props, null));
-        assertTrue("server did not launch correctly", launchServer(Server.class, false));
-        createStaticBus();
-    }
-    
-    private void oneWayTest(TestCaseType testcase, JMSSimplePortType port) throws Exception {
-        InvocationHandler handler = Proxy.getInvocationHandler(port);
-        BindingProvider bp = (BindingProvider)handler;
-
-        Map<String, Object> requestContext = bp.getRequestContext();
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-
-        requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
-        Exception e = null;
-        try {
-            port.ping("test");
-        } catch (Exception e1) {
-            e = e1;
-        }
-        checkJMSProperties(testcase, requestHeader);
-        if (e != null) {
-            throw e;
-        }
-    }
-
-    private void twoWayTest(TestCaseType testcase, final JMSSimplePortType port)
-        throws Exception {
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        twoWayTestWithRequestHeader(testcase, port, requestHeader);
-    }
-
-    private void twoWayTestWithRequestHeader(TestCaseType testcase, final JMSSimplePortType port,
-                                             JMSMessageHeadersType requestHeader)
-        throws Exception {
-        InvocationHandler handler = Proxy.getInvocationHandler(port);
-        BindingProvider bp = (BindingProvider)handler;
-
-        Map<String, Object> requestContext = bp.getRequestContext();
-        if (requestHeader == null) {
-            requestHeader = new JMSMessageHeadersType();
-        }
-        requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
-        Exception e = null;
-        try {
-            String response = port.echo("test");
-            assertEquals(response, "test");
-        } catch (WebServiceException ew) {
-            throw ew;
-        } catch (Exception e1) {
-            e = e1;
-        }
-        Map<String, Object> responseContext = bp.getResponseContext();
-        JMSMessageHeadersType responseHeader = (JMSMessageHeadersType)responseContext
-            .get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
-        checkJMSProperties(testcase, requestHeader, responseHeader);
-        if (e != null) {
-            throw e;
-        }
-    }
-
-    @Test
-    public void test0001() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0001");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0001", "SimplePort",
-                                                     JMSSimpleService0001.class,
-                                                     JMSSimplePortType.class);
-        oneWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0101() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0101");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0101", "SimplePort",
-                                                     JMSSimpleService0101.class,
-                                                     JMSSimplePortType.class);
-        oneWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0002() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0002");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0001", "SimplePort",
-                                                     JMSSimpleService0001.class,
-                                                     JMSSimplePortType.class);
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        requestHeader.setJMSCorrelationID("Correlator0002");
-
-        twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
-    }
-
-    @Test
-    public void test0102() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0102");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0101", "SimplePort",
-                                                     JMSSimpleService0101.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0003() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0003");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0003", "SimplePort",
-                                                     JMSSimpleService0003.class,
-                                                     JMSSimplePortType.class);
-        oneWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0004() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0004");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0003", "SimplePort",
-                                                     JMSSimpleService0003.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0005() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0005");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0005", "SimplePort",
-                                                     JMSSimpleService0005.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0006() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0006");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0006", "SimplePort",
-                                                     JMSSimpleService0006.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0008() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0008");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0008", "SimplePort",
-                                                     JMSSimpleService0008.class,
-                                                     JMSSimplePortType.class);
-
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        requestHeader.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
-        requestHeader.setTimeToLive(14400000);
-        requestHeader.setJMSPriority(8);
-        requestHeader.setJMSReplyTo("dynamicQueues/replyqueue0008");
-
-        twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
-    }
-
-    @Test
-    public void test0009() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0009");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0009", "SimplePort",
-                                                     JMSSimpleService0009.class,
-                                                     JMSSimplePortType.class);
-
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        requestHeader.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
-        requestHeader.setTimeToLive(10800000);
-        requestHeader.setJMSPriority(3);
-        requestHeader.setJMSReplyTo("dynamicQueues/replyqueue00093");
-
-        twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
-    }
-
-    @Test
-    public void test0010() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0010");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0010", "SimplePort",
-                                                     JMSSimpleService0010.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0011() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0011");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0011", "SimplePort",
-                                                     JMSSimpleService0011.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0012() throws Exception {
-        // same to test0002
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0012");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0012", "SimplePort",
-                                                     JMSSimpleService0012.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0013() throws Exception {
-        // same to test0002
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0013");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0013", "SimplePort",
-                                                     JMSSimpleService0013.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test0014() throws Exception {
-        // same to test0002
-        TestCaseType testcase = JMSTestUtil.getTestCase("test0014");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService0014", "SimplePort",
-                                                     JMSSimpleService0014.class,
-                                                     JMSSimplePortType.class);
-        twoWayTest(testcase, simplePort);
-    }
-
-    @Test
-    public void test1001() throws Exception {
-        // same to test0002
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1001");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService1001", "SimplePort",
-                                                     JMSSimpleService1001.class,
-                                                     JMSSimplePortType.class);
-
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        requestHeader.setSOAPJMSBindingVersion("0.3");
-        try {
-            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
-        } catch (Exception e) {
-            assertTrue(e.getMessage().contains("Unrecognized BindingVersion"));
-        }
-    }
-    
-    @Test
-    public void test1002() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1002");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1003() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1003");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1004() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1004");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1006() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1006");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1007() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1007");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1008() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1008");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-
-    @Test
-    public void test1009() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1009");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService1009", "SimplePort",
-                                                     JMSSimpleService1009.class,
-                                                     JMSSimplePortType.class);
-
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        try {
-            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
-        } catch (Exception e) {
-            assertTrue(e.getMessage().contains("Unknow JMS Variant"));
-        }
-    }
-
-    @Test
-    public void test1101() throws Exception {
-        // same to test0002
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1101");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService1101", "SimplePort",
-                                                     JMSSimpleService1101.class,
-                                                     JMSSimplePortType.class);
-
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        requestHeader.setSOAPJMSBindingVersion("0.3");
-        try {
-            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
-        } catch (Exception e) {
-            assertTrue(e.getMessage().contains("Unrecognized BindingVersion"));
-        }
-    }
-    
-    @Test
-    public void test1102() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1102");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1103() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1103");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1104() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1104");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1105() throws Exception {
- 
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1105");
-         
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService1105", "SimplePort",
-                                                     JMSSimpleService1105.class,
-                                                     JMSSimplePortType.class);
-
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        requestHeader.setSOAPJMSSOAPAction("mismatch");
-        try {
-            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
-        } catch (Exception e) {
-            assertTrue(e.getMessage().contains("Mismatched SoapAction"));
-        }
-    }
-    
-    @Test
-    public void test1106() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1106");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1107() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1107");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1108() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1108");
-        
-        twoWayTestWithCreateMessage(testcase);
-    }
-    
-    @Test
-    public void test1109() throws Exception {
-        TestCaseType testcase = JMSTestUtil.getTestCase("test1109");
-        final JMSSimplePortType simplePort = getPort("JMSSimpleService1109", "SimplePort",
-                                                     JMSSimpleService1109.class,
-                                                     JMSSimplePortType.class);
-
-        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
-        try {
-            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
-        } catch (Exception e) {
-            assertTrue(e.getMessage().contains("Unknow JMS Variant"));
-        }
-    }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jms.testsuite.testcases;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.DeliveryMode;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.cxf.jms.testsuite.services.Server;
+import org.apache.cxf.jms.testsuite.util.JMSTestUtil;
+import org.apache.cxf.jms_simple.JMSSimplePortType;
+import org.apache.cxf.jms_simple.JMSSimpleService0001;
+import org.apache.cxf.jms_simple.JMSSimpleService0003;
+import org.apache.cxf.jms_simple.JMSSimpleService0005;
+import org.apache.cxf.jms_simple.JMSSimpleService0006;
+import org.apache.cxf.jms_simple.JMSSimpleService0008;
+import org.apache.cxf.jms_simple.JMSSimpleService0009;
+import org.apache.cxf.jms_simple.JMSSimpleService0010;
+import org.apache.cxf.jms_simple.JMSSimpleService0011;
+import org.apache.cxf.jms_simple.JMSSimpleService0012;
+import org.apache.cxf.jms_simple.JMSSimpleService0013;
+import org.apache.cxf.jms_simple.JMSSimpleService0014;
+import org.apache.cxf.jms_simple.JMSSimpleService0101;
+import org.apache.cxf.jms_simple.JMSSimpleService1001;
+import org.apache.cxf.jms_simple.JMSSimpleService1009;
+import org.apache.cxf.jms_simple.JMSSimpleService1101;
+import org.apache.cxf.jms_simple.JMSSimpleService1105;
+import org.apache.cxf.jms_simple.JMSSimpleService1109;
+import org.apache.cxf.testsuite.testcase.TestCaseType;
+import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
+import org.apache.cxf.transport.jms.JMSConstants;
+import org.apache.cxf.transport.jms.JMSMessageHeadersType;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class SOAPJMSTestSuiteTest extends AbstractSOAPJMSTestSuite {
+    static final String JMS_PORT = EmbeddedJMSBrokerLauncher.PORT;
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        Map<String, String> props = new HashMap<String, String>();
+        if (System.getProperty("org.apache.activemq.default.directory.prefix") != null) {
+            props.put("org.apache.activemq.default.directory.prefix", 
+                      System.getProperty("org.apache.activemq.default.directory.prefix"));
+        }
+        props.put("java.util.logging.config.file", System
+            .getProperty("java.util.logging.config.file"));
+        assertTrue("server did not launch correctly", launchServer(EmbeddedJMSBrokerLauncher.class,
+                                                                   props, null));
+        assertTrue("server did not launch correctly", launchServer(Server.class, false));
+        createStaticBus();
+    }
+    
+    private void oneWayTest(TestCaseType testcase, JMSSimplePortType port) throws Exception {
+        InvocationHandler handler = Proxy.getInvocationHandler(port);
+        BindingProvider bp = (BindingProvider)handler;
+
+        Map<String, Object> requestContext = bp.getRequestContext();
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+
+        requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
+        Exception e = null;
+        try {
+            port.ping("test");
+        } catch (Exception e1) {
+            e = e1;
+        }
+        checkJMSProperties(testcase, requestHeader);
+        if (e != null) {
+            throw e;
+        }
+    }
+
+    private void twoWayTest(TestCaseType testcase, final JMSSimplePortType port)
+        throws Exception {
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        twoWayTestWithRequestHeader(testcase, port, requestHeader);
+    }
+
+    private void twoWayTestWithRequestHeader(TestCaseType testcase, final JMSSimplePortType port,
+                                             JMSMessageHeadersType requestHeader)
+        throws Exception {
+        InvocationHandler handler = Proxy.getInvocationHandler(port);
+        BindingProvider bp = (BindingProvider)handler;
+
+        Map<String, Object> requestContext = bp.getRequestContext();
+        if (requestHeader == null) {
+            requestHeader = new JMSMessageHeadersType();
+        }
+        requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
+        Exception e = null;
+        try {
+            String response = port.echo("test");
+            assertEquals(response, "test");
+        } catch (WebServiceException ew) {
+            throw ew;
+        } catch (Exception e1) {
+            e = e1;
+        }
+        Map<String, Object> responseContext = bp.getResponseContext();
+        JMSMessageHeadersType responseHeader = (JMSMessageHeadersType)responseContext
+            .get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
+        checkJMSProperties(testcase, requestHeader, responseHeader);
+        if (e != null) {
+            throw e;
+        }
+    }
+
+    @Test
+    public void test0001() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0001");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0001", "SimplePort",
+                                                     JMSSimpleService0001.class,
+                                                     JMSSimplePortType.class);
+        oneWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0101() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0101");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0101", "SimplePort",
+                                                     JMSSimpleService0101.class,
+                                                     JMSSimplePortType.class);
+        oneWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0002() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0002");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0001", "SimplePort",
+                                                     JMSSimpleService0001.class,
+                                                     JMSSimplePortType.class);
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        requestHeader.setJMSCorrelationID("Correlator0002");
+
+        twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
+    }
+
+    @Test
+    public void test0102() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0102");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0101", "SimplePort",
+                                                     JMSSimpleService0101.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0003() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0003");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0003", "SimplePort",
+                                                     JMSSimpleService0003.class,
+                                                     JMSSimplePortType.class);
+        oneWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0004() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0004");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0003", "SimplePort",
+                                                     JMSSimpleService0003.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0005() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0005");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0005", "SimplePort",
+                                                     JMSSimpleService0005.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0006() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0006");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0006", "SimplePort",
+                                                     JMSSimpleService0006.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0008() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0008");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0008", "SimplePort",
+                                                     JMSSimpleService0008.class,
+                                                     JMSSimplePortType.class);
+
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        requestHeader.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+        requestHeader.setTimeToLive(14400000);
+        requestHeader.setJMSPriority(8);
+        requestHeader.setJMSReplyTo("dynamicQueues/replyqueue0008");
+
+        twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
+    }
+
+    @Test
+    public void test0009() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0009");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0009", "SimplePort",
+                                                     JMSSimpleService0009.class,
+                                                     JMSSimplePortType.class);
+
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        requestHeader.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+        requestHeader.setTimeToLive(10800000);
+        requestHeader.setJMSPriority(3);
+        requestHeader.setJMSReplyTo("dynamicQueues/replyqueue00093");
+
+        twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
+    }
+
+    @Test
+    public void test0010() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0010");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0010", "SimplePort",
+                                                     JMSSimpleService0010.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0011() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0011");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0011", "SimplePort",
+                                                     JMSSimpleService0011.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0012() throws Exception {
+        // same to test0002
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0012");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0012", "SimplePort",
+                                                     JMSSimpleService0012.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0013() throws Exception {
+        // same to test0002
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0013");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0013", "SimplePort",
+                                                     JMSSimpleService0013.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test0014() throws Exception {
+        // same to test0002
+        TestCaseType testcase = JMSTestUtil.getTestCase("test0014");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService0014", "SimplePort",
+                                                     JMSSimpleService0014.class,
+                                                     JMSSimplePortType.class);
+        twoWayTest(testcase, simplePort);
+    }
+
+    @Test
+    public void test1001() throws Exception {
+        // same to test0002
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1001");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService1001", "SimplePort",
+                                                     JMSSimpleService1001.class,
+                                                     JMSSimplePortType.class);
+
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        requestHeader.setSOAPJMSBindingVersion("0.3");
+        try {
+            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("Unrecognized BindingVersion"));
+        }
+    }
+    
+    @Test
+    public void test1002() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1002");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1003() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1003");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1004() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1004");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1006() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1006");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1007() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1007");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1008() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1008");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+
+    @Test
+    public void test1009() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1009");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService1009", "SimplePort",
+                                                     JMSSimpleService1009.class,
+                                                     JMSSimplePortType.class);
+
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        try {
+            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("Unknow JMS Variant"));
+        }
+    }
+
+    @Test
+    public void test1101() throws Exception {
+        // same to test0002
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1101");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService1101", "SimplePort",
+                                                     JMSSimpleService1101.class,
+                                                     JMSSimplePortType.class);
+
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        requestHeader.setSOAPJMSBindingVersion("0.3");
+        try {
+            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("Unrecognized BindingVersion"));
+        }
+    }
+    
+    @Test
+    public void test1102() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1102");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1103() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1103");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1104() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1104");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1105() throws Exception {
+ 
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1105");
+         
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService1105", "SimplePort",
+                                                     JMSSimpleService1105.class,
+                                                     JMSSimplePortType.class);
+
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        requestHeader.setSOAPJMSSOAPAction("mismatch");
+        try {
+            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("Mismatched SoapAction"));
+        }
+    }
+    
+    @Test
+    public void test1106() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1106");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1107() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1107");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1108() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1108");
+        
+        twoWayTestWithCreateMessage(testcase);
+    }
+    
+    @Test
+    public void test1109() throws Exception {
+        TestCaseType testcase = JMSTestUtil.getTestCase("test1109");
+        final JMSSimplePortType simplePort = getPort("JMSSimpleService1109", "SimplePort",
+                                                     JMSSimpleService1109.class,
+                                                     JMSSimplePortType.class);
+
+        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+        try {
+            twoWayTestWithRequestHeader(testcase, simplePort, requestHeader);
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("Unknow JMS Variant"));
+        }
+    }
+
+}

Propchange: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/util/JMSTestUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/util/JMSTestUtil.java?rev=1133913&r1=1133912&r2=1133913&view=diff
==============================================================================
--- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/util/JMSTestUtil.java (original)
+++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/util/JMSTestUtil.java Thu Jun  9 15:08:22 2011
@@ -1,243 +1,243 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.jms.testsuite.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.cxf.testsuite.testcase.MessagePropertiesType;
-import org.apache.cxf.testsuite.testcase.TestCaseType;
-import org.apache.cxf.testsuite.testcase.TestCasesType;
-import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
-import org.apache.cxf.transport.jms.JMSConfiguration;
-import org.apache.cxf.transport.jms.JMSFactory;
-import org.apache.cxf.transport.jms.JMSOldConfigHolder;
-import org.apache.cxf.transport.jms.JNDIConfiguration;
-import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
-import org.apache.cxf.transport.jms.uri.JMSEndpoint;
-import org.apache.cxf.transport.jms.uri.JMSEndpointParser;
-import org.apache.cxf.transport.jms.uri.JMSURIConstants;
-import org.springframework.jms.core.JmsTemplate;
-import org.springframework.jms.support.destination.JndiDestinationResolver;
-import org.springframework.jndi.JndiTemplate;
-
-/**
- * 
- */
-public final class JMSTestUtil {
-
-    private static TestCasesType testcases;
-
-    private JMSTestUtil() {
-    }
-    
-    public static List<TestCaseType> getTestCases() {
-        try {
-            if (testcases == null) {
-                loadTestCases();
-            }
-            return testcases.getTestCase();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return new ArrayList<TestCaseType>();
-    }
-
-    public static TestCaseType getTestCase(String testId) {
-        if (testId == null) {
-            return null;
-        }
-        Iterator<TestCaseType> iter = getTestCases().iterator();
-        while (iter.hasNext()) {
-            TestCaseType testcase = iter.next();
-            if (testId.equals(testcase.getId())) {
-                return testcase;
-            }
-        }
-        return null;
-    }
-
-    private static void loadTestCases() throws Exception {
-        JAXBContext context = JAXBContext.newInstance("org.apache.cxf.testsuite.testcase");
-        Unmarshaller unmarshaller = context.createUnmarshaller();
-        JAXBElement e = (JAXBElement)unmarshaller.unmarshal(new JMSTestUtil().getClass()
-            .getResource("/org/apache/cxf/jms/testsuite/util/testcases.xml"));
-        testcases = (TestCasesType)e.getValue();
-        for (TestCaseType tct : testcases.getTestCase()) {
-            if (tct.isSetAddress()) {
-                String add = tct.getAddress();
-                int idx = add.indexOf("jndiURL=");
-                if (idx != -1) {
-                    int idx2 = add.indexOf("&", idx);
-                    add = add.substring(0, idx)
-                        + "jndiURL=tcp://localhost:" + EmbeddedJMSBrokerLauncher.PORT
-                        + (idx2 == -1 ? "" : add.substring(idx2));
-                    tct.setAddress(add);
-                }
-            }
-        }
-    }
-
-    public static JmsTemplate getJmsTemplate(String address) throws Exception {
-        return JMSFactory.createJmsTemplate(getInitJMSConfiguration(address), null);
-    }
-
-    public static Destination getJmsDestination(JmsTemplate jmsTemplate, String destinationName,
-                                                boolean pubSubDomain) {
-        return JMSFactory.resolveOrCreateDestination(jmsTemplate, destinationName, pubSubDomain);
-    }
-
-    public static JMSConfiguration getInitJMSConfiguration(String address) throws Exception {
-        JMSEndpoint endpoint = JMSEndpointParser.createEndpoint(address);
-
-        JMSConfiguration jmsConfig = new JMSConfiguration();
-
-        if (endpoint.isSetDeliveryMode()) {
-            int deliveryMode = endpoint.getDeliveryMode()
-                .equals(JMSURIConstants.DELIVERYMODE_PERSISTENT)
-                ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
-            jmsConfig.setDeliveryMode(deliveryMode);
-        }
-
-        if (endpoint.isSetPriority()) {
-            int priority = endpoint.getPriority();
-            jmsConfig.setPriority(priority);
-        }
-
-        if (endpoint.isSetTimeToLive()) {
-            long timeToLive = endpoint.getTimeToLive();
-            jmsConfig.setTimeToLive(timeToLive);
-        }
-
-        if (jmsConfig.isUsingEndpointInfo()) {
-            JndiTemplate jt = new JndiTemplate();
-            jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(endpoint));
-            boolean pubSubDomain = false;
-            pubSubDomain = endpoint.getJmsVariant().equals(JMSURIConstants.TOPIC);
-            JNDIConfiguration jndiConfig = new JNDIConfiguration();
-            jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
-            jmsConfig.setJndiTemplate(jt);
-            jmsConfig.setJndiConfig(jndiConfig);
-            jmsConfig.setExplicitQosEnabled(true);
-            jmsConfig.setPubSubDomain(pubSubDomain);
-            jmsConfig.setPubSubNoLocal(true);
-            boolean useJndi = endpoint.getJmsVariant().equals(JMSURIConstants.JNDI);
-            if (useJndi) {
-                // Setup Destination jndi destination resolver
-                final JndiDestinationResolver jndiDestinationResolver = new JndiDestinationResolver();
-                jndiDestinationResolver.setJndiTemplate(jt);
-                jmsConfig.setDestinationResolver(jndiDestinationResolver);
-                jmsConfig.setTargetDestination(endpoint.getDestinationName());
-                jmsConfig.setReplyDestination(endpoint.getReplyToName());
-            } else {
-                // Use the default dynamic destination resolver
-                jmsConfig.setTargetDestination(endpoint.getDestinationName());
-                jmsConfig.setReplyDestination(endpoint.getReplyToName());
-            }
-        }
-        return jmsConfig;
-    }
-
-    /**
-     * @param testcase
-     * @param session
-     * @param rtd
-     * @return
-     * @throws JMSException 
-     */
-    public static Message buildJMSMessageFromTestCase(TestCaseType testcase, Session session,
-                                                      Destination rtd) throws JMSException {
-        MessagePropertiesType messageProperties = testcase.getRequestMessage();
-        Message jmsMessage = null;
-        String messageType = messageProperties.getMessageType();
-        if ("text".equals(messageType)) {
-            jmsMessage = session.createTextMessage();
-            ((TextMessage)jmsMessage).setText("test");
-        } else if ("byte".equals(messageType)) {
-            jmsMessage = session.createBytesMessage();
-        } else if ("stream".equals(messageType)) {
-            jmsMessage = session.createStreamMessage();
-            ((StreamMessage)jmsMessage).writeString("test");
-        } else {
-            jmsMessage = session.createBytesMessage();
-        }
-
-        jmsMessage.setJMSReplyTo(rtd);
-
-        if (messageProperties.isSetDeliveryMode()) {
-            jmsMessage.setJMSDeliveryMode(messageProperties.getDeliveryMode());
-        }
-        if (messageProperties.isSetExpiration()) {
-            jmsMessage.setJMSExpiration(messageProperties.getExpiration());
-        }
-        if (messageProperties.isSetPriority()) {
-            jmsMessage.setJMSPriority(messageProperties.getPriority());
-        }
-        if (messageProperties.isSetExpiration()) {
-            jmsMessage.setJMSPriority(messageProperties.getExpiration());
-        }
-        if (messageProperties.isSetCorrelationID()) {
-            jmsMessage.setJMSCorrelationID(messageProperties.getCorrelationID());
-        }
-        
-        if (messageProperties.isSetTargetService()
-            && !"".equals(messageProperties.getTargetService().trim())) {
-            jmsMessage.setStringProperty(JMSSpecConstants.TARGETSERVICE_FIELD, messageProperties
-                .getTargetService().trim());
-        }
-
-        if (messageProperties.isSetBindingVersion()
-            && !"".equals(messageProperties.getBindingVersion().trim())) {
-            jmsMessage.setStringProperty(JMSSpecConstants.BINDINGVERSION_FIELD, messageProperties
-                                         .getBindingVersion().trim());
-        }
-
-        if (messageProperties.isSetContentType()
-            && !"".equals(messageProperties.getContentType().trim())) {
-            jmsMessage.setStringProperty(JMSSpecConstants.CONTENTTYPE_FIELD, messageProperties
-                .getContentType().trim());
-        }
-
-        if (messageProperties.isSetSoapAction()
-            && !"".equals(messageProperties.getSoapAction().trim())) {
-            jmsMessage.setStringProperty(JMSSpecConstants.SOAPACTION_FIELD, messageProperties
-                .getSoapAction().trim());
-        }
-
-        if (messageProperties.isSetRequestURI()
-            && !"".equals(messageProperties.getRequestURI().trim())) {
-            jmsMessage.setStringProperty(JMSSpecConstants.REQUESTURI_FIELD, messageProperties
-                .getRequestURI().trim());
-        }
-        return jmsMessage;
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jms.testsuite.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.cxf.testsuite.testcase.MessagePropertiesType;
+import org.apache.cxf.testsuite.testcase.TestCaseType;
+import org.apache.cxf.testsuite.testcase.TestCasesType;
+import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
+import org.apache.cxf.transport.jms.JMSConfiguration;
+import org.apache.cxf.transport.jms.JMSFactory;
+import org.apache.cxf.transport.jms.JMSOldConfigHolder;
+import org.apache.cxf.transport.jms.JNDIConfiguration;
+import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
+import org.apache.cxf.transport.jms.uri.JMSEndpoint;
+import org.apache.cxf.transport.jms.uri.JMSEndpointParser;
+import org.apache.cxf.transport.jms.uri.JMSURIConstants;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.jms.support.destination.JndiDestinationResolver;
+import org.springframework.jndi.JndiTemplate;
+
+/**
+ * 
+ */
+public final class JMSTestUtil {
+
+    private static TestCasesType testcases;
+
+    private JMSTestUtil() {
+    }
+    
+    public static List<TestCaseType> getTestCases() {
+        try {
+            if (testcases == null) {
+                loadTestCases();
+            }
+            return testcases.getTestCase();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return new ArrayList<TestCaseType>();
+    }
+
+    public static TestCaseType getTestCase(String testId) {
+        if (testId == null) {
+            return null;
+        }
+        Iterator<TestCaseType> iter = getTestCases().iterator();
+        while (iter.hasNext()) {
+            TestCaseType testcase = iter.next();
+            if (testId.equals(testcase.getId())) {
+                return testcase;
+            }
+        }
+        return null;
+    }
+
+    private static void loadTestCases() throws Exception {
+        JAXBContext context = JAXBContext.newInstance("org.apache.cxf.testsuite.testcase");
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        JAXBElement e = (JAXBElement)unmarshaller.unmarshal(new JMSTestUtil().getClass()
+            .getResource("/org/apache/cxf/jms/testsuite/util/testcases.xml"));
+        testcases = (TestCasesType)e.getValue();
+        for (TestCaseType tct : testcases.getTestCase()) {
+            if (tct.isSetAddress()) {
+                String add = tct.getAddress();
+                int idx = add.indexOf("jndiURL=");
+                if (idx != -1) {
+                    int idx2 = add.indexOf("&", idx);
+                    add = add.substring(0, idx)
+                        + "jndiURL=tcp://localhost:" + EmbeddedJMSBrokerLauncher.PORT
+                        + (idx2 == -1 ? "" : add.substring(idx2));
+                    tct.setAddress(add);
+                }
+            }
+        }
+    }
+
+    public static JmsTemplate getJmsTemplate(String address) throws Exception {
+        return JMSFactory.createJmsTemplate(getInitJMSConfiguration(address), null);
+    }
+
+    public static Destination getJmsDestination(JmsTemplate jmsTemplate, String destinationName,
+                                                boolean pubSubDomain) {
+        return JMSFactory.resolveOrCreateDestination(jmsTemplate, destinationName, pubSubDomain);
+    }
+
+    public static JMSConfiguration getInitJMSConfiguration(String address) throws Exception {
+        JMSEndpoint endpoint = JMSEndpointParser.createEndpoint(address);
+
+        JMSConfiguration jmsConfig = new JMSConfiguration();
+
+        if (endpoint.isSetDeliveryMode()) {
+            int deliveryMode = endpoint.getDeliveryMode()
+                .equals(JMSURIConstants.DELIVERYMODE_PERSISTENT)
+                ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
+            jmsConfig.setDeliveryMode(deliveryMode);
+        }
+
+        if (endpoint.isSetPriority()) {
+            int priority = endpoint.getPriority();
+            jmsConfig.setPriority(priority);
+        }
+
+        if (endpoint.isSetTimeToLive()) {
+            long timeToLive = endpoint.getTimeToLive();
+            jmsConfig.setTimeToLive(timeToLive);
+        }
+
+        if (jmsConfig.isUsingEndpointInfo()) {
+            JndiTemplate jt = new JndiTemplate();
+            jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(endpoint));
+            boolean pubSubDomain = false;
+            pubSubDomain = endpoint.getJmsVariant().equals(JMSURIConstants.TOPIC);
+            JNDIConfiguration jndiConfig = new JNDIConfiguration();
+            jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
+            jmsConfig.setJndiTemplate(jt);
+            jmsConfig.setJndiConfig(jndiConfig);
+            jmsConfig.setExplicitQosEnabled(true);
+            jmsConfig.setPubSubDomain(pubSubDomain);
+            jmsConfig.setPubSubNoLocal(true);
+            boolean useJndi = endpoint.getJmsVariant().equals(JMSURIConstants.JNDI);
+            if (useJndi) {
+                // Setup Destination jndi destination resolver
+                final JndiDestinationResolver jndiDestinationResolver = new JndiDestinationResolver();
+                jndiDestinationResolver.setJndiTemplate(jt);
+                jmsConfig.setDestinationResolver(jndiDestinationResolver);
+                jmsConfig.setTargetDestination(endpoint.getDestinationName());
+                jmsConfig.setReplyDestination(endpoint.getReplyToName());
+            } else {
+                // Use the default dynamic destination resolver
+                jmsConfig.setTargetDestination(endpoint.getDestinationName());
+                jmsConfig.setReplyDestination(endpoint.getReplyToName());
+            }
+        }
+        return jmsConfig;
+    }
+
+    /**
+     * @param testcase
+     * @param session
+     * @param rtd
+     * @return
+     * @throws JMSException 
+     */
+    public static Message buildJMSMessageFromTestCase(TestCaseType testcase, Session session,
+                                                      Destination rtd) throws JMSException {
+        MessagePropertiesType messageProperties = testcase.getRequestMessage();
+        Message jmsMessage = null;
+        String messageType = messageProperties.getMessageType();
+        if ("text".equals(messageType)) {
+            jmsMessage = session.createTextMessage();
+            ((TextMessage)jmsMessage).setText("test");
+        } else if ("byte".equals(messageType)) {
+            jmsMessage = session.createBytesMessage();
+        } else if ("stream".equals(messageType)) {
+            jmsMessage = session.createStreamMessage();
+            ((StreamMessage)jmsMessage).writeString("test");
+        } else {
+            jmsMessage = session.createBytesMessage();
+        }
+
+        jmsMessage.setJMSReplyTo(rtd);
+
+        if (messageProperties.isSetDeliveryMode()) {
+            jmsMessage.setJMSDeliveryMode(messageProperties.getDeliveryMode());
+        }
+        if (messageProperties.isSetExpiration()) {
+            jmsMessage.setJMSExpiration(messageProperties.getExpiration());
+        }
+        if (messageProperties.isSetPriority()) {
+            jmsMessage.setJMSPriority(messageProperties.getPriority());
+        }
+        if (messageProperties.isSetExpiration()) {
+            jmsMessage.setJMSPriority(messageProperties.getExpiration());
+        }
+        if (messageProperties.isSetCorrelationID()) {
+            jmsMessage.setJMSCorrelationID(messageProperties.getCorrelationID());
+        }
+        
+        if (messageProperties.isSetTargetService()
+            && !"".equals(messageProperties.getTargetService().trim())) {
+            jmsMessage.setStringProperty(JMSSpecConstants.TARGETSERVICE_FIELD, messageProperties
+                .getTargetService().trim());
+        }
+
+        if (messageProperties.isSetBindingVersion()
+            && !"".equals(messageProperties.getBindingVersion().trim())) {
+            jmsMessage.setStringProperty(JMSSpecConstants.BINDINGVERSION_FIELD, messageProperties
+                                         .getBindingVersion().trim());
+        }
+
+        if (messageProperties.isSetContentType()
+            && !"".equals(messageProperties.getContentType().trim())) {
+            jmsMessage.setStringProperty(JMSSpecConstants.CONTENTTYPE_FIELD, messageProperties
+                .getContentType().trim());
+        }
+
+        if (messageProperties.isSetSoapAction()
+            && !"".equals(messageProperties.getSoapAction().trim())) {
+            jmsMessage.setStringProperty(JMSSpecConstants.SOAPACTION_FIELD, messageProperties
+                .getSoapAction().trim());
+        }
+
+        if (messageProperties.isSetRequestURI()
+            && !"".equals(messageProperties.getRequestURI().trim())) {
+            jmsMessage.setStringProperty(JMSSpecConstants.REQUESTURI_FIELD, messageProperties
+                .getRequestURI().trim());
+        }
+        return jmsMessage;
+    }
+}

Propchange: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/util/JMSTestUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/util/JMSTestUtil.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message