Added: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java?rev=1089887&view=auto ============================================================================== --- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java (added) +++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java Thu Apr 7 14:11:51 2011 @@ -0,0 +1,46 @@ +/** + * 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.systest.jms.tx; + +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.jws.WebService; + + +import org.apache.cxf.systest.jms.GreeterImplDocBase; + +@WebService(endpointInterface = "org.apache.hello_world_doc_lit.Greeter") +public class GreeterImplWithTransaction extends GreeterImplDocBase { + private AtomicBoolean flag = new AtomicBoolean(true); + + public String greetMe(String requestType) { + System.out.println("Reached here :" + requestType); + if ("Bad guy".equals(requestType)) { + if (flag.getAndSet(false)) { + System.out.println("Throw exception here :" + requestType); + throw new RuntimeException("Got a bad guy call for greetMe"); + } else { + requestType = "[Bad guy]"; + flag.set(true); + } + } + return "Hello " + requestType; + } + +}
Added: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java?rev=1089887&view=auto ============================================================================== --- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java (added) +++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java Thu Apr 7 14:11:51 2011 @@ -0,0 +1,141 @@ +/** + * 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.systest.jms.tx; + +import java.lang.reflect.UndeclaredThrowableException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import javax.jms.ConnectionFactory; +import javax.xml.namespace.QName; + +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher; +import org.apache.cxf.transport.jms.JMSConfigFeature; +import org.apache.cxf.transport.jms.JMSConfiguration; +import org.apache.hello_world_doc_lit.Greeter; +import org.apache.hello_world_doc_lit.PingMeFault; +import org.apache.hello_world_doc_lit.SOAPService2; +import org.junit.Before; +import org.junit.Test; + +public class JMSTransactionClientServerTest extends AbstractBusClientServerTestBase { + protected static boolean serversStarted; + static final String JMS_PORT = EmbeddedJMSBrokerLauncher.PORT; + + + @Before + public void startServers() throws Exception { + if (serversStarted) { + return; + } + 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)); + serversStarted = true; + } + + public URL getWSDLURL(String s) throws Exception { + return getClass().getResource(s); + } + public QName getServiceName(QName q) { + return q; + } + public QName getPortName(QName q) { + return q; + } + + @Test + public void testDocBasicConnection() throws Exception { + QName serviceName = getServiceName(new QName("http://apache.org/hello_world_doc_lit", + "SOAPService2")); + QName portName = getPortName(new QName("http://apache.org/hello_world_doc_lit", "SoapPort2")); + URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl"); + assertNotNull(wsdl); + String wsdlString = wsdl.toString(); + EmbeddedJMSBrokerLauncher.updateWsdlExtensors(getBus(), wsdlString); + SOAPService2 service = new SOAPService2(wsdl, serviceName); + assertNotNull(service); + + Greeter greeter = service.getPort(portName, Greeter.class); + doService(greeter, true); + } + @Test + public void testNonAopTransaction() throws Exception { + JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); + factory.setServiceClass(Greeter.class); + factory.setAddress("jms://"); + + JMSConfiguration jmsConfig = new JMSConfiguration(); + ConnectionFactory connectionFactory + = new org.apache.activemq.ActiveMQConnectionFactory("tcp://localhost:" + JMS_PORT); + jmsConfig.setConnectionFactory(connectionFactory); + jmsConfig.setTargetDestination("greeter.queue.noaop"); + jmsConfig.setPubSubDomain(false); + jmsConfig.setUseJms11(true); + + JMSConfigFeature jmsConfigFeature = new JMSConfigFeature(); + jmsConfigFeature.setJmsConfig(jmsConfig); + factory.getFeatures().add(jmsConfigFeature); + + Greeter greeter = (Greeter)factory.create(); + doService(greeter, false); + } + public void doService(Greeter greeter, boolean doEx) throws Exception { + + String response1 = new String("Hello "); + + try { + + String greeting = greeter.greetMe("Good guy"); + assertNotNull("No response received from service", greeting); + String exResponse = response1 + "Good guy"; + assertEquals("Get unexcpeted result", exResponse, greeting); + + greeting = greeter.greetMe("Bad guy"); + assertNotNull("No response received from service", greeting); + exResponse = response1 + "[Bad guy]"; + assertEquals("Get unexcpeted result", exResponse, greeting); + + if (doEx) { + try { + greeter.pingMe(); + fail("Should have thrown FaultException"); + } catch (PingMeFault ex) { + assertNotNull(ex.getFaultInfo()); + } + } + } catch (UndeclaredThrowableException ex) { + throw (Exception)ex.getCause(); + } + } + +} Added: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/Server.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/Server.java?rev=1089887&view=auto ============================================================================== --- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/Server.java (added) +++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/Server.java Thu Apr 7 14:11:51 2011 @@ -0,0 +1,71 @@ +/** + * 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.systest.jms.tx; + +import javax.jms.ConnectionFactory; + +import org.apache.cxf.jaxws.EndpointImpl; +import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.transport.jms.JMSConfigFeature; +import org.apache.cxf.transport.jms.JMSConfiguration; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.jms.connection.JmsTransactionManager; + +public class Server extends AbstractBusTestServerBase { + + + protected void run() { + // create the application context + ClassPathXmlApplicationContext context = + new ClassPathXmlApplicationContext("org/apache/cxf/systest/jms/tx/jms_server_config.xml"); + context.start(); + + EndpointImpl endpoint = new EndpointImpl(new GreeterImplWithTransaction()); + endpoint.setAddress("jms://"); + JMSConfiguration jmsConfig = new JMSConfiguration(); + + ConnectionFactory connectionFactory + = (ConnectionFactory)context.getBean("jmsConnectionFactory", ConnectionFactory.class); + jmsConfig.setConnectionFactory(connectionFactory); + jmsConfig.setTargetDestination("greeter.queue.noaop"); + jmsConfig.setSessionTransacted(true); + jmsConfig.setPubSubDomain(false); + jmsConfig.setUseJms11(true); + jmsConfig.setTransactionManager(new JmsTransactionManager(connectionFactory)); + jmsConfig.setCacheLevel(3); + + JMSConfigFeature jmsConfigFeature = new JMSConfigFeature(); + jmsConfigFeature.setJmsConfig(jmsConfig); + endpoint.getFeatures().add(jmsConfigFeature); + endpoint.publish(); + } + + + public static void main(String[] args) { + try { + Server s = new Server(); + s.start(); + } catch (Exception ex) { + ex.printStackTrace(); + System.exit(-1); + } finally { + System.out.println("done!"); + } + } +} Added: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml?rev=1089887&view=auto ============================================================================== --- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml (added) +++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml Thu Apr 7 14:11:51 2011 @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> + +<beans + xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ct="http://cxf.apache.org/configuration/types" + xmlns:jms="http://cxf.apache.org/transports/jms" + xmlns:p="http://www.springframework.org/schema/p" + xmlns:jaxws="http://cxf.apache.org/jaxws" + xsi:schemaLocation=" +http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd +http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd +http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> + + <import resource="classpath:META-INF/cxf/cxf.xml" /> + + <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> + + <jaxws:endpoint implementor="#transactionalImplementor" + implementorClass="org.apache.hello_world_doc_lit.Greeter" + wsdlLocation="testutils/hello_world_doc_lit.wsdl" + serviceName="s:SOAPService2" + endpointName="s:SoapPort2" + xmlns:s= "http://apache.org/hello_world_doc_lit" /> + + <jms:destination name="{http://apache.org/hello_world_doc_lit}SoapPort2.jms-destination"> + <jms:jmsConfig-ref>jmsConf</jms:jmsConfig-ref> + </jms:destination> + + + <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" + p:brokerURL="tcp://localhost:${testutil.ports.EmbeddedJMSBrokerLauncher}" + /> + + <bean id="singleConnectionFactory" + class="org.springframework.jms.connection.SingleConnectionFactory" destroy-method="destroy"> + <property name="targetConnectionFactory" ref="jmsConnectionFactory"/> + </bean> + + <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager"> + <property name="connectionFactory" ref="singleConnectionFactory"/> + </bean> + + <bean id="implementor" class="org.apache.cxf.systest.jms.tx.GreeterImplWithTransaction"/> + + <bean id="transactionalImplementor" + class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> + <property name="transactionManager" ref="jmsTransactionManager" /> + <property name="target" ref="implementor" /> + <property name="transactionAttributes"> + <props> + <prop key="greetMe">PROPAGATION_REQUIRED</prop> + <!-- Commit if pingMe throw PingMeFault --> + <prop key="pingMe">PROPAGATION_REQUIRED,+PingMeFault</prop> + </props> + </property> + </bean> + + <bean id="jmsConf" class="org.apache.cxf.transport.jms.JMSConfiguration" + p:connectionFactory-ref="singleConnectionFactory" + p:sessionTransacted="true" + p:transactionManager-ref="jmsTransactionManager" + p:usingEndpointInfo="true" + /> + +</beans> Added: cxf/trunk/systests/transport-jms/src/test/resources/jms/testcase.xjb URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/resources/jms/testcase.xjb?rev=1089887&view=auto ============================================================================== --- cxf/trunk/systests/transport-jms/src/test/resources/jms/testcase.xjb (added) +++ cxf/trunk/systests/transport-jms/src/test/resources/jms/testcase.xjb Thu Apr 7 14:11:51 2011 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + 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. +--> +<jaxb:bindings version="1.0" + xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" + jaxb:extensionBindingPrefixes="xjc"> + <jaxb:bindings schemaLocation="testcase.xsd" node="/xs:schema"> + <jaxb:schemaBindings> + <jaxb:package name="org.apache.cxf.testsuite.testcase"/> + </jaxb:schemaBindings> + <jaxb:globalBindings generateIsSetMethod="true"/> + </jaxb:bindings> +</jaxb:bindings> Added: cxf/trunk/systests/transport-jms/src/test/resources/jms/testcase.xsd URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/resources/jms/testcase.xsd?rev=1089887&view=auto ============================================================================== --- cxf/trunk/systests/transport-jms/src/test/resources/jms/testcase.xsd (added) +++ cxf/trunk/systests/transport-jms/src/test/resources/jms/testcase.xsd Thu Apr 7 14:11:51 2011 @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema targetNamespace="http://cxf.apache.org/jms/testcase/" + xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://cxf.apache.org/jms/testcase/"> + + <xs:element name="testCases" type="tns:testCasesType" /> + <xs:element name="testCase" type="tns:testCaseType" /> + <xs:element name="requestMessage" type="tns:messagePropertiesType" /> + <xs:element name="responseMessage" type="tns:messagePropertiesType" /> + + <xs:element name="messageType" type="xs:string"></xs:element> + <xs:element name="deliveryMode" type="xs:int"></xs:element> + <xs:element name="priority" type="xs:int"></xs:element> + <xs:element name="expiration" type="xs:int"></xs:element> + <xs:element name="replyTo" type="xs:string"></xs:element> + <xs:element name="correlationID" type="xs:string"></xs:element> + <xs:element name="destination" type="xs:string"></xs:element> + <xs:element name="redelivered" type="xs:boolean"></xs:element> + <xs:element name="bindingVersion" type="xs:string"></xs:element> + <xs:element name="targetService" type="xs:string"></xs:element> + <xs:element name="contentType" type="xs:string"></xs:element> + <xs:element name="soapAction" type="xs:string"></xs:element> + <xs:element name="requestURI" type="xs:string"></xs:element> + <xs:element name="messageBody" type="xs:string"></xs:element> + <xs:element name="address" type="xs:string"></xs:element> + <xs:element name="isFault" type="xs:boolean"></xs:element> + + <xs:complexType name="testCasesType"> + <xs:sequence> + <xs:element ref="tns:testCase" minOccurs="0" maxOccurs="unbounded"></xs:element> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="testCaseType"> + <xs:all> + <xs:element ref="tns:address"></xs:element> + <xs:element ref="tns:requestMessage"></xs:element> + <xs:element ref="tns:responseMessage" minOccurs="0" + maxOccurs="1"> + </xs:element> + </xs:all> + <xs:attribute name="id" type="xs:string" use="required"></xs:attribute> + <xs:attribute name="mep" type="tns:mepType" use="required"></xs:attribute> + </xs:complexType> + + <xs:simpleType name="mepType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="inonly" /> + <xs:enumeration value="inout" /> + </xs:restriction> + </xs:simpleType> + + <xs:complexType name="messagePropertiesType"> + <xs:all> + <xs:element ref="tns:messageType" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:deliveryMode" minOccurs="0" + maxOccurs="1"></xs:element> + <xs:element ref="tns:priority" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:expiration" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:replyTo" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:correlationID" minOccurs="0" + maxOccurs="1"></xs:element> + <xs:element ref="tns:destination" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:redelivered" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:bindingVersion" minOccurs="0" + maxOccurs="1"></xs:element> + <xs:element ref="tns:targetService" minOccurs="0" + maxOccurs="1"></xs:element> + <xs:element ref="tns:contentType" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:soapAction" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:requestURI" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:isFault" minOccurs="0" maxOccurs="1"></xs:element> + <xs:element ref="tns:messageBody" minOccurs="0" maxOccurs="1"></xs:element> + </xs:all> + </xs:complexType> +</xs:schema> \ No newline at end of file Modified: cxf/trunk/systests/transports/pom.xml URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/pom.xml?rev=1089887&r1=1089886&r2=1089887&view=diff ============================================================================== --- cxf/trunk/systests/transports/pom.xml (original) +++ cxf/trunk/systests/transports/pom.xml Thu Apr 7 14:11:51 2011 @@ -62,30 +62,6 @@ </execution> </executions> </plugin> - <plugin> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-xjc-plugin</artifactId> - <version>${cxf.xjc-utils.version}</version> - <executions> - <execution> - <id>generate-sources</id> - <phase>generate-sources</phase> - <configuration> - <testSourceRoot>${basedir}/target/generated/src/test/java</testSourceRoot> - <xsdOptions> - <xsdOption> - <xsd>${basedir}/src/test/resources/jms/testcase.xsd</xsd> - <bindingFile>${basedir}/src/test/resources/jms/testcase.xjb</bindingFile> - <catalog>${basedir}/src/test/build-resources/catalog.cat</catalog> - </xsdOption> - </xsdOptions> - </configuration> - <goals> - <goal>xsdtojava</goal> - </goals> - </execution> - </executions> - </plugin> </plugins> </build> <profiles>
