提交 df988731 编写于 作者: G gnt

[ACT-221] Add an integration test for the webservice task solely based on CXF

上级 052d1a38
...@@ -41,6 +41,16 @@ ...@@ -41,6 +41,16 @@
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>cxf-rt-frontend-jaxws</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>
......
/* Licensed 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.activiti.engine.impl.webservice;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
/**
* A simple Counter WS that starts the counter in -1
*
* @author Esteban Robles Luna
*/
@WebService
public interface Counter {
/**
* Increase the counter in 1
*/
void inc();
/**
* Returns the current count
*
* @return the count
*/
@WebResult(name="count")
int getCount();
/**
* Resets the counter to 0
*/
void reset();
/**
* Sets the counter to value
*
* @param value the value of the new counter
*/
void setTo(@WebParam(name="value") int value);
/**
* Returns a formated string composed of prefix + current count + suffix
*
* @param prefix the prefix
* @param suffix the suffix
* @return the formated string
*/
@WebResult(name="prettyPrint")
String prettyPrintCount(@WebParam(name="prefix") String prefix, @WebParam(name="suffix") String suffix);
}
/* Licensed 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.activiti.engine.impl.webservice;
import javax.jws.WebService;
/**
* An implementation of a Counter WS
*
* @author Esteban Robles Luna
*/
@WebService(endpointInterface = "org.activiti.engine.impl.webservice.Counter",
serviceName = "Counter")
public class CounterImpl implements Counter {
protected int count;
public CounterImpl() {
this.count = -1;
}
/**
* {@inheritDoc}
*/
public int getCount() {
return this.count;
}
/**
* {@inheritDoc}
*/
public void inc() {
this.count++;
}
/**
* {@inheritDoc}
*/
public void reset() {
this.setTo(0);
}
/**
* {@inheritDoc}
*/
public void setTo(int value) {
this.count = value;
}
/**
* {@inheritDoc}
*/
public String prettyPrintCount(String prefix, String suffix) {
return prefix + this.getCount() + suffix;
}
}
\ No newline at end of file
/* Licensed 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.activiti.engine.impl.webservice;
import org.activiti.engine.impl.test.ActivitiInternalTestCase;
import org.activiti.engine.test.Deployment;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
/**
* An integration test for CXF based web services
*
* @author <a href="mailto:gnodet@gmail.com">Guillaume Nodet</a>
*/
public class WebServiceTaskTest extends ActivitiInternalTestCase {
private Counter counter;
private Server server;
@Override
protected void initializeProcessEngine() {
super.initializeProcessEngine();
counter = new CounterImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(Counter.class);
svrFactory.setAddress("http://localhost:63081/counter");
svrFactory.setServiceBean(counter);
svrFactory.getInInterceptors().add(new LoggingInInterceptor());
svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
server = svrFactory.create();
server.start();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
server.stop();
}
@Deployment
public void testWebServiceInvocation() throws Exception {
assertEquals(-1, counter.getCount());
runtimeService.startProcessInstanceByKey("webServiceInvocation");
waitForJobExecutorToProcessAllJobs(10000L, 250L);
assertEquals(0, counter.getCount());
}
}
database=h2
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000
jdbc.username=sa
jdbc.password=
db.schema.strategy=create-drop
job.executor.auto.activate=off
ws.sync.factory=org.activiti.engine.impl.webservice.CxfWebServiceClientFactory
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn-extensions"
targetNamespace="http://www.activiti.org/bpmn2.0/examples/webServiceInvocationWithoutDataFlow"
xmlns:tns="http://www.activiti.org/bpmn2.0/examples/webServiceInvocationWithoutDataFlow"
xmlns:counter="http://webservice.activiti.org/">
<import importType="http://schemas.xmlsoap.org/wsdl/"
location="http://localhost:63081/counter?wsdl"
namespace="http://webservice.activiti.org/" />
<process id="webServiceInvocation">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="webService" />
<serviceTask id="webService"
name="Web service invocation"
implementation="##WebService"
operationRef="incOperation" />
<sequenceFlow id="flow2" sourceRef="webService" targetRef="waitState" />
<receiveTask id="waitState" />
<sequenceFlow id="flow3" sourceRef="waitState" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
<!-- Interface: implementationRef = QName of WSDL Port Type -->
<interface name="Counter Interface"> <!-- NEEDED FOR THE PORT -->
<!-- Operation: implementationRef = QName of WSDL Operation -->
<operation id="incOperation" name="Increase Operation" implementationRef="inc"> <!-- NEEDED FOR THE OPERATION NAME -->
<inMessageRef>incRequestMessage</inMessageRef>
<outMessageRef>incResponseMessage</outMessageRef>
</operation>
</interface>
<message id="incRequestMessage" itemRef="incRequestItem" />
<message id="incResponseMessage" itemRef="incResponseItem" />
<itemDefinition id="incRequestItem" structureRef="inc" /><!-- QName of input element --> <!-- NEEDED FOR THE ARGUMENTS -->
<itemDefinition id="incResponseItem" structureRef="incResponse" /><!-- QName of output element -->
</definitions>
\ No newline at end of file
...@@ -219,6 +219,21 @@ ...@@ -219,6 +219,21 @@
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.1.2</version> <version>2.1.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>2.1.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.mule.transports</groupId> <groupId>org.mule.transports</groupId>
<artifactId>mule-transport-cxf</artifactId> <artifactId>mule-transport-cxf</artifactId>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册