public class SwitchYardTestKit extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
SwitchYardTestKit.MixInEntry
Helper class to keep mixin and it's dependencies.
|
protected static class |
SwitchYardTestKit.NullMixIns
Hidden marker type to provide a valid NULL
TestMixIns configuration for
SwitchYardTestCaseConfig . |
protected static class |
SwitchYardTestKit.NullScanners
Hidden marker type to provide a valid NULL
Scanners configuration for
SwitchYardTestCaseConfig . |
Modifier and Type | Field and Description |
---|---|
protected static String |
NULL_CONFIG
Constant for the
SwitchYardTestCaseConfig.config() default. |
Constructor and Description |
---|
SwitchYardTestKit(Object testInstance)
Public default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addTransformer(Transformer transformer)
Add a Transformer instance.
|
void |
cleanup()
Cleanup.
|
void |
compareXMLToResource(String xml,
String resourcePath)
Compare an XML string (e.g.
|
static void |
compareXMLToString(String xml,
String string)
Compare an XML String (e.g.
|
QName |
createQName(String localPart)
Creates a QName given this test kit's config model's targetNamespace + the specified localPart.
|
List<org.switchyard.deploy.Activator> |
getActivators()
Get the list of activators for the test.
|
org.switchyard.config.model.switchyard.SwitchYardModel |
getConfigModel()
Get the configuration model driving this test instance, if one exists.
|
org.switchyard.deploy.internal.AbstractDeployment |
getDeployment()
Get the deployment instance associated with the test case.
|
<T extends TestMixIn> |
getMixIn(Class<T> type)
Get the "active"
TestMixIn instance of the specified type. |
List<TestMixIn> |
getMixIns()
Get the
TestMixIn instances associated with this test instance. |
Set<TestMixIn> |
getOptionalDependencies(TestMixIn mixIn)
Returns optional mixin dependencies.
|
Set<TestMixIn> |
getRequiredDependencies(TestMixIn mixIn)
Returns required mixin dependencies.
|
InputStream |
getResourceAsStream(String name)
Finds a resource with a given name.
|
ServiceDomain |
getServiceDomain()
Get the ServiceDomain.
|
Object |
getTestInstance()
Get the test class instance.
|
<M extends org.switchyard.config.model.Model> |
loadConfigModel(InputStream configModel,
Class<M> modelType)
Load the configuration model specified by the configModel stream.
|
<M extends org.switchyard.config.model.Model> |
loadConfigModel(InputStream configModel,
Class<M> modelType,
boolean validate)
Load the SwitchYard configuration model specified by the configModel stream.
|
org.switchyard.config.model.switchyard.SwitchYardModel |
loadSwitchYardModel(InputStream configModel)
Load the SwitchYard configuration model specified by the configModel stream.
|
org.switchyard.config.model.switchyard.SwitchYardModel |
loadSwitchYardModel(InputStream configModel,
boolean validate)
Load the SwitchYard configuration model specified by the configModel stream.
|
Invoker |
newInvoker(QName serviceName)
Create a new
Invoker instance for invoking a Service in the test ServiceDomain. |
Invoker |
newInvoker(String serviceName)
Create a new
Invoker instance for invoking a Service in the test ServiceDomain. |
protected static <T extends TestMixIn> |
newMixInInstance(Class<T> mixInType,
Object testInstance) |
Transformer |
newTransformer(org.switchyard.config.model.transform.TransformModel transformModel)
Create a new
Transformer instance from the specified TransformModel . |
byte[] |
readResourceBytes(String path)
Read a classpath resource and return as a byte array.
|
Document |
readResourceDocument(String path)
Read a classpath resource and return as an XML DOM Document.
|
String |
readResourceString(String path)
Read a classpath resource and return as a String.
|
MockHandler |
registerInOnlyService(String serviceName)
Register an IN_ONLY Service.
|
void |
registerInOnlyService(String serviceName,
ExchangeHandler serviceHandler)
Register an IN_ONLY Service.
|
MockHandler |
registerInOutService(String serviceName)
Register an IN_OUT Service.
|
void |
registerInOutService(String serviceName,
ExchangeHandler serviceHandler)
Register an IN_OUT Service.
|
void |
registerInOutService(String serviceName,
ExchangeHandler serviceHandler,
ServiceInterface metadata)
Register an IN_OUT Service.
|
Transformer |
registerTransformer(org.switchyard.config.model.transform.TransformModel transformModel)
Create a new
Transformer instance from the specified TransformModel and
register it with the test ServiceDomain. |
void |
removeService(QName serviceName)
Removes all service providers from the domain with the specified name.
|
void |
removeService(String serviceName)
Removes all service providers from the domain with the specified name.
|
MockHandler |
replaceService(QName name)
Replaces an existing service registration (e.g.
|
void |
replaceService(QName name,
ExchangeHandler handler)
Replaces an existing service registration (e.g.
|
MockHandler |
replaceService(String name)
Replaces an existing service registration (e.g.
|
void |
replaceService(String name,
ExchangeHandler handler)
Replaces an existing service registration (e.g.
|
void |
start()
invoke the methods annotated with
BeforeDeploy on test class and deploy SwitchYard application. |
void |
traceMessages(boolean doTrace)
Enables message tracing for the application under test.
|
protected static final String NULL_CONFIG
SwitchYardTestCaseConfig.config()
default.public void start() throws Exception
BeforeDeploy
on test class and deploy SwitchYard application.Exception
- failed to deploypublic void cleanup()
public Object getTestInstance()
public org.switchyard.config.model.switchyard.SwitchYardModel getConfigModel()
public List<org.switchyard.deploy.Activator> getActivators()
public org.switchyard.deploy.internal.AbstractDeployment getDeployment()
public ServiceDomain getServiceDomain()
public QName createQName(String localPart)
localPart
- the specified localPartpublic MockHandler registerInOutService(String serviceName)
MockHandler
as the service handler.serviceName
- The Service name.MockHandler
service handler.public void registerInOutService(String serviceName, ExchangeHandler serviceHandler)
serviceName
- The Service name.serviceHandler
- The service handler.public void registerInOutService(String serviceName, ExchangeHandler serviceHandler, ServiceInterface metadata)
serviceName
- The Service name.serviceHandler
- The service handler.metadata
- Service interface.public MockHandler registerInOnlyService(String serviceName)
MockHandler
as the fault service handler.serviceName
- The Service name.MockHandler
service fault handler.public void registerInOnlyService(String serviceName, ExchangeHandler serviceHandler)
serviceName
- The Service name.serviceHandler
- The service handler.public MockHandler replaceService(String name) throws SwitchYardException
name
- name of the service to replaceSwitchYardException
- if a service with the specified name does not existpublic void replaceService(String name, ExchangeHandler handler) throws SwitchYardException
name
- name of the service to replacehandler
- implementation to use as the service providerSwitchYardException
- if a service with the specified name does not existpublic MockHandler replaceService(QName name) throws SwitchYardException
name
- name of the service to replaceSwitchYardException
- if a service with the specified name does not existpublic void replaceService(QName name, ExchangeHandler handler) throws SwitchYardException
name
- name of the service to replacehandler
- implementation to use as the service providerSwitchYardException
- if a service with the specified name does not existpublic void removeService(String serviceName)
serviceName
- local part of a service QNamepublic void removeService(QName serviceName)
serviceName
- qualified name of the servicepublic void addTransformer(Transformer transformer)
transformer
- The transformer instance.public Invoker newInvoker(QName serviceName)
Invoker
instance for invoking a Service in the test ServiceDomain.serviceName
- The target Service name.public Invoker newInvoker(String serviceName)
Invoker
instance for invoking a Service in the test ServiceDomain.serviceName
- The target Service name. Can be a serialized QName
. Can also
include the operation name e.g. "OrderManagementService.createOrder".public Transformer newTransformer(org.switchyard.config.model.transform.TransformModel transformModel)
Transformer
instance from the specified TransformModel
.transformModel
- The TransformModel.public Transformer registerTransformer(org.switchyard.config.model.transform.TransformModel transformModel)
Transformer
instance from the specified TransformModel
and
register it with the test ServiceDomain.transformModel
- The TransformModel.public List<TestMixIn> getMixIns()
TestMixIn
instances associated with this test instance.TestMixIn
instances associated with this test instance.public <T extends TestMixIn> T getMixIn(Class<T> type)
TestMixIn
instance of the specified type.
This method can only be called from inside a test method.T
- type TestMixIn
type.type
- The TestMixIn
type, as specified in the SwitchYardTestCaseConfig
annotation.TestMixIn
instance.public Set<TestMixIn> getRequiredDependencies(TestMixIn mixIn)
mixIn
- Mix in asking about dependencies.public Set<TestMixIn> getOptionalDependencies(TestMixIn mixIn)
mixIn
- Mix in asking about dependencies.public InputStream getResourceAsStream(String name)
name
- Name of the desired resourceInputStream
object or null if no resource with this name is found.Classes.getResourceAsStream(String,Class)
public byte[] readResourceBytes(String path)
path
- The path to the classpath resource. The specified path can be
relative to the test class' location on the classpath.public String readResourceString(String path)
path
- The path to the classpath resource. The specified path can be
relative to the test class' location on the classpath.public Document readResourceDocument(String path)
path
- The path to the classpath resource. The specified path can be
relative to the test class' location on the classpath.public org.switchyard.config.model.switchyard.SwitchYardModel loadSwitchYardModel(InputStream configModel)
configModel
- The config model stream.public org.switchyard.config.model.switchyard.SwitchYardModel loadSwitchYardModel(InputStream configModel, boolean validate)
configModel
- The config model stream.validate
- Validate the model?public <M extends org.switchyard.config.model.Model> M loadConfigModel(InputStream configModel, Class<M> modelType)
M
- Model type.configModel
- The config model stream.modelType
- Model type.public <M extends org.switchyard.config.model.Model> M loadConfigModel(InputStream configModel, Class<M> modelType, boolean validate)
M
- Model type.configModel
- The config model stream.modelType
- Model type.validate
- Validate the model?public void compareXMLToResource(String xml, String resourcePath)
xml
- The XML (as a String) to be compared against the XML in the specified
classpath resource.resourcePath
- The path to the classpath resource against which the XML is to be
compared. The specified path can be relative to the test class' location on the classpath.public static void compareXMLToString(String xml, String string)
xml
- The XML (as a String) to be compared against the XML in the specified
classpath resource.string
- The String against which the XML is to be
compared.public void traceMessages(boolean doTrace)
doTrace
- true to enable message tracing, false to disableCopyright © 2013–2017 JBoss by Red Hat. All rights reserved.