13.8. Metadata and Support Class Injections
13.8.1. TestKit Injection
- You can inject the SwitchYardTestKit instance into the test at runtime by declaring a property of that type in the test class, as shown below:
@RunWith(SwitchYardRunner.class) public class MyServiceTest { private SwitchYardTestKit testKit; // implement test methods... }
13.8.2. Deployment Injection
You can inject the deployment instance by declaring a property of the type Deployment, as shown below:
@RunWith(SwitchYardRunner.class) public class MyServiceTest { private Deployment deployment; // implement test methods... }
13.8.3. SwitchYardModel Injection
You can inject the SwitchYardModel instance by declaring a property of the type SwitchYardModel, as shown below:
@RunWith(SwitchYardRunner.class) public class MyServiceTest { private SwitchYardModel model; // implement test methods... }
13.8.4. ServiceDomain Injection
You can inject the ServiceDomain instance by declaring a property of the type ServiceDomain, as shown below:
@RunWith(SwitchYardRunner.class) public class MyServiceTest { private ServiceDomain serviceDomain; // implement test methods... }
13.8.5. TransformerRegistry Injection
You can inject the TransformerRegistry instance by declaring a property of the type TransformerRegistry, as shown below:
@RunWith(SwitchYardRunner.class) public class MyServiceTest { private TransformerRegistry transformRegistry; // implement test methods... }
13.8.6. TestMixIn Injection
You can inject the TestMixIn Injection instance by declaring a property of the type TestMixIn Injection, as shown below:
@RunWith(SwitchYardRunner.class) @SwitchYardTestCaseConfig(mixins = {CDIMixIn.class, HTTPMixIn.class}) public class MyServiceTest { private CDIMixIn cdiMixIn; private HTTPMixIn httpIn; // implement test methods... }
13.8.7. PropertyMixIn Injection
PropertyMixIn instances are injected like any other TestMixIn type, however you must set any properties you wish to use on the MixIn before deployment in order for them to be used. To do this, use the @BeforeDeploy annotation:
@RunWith(SwitchYardRunner.class) @SwitchYardTestCaseConfig(mixins = {CDIMixIn.class, PropertyMixIn.class, HTTPMixIn.class}) public class MyServiceTest { private PropertyMixIn propMixIn; private HTTPMixIn httpMixIn; @BeforeDeploy public void setTestProperties() { propMixIn.set("soapPort", Integer.valueOf(18002)); } // implement test methods... }
13.8.8. Invoker Injection
To inject Service Invoker instances, declare properties of the type Invoker and annotate them with @ServiceOperation. (Note the annotation value is a dot-delimited Service Operation name of the form
[service-name].[operation-name]
.)
@RunWith(SwitchYardRunner.class) @SwitchYardTestCaseConfig(config = "testconfigs/switchyard-01.xml") public class MyServiceTest { @ServiceOperation("OrderService.createOrder") private Invoker createOrderInvoker; @Test public void test_createOrder() { createOrderInvoker.sendInOnly("<order><product>AAA</product><quantity>2</quantity></order>"); } }