Ce contenu n'est pas disponible dans la langue sélectionnée.

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
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat