How to test a SOAP binding
simplex-software Mar 18, 2016 2:37 PMGreetings,
In a composite, I have a service exposing a WSDL interface and having a SOAP binding. The service has a reference to a component with a JPA binding. In order to test the composite, I deploy it and I use SoapUI. But I'm wondering how to test it using the Switchyard test kit or Arquillian ?
Using the Switchyard test kit, as follows:
@RunWith(SwitchYardRunner.class)
@SwitchYardTestCaseConfig(config = SwitchYardTestCaseConfig.SWITCHYARD_XML, mixins = { CDIMixIn.class })
public class PaymentTest {
@ServiceOperation("Payment")
private Invoker service;
@Test
public void testMakePayment() throws Exception {
Invoice invoice = new Invoice("companyName", new Integer(160), new BigDecimal(75), new Integer(35));
service.operation("makePayment").sendInOnly(invoice);
}
}
raises javax.persistence.PersistenceException: No Persistence provider for EntityManager. This must be obviously because the Switchyard test kit uses jetty who, as opposed to EAP/WildFly, doesn't provide any EntityManager instance. It should be created using an EntityManager factory, like in non Java EE applications.
Trying to test with Arquillian, as follows:
@RunWith(Arquillian.class)
public class ArquillianPaymentTest1 {
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.createFromZipFile(JavaArchive.class, new File("target/switchyard-demo-0.0.1-SNAPSHOT.jar"));
}
@Test
public void test() throws MalformedURLException {
Service service = Service.create(new URL ("http://localhost:8080/pay/Payment?wsdl"), new QName("...", "Payment"));
Invoice invoice = new Invoice("companyName", new Integer(160), new BigDecimal(75), new Integer(35));
service.getPort(Payment.class).makePayment(invoice);
}
}
correctly starts the EAP managed container, deploys the composite as shown below:
19:31:40,549 INFO [org.jboss.ws.cxf.metadata] (MSC service thread 1-1) JBWS024061: Adding service endpoint metadata: id=Payment
address=http://localhost:8080/pay/Payment
implementor=org.switchyard.component.soap.endpoint.BaseWebService
serviceName={urn:fr.simplex-software.example.switchyard:switchyard-demo:1.0}Payment
portName={urn:fr.simplex-software.example.switchyard:switchyard-demo:1.0}PaymentPort
annotationWsdlLocation=null
wsdlLocationOverride=vfs:/C:/Users/nicolas/workspace8/switchyard-demo/content/switchyard-demo-0.0.1-SNAPSHOT.jar/Payment.wsdl
mtomEnabled=false
but raises the following exception:
19:31:42,752 SEVERE [org.jboss.arquillian.protocol.jmx.JMXTestRunner] (pool-1-thread-1) Failed: ... ArquillianPaymentTest.test: javax.xml.ws.WebServiceException: Service endpoint interface class ... Payment does not have a javax.jws.WebService annotation.
which is, of course, true.
So, is there anyway I could test in container this service, using either Switchyard test kit, or Arquillian, or a combination of both ?
Many thanks in advance,
Nicolas