此内容没有您所选择的语言版本。

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...
    }                
    
    
    Copy to Clipboard Toggle word wrap

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...
}
Copy to Clipboard Toggle word wrap

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...
}
Copy to Clipboard Toggle word wrap

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...
}
Copy to Clipboard Toggle word wrap

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...
}
Copy to Clipboard Toggle word wrap

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...
}            

Copy to Clipboard Toggle word wrap

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...
}

Copy to Clipboard Toggle word wrap

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>");
    }
}
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat