{
// Check that the test to have an in-vm broker setup/teardown task added to it, is actually a framework
// test that can handle setup tasks.
if ((test instanceof SetupTaskAware))
{
SetupTaskAware frameworkTest = (SetupTaskAware) test;
frameworkTest.chainSetupTask(new Runnable()
{
public void run()
{
// Ensure that the in-vm broker is created.
try
{
ApplicationRegistry.getInstance(1);
TransportConnection.createVMBroker(1);
}
catch (AMQVMBrokerCreationException e)
{
throw new RuntimeException("In-VM broker creation failed: " + e.getMessage(), e);
}
}
});
frameworkTest.chainTearDownTask(new Runnable()
{
public void run()
{
// Ensure that the in-vm broker is cleaned up so that the next test starts afresh.
TransportConnection.killVMBroker(1);