org.apache.qpid.test.framework
Class FrameworkBaseCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.qpid.test.utils.QpidTestCase
              extended by org.apache.qpid.test.utils.QpidBrokerTestCase
                  extended by org.apache.qpid.test.framework.FrameworkBaseCase
All Implemented Interfaces:
junit.framework.Test, org.apache.qpid.junit.extensions.SetupTaskAware, BrokerLifecycleAware, FrameworkTestContext
Direct Known Subclasses:
FailoverTest, ImmediateMessageTest, MandatoryMessageTest, OptOutTestCase, RollbackTest, TTLTest

public class FrameworkBaseCase
extends QpidBrokerTestCase
implements FrameworkTestContext, org.apache.qpid.junit.extensions.SetupTaskAware, BrokerLifecycleAware

FrameworkBaseCase provides a starting point for writing test cases against the test framework. Its main purpose is to provide some convenience methods for testing.

CRC Card
Responsibilities Collaborations
Create and clean up in-vm brokers on every test case.
Produce lists of assertions from assertion creation calls.
Produce JUnit failures from assertion failures.
Convert failed assertions to error messages.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
QpidBrokerTestCase.MessageType
 
Field Summary
 
Fields inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
_broker, _brokerLanguage, _brokerLogPrefix, _brokerOutputStream, _brokerPersistent, _brokers, _configFile, _connectionFactory, _connections, _initialContext, _interleaveBrokerLog, _logger, _output, _outputFile, _testName, BROKER_READY, CONTENT, CPP, DEFAULT_MANAGEMENT_PORT, DEFAULT_MESSAGE_SIZE, DEFAULT_PORT, DEFAULT_SSL_PORT, DEFAULT_VM_PORT, EXTERNAL, INDEX, JAVA, LOGMONITOR_TIMEOUT, QPID_HOME, QpidHome, QUEUE, RECEIVE_TIMEOUT, TOPIC, VM
 
Fields inherited from class org.apache.qpid.test.utils.QpidTestCase
MEMORY_STORE_CLASS_NAME, MS_CLASS_NAME_KEY
 
Constructor Summary
FrameworkBaseCase(String name)
          Creates a new test case with the specified name.
 
Method Summary
protected  List<Assertion> assertionList(Assertion... asserts)
          Creates a list of assertions.
protected static String assertionsToString(List<Assertion> asserts)
          Converts a list of failed assertions into an error message.
protected static void assertNoFailures(List<Assertion> asserts)
          Generates a JUnit assertion exception (failure) if any assertions are passed into this method, also concatenating all of the error messages in the assertions together to form an error message to diagnose the test failure with.
 void chainSetupTask(Runnable task)
          Adds the specified task to the tests setup.
 void chainTearDownTask(Runnable task)
          Adds the specified task to the tests tear down.
protected  CircuitFactory getCircuitFactory()
          Returns the test case sequencer that provides test circuit, and test sequence implementations.
protected  CauseFailure getFailureMechanism()
           
 int getLiveBroker()
          Reports the currently live in-vm broker.
protected  org.apache.qpid.junit.extensions.SetupTaskHandler getTaskHandler()
           
 String getTestCaseNameForTestMethod(String methodName)
          Should provide a translation from the junit method name of a test to its test case name as known to the test clients that will run the test.
 TestCaseVector getTestCaseVector()
          Reports the current test case name.
 MessagingTestConfigProperties getTestParameters()
          Reports the current test case parameters.
protected  org.apache.qpid.junit.extensions.util.ParsedProperties getTestProps()
           
 void setCircuitFactory(CircuitFactory circuitFactory)
          Overrides the default test circuit factory.
 void setFailureMechanism(CauseFailure failureMechanism)
          Accepts a failure mechanism.
 void setInVmBrokers()
           
 void setLiveBroker(int i)
          Sets the currently live in-vm broker.
protected  void setTestProps(org.apache.qpid.junit.extensions.util.ParsedProperties testProps)
           
protected  void setUp()
          Ensures that the in-vm broker is created and initialized.
protected  void tearDown()
          Ensures that the in-vm broker is cleaned up after each test run.
 boolean usingInVmBroker()
          Indicates whether or not a test case is using in-vm brokers.
 
Methods inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
cleanBroker, createMessage, createNextMessage, drainQueue, getBroker, getBrokerCommand, getClientConnection, getConfigurationStringProperty, getConnection, getConnection, getConnection, getConnectionFactory, getConnectionFactory, getConnectionURL, getInitialContext, getLogger, getManagementPort, getMessageSize, getPort, getPort, getTestConfigFile, getTestQueue, getTestQueueName, getTestVirtualhostsFile, isBroker010, isBroker08, isBrokerStorePersistent, isCppBroker, isExternalBroker, isJavaBroker, makeVirtualHostPersistent, reloadBrokerSecurityConfig, restartBroker, restartBroker, revertLoggingLevels, revertSystemProperties, runBare, saveTestConfiguration, saveTestVirtualhosts, sendMessage, sendMessage, sendMessage, setBrokerEnvironment, setBrokerOnlySystemProperty, setConfigurationProperty, setLoggerLevel, setMessageSize, setSystemProperty, setSystemProperty, setTestClientSystemProperty, startBroker, startBroker, stopBroker, stopBroker
 
Methods inherited from class org.apache.qpid.test.utils.QpidTestCase
getTestProfileMessageStoreClassName, run
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FrameworkBaseCase

public FrameworkBaseCase(String name)
Creates a new test case with the specified name.

Parameters:
name - The test case name.
Method Detail

getCircuitFactory

protected CircuitFactory getCircuitFactory()
Returns the test case sequencer that provides test circuit, and test sequence implementations. The sequencer that this base case returns by default is suitable for running a test circuit with both circuit ends colocated on the same JVM.

Returns:
The test case sequencer.

setCircuitFactory

public void setCircuitFactory(CircuitFactory circuitFactory)
Overrides the default test circuit factory. Test decorators can use this to supply distributed test sequencers or other test circuit factory specializations.

Parameters:
circuitFactory - The new test circuit factory.

getTestCaseVector

public TestCaseVector getTestCaseVector()
Reports the current test case name.

Specified by:
getTestCaseVector in interface FrameworkTestContext
Returns:
The current test case name.

getTestParameters

public MessagingTestConfigProperties getTestParameters()
Reports the current test case parameters.

Specified by:
getTestParameters in interface FrameworkTestContext
Returns:
The current test case parameters.

assertionList

protected List<Assertion> assertionList(Assertion... asserts)
Creates a list of assertions.

Parameters:
asserts - The assertions to compile in a list.
Returns:
A list of assertions.

assertNoFailures

protected static void assertNoFailures(List<Assertion> asserts)
Generates a JUnit assertion exception (failure) if any assertions are passed into this method, also concatenating all of the error messages in the assertions together to form an error message to diagnose the test failure with.

Parameters:
asserts - The list of failed assertions.

assertionsToString

protected static String assertionsToString(List<Assertion> asserts)
Converts a list of failed assertions into an error message.

Parameters:
asserts - The failed assertions.
Returns:
The error message.

setUp

protected void setUp()
              throws Exception
Ensures that the in-vm broker is created and initialized.

Overrides:
setUp in class QpidBrokerTestCase
Throws:
Exception - Any exceptions allowed to fall through and fail the test.

tearDown

protected void tearDown()
Ensures that the in-vm broker is cleaned up after each test run.

Overrides:
tearDown in class QpidBrokerTestCase

chainSetupTask

public void chainSetupTask(Runnable task)
Adds the specified task to the tests setup.

Specified by:
chainSetupTask in interface org.apache.qpid.junit.extensions.SetupTaskAware
Parameters:
task - The task to add to the tests setup.

chainTearDownTask

public void chainTearDownTask(Runnable task)
Adds the specified task to the tests tear down.

Specified by:
chainTearDownTask in interface org.apache.qpid.junit.extensions.SetupTaskAware
Parameters:
task - The task to add to the tests tear down.

getTestCaseNameForTestMethod

public String getTestCaseNameForTestMethod(String methodName)
Should provide a translation from the junit method name of a test to its test case name as known to the test clients that will run the test. The purpose of this is to convert the JUnit method name into the correct test case name to place into the test invite. For example the method "testP2P" might map onto the interop test case name "TC2_BasicP2P".

Parameters:
methodName - The name of the JUnit test method.
Returns:
The name of the corresponding interop test case.

setInVmBrokers

public void setInVmBrokers()
Specified by:
setInVmBrokers in interface BrokerLifecycleAware

usingInVmBroker

public boolean usingInVmBroker()
Indicates whether or not a test case is using in-vm brokers.

Specified by:
usingInVmBroker in interface BrokerLifecycleAware
Returns:
true if the test is using in-vm brokers, false otherwise.

setLiveBroker

public void setLiveBroker(int i)
Sets the currently live in-vm broker.

Specified by:
setLiveBroker in interface BrokerLifecycleAware
Parameters:
i - The currently live in-vm broker.

getLiveBroker

public int getLiveBroker()
Reports the currently live in-vm broker.

Specified by:
getLiveBroker in interface BrokerLifecycleAware
Returns:
The currently live in-vm broker.

setFailureMechanism

public void setFailureMechanism(CauseFailure failureMechanism)
Accepts a failure mechanism.

Specified by:
setFailureMechanism in interface BrokerLifecycleAware
Parameters:
failureMechanism - The failure mechanism.

getTestProps

protected org.apache.qpid.junit.extensions.util.ParsedProperties getTestProps()

setTestProps

protected void setTestProps(org.apache.qpid.junit.extensions.util.ParsedProperties testProps)

getTaskHandler

protected org.apache.qpid.junit.extensions.SetupTaskHandler getTaskHandler()

getFailureMechanism

protected CauseFailure getFailureMechanism()


Licensed to the Apache Software Foundation